[Python-checkins] distutils2: Whitespace cleaning

tarek.ziade python-checkins at python.org
Thu Aug 19 08:34:13 CEST 2010


tarek.ziade pushed f91c9afa25fb to distutils2:

http://hg.python.org/distutils2/rev/f91c9afa25fb
changeset:   545:f91c9afa25fb
user:        ?ric Araujo <merwok at netwok.org>
date:        Wed Aug 11 06:15:30 2010 +0200
summary:     Whitespace cleaning
files:       src/distutils2/mkpkg.py

diff --git a/src/distutils2/mkpkg.py b/src/distutils2/mkpkg.py
--- a/src/distutils2/mkpkg.py
+++ b/src/distutils2/mkpkg.py
@@ -14,73 +14,67 @@
 #
 #  TODO:
 #
-#    Look for a license file and automatically add the category.
-#
-#    When a .c file is found during the walk, can we add it as an extension?
-#
-#    Ask if the author is the maintainer?
-#
-#    Ask for the platform (can we detect this via "import win32" or something)?
-#
-#    Ask for the dependencies.
-#
-#    Ask for the Requires-Dist
-#
-#    Ask for the Provides-Dist
-#
-#    Detect scripts (not sure how.  #! outside of package?)
+#  Look for a license file and automatically add the category.
+#  When a .c file is found during the walk, can we add it as an extension?
+#  Ask if there is a maintainer different that the author
+#  Ask for the platform (can we detect this via "import win32" or something)?
+#  Ask for the dependencies.
+#  Ask for the Requires-Dist
+#  Ask for the Provides-Dist
+#  Detect scripts (not sure how.  #! outside of package?)
 
+import os
 import sys
-import os
 import re
 import shutil
 import ConfigParser
+from textwrap import dedent
 from distutils2._trove import all_classifiers
 
 
 helpText = {
-   'name' : '''
+    'name': '''
 The name of the program to be packaged, usually a single word composed
 of lower-case characters such as "python", "sqlalchemy", or "CherryPy".
 ''',
-   'version' : '''
+    'version': '''
 Version number of the software, typically 2 or 3 numbers separated by dots
 such as "1.00", "0.6", or "3.02.01".  "0.1.0" is recommended for initial
 development.
 ''',
-   'description' : '''
+    'description': '''
 A short summary of what this package is or does, typically a sentence 80
 characters or less in length.
 ''',
-   'author' : '''
+    'author': '''
 The full name of the author (typically you).
 ''',
-   'author_email' : '''
+    'author_email': '''
 E-mail address of the package author (typically you).
 ''',
-   'do_classifier' : '''
+    'do_classifier': '''
 Trove classifiers are optional identifiers that allow you to specify the
 intended audience by saying things like "Beta software with a text UI
 for Linux under the PSF license.  However, this can be a somewhat involved
 process.
 ''',
-   'url' : '''
+    'url': '''
 The home page for the package, typically starting with "http://".
 ''',
-   'trove_license' : '''
+    'trove_license': '''
 Optionally you can specify a license.  Type a string that identifies a common
 license, and then you can select a list of license specifiers.
 ''',
-   'trove_generic' : '''
+    'trove_generic': '''
 Optionally, you can set other trove identifiers for things such as the
 human language, programming language, user interface, etc...
 ''',
 }
 
 
-def askYn(question, default = None, helptext = None):
+def askYn(question, default=None, helptext=None):
     while True:
-        answer = ask(question, default, helptext, required = True)
+        answer = ask(question, default, helptext, required=True)
         if answer and answer[0].lower() in 'yn':
             return answer[0].lower()
 
@@ -144,23 +138,19 @@
         self.setupData = {}
         self.setupData['classifier'] = self.classifierDict
         self.setupData['packages'] = {}
-
         self.loadConfigFile()
 
-
     def lookupOption(self, key):
         if not self.config.has_option('DEFAULT', key):
             return None
         return self.config.get('DEFAULT', key)
 
-
     def loadConfigFile(self):
         self.config = ConfigParser.RawConfigParser()
         self.config.read(os.path.expanduser('~/.mkpkgpy'))
         self.setupData['author'] = self.lookupOption('author')
         self.setupData['author_email'] = self.lookupOption('author_email')
 
-
     def updateConfigFile(self):
         valuesDifferent = False
         for compareKey in ('author', 'author_email'):
@@ -174,11 +164,9 @@
 
         self.config.write(open(os.path.expanduser('~/.pygiver'), 'w'))
 
-
     def loadExistingSetup(self):
         raise NotImplementedError
 
-
     def inspectFile(self, path):
         fp = open(path, 'r')
         try:
@@ -192,7 +180,6 @@
         finally:
             fp.close()
 
-
     def inspectDirectory(self):
         dirName = os.path.basename(os.getcwd())
         self.setupData['name'] = dirName
@@ -218,7 +205,6 @@
 
                     self.setupData['packages'][tmpRoot] = root[1 + len(os.path.sep):]
 
-
     def queryUser(self):
         self.setupData['name'] = ask('Package name', self.setupData['name'],
               helpText['name'])
@@ -234,21 +220,18 @@
         self.setupData['url'] = ask('Project URL',
               self.setupData.get('url'), helpText['url'], required=False)
 
-        if (askYn('Do you want to set Trove classifiers?',
-                helptext=helpText['do_classifier']) == 'y'):
+        if askYn('Do you want to set Trove classifiers?',
+                 helptext=helpText['do_classifier']) == 'y':
             self.setTroveClassifier()
 
-
     def setTroveClassifier(self):
         self.setTroveDevStatus(self.classifierDict)
         self.setTroveLicense(self.classifierDict)
         self.setTroveOther(self.classifierDict)
 
-
     def setTroveOther(self, classifierDict):
-        if askYn('Do you want to set other trove identifiers',
-                'n',
-                helpText['trove_generic']) != 'y':
+        if askYn('Do you want to set other trove identifiers', 'n',
+                 helpText['trove_generic']) != 'y':
             return
 
         self.walkTrove(classifierDict, [troveDict], '')
@@ -271,7 +254,6 @@
                 self.walkTrove(classifierDict, trovePath + [trove[key]],
                         desc + ' :: ' + key)
 
-
     def setTroveLicense(self, classifierDict):
         while True:
             license = ask('What license do you use',
@@ -301,7 +283,7 @@
             for i in xrange(1, len(foundList) + 1):
                 question += '   %s) %s\n' % (i, all_classifiers[foundList[i - 1]])
             question += ('\nType the number of the license you wish to use or '
-                     '? to try again:')
+                         '? to try again:')
             troveLicense = ask(question, required=False)
 
             if troveLicense == '?':
@@ -316,30 +298,30 @@
                 print ("ERROR: Invalid selection, type a number from the list "
                        "above.")
 
-
     def setTroveDevStatus(self, classifierDict):
         while True:
-            devStatus = ask('''Please select the project status:
+            devStatus = ask(dedent('''\
+                Please select the project status:
 
-1 - Planning
-2 - Pre-Alpha
-3 - Alpha
-4 - Beta
-5 - Production/Stable
-6 - Mature
-7 - Inactive
+                1 - Planning
+                2 - Pre-Alpha
+                3 - Alpha
+                4 - Beta
+                5 - Production/Stable
+                6 - Mature
+                7 - Inactive
 
-Status''', required=False)
+                Status'''), required=False)
             if devStatus:
                 try:
                     key = {
-                           '1' : 'Development Status :: 1 - Planning',
-                           '2' : 'Development Status :: 2 - Pre-Alpha',
-                           '3' : 'Development Status :: 3 - Alpha',
-                           '4' : 'Development Status :: 4 - Beta',
-                           '5' : 'Development Status :: 5 - Production/Stable',
-                           '6' : 'Development Status :: 6 - Mature',
-                           '7' : 'Development Status :: 7 - Inactive',
+                           '1': 'Development Status :: 1 - Planning',
+                           '2': 'Development Status :: 2 - Pre-Alpha',
+                           '3': 'Development Status :: 3 - Alpha',
+                           '4': 'Development Status :: 4 - Beta',
+                           '5': 'Development Status :: 5 - Production/Stable',
+                           '6': 'Development Status :: 6 - Mature',
+                           '7': 'Development Status :: 7 - Inactive',
                            }[devStatus]
                     classifierDict[key] = 1
                     return

--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list