Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r145 - trunk/repoguard/src/repoguard/main.py

repoguard
Discussion topic

Back to topic list

svn commit: r145 - trunk/repoguard/src/repoguard/main.py

Author schlauch
Full name Tobias Schlauch
Date 2012-10-10 14:07:46 PDT
Message Author: schlauch
Date: 2012-10-10 14:07:46-0700
New Revision: 145

Modified:
   trunk/repoguard/src/​repoguard/main.py

Log:
Corrected loading of entry points for command line tools. Now separate projects can define the entry point "repoguard.tools" and RepoGuard finds the corresponding sub-command.

Modified: trunk/repoguard/src/​repoguard/main.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/src/repoguar​d/main.py?view=diff​&pathrev=145&​r1=144&r2=145
====================​====================​====================​==================
--- trunk/repoguard/src/​repoguard/main.py (original)
+++ trunk/repoguard/src/​repoguard/main.py 2012-10-10 14:07:46-0700
@@ -37,15 +37,18 @@
     
     usage = "\n repoguard [options] mode\n\n" \
           + "Following 'mode'-values are accepted:\n"
+
+ tools = dict()
     
- group = 'repoguard.tools'
- tools = {}
- names = pkg_resources.get_en​try_map('repoguard',​ group).keys()
- names.sort(cmp=lambda x,y: cmp(x.lower(), y.lower()))
+ entrypoints = dict()
+ for entrypoint in pkg_resources.iter_e​ntry_points("repogua​rd.tools"):
+ entrypoints[entrypoint.name] = entrypoint.load()()
+ names = entrypoints.keys()
+ names.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
     for name in names:
- tool = pkg_resources.load_e​ntry_point('repoguar​d', group, name)()
+ tool = entrypoints[name]
         descriptors = tool.descriptors.items()
- descriptors.sort(cmp=lambda x,y: cmp(x[0].lower(), y[0].lower()))
+ descriptors.sort(cmp=lambda x, y: cmp(x[0].lower(), y[0].lower()))
         
         usage += "%-18s\t%s\n" % (name, tool.description)
         for command, descriptor in descriptors:
@@ -56,7 +59,6 @@
             tools[command] = (tool, descriptor)
         
     usage += "Write repoguard mode -h to get more help for every option"
-
     version = pkg_resources.requir​e("repoguard")[0].ve​rsion
     full_name = "RepoGuard Command Line Tools v" + version
     parser = OptionParser(usage=usage, version=full_name)
@@ -71,4 +73,4 @@
     return getattr(tool, descriptor.method)(parser) or 0
 
 if __name__ == "__main__":
- sys.exit(main(sys.argv))
\ No newline at end of file
+ sys.exit(main(sys.argv))

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r145 - trunk/repoguard/src/repoguard/main.py schlauch Tobias Schlauch 2012-10-10 14:07:46 PDT
Messages per page: