Mercurial > hg > MakeItSo
diff makeitso/python.py @ 159:cfd4f1e91090
wip
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 30 Jul 2013 15:20:38 -0700 |
parents | 386a44a52139 |
children | 9033a5f11b92 |
line wrap: on
line diff
--- a/makeitso/python.py Tue Jul 30 11:08:01 2013 -0700 +++ b/makeitso/python.py Tue Jul 30 15:20:38 2013 -0700 @@ -27,17 +27,24 @@ class PythonTemplate(MakeItSoTemplate): """abstract base class for python-type templates""" + def path2name(self, path): + return os.path.basename(path.rstrip(os.path.sep)) class PythonScriptTemplate(PythonTemplate): """template for a single python script""" - templates = [os.path.join('python_package', '{{package}}', 'main.py')] + templates = [('python_package', '{{package}}', '{{main}}.py')] class PythonModuleTemplate(PythonTemplate): """single module python package""" # TODO: this should use the same files as PythonPackageTemplate - templates = ['python_module'] + templates = ['python_module', + ('python_package', '{{package}}', '{{main}}.py')] + vars = [Variable('description')] + look = False + def pre(self, variables, output): + variables['module'] = variables['main'] = path2name(output) class PythonPackageTemplate(PythonTemplate): """ @@ -48,7 +55,7 @@ vars = [Variable('description'), Variable('author', 'author of the package'), Variable('email', "author's email"), - Variable('url'), + Variable('url', 'project url'), Variable('repo', 'project repository'), ] look = False @@ -56,7 +63,7 @@ # things that go in setup.py dependencies = {'web.py': ['webob'], 'template.py': ['MakeItSo']} - console_scripts = {'main.py': '{{project}} = {{project}}.main:main', + console_scripts = {'main.py': '{{project}} = {{project}}.{{main}}:main', 'template.py': '{{project}}-template = {{project}}.template:main' } @@ -71,13 +78,16 @@ """ # get project from output directory - variables['project'] = os.path.basename(output) + variables['project'] = self.path2name(output) # get package name from project # XXX could have looser restrictions with transforms assert variables['project'].isalnum(), 'Project name must be just letters, you gave %s' % variables['project'] variables['package'] = variables['project'].lower() + # name of CLI main file + variables.setdefault('main', 'main') + # dependencies dependencies = set([]) for template, dependency in self.dependencies.items():