[cig-commits] r5325 - cs/merlin/branches/v1/merlin
leif at geodynamics.org
leif at geodynamics.org
Fri Nov 17 16:43:47 PST 2006
Author: leif
Date: 2006-11-17 16:43:47 -0800 (Fri, 17 Nov 2006)
New Revision: 5325
Modified:
cs/merlin/branches/v1/merlin/__init__.py
Log:
Incorporated some methods from Pythia as extensions --
this is where the methods really belong.
Modified: cs/merlin/branches/v1/merlin/__init__.py
===================================================================
--- cs/merlin/branches/v1/merlin/__init__.py 2006-11-18 00:41:52 UTC (rev 5324)
+++ cs/merlin/branches/v1/merlin/__init__.py 2006-11-18 00:43:47 UTC (rev 5325)
@@ -682,7 +682,7 @@
to resolve their dependencies. `error_info` is a dictionary mapping
unloadable plugin distributions to an exception instance describing the
error that occurred. Usually this will be a ``DistributionNotFound`` or
- ``VersionConflict`` instance.
+ ``VersionConflict`` instance."
"""
plugin_projects = list(plugin_env)
@@ -765,14 +765,43 @@
+ # Merlin extensions
+ def strict(cls, requires):
+ """Return the a working set for the given requirement, excluding
+ any meta-dependencies."""
+
+ workingSet = WorkingSet([])
+ requirements = parse_requirements(requires)
+
+ for dist in workingSet.resolve(requirements, Environment()):
+ workingSet.add(dist)
+ return workingSet
+ strict = classmethod(strict)
+ def minimal(cls, requires):
+ """Return the minimal working set for the given requirement."""
+
+ workingSet = cls.strict(requires)
+ for dist in workingSet.resolve([Requirement.parse("merlin")], Environment()):
+ workingSet.add(dist)
+
+ return workingSet
+
+ minimal = classmethod(minimal)
+
+
+
+
+
+
+
class Environment(object):
"""Searchable snapshot of distributions on a search path"""
@@ -2659,3 +2688,23 @@
add_activation_listener(lambda dist: dist.activate())
working_set.entries=[]; map(working_set.add_entry,sys.path) # match order
+
+
+# Merlin extensions
+
+def loadObject(name):
+ """Load and return the object referenced by <name> ==
+ some.module[:some.attr].
+
+ Derived from EntryPoint.
+
+ """
+
+ module, attrs = name.split(':')
+ attrs = attrs.split('.')
+ obj = __import__(module, globals(), globals(), ['__name__'])
+ for attr in attrs:
+ obj = getattr(obj, attr)
+ return obj
+
+
More information about the cig-commits
mailing list