Commit 11051abd authored by Jason R. Coombs's avatar Jason R. Coombs

Extract _parents function and _set_egg method. Reword comment.

parent 41732cd2
...@@ -1577,6 +1577,17 @@ is not allowed. ...@@ -1577,6 +1577,17 @@ is not allowed.
register_loader_type(object, NullProvider) register_loader_type(object, NullProvider)
def _parents(path):
"""
yield all parents of path including path
"""
last = None
while path != last:
yield path
last = path
path, _ = os.path.split(path)
class EggProvider(NullProvider): class EggProvider(NullProvider):
"""Provider based on a virtual filesystem""" """Provider based on a virtual filesystem"""
...@@ -1585,18 +1596,16 @@ class EggProvider(NullProvider): ...@@ -1585,18 +1596,16 @@ class EggProvider(NullProvider):
self._setup_prefix() self._setup_prefix()
def _setup_prefix(self): def _setup_prefix(self):
# we assume here that our metadata may be nested inside a "basket" # Assume that metadata may be nested inside a "basket"
# of multiple eggs; that's why we use module_path instead of .archive # of multiple eggs and use module_path instead of .archive.
path = self.module_path eggs = filter(_is_egg_path, _parents(self.module_path))
old = None egg = next(eggs, None)
while path != old: egg and self._set_egg(egg)
if _is_egg_path(path):
def _set_egg(self, path):
self.egg_name = os.path.basename(path) self.egg_name = os.path.basename(path)
self.egg_info = os.path.join(path, 'EGG-INFO') self.egg_info = os.path.join(path, 'EGG-INFO')
self.egg_root = path self.egg_root = path
break
old = path
path, base = os.path.split(path)
class DefaultProvider(EggProvider): class DefaultProvider(EggProvider):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment