~ubuntu-branches/ubuntu/utopic/kazoo/utopic-proposed

« back to all changes in this revision

Viewing changes to kazoo/protocol/paths.py

  • Committer: Package Import Robot
  • Author(s): Neil Williams
  • Date: 2013-08-26 06:26:20 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130826062620-dv79eayvq78028jb
Tags: 1.2.1-1
* New upstream release.
* Fix sphinx documentation build on clean systems (added
  python-gevent to Build-Depends and patched config).
* Bumped standards version to 3.9.4. No changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
def normpath(path):
 
1
def normpath(path, trailing=False):
2
2
    """Normalize path, eliminating double slashes, etc."""
3
3
    comps = path.split('/')
4
4
    new_comps = []
9
9
            raise ValueError('relative paths not allowed')
10
10
        new_comps.append(comp)
11
11
    new_path = '/'.join(new_comps)
 
12
    if trailing is True and path.endswith('/'):
 
13
        new_path += '/'
12
14
    if path.startswith('/'):
13
15
        return '/' + new_path
14
16
    return new_path
43
45
    return p[i:]
44
46
 
45
47
 
46
 
def _prefix_root(root, path):
 
48
def _prefix_root(root, path, trailing=False):
47
49
    """Prepend a root to a path. """
48
 
    return normpath(join(_norm_root(root), path.lstrip('/')))
 
50
    return normpath(join(_norm_root(root), path.lstrip('/')), trailing=trailing)
49
51
 
50
52
 
51
53
def _norm_root(root):