Mercurial > hg > MakeItSo
comparison makeitso/python.py @ 161:a5d058957734
wip
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Tue, 30 Jul 2013 15:36:24 -0700 |
| parents | 9033a5f11b92 |
| children | 1a419ebe0fe5 |
comparison
equal
deleted
inserted
replaced
| 160:9033a5f11b92 | 161:a5d058957734 |
|---|---|
| 31 Variable('email', "author's email"), | 31 Variable('email', "author's email"), |
| 32 Variable('url', 'project url'), | 32 Variable('url', 'project url'), |
| 33 Variable('repo', 'project repository'), | 33 Variable('repo', 'project repository'), |
| 34 ] | 34 ] |
| 35 | 35 |
| 36 def path2name(self, path): | 36 def output2name(self, path): |
| 37 return os.path.basename(path.rstrip(os.path.sep)) | 37 return os.path.splitext(os.path.basename(path.rstrip(os.path.sep)))[0] |
| 38 | 38 |
| 39 class PythonScriptTemplate(PythonTemplate): | 39 class PythonScriptTemplate(PythonTemplate): |
| 40 """template for a single python script""" | 40 """template for a single python script""" |
| 41 templates = [('python_package', '{{package}}', '{{main}}.py')] | 41 templates = [('python_package', '{{package}}', '{{main}}.py')] |
| 42 vars = [Variable('description')] | 42 vars = [Variable('description')] |
| 48 ('python_package', '{{package}}', '{{main}}.py')] | 48 ('python_package', '{{package}}', '{{main}}.py')] |
| 49 vars = [Variable('description')] | 49 vars = [Variable('description')] |
| 50 look = False | 50 look = False |
| 51 | 51 |
| 52 def pre(self, variables, output): | 52 def pre(self, variables, output): |
| 53 variables['module'] = variables['main'] = path2name(output) | 53 variables['module'] = variables['main'] = self.output2name(output) |
| 54 | 54 |
| 55 class PythonPackageTemplate(PythonTemplate): | 55 class PythonPackageTemplate(PythonTemplate): |
| 56 """ | 56 """ |
| 57 python package template | 57 python package template |
| 58 """ | 58 """ |
| 82 """ | 82 """ |
| 83 sanitize some variables | 83 sanitize some variables |
| 84 """ | 84 """ |
| 85 | 85 |
| 86 # get project from output directory | 86 # get project from output directory |
| 87 variables['project'] = self.path2name(output) | 87 variables['project'] = self.output2name(output) |
| 88 | 88 |
| 89 # get package name from project | 89 # get package name from project |
| 90 # XXX could have looser restrictions with transforms | 90 # XXX could have looser restrictions with transforms |
| 91 assert variables['project'].isalnum(), 'Project name must be just letters, you gave %s' % variables['project'] | 91 assert variables['project'].isalnum(), 'Project name must be just letters, you gave %s' % variables['project'] |
| 92 variables['package'] = variables['project'].lower() | 92 variables['package'] = variables['project'].lower() |
