comparison makeitso/python.py @ 155:386a44a52139

moving to a thing with script template
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 05 Jun 2013 13:38:23 -0700
parents e70421c50d0a
children cfd4f1e91090
comparison
equal deleted inserted replaced
154:ebc5cfe17d95 155:386a44a52139
25 from template import Variable 25 from template import Variable
26 26
27 class PythonTemplate(MakeItSoTemplate): 27 class PythonTemplate(MakeItSoTemplate):
28 """abstract base class for python-type templates""" 28 """abstract base class for python-type templates"""
29 29
30
31 class PythonScriptTemplate(PythonTemplate):
32 """template for a single python script"""
33 templates = [os.path.join('python_package', '{{package}}', 'main.py')]
34
35
30 class PythonModuleTemplate(PythonTemplate): 36 class PythonModuleTemplate(PythonTemplate):
31 """single module python package""" 37 """single module python package"""
38 # TODO: this should use the same files as PythonPackageTemplate
32 templates = ['python_module'] 39 templates = ['python_module']
40
33 41
34 class PythonPackageTemplate(PythonTemplate): 42 class PythonPackageTemplate(PythonTemplate):
35 """ 43 """
36 python package template 44 python package template
37 """ 45 """
74 dependencies = set([]) 82 dependencies = set([])
75 for template, dependency in self.dependencies.items(): 83 for template, dependency in self.dependencies.items():
76 dependencies.update(dependency) 84 dependencies.update(dependency)
77 dependencies = list(dependencies) 85 dependencies = list(dependencies)
78 variables['dependencies'] = dependencies 86 variables['dependencies'] = dependencies
79 87
80 # console_scripts 88 # console_scripts
81 console_scripts = [] 89 console_scripts = []
82 for template, console_script in self.console_scripts.items(): 90 for template, console_script in self.console_scripts.items():
83 console_scripts.append(console_script) 91 console_scripts.append(console_script)
84 if console_scripts: 92 if console_scripts:
103 def main(args=sys.argv[1:]): 111 def main(args=sys.argv[1:]):
104 cli = PythonPackageCLI(PythonPackageTemplate) 112 cli = PythonPackageCLI(PythonPackageTemplate)
105 cli(*args) 113 cli(*args)
106 114
107 if __name__ == '__main__': 115 if __name__ == '__main__':
108 main() 116 main()