~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-02 20:46:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060502204611-02caa5c20fb84ef8
Moved url functions into bzrlib.urlutils

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from stat import ST_MODE, S_ISDIR, ST_SIZE
25
25
import tempfile
26
26
 
27
 
from bzrlib.trace import mutter
28
 
from bzrlib.transport import Transport, Server, urlescape, urlunescape
29
27
from bzrlib.osutils import (abspath, realpath, normpath, pathjoin, rename, 
30
 
                            check_legal_path,
31
 
                            local_path_to_url, local_path_from_url)
 
28
                            check_legal_path)
32
29
from bzrlib.symbol_versioning import warn
 
30
from bzrlib.trace import mutter
 
31
from bzrlib.transport import Transport, Server
 
32
import bzrlib.urlutils as urlutils
33
33
 
34
34
 
35
35
class LocalTransport(Transport):
45
45
                 DeprecationWarning,
46
46
                 stacklevel=2
47
47
                 )
48
 
            base = local_path_to_url(base)
 
48
            base = urlutils.local_path_to_url(base)
49
49
        if base[-1] != '/':
50
50
            base = base + '/'
51
51
        super(LocalTransport, self).__init__(base)
52
 
        self._local_base = local_path_from_url(base)
 
52
        self._local_base = urlutils.local_path_from_url(base)
53
53
 
54
54
    def should_cache(self):
55
55
        return False
69
69
        assert isinstance(relpath, basestring), (type(relpath), relpath)
70
70
        # jam 20060426 Using normpath on the real path, because that ensures
71
71
        #       proper handling of stuff like
72
 
        path = normpath(pathjoin(self._local_base, urlunescape(relpath)))
73
 
        return local_path_to_url(path)
 
72
        path = normpath(pathjoin(self._local_base, urlutils.unescape(relpath)))
 
73
        return urlutils.local_path_to_url(path)
74
74
 
75
75
    def local_abspath(self, relpath):
76
76
        """Transform the given relative path URL into the actual path on disk
82
82
        """
83
83
        absurl = self.abspath(relpath)
84
84
        # mutter(u'relpath %s => base: %s, absurl %s', relpath, self.base, absurl)
85
 
        return local_path_from_url(absurl)
 
85
        return urlutils.local_path_from_url(absurl)
86
86
 
87
87
    def relpath(self, abspath):
88
88
        """Return the local path portion from a given absolute path.
89
89
        """
90
 
        from bzrlib.osutils import urlrelpath, strip_url_trailing_slash
91
90
        if abspath is None:
92
91
            abspath = u'.'
93
92
 
94
 
        return urlrelpath(strip_url_trailing_slash(self.base), 
95
 
                       strip_url_trailing_slash(abspath))
 
93
        return urlutils.file_relpath(
 
94
            urlutils.strip_trailing_slash(self.base), 
 
95
            urlutils.strip_trailing_slash(abspath))
96
96
 
97
97
    def has(self, relpath):
98
98
        return os.access(self.local_abspath(relpath), os.F_OK)
251
251
        """
252
252
        path = self.local_abspath(relpath)
253
253
        try:
254
 
            return [urlescape(entry) for entry in os.listdir(path)]
 
254
            return [urlutils.escape(entry) for entry in os.listdir(path)]
255
255
        except (IOError, OSError), e:
256
256
            self._translate_error(e, path)
257
257
 
341
341
 
342
342
    def get_url(self):
343
343
        """See Transport.Server.get_url."""
344
 
        return local_path_to_url('')
 
344
        return urlutils.local_path_to_url('')
345
345
 
346
346
 
347
347
def get_test_permutations():