Skip to content
Snippets Groups Projects
Commit 5bff2ec3 authored by Piotr Ożarowski's avatar Piotr Ożarowski
Browse files

"--namespace foo" no longer triggers .../dist-packages/bar/foo/__init__.py

creation, use "--namespace bar.foo" instead
parent 93d1d4fd
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,8 @@ python-defaults (2.7.2-2) UNRELEASED; urgency=low ...@@ -29,6 +29,8 @@ python-defaults (2.7.2-2) UNRELEASED; urgency=low
python:Breaks - closes: 631397, describes .pyinstall and .pyremove files) python:Breaks - closes: 631397, describes .pyinstall and .pyremove files)
- remove setuptools from requires.txt (it is replaced with - remove setuptools from requires.txt (it is replaced with
python-pkg-resources Debian dependency) python-pkg-resources Debian dependency)
- "--namespace foo" no longer triggers .../dist-packages/bar/foo/__init__.py
creation, use "--namespace bar.foo" instead
-- Piotr Ożarowski <piotr@debian.org> Sun, 12 Jun 2011 13:28:48 +0200 -- Piotr Ożarowski <piotr@debian.org> Sun, 12 Jun 2011 13:28:48 +0200
......
...@@ -71,7 +71,7 @@ def load(package=None): ...@@ -71,7 +71,7 @@ def load(package=None):
def add_namespace_files(files, package=None, action=None): def add_namespace_files(files, package=None, action=None):
"""Add __init__.py files to given generator.""" """Add __init__.py files to given generator."""
if action is not None: if action is not None:
namespaces = set("/%s" % i for i in load(package)) namespaces = load(package)
already_processed = set() already_processed = set()
removal_candidates = set() removal_candidates = set()
for fn in files: for fn in files:
...@@ -81,21 +81,23 @@ def add_namespace_files(files, package=None, action=None): ...@@ -81,21 +81,23 @@ def add_namespace_files(files, package=None, action=None):
dpath = dirname(fn) dpath = dirname(fn)
if dpath not in already_processed: if dpath not in already_processed:
already_processed.add(dpath) already_processed.add(dpath)
if PUBLIC_DIR_RE.match(dpath): m = PUBLIC_DIR_RE.match(dpath)
while not dpath.endswith(('site-packages', 'dist-packages')): if m:
for ns in namespaces: public_dir = m.group()
while dpath != public_dir:
ns_dir = dpath[len(public_dir) + 1:]
if ns_dir in namespaces:
fpath = join(dpath, '__init__.py') fpath = join(dpath, '__init__.py')
if dpath.endswith(ns): if action is True:
if action is True: try:
try: open(fpath, 'a').close()
open(fpath, 'a').close() except:
except: log.error('cannot create %s', fpath)
log.error('cannot create %s', fpath) else:
else: yield fpath
yield fpath else: # action is False
else: # action is False # postpone it due to dpkg -S call
# postpone it due to dpkg -S call removal_candidates.add(fpath)
removal_candidates.add(fpath)
already_processed.add(dpath) already_processed.add(dpath)
dpath = split(dpath)[0] dpath = split(dpath)[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment