Mercurial > hg > decoupage
annotate decoupage/templates.py @ 3:ea5a5ef8ae2e
add stub for template printing; does not work yet
author | k0s <k0scist@gmail.com> |
---|---|
date | Sun, 22 Nov 2009 02:27:44 -0500 |
parents | |
children | 6a802c87f070 |
rev | line source |
---|---|
3
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
2 |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
3 import os |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
4 import sys |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
5 from optparse import OptionParser |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
6 from pkg_resources import iter_entry_points |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
7 |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
8 def template_dirs(): |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
9 template_dirs = set() |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
10 for formatter in iter_entry_points('decoupage.formatters'): |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
11 try: |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
12 formatter.load() |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 except: |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
14 continue |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 template_dir = resource_filename(formatter.module_name, 'templates') |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
16 if os.path.isdir(template_dir): |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
17 template_dirs.add(template_dir) |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
18 return template_dirs |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
19 |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
20 def main(args=sys.argv[1:]): |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
21 _template_dirs = template_dirs() |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
22 for d in _template_dirs: |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
23 print d |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
24 |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
25 if __name__ == '__main__': |
ea5a5ef8ae2e
add stub for template printing; does not work yet
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
26 main() |