[geneagrapher] 105/226: Extracting version from the egg and letting the OptionParser take care of requests for the version. This fixes #17.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jul 11 17:10:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository geneagrapher.

commit 986f1bf8d8ded4717d757c0f6ec21412ac9f5213
Author: David Alber <alber.david at gmail.com>
Date:   Mon Dec 29 04:39:53 2008 +0000

    Extracting version from the egg and letting the OptionParser take care of requests for the version. This fixes #17.
---
 Geneagrapher/geneagrapher/geneagrapher.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/Geneagrapher/geneagrapher/geneagrapher.py b/Geneagrapher/geneagrapher/geneagrapher.py
index 3db9f2c..0b4110e 100644
--- a/Geneagrapher/geneagrapher/geneagrapher.py
+++ b/Geneagrapher/geneagrapher/geneagrapher.py
@@ -1,5 +1,6 @@
 from optparse import OptionParser
 import sys
+import pkg_resources
 import GGraph
 import grab
 
@@ -27,7 +28,9 @@ class Geneagrapher:
 		"""
 		Parse command-line information.
 		"""
-		self.parser = OptionParser()
+		pkg_env = pkg_resources.Environment()
+		version = "Geneagrapher %s" % (pkg_env[self.__module__.split('.')[0]][0].version)
+		self.parser = OptionParser(version=version)
 
 		self.parser.set_usage("%prog [options] ID ...")
 		self.parser.set_description('Create a Graphviz "dot" file for a mathematics genealogy, where ID is a record identifier from the Mathematics Genealogy Project. Multiple IDs may be passed.')
@@ -40,8 +43,6 @@ class Geneagrapher:
 				       default=False, help="retrieve descendants of IDs and include in graph")
 		self.parser.add_option("--verbose", "-v", action="store_true", dest="verbose", default=False,
 				       help="list nodes being retrieved")
-		self.parser.add_option("--version", "-V", action="store_true", dest="print_version", default=False,
-				       help="print version and exit")
 		self.parser.add_option("-n", "--attach-node-file", dest="supp_node_filename", metavar="FILE",
 				       help="attach supplementary nodes returned by function 'define_supp_nodes()' in FILE to the graph", default=None)
 		self.parser.add_option("-s", "--node-sort", dest="node_sort_order", metavar="SORT_TYPE",
@@ -49,10 +50,6 @@ class Geneagrapher:
 
 		(options, args) = self.parser.parse_args()
 		
-		if options.print_version:
-			print "Geneagrapher Version 0.2"
-			self.parser.exit()
-		
 		if len(args) == 0:
 			raise SyntaxError("%s: error: no record IDs passed" % (self.parser.get_prog_name()))
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/geneagrapher.git



More information about the debian-science-commits mailing list