[geneagrapher] 140/226: Reformatting: getting rid of ancient tabs.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Sat Jul 11 17:10:56 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 21575b22148fe30c976c54b8c926610c40e64bbd
Author: David Alber <alber.david at gmail.com>
Date: Fri Oct 28 22:43:34 2011 -0700
Reformatting: getting rid of ancient tabs.
---
geneagrapher/geneagrapher.py | 235 ++++++++++++++++++++++---------------------
geneagrapher/ggrapher.py | 20 ++--
2 files changed, 129 insertions(+), 126 deletions(-)
diff --git a/geneagrapher/geneagrapher.py b/geneagrapher/geneagrapher.py
index 4f6cadc..20012d5 100644
--- a/geneagrapher/geneagrapher.py
+++ b/geneagrapher/geneagrapher.py
@@ -4,127 +4,130 @@ import GGraph
import grab
class Geneagrapher:
- """
- A class for building Graphviz "dot" files for math genealogies
- extracted from the Mathematics Genealogy Project website.
- """
- def __init__(self):
- self.graph = GGraph.Graph()
- self.leaf_ids = []
- self.get_ancestors = False
- self.get_descendants = False
- self.verbose = False
- self.write_filename = None
+ """
+ A class for building Graphviz "dot" files for math genealogies
+ extracted from the Mathematics Genealogy Project website.
+ """
+ def __init__(self):
+ self.graph = GGraph.Graph()
+ self.leaf_ids = []
+ self.get_ancestors = False
+ self.get_descendants = False
+ self.verbose = False
+ self.write_filename = None
- def parseInput(self):
- """
- Parse command-line information.
- """
- pkg_env = pkg_resources.Environment()
- self.parser = OptionParser(version="{}".format(
- pkg_env[self.__module__.split('.')[0]][0].version))
+ def parseInput(self):
+ """
+ Parse command-line information.
+ """
+ pkg_env = pkg_resources.Environment()
+ self.parser = OptionParser(version="{}".format(
+ pkg_env[self.__module__.split('.')[0]][0].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.')
+ 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.')
- self.parser.add_option("-f", "--file", dest="filename",
- help="write output to FILE [default: stdout]", metavar="FILE", default=None)
- self.parser.add_option("-a", "--with-ancestors", action="store_true", dest="get_ancestors",
- default=False, help="retrieve ancestors of IDs and include in graph")
- self.parser.add_option("-d", "--with-descendants", action="store_true", dest="get_descendants",
- 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("-f", "--file", dest="filename",
+ help="write output to FILE [default: stdout]",
+ metavar="FILE", default=None)
+ self.parser.add_option("-a", "--with-ancestors", action="store_true",
+ dest="get_ancestors", default=False,
+ help="retrieve ancestors of IDs and include in graph")
+ self.parser.add_option("-d", "--with-descendants", action="store_true",
+ dest="get_descendants", 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")
- (options, args) = self.parser.parse_args()
-
- if len(args) == 0:
- raise SyntaxError("%s: error: no record IDs passed" % (self.parser.get_prog_name()))
+ (options, args) = self.parser.parse_args()
+
+ if len(args) == 0:
+ raise SyntaxError("%s: error: no record IDs passed" % (self.parser.get_prog_name()))
- self.get_ancestors = options.get_ancestors
- self.get_descendants = options.get_descendants
- self.verbose = options.verbose
- self.write_filename = options.filename
- for arg in args:
- self.leaf_ids.append(int(arg))
-
- def buildGraph(self):
- """
- Populate the graph member by grabbing the mathematician
- pages and extracting relevant data.
- """
- leaf_grab_queue = list(self.leaf_ids)
- ancestor_grab_queue = []
- descendant_grab_queue = []
+ self.get_ancestors = options.get_ancestors
+ self.get_descendants = options.get_descendants
+ self.verbose = options.verbose
+ self.write_filename = options.filename
+ for arg in args:
+ self.leaf_ids.append(int(arg))
+
+ def buildGraph(self):
+ """
+ Populate the graph member by grabbing the mathematician
+ pages and extracting relevant data.
+ """
+ leaf_grab_queue = list(self.leaf_ids)
+ ancestor_grab_queue = []
+ descendant_grab_queue = []
- # Grab "leaf" nodes.
- while len(leaf_grab_queue) != 0:
- id = leaf_grab_queue.pop()
- if not self.graph.hasNode(id):
- # Then this information has not yet been grabbed.
- grabber = grab.Grabber(id)
- if self.verbose:
- print "Grabbing record #{}".format(id)
- try:
- [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
- except ValueError:
- # The given id does not exist in the Math Genealogy Project's database.
- raise
- self.graph.addNode(name, institution, year, id, advisors, descendants, True)
- if self.get_ancestors:
- ancestor_grab_queue += advisors
- if self.get_descendants:
- descendant_grab_queue += descendants
+ # Grab "leaf" nodes.
+ while len(leaf_grab_queue) != 0:
+ id = leaf_grab_queue.pop()
+ if not self.graph.hasNode(id):
+ # Then this information has not yet been grabbed.
+ grabber = grab.Grabber(id)
+ if self.verbose:
+ print "Grabbing record #{}".format(id)
+ try:
+ [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
+ except ValueError:
+ # The given id does not exist in the Math Genealogy Project's database.
+ raise
+ self.graph.addNode(name, institution, year, id, advisors, descendants, True)
+ if self.get_ancestors:
+ ancestor_grab_queue += advisors
+ if self.get_descendants:
+ descendant_grab_queue += descendants
- # Grab ancestors of leaf nodes.
- if self.get_ancestors:
- while len(ancestor_grab_queue) != 0:
- id = ancestor_grab_queue.pop()
- if not self.graph.hasNode(id):
- # Then this information has not yet been grabbed.
- grabber = grab.Grabber(id)
- if self.verbose:
- print "Grabbing record #{}".format(id)
- try:
- [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
- except ValueError:
- # The given id does not exist in the Math Genealogy Project's database.
- raise
- self.graph.addNode(name, institution, year, id, advisors, descendants)
- ancestor_grab_queue += advisors
-
- # Grab descendants of leaf nodes.
- if self.get_descendants:
- while len(descendant_grab_queue) != 0:
- id = descendant_grab_queue.pop()
- if not self.graph.hasNode(id):
- # Then this information has not yet been grabbed.
- grabber = grab.Grabber(id)
- if self.verbose:
- print "Grabbing record #{}".format(id)
- try:
- [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
- except ValueError:
- # The given id does not exist in the Math Genealogy Project's database.
- raise
- self.graph.addNode(name, institution, year, id, advisors, descendants)
- descendant_grab_queue += descendants
-
- def generateDotFile(self):
- dotfile = self.graph.generateDotFile(self.get_ancestors, self.get_descendants)
- if self.write_filename is not None:
- outfile = open(self.write_filename, "w")
- outfile.write(dotfile)
- outfile.close()
- else:
- print dotfile
-
+ # Grab ancestors of leaf nodes.
+ if self.get_ancestors:
+ while len(ancestor_grab_queue) != 0:
+ id = ancestor_grab_queue.pop()
+ if not self.graph.hasNode(id):
+ # Then this information has not yet been grabbed.
+ grabber = grab.Grabber(id)
+ if self.verbose:
+ print "Grabbing record #{}".format(id)
+ try:
+ [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
+ except ValueError:
+ # The given id does not exist in the Math Genealogy Project's database.
+ raise
+ self.graph.addNode(name, institution, year, id, advisors, descendants)
+ ancestor_grab_queue += advisors
+
+ # Grab descendants of leaf nodes.
+ if self.get_descendants:
+ while len(descendant_grab_queue) != 0:
+ id = descendant_grab_queue.pop()
+ if not self.graph.hasNode(id):
+ # Then this information has not yet been grabbed.
+ grabber = grab.Grabber(id)
+ if self.verbose:
+ print "Grabbing record #{}".format(id)
+ try:
+ [name, institution, year, advisors, descendants] = grabber.extractNodeInformation()
+ except ValueError:
+ # The given id does not exist in the Math Genealogy Project's database.
+ raise
+ self.graph.addNode(name, institution, year, id, advisors, descendants)
+ descendant_grab_queue += descendants
+
+ def generateDotFile(self):
+ dotfile = self.graph.generateDotFile(self.get_ancestors, self.get_descendants)
+ if self.write_filename is not None:
+ outfile = open(self.write_filename, "w")
+ outfile.write(dotfile)
+ outfile.close()
+ else:
+ print dotfile
+
if __name__ == "__main__":
- geneagrapher = Geneagrapher()
- try:
- geneagrapher.parseInput()
- except SyntaxError, e:
- print geneagrapher.parser.get_usage()
- print e
- geneagrapher.buildGraph()
- geneagrapher.generateDotFile()
+ geneagrapher = Geneagrapher()
+ try:
+ geneagrapher.parseInput()
+ except SyntaxError, e:
+ print geneagrapher.parser.get_usage()
+ print e
+ geneagrapher.buildGraph()
+ geneagrapher.generateDotFile()
diff --git a/geneagrapher/ggrapher.py b/geneagrapher/ggrapher.py
index d816605..a059270 100644
--- a/geneagrapher/ggrapher.py
+++ b/geneagrapher/ggrapher.py
@@ -1,13 +1,13 @@
import geneagrapher
def ggrapher():
- """Function to run the Geneagrapher. This is the function called when
- the ggrapher script is run."""
- ggrapher = geneagrapher.Geneagrapher()
- try:
- ggrapher.parseInput()
- except SyntaxError, e:
- print ggrapher.parser.get_usage()
- print e
- ggrapher.buildGraph()
- ggrapher.generateDotFile()
+ """Function to run the Geneagrapher. This is the function called when
+ the ggrapher script is run."""
+ ggrapher = geneagrapher.Geneagrapher()
+ try:
+ ggrapher.parseInput()
+ except SyntaxError, e:
+ print ggrapher.parser.get_usage()
+ print e
+ ggrapher.buildGraph()
+ ggrapher.generateDotFile()
--
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