def file_link(filename): if currently_showing and filename == currently_showing: return html_format('<b><a href="#%s">%s</a></b>', urlutils.quote(filename), filename) else: return revision_link(url, entry.revno, filename, '#' + urlutils.quote(filename))
def url(self, *args, **kw): if isinstance(args[0], list): args = args[0] qs = [] for k, v in kw.items(): if v is not None: qs.append('%s=%s' % (k, urlutils.quote(v))) qs = '&'.join(qs) path_info = urlutils.quote('/'.join(args), safe='/~:') if qs: path_info += '?' + qs return self._url_base + path_info
def generate_text_parents_property(text_parents): return "".join([ "%s\t%s\n" % (urlutils.quote(path.encode("utf-8")), "\t".join(text_parents[path])) for path in sorted(text_parents.keys()) if text_parents[path] is not None ])
def _extract_git_svn_id(rev): if "git-svn-id" not in rev.properties: return (full_url, revnum, uuid) = parse_git_svn_id(rev.properties['git-svn-id']) branch_path = svn_branch_path_finder.find_branch_path(uuid, full_url) if branch_path is not None: yield ("svn", "%s:%d:%s" % (uuid, revnum, urlutils.quote(branch_path)))
def escape_svn_path(x): """Escape a Subversion path for use in a revision identifier. :param x: Path :return: Escaped path """ return urlutils.quote(x, "").encode('utf-8')
def url_join_unescaped_path(url, path): (scheme, netloc, basepath, query, fragment) = urlparse.urlsplit(url) path = urlutils.join(urlutils.unquote(basepath), path) if scheme in ("http", "https"): # Without this, URLs with + in them break path = urlutils.quote(path, safe="/+%") return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
def generate_text_revisions_property(text_revisions): return "".join([ "%s\t%s\n" % (urlutils.quote(path.encode("utf-8")), text_revisions[path]) for path in sorted(text_revisions.keys()) if text_revisions[path] is not None ])
def _url_unescape_uri(url): (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url) if scheme in ("http", "https"): # Without this, URLs with + in them break path = urlutils.quote(urlutils.unquote(path), safe="/+%") while "//" in path: path = path.replace("//", "/") return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
def git_url_to_bzr_url(location): url = URL.from_string(location) if (url.scheme not in KNOWN_GIT_SCHEMES and not url.scheme.startswith('chroot-')): try: (username, host, path) = parse_rsync_url(location) except ValueError: return location else: url = URL(scheme='git+ssh', quoted_user=(quote(username) if username else None), quoted_password=None, quoted_host=quote(host), port=None, quoted_path=quote(path, safe="/~")) return str(url) else: return location
def _extract_cscvs(rev): """Older-style launchpad-cscvs import.""" if "cscvs-svn-branch-path" not in rev.properties: return yield ( "svn", "%s:%s:%s" % (rev.properties["cscvs-svn-repository-uuid"], rev.properties["cscvs-svn-revision-number"], urlutils.quote(rev.properties["cscvs-svn-branch-path"].strip("/"))))
def generate_fileid_property(fileids): """Marshall a dictionary with file ids. :param fileids: Map of path -> fileid :return: Property value """ return "".join([ "%s\t%s\n" % (urlutils.quote(path.encode("utf-8")), fileids[path]) for path in sorted(fileids.keys()) ])
def check_mode_r(test, base, file_mode, dir_mode, include_base=True): """Check that all permissions match :param test: The TestCase being run :param base: The path to the root directory to check :param file_mode: The mode for all files :param dir_mode: The mode for all directories :param include_base: If false, only check the subdirectories """ t = test.get_transport() if include_base: test.assertTransportMode(t, base, dir_mode) for root, dirs, files in os.walk(base): for d in dirs: p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [d]]) test.assertTransportMode(t, p, dir_mode) for f in files: p = os.path.join(root, f) p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [f]]) test.assertTransportMode(t, p, file_mode)
def sort_url(self, *args, **kw): if isinstance(args[0], list): args = args[0] qs = [] for k, v in kw.items(): if v is not None: qs.append('%s=%s' % (k, urlutils.quote(v))) qs = '&'.join(qs) path_info = self._path_info.strip('/').split('?')[0] path_info += '?' + qs return self._url_base + '/' + path_info
def full_branch_url(branch): """Get the full URL for a branch. Ideally this should just return Branch.user_url, but that currently exclude the branch name in some situations. """ if branch.name is None: return branch.user_url url, params = urlutils.split_segment_parameters(branch.user_url) if branch.name != "": params["branch"] = urlutils.quote(branch.name, "") return urlutils.join_segment_parameters(url, params)
def __init__(self, path, layout): BzrError.__init__(self) self.path = urlutils.quote(path) self.layout = layout
def file_link(filename): return html_format( '<a href="%s%s" title="View changes to %s in revision %s">' '%s</a>', url(['/revision', entry.revno]), '#' + urlutils.quote(filename), filename, entry.revno, filename)
def revision_id_foreign_to_bzr(self, foreign_revid): (uuid, path, revnum) = foreign_revid return b"svn-v4:%s:%s:%d" % ( uuid.encode('ascii'), urlutils.quote(path).encode('ascii'), revnum)
def _url_escape_uri(url): (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url) if scheme in ("http", "https"): # Without this, URLs with + in them break path = urlutils.quote(path, safe="/+%") return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
def dq(p): if not isinstance(p, bytes): p = p.encode('UTF-8') return urlutils.quote(urlutils.quote_from_bytes(p, safe=''))
def serialize_foreign_revid(self, foreign_revid): (uuid, bp, revnum) = foreign_revid return "%s:%d:%s" % (uuid, revnum, urlutils.quote(bp))
def __init__(self, branch_path, mapping=None): BzrError.__init__(self) self.branch_path = urlutils.quote(branch_path) self.mapping = mapping