Mercurial > hg > decoupage
comparison decoupage/templates.py @ 8:16d41af2d8ef
add ability to print templates
author | k0s <k0scist@gmail.com> |
---|---|
date | Thu, 24 Dec 2009 22:48:55 -0500 |
parents | ffb7753bb7bf |
children | 78139c3cecfa |
comparison
equal
deleted
inserted
replaced
7:ffb7753bb7bf | 8:16d41af2d8ef |
---|---|
2 | 2 |
3 import os | 3 import os |
4 import sys | 4 import sys |
5 from optparse import OptionParser | 5 from optparse import OptionParser |
6 from pkg_resources import iter_entry_points | 6 from pkg_resources import iter_entry_points |
7 from pkg_resources import resource_filename | |
7 | 8 |
8 def template_dirs(): | 9 def template_dirs(): |
9 template_dirs = set() | 10 template_dirs = set() |
10 for formatter in iter_entry_points('decoupage.formatters'): | 11 for formatter in iter_entry_points('decoupage.formatters'): |
11 try: | 12 try: |
15 template_dir = resource_filename(formatter.module_name, 'templates') | 16 template_dir = resource_filename(formatter.module_name, 'templates') |
16 if os.path.isdir(template_dir): | 17 if os.path.isdir(template_dir): |
17 template_dirs.add(template_dir) | 18 template_dirs.add(template_dir) |
18 return template_dirs | 19 return template_dirs |
19 | 20 |
21 def templates(): | |
22 templates = [] | |
23 for directory in template_dirs(): | |
24 templates.extend([os.path.join(directory, filename) | |
25 for filename in os.listdir(directory) | |
26 if filename.endswith('.html')]) | |
27 return templates | |
28 | |
20 def main(args=sys.argv[1:]): | 29 def main(args=sys.argv[1:]): |
21 _template_dirs = template_dirs() | 30 for template in templates(): |
22 for d in _template_dirs: | 31 print template |
23 print d | |
24 | 32 |
25 if __name__ == '__main__': | 33 if __name__ == '__main__': |
26 main() | 34 main() |