# HG changeset patch # User Jeff Hammel # Date 1295018963 28800 # Node ID 2142ad247eb6e2d5846e853019efb7360d3b4ee7 # Parent 1295df1700a42e2115322611cec6cd1ec94aacc0 we can has entry points diff -r 1295df1700a4 -r 2142ad247eb6 makeitso/makeitso.py --- a/makeitso/makeitso.py Tue Jan 11 19:30:13 2011 -0800 +++ b/makeitso/makeitso.py Fri Jan 14 07:29:23 2011 -0800 @@ -325,14 +325,16 @@ """template for several files/directories""" def __init__(self, templates, interactive=True, variables=None): - self.interactive = interactive self.templates = [] + entry_points = get_entry_points() for template in templates: if isinstance(template, basestring): # TODO: check if the template is a [e.g] PasteScript.template entry point if os.path.isdir(template): self.templates.append(DirectoryTemplate(template, interactive=self.interactive, variables=variables)) + elif not os.path.exists(template) and template in entry_points: + self.templates.append(entry_points[template](interactive=interactive, variables=variables)) else: self.templates.append(URITemplate(template, interactive=self.interactive, variables=variables)) else: @@ -512,11 +514,16 @@ # get templates from pkg_resources # (MakeItSo! and [TODO] pastescript templates) # this should go last to ensure the module is wholly loaded -def get_entry_points(name): +def get_entry_points(): + retval = {} try: from pkg_resources import iter_entry_points for i in iter_entry_points('makeitso.templates'): - pass # :( + try: + retval[i.name] = i.load() + except: + continue except ImportError: - return None + return retval + return retval