[Checkins] SVN: z3c.recipe.depgraph/trunk/ Merge with sdouche-exclude-eggs branch.
Sébastien Douche
sdouche at free.fr
Wed Nov 4 12:52:30 EST 2009
Log message for revision 105478:
Merge with sdouche-exclude-eggs branch.
Changed:
U z3c.recipe.depgraph/trunk/CHANGES.txt
U z3c.recipe.depgraph/trunk/README.txt
U z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py
U z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py
-=-
Modified: z3c.recipe.depgraph/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.depgraph/trunk/CHANGES.txt 2009-11-04 12:58:04 UTC (rev 105477)
+++ z3c.recipe.depgraph/trunk/CHANGES.txt 2009-11-04 17:52:29 UTC (rev 105478)
@@ -3,8 +3,15 @@
0.4 (unreleased)
----------------
+- Added additional ``formats`` option, to control in which fileformats the output
+ is generated. [WouterVH]
+- Added additional ``re-exclude``, ``dead-ends`` and ``re-dead-ends`` options,
+ to control used eggs more precisely.
+- Added additional ``strict`` option, if you want graphs only for eggs
+ in eggs option.
+
0.3 (2009-07-23)
----------------
Modified: z3c.recipe.depgraph/trunk/README.txt
===================================================================
--- z3c.recipe.depgraph/trunk/README.txt 2009-11-04 12:58:04 UTC (rev 105477)
+++ z3c.recipe.depgraph/trunk/README.txt 2009-11-04 17:52:29 UTC (rev 105478)
@@ -13,6 +13,15 @@
exclude
A list of eggs which should be excluded from the graph processing.
+re-exclude
+ A list of eggs' regular expressions which should be excluded.
+
+dead-ends
+ A list of eggs which dependencies should be excluded.
+
+re-dead-ends
+ A list of eggs' regular expressions which dependencies should be excluded.
+
extras
A boolean determining if extra requirements should be included. Defaults
to False.
@@ -23,8 +32,20 @@
variants
A whitespace separated list of variants of graphs to create. The available
- options are:
+ options are::
base - The basic full graphs.
tred - The transitive reduction of the graphs.
scc - Extracts graphs of strongly connected components.
+
+formats
+ A whitespace separated list of output-formats to create. Defaults to svg.
+ Please consult the manpages for the dot-command or visit the graphviz-website
+ for a full list_. Most commonly used options are::
+
+ svg - Scalable Vector Graphics
+ png - Portable Network Graphics
+ gif - Graphics Interchange Format
+
+
+ .. _list: http://www.graphviz.org/cvs/doc/info/output.html
Modified: z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py
===================================================================
--- z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py 2009-11-04 12:58:04 UTC (rev 105477)
+++ z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py 2009-11-04 17:52:29 UTC (rev 105478)
@@ -1,4 +1,5 @@
import os
+import re
from zc.buildout import easy_install
from zc.recipe.egg import Egg
@@ -21,13 +22,25 @@
self.name = name
self.options = options
self.egg = Egg(buildout, options['recipe'], options)
+ self.eggs = self.options.get('eggs', '').split()
+ self.strict = self.options.get('strict', '').lower() in ('1', 'true', 'yes')
+
exclude = self.options.get('exclude', '')
+ re_exclude = self.options.get('re-exclude', '')
+ dead_ends = self.options.get('dead-ends', '')
+ re_dead_ends = self.options.get('re-dead-ends', '')
+
self.exclude = set(exclude.split())
+ self.re_exclude = set(re_exclude.split())
+ self.dead_ends = set(dead_ends.split())
+ self.re_dead_ends = set(re_dead_ends.split())
+
self.output = self.options.get(
'output', os.path.join(
- self.buildout['buildout']['parts-directory'], self.name))
+ self.buildout['buildout']['parts-directory'], self.name))
extras = self.options.get('extras', 'false')
self.extras = extras.lower() in ('1', 'true', 'yes')
+ self.formats = self.options.get('formats', 'svg').split()
def install(self):
options = self.options
@@ -39,11 +52,36 @@
variants = options.get('variants', 'base tred scc')
variants = [v.strip() for v in variants.split()]
- # Install an interpreter
- packages = set([dist.project_name for dist in ws.by_key.values()])
- packages = packages - EXCLUDE_PACKAGES - self.exclude
- packages = list(packages)
+ def matcher(names, patterns):
+ names = set(names)
+ matched_names = set()
+ compiled_patterns = [re.compile(pattern) for pattern in patterns]
+
+ def match(name, compiled_patterns):
+ for pattern in compiled_patterns:
+ if pattern.search(name):
+ # matching one pattern is sufficient
+ matched_names.add(name)
+ return
+
+ for name in names:
+ match(name, compiled_patterns)
+ return matched_names
+
+ if self.strict:
+ # use only eggs in the list
+ packages = self.eggs
+
+ else:
+ # Install an interpreter to find eggs
+ packages = set([dist.project_name for dist in ws.by_key.values()])
+ # Remove eggs listed in exclude option
+ packages = packages - EXCLUDE_PACKAGES - self.exclude
+ # Remove eggs listed in re-exclude option
+ packages = packages - matcher(packages, self.re_exclude)
+ packages = list(packages)
+
# Allow to map distribution names to different package names
pmap = dict()
package_map = options.get('package-map', '').strip()
@@ -60,9 +98,14 @@
name=self.name,
path=self.output,
variants=variants,
+ formats=self.formats,
extras=self.extras,
+ exclude = self.exclude,
+ re_exclude = self.re_exclude,
+ dead_ends = self.dead_ends,
+ re_dead_ends = self.re_dead_ends
),
- )
+ )
reqs = ['tl.eggdeps']
scripts = {
@@ -72,7 +115,7 @@
easy_install.scripts(
reqs, ws, options['executable'], options['bin-directory'],
scripts=scripts,
- )
+ )
return self.output
def update(self):
Modified: z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py
===================================================================
--- z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py 2009-11-04 12:58:04 UTC (rev 105477)
+++ z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py 2009-11-04 17:52:29 UTC (rev 105478)
@@ -1,16 +1,23 @@
import os
-GENERATE = "./bin/%(scriptname)s %(extras)s-d %(package)s -i setuptools > %(output)s"
+GENERATE = "./bin/%(scriptname)s %(exclude)s %(re_exclude)s %(dead_ends)s %(re_dead_ends)s %(extras)s-d %(package)s -i setuptools > %(output)s"
TRED = "tred %(input)s > %(output)s"
-GRAPH = "dot -Tsvg %(input)s > %(output)s"
+GRAPH = "dot -T%(format)s %(input)s > %(output)s"
SCCMAP = "sccmap %(input)s > %(output)s"
-SCCGRAPH = "dot -Tsvg %(input)s -O"
+SCCGRAPH = "dot -T%(format)s %(input)s -O"
def execute(template, **kwargs):
os.system(template % kwargs)
+def build_option(option, pattern):
+ result = ''
+ for i in pattern:
+ result += '%s %s ' % (option, i)
+ return result
+
+
def main(args):
name = args.get('name')
packages = args.get('packages')
@@ -18,7 +25,12 @@
path = args.get('path')
scriptname = name + '-eggdeps'
variants = args.get('variants', ['base', 'tred', 'scc'])
+ formats = args.get('formats', ['svg'])
extras = args.get('extras')
+ exclude = build_option('-i', args.get('exclude'))
+ re_exclude = build_option('-I', args.get('re_exclude'))
+ dead_ends = build_option('-e', args.get('dead_ends'))
+ re_dead_ends = build_option('-E', args.get('re_dead_ends'))
for package in packages:
name = package
@@ -39,25 +51,35 @@
extras=extras,
scriptname=scriptname,
package=package,
+ exclude=exclude,
+ re_exclude=re_exclude,
+ dead_ends=dead_ends,
+ re_dead_ends=re_dead_ends,
output=specfile + '.dot')
- execute(GRAPH,
- input=specfile + '.dot',
- output=specfile + '.svg')
+ for format in formats:
+ execute(GRAPH,
+ format=format,
+ input=specfile + '.dot',
+ output=specfile + '.%s' % format)
if 'tred' in variants:
execute(TRED,
input=specfile + '.dot',
output=specfile + '-tred.dot')
- execute(GRAPH,
- input=specfile + '-tred.dot',
- output=specfile + '-tred.svg')
+ for format in formats:
+ execute(GRAPH,
+ format=format,
+ input=specfile + '-tred.dot',
+ output=specfile + '-tred.%s' % format)
if 'scc' in variants:
execute(SCCMAP,
input=specfile + '.dot',
output=specfile + '-sccmap')
- execute(SCCGRAPH,
- input=specfile + '-sccmap')
+ for format in formats:
+ execute(SCCGRAPH,
+ format=format,
+ input=specfile + '-sccmap')
More information about the checkins
mailing list