/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/location.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""UI location string handling."""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import re
21
23
 
22
24
from . import (
23
25
    urlutils,
24
26
    )
25
27
from .hooks import Hooks
 
28
from .sixish import (
 
29
    PY3,
 
30
    string_types,
 
31
    )
26
32
 
27
33
 
28
34
class LocationHooks(Hooks):
116
122
    :raise InvalidURL: If the location is already a URL, but not valid.
117
123
    :return: Byte string with resulting URL
118
124
    """
119
 
    if not isinstance(location, str):
 
125
    if not isinstance(location, string_types):
120
126
        raise AssertionError("location not a byte or unicode string")
121
127
 
122
128
    if location.startswith(':pserver:'):
134
140
                path=location, extra='URLs must be properly escaped')
135
141
        location = urlutils.local_path_to_url(location)
136
142
    else:
137
 
        location = location.decode('ascii')
 
143
        if PY3:
 
144
            location = location.decode('ascii')
138
145
 
139
146
    if location.startswith("file:") and not location.startswith("file://"):
140
147
        return urlutils.join(urlutils.local_path_to_url("."), location[5:])