| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | """ |
|---|
| 4 | script to create a trac plugin given the interfaces to be used |
|---|
| 5 | """ |
|---|
| 6 | |
|---|
| 7 | import os |
|---|
| 8 | import subprocess |
|---|
| 9 | import sys |
|---|
| 10 | |
|---|
| 11 | from create_trac_plugin.create_component import check_interfaces |
|---|
| 12 | from create_trac_plugin.create_component import parse_args |
|---|
| 13 | from create_trac_plugin.create_component import print_component |
|---|
| 14 | |
|---|
| 15 | def main(): |
|---|
| 16 | |
|---|
| 17 | ### parse the arguments |
|---|
| 18 | parse_args() |
|---|
| 19 | |
|---|
| 20 | ### check to ensure that the interfaces given actually exist |
|---|
| 21 | nonexistant = check_interfaces(*sys.argv[2:]) |
|---|
| 22 | if nonexistant: |
|---|
| 23 | print "Error: interfaces specified not found: " + ', '.join(nonexistant) |
|---|
| 24 | sys.exit(1) |
|---|
| 25 | |
|---|
| 26 | ### run paster create -t trac_plugin |
|---|
| 27 | ### this should be installed as a dependency |
|---|
| 28 | # XXX this should probably use python code instead of shelling out |
|---|
| 29 | subprocess.call(['paster', 'create', '-t', 'trac_plugin', sys.argv[1]]) |
|---|
| 30 | |
|---|
| 31 | # figure out what paster did |
|---|
| 32 | project = sys.argv[1].lower() |
|---|
| 33 | filename = os.path.join(sys.argv[1], project, '%s.py' % project) |
|---|
| 34 | |
|---|
| 35 | ### (re)generate the plugin file based on the interfaces passed |
|---|
| 36 | component = print_component(*sys.argv[1:]) |
|---|
| 37 | module = file(filename, 'w') |
|---|
| 38 | print >> module, component |
|---|
| 39 | module.close() |
|---|
| 40 | |
|---|
| 41 | if __name__ == '__main__': |
|---|
| 42 | main() |
|---|
| 43 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.