changeset 83:78139c3cecfa

CLI
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 15 Dec 2013 12:38:24 -0800
parents 8596a1d97740
children 95820b36d7e3
files decoupage/templates.py
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/templates.py
+++ b/decoupage/templates.py
@@ -1,10 +1,14 @@
 #!/usr/bin/env python
 
+"""
+functionality related to templates
+"""
+
 import os
 import sys
 from optparse import OptionParser
 from pkg_resources import iter_entry_points
 from pkg_resources import resource_filename
 
 def template_dirs():
     template_dirs = set()
@@ -12,23 +16,33 @@ def template_dirs():
         try:
             formatter.load()
         except:
             continue
         template_dir = resource_filename(formatter.module_name, 'templates')
         if os.path.isdir(template_dir):
             template_dirs.add(template_dir)
     return template_dirs
-        
+
+
 def templates():
     templates = []
     for directory in template_dirs():
-        templates.extend([os.path.join(directory, filename) 
+        templates.extend([os.path.join(directory, filename)
                           for filename in os.listdir(directory)
                           if filename.endswith('.html')])
     return templates
 
+
 def main(args=sys.argv[1:]):
+
+    # comman line option parser
+    description = 'list available templates'
+    parser = OptionParser(description=description)
+    options, args = parser.parse_args(args)
+
+    # list templates
     for template in templates():
         print template
 
+
 if __name__ == '__main__':
     main()