From 8e0b359e15ae9de89ee57198b496f616d64dac84 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Jul 2016 11:03:12 -0700 Subject: [PATCH 1/5] Use single quotes for python commands containing a ';', otherwise in some cases the shell sees it as separate shell commands instead of one python command with multiple statements. --- build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 04e35317..2b04b0e1 100755 --- a/build.py +++ b/build.py @@ -231,7 +231,7 @@ def setPythonVersion(args): else: PYTHON = args[idx+1] del args[idx:idx+2] - PYVER = runcmd('"%s" -c "import sys; print(sys.version[:3])"' % PYTHON, + PYVER = runcmd("'%s' -c 'import sys; print(sys.version[:3])'" % PYTHON, getOutput=True, echoCmd=False) PYSHORTVER = PYVER[0] + PYVER[2] break @@ -284,8 +284,8 @@ def setPythonVersion(args): PYTHON = os.path.abspath(PYTHON) msg('Build using: "%s"' % PYTHON) - msg(runcmd('"%s" -c "import sys; print(sys.version)"' % PYTHON, True, False)) - PYTHON_ARCH = runcmd('"%s" -c "import platform; print(platform.architecture()[0])"' + msg(runcmd("'%s' -c 'import sys; print(sys.version)'" % PYTHON, True, False)) + PYTHON_ARCH = runcmd("'%s' -c 'import platform; print(platform.architecture()[0])'" % PYTHON, True, False) msg('Python\'s architecture is %s' % PYTHON_ARCH) os.environ['PYTHON'] = PYTHON From 5e8f4b12646d5f2716fc3c0aee8b986f0f60139c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Jul 2016 13:36:10 -0700 Subject: [PATCH 2/5] Revert 8e0b359e, it just caused additional problems. It will need a different solution. --- build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 2b04b0e1..04e35317 100755 --- a/build.py +++ b/build.py @@ -231,7 +231,7 @@ def setPythonVersion(args): else: PYTHON = args[idx+1] del args[idx:idx+2] - PYVER = runcmd("'%s' -c 'import sys; print(sys.version[:3])'" % PYTHON, + PYVER = runcmd('"%s" -c "import sys; print(sys.version[:3])"' % PYTHON, getOutput=True, echoCmd=False) PYSHORTVER = PYVER[0] + PYVER[2] break @@ -284,8 +284,8 @@ def setPythonVersion(args): PYTHON = os.path.abspath(PYTHON) msg('Build using: "%s"' % PYTHON) - msg(runcmd("'%s' -c 'import sys; print(sys.version)'" % PYTHON, True, False)) - PYTHON_ARCH = runcmd("'%s' -c 'import platform; print(platform.architecture()[0])'" + msg(runcmd('"%s" -c "import sys; print(sys.version)"' % PYTHON, True, False)) + PYTHON_ARCH = runcmd('"%s" -c "import platform; print(platform.architecture()[0])"' % PYTHON, True, False) msg('Python\'s architecture is %s' % PYTHON_ARCH) os.environ['PYTHON'] = PYTHON From 648e5789fc3249701c865ee00e15db767a386790 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Jul 2016 14:28:00 -0700 Subject: [PATCH 3/5] Enable runcmd to use a list for the command, and have it quote elements as needed. --- build.py | 19 +++++++++++-------- buildtools/config.py | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/build.py b/build.py index 04e35317..7e86fcb9 100755 --- a/build.py +++ b/build.py @@ -231,16 +231,17 @@ def setPythonVersion(args): else: PYTHON = args[idx+1] del args[idx:idx+2] - PYVER = runcmd('"%s" -c "import sys; print(sys.version[:3])"' % PYTHON, - getOutput=True, echoCmd=False) + PYVER = runcmd([PYTHON, '-c', 'import sys; print(sys.version[:3])'], + getOutput=True, echoCmd=True) + msg("PYVER: {!r}".format(PYVER)) PYSHORTVER = PYVER[0] + PYVER[2] break if havePyVer: if isWindows and os.environ.get('TOOLS'): - # Use $TOOLS to find the correct Python. It should be the install - # root of all Python's on the system, with the 64-bit ones in an - # amd64 subfolder, like this: + # Use $TOOLS to find the correct Python. If set then it should be + # the install root of all Python's on the system, with the 64-bit + # ones in an amd64 subfolder, like this: # # $TOOLS\Python27\python.exe # $TOOLS\Python33\python.exe @@ -284,9 +285,11 @@ def setPythonVersion(args): PYTHON = os.path.abspath(PYTHON) msg('Build using: "%s"' % PYTHON) - msg(runcmd('"%s" -c "import sys; print(sys.version)"' % PYTHON, True, False)) - PYTHON_ARCH = runcmd('"%s" -c "import platform; print(platform.architecture()[0])"' - % PYTHON, True, False) + msg(runcmd([PYTHON, '-c', 'import sys; print(sys.version)'], True, False)) + PYTHON_ARCH = runcmd( + [PYTHON, '-c', 'import platform; print(platform.architecture()[0])'], + True, False) + msg('Python\'s architecture is %s' % PYTHON_ARCH) os.environ['PYTHON'] = PYTHON diff --git a/buildtools/config.py b/buildtools/config.py index 4a1cd0c3..5df36dcb 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -781,6 +781,24 @@ def getVcsRev(): def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True): + """ + Runs a give command-line command, optionally returning the output. + """ + if isinstance(cmd, list): + # add quotes to elements of the command that need it + cmd = cmd[:] + for idx, item in enumerate(cmd): + if ' ' in item or ';' in item: + if item[0] not in ['"', "'"]: + if '"' in item: + item = item.replace('"', '\\"') + item = '"{}"'.format(item) + cmd[idx] = item + + cmd = ' '.join(cmd) + #if echoCmd: + # msg(' '.join(cmd)) + if echoCmd: msg(cmd) From 09d4d817e6d01ac2caaf44effd2f40829b8ee5cc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Jul 2016 14:41:14 -0700 Subject: [PATCH 4/5] Enable runcmd to use a list for the command, and have it quote elements as needed. --- build.py | 5 ++--- buildtools/config.py | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index 7e86fcb9..3037246e 100755 --- a/build.py +++ b/build.py @@ -232,8 +232,7 @@ def setPythonVersion(args): PYTHON = args[idx+1] del args[idx:idx+2] PYVER = runcmd([PYTHON, '-c', 'import sys; print(sys.version[:3])'], - getOutput=True, echoCmd=True) - msg("PYVER: {!r}".format(PYVER)) + getOutput=True, echoCmd=False) PYSHORTVER = PYVER[0] + PYVER[2] break @@ -283,7 +282,7 @@ def setPythonVersion(args): PYSHORTVER = PYVER[0] + PYVER[2] PYTHON = os.path.abspath(PYTHON) - msg('Build using: "%s"' % PYTHON) + msg('Will build using: "%s"' % PYTHON) msg(runcmd([PYTHON, '-c', 'import sys; print(sys.version)'], True, False)) PYTHON_ARCH = runcmd( diff --git a/buildtools/config.py b/buildtools/config.py index 5df36dcb..560eb607 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -788,16 +788,14 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True): # add quotes to elements of the command that need it cmd = cmd[:] for idx, item in enumerate(cmd): - if ' ' in item or ';' in item: + if ' ' in item or '\t' in item or ';' in item: if item[0] not in ['"', "'"]: if '"' in item: item = item.replace('"', '\\"') item = '"{}"'.format(item) cmd[idx] = item - + # convert the resulting command to a string cmd = ' '.join(cmd) - #if echoCmd: - # msg(' '.join(cmd)) if echoCmd: msg(cmd) From 9bcccff097e91160d878e69a12f6c3165877aa73 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 23 Jul 2016 00:17:55 -0700 Subject: [PATCH 5/5] If a property's getter has a docstring, use it. --- sphinxtools/librarydescription.py | 29 ++++++++++++++++------------- sphinxtools/modulehunter.py | 3 --- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sphinxtools/librarydescription.py b/sphinxtools/librarydescription.py index 5c4828a8..27271a55 100644 --- a/sphinxtools/librarydescription.py +++ b/sphinxtools/librarydescription.py @@ -941,7 +941,7 @@ class Property(ChildrenBase): def __init__(self, name, item): ChildrenBase.__init__(self, name, object_types.PROPERTY) - + self.getter = self.setter = self.deleter = '' try: @@ -972,19 +972,22 @@ class Property(ChildrenBase): if self.is_redundant: return - docs = '' - for item in [self.setter, self.getter, self.deleter]: - if item and 'lambda' not in item and not item.startswith('_'): - if docs: - docs += ', :meth:`~%s.%s` '%(class_name, item) - else: - docs += ':meth:`~%s.%s` '%(class_name, item) - + docs = self.docs + if not docs: + for item in [self.setter, self.getter, self.deleter]: + if item and 'lambda' not in item and not item.startswith('_'): + if docs: + docs += ', :meth:`~%s.%s` ' % (class_name, item) + else: + docs += ':meth:`~%s.%s` ' % (class_name, item) + + if docs: + docs = 'See %s' % docs + if docs: - docs = 'See %s'%docs - - stream.write(' .. attribute:: %s\n\n'%self.GetShortName()) - stream.write(' %s\n\n\n'%docs) + stream.write(' .. attribute:: %s\n\n' % self.GetShortName()) + docs = '\n '.join(docs.splitlines()) + stream.write(' %s\n\n\n' % docs) class Attribute(ChildrenBase): diff --git a/sphinxtools/modulehunter.py b/sphinxtools/modulehunter.py index f484ec1f..7fbd5a55 100644 --- a/sphinxtools/modulehunter.py +++ b/sphinxtools/modulehunter.py @@ -318,9 +318,6 @@ def describe_class(obj, module_class, module_name, constants): if class_name == 'object': return - if 'GenBitmapButton' in class_name: - print('GenBitmapButton') - class_name = module_class.name + '.' + class_name docs = getdoc(obj)