[Scons-users] sort function changes

Bill Deegan bill at baddogconsulting.com
Wed Oct 11 17:31:21 EDT 2017


Code doesn't match the manpage, (Or the tests).

GenerateHelpText(*env*, [*sort*])

This generates help text documenting the customizable construction
variables suitable to passing in to the Help() function. *env* is the
construction environment that will be used to get the actual values of
customizable variables. Calling with an optional *sort* function will cause
the output to be sorted by the specified argument. The specific *sort* function
should take two arguments and return -1, 0 or 1 (like the standard Python
*cmp* function).

Help(vars.GenerateHelpText(env))
Help(vars.GenerateHelpText(env, sort=cmp))


I'll have to change the code. Crap. This was a mistake when one of the old
developers ran 2to3 and didn't check the semantics of the changes.
https://github.com/SConsProject/scons/commit/c06950cad4c02ba6b759c1cbd65cfb52ab6868c3#diff-355bbb003e869b5c15d5e835e7ce7d86
I'll have to fix.

On Wed, Oct 11, 2017 at 11:55 AM, Tim Jenness <tjenness at lsst.org> wrote:

> The docstring is missing the "sort" definition. Can we make it default to
> False rather than None to make it clearer it’s a boolean?
>
>
> On Oct 11, 2017, at 11:52 , Eric Fahlgren <ericfahlgren at gmail.com> wrote:
>
> But isn't the 'sort' parameter just a bool, so no need for a function?
>
>     def GenerateHelpText(self, env, sort=None):
>         """
>         Generate the help text for the options.
>
>         env - an environment that is used to get the current values
>               of the options.
>         """
>
>         if sort:
>             options = sorted(self.options, key=lambda x: x.key)
>
> On Wed, Oct 11, 2017 at 11:35 AM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> Added this:
>>
>> Please comment
>> https://github.com/SConsProject/scons/pull/12
>>
>> On Wed, Oct 11, 2017 at 11:31 AM, Bill Deegan <bill at baddogconsulting.com>
>> wrote:
>>
>>> We ran into same issue in our VariablesTests.py (a unit test).
>>>
>>> Here's the implementation we used:
>>>
>>> def cmp(a, b):
>>>     """
>>>     Define cmp because it's no longer available in python3
>>>     Works under python 2 as well
>>>     """
>>>     return (a > b) - (a < b)
>>>
>>> I'll make a note and see if we can provision this into SConscript/SConstruct environment..
>>>
>>>
>>> On Wed, Oct 11, 2017 at 8:03 AM, Mats Wichmann <mats at wichmann.us> wrote:
>>>
>>>>
>>>> This does not work with Python3, since cmp is gone:
>>>>
>>>>     Help(help_vars.GenerateHelpText(env, sort=cmp))
>>>>
>>>>
>>>> Quick suggestion?
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>
>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20171011/b4607e4a/attachment.html>


More information about the Scons-users mailing list