~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
138
138
def register_lazy_transport(prefix, module, classname):
139
139
    if not prefix in transport_list_registry:
140
140
        register_transport_proto(prefix)
141
 
    transport_list_registry.register_lazy_transport_provider(
142
 
        prefix, module, classname)
143
 
 
144
 
 
145
 
def register_transport(prefix, klass):
 
141
    transport_list_registry.register_lazy_transport_provider(prefix, module, classname)
 
142
 
 
143
 
 
144
def register_transport(prefix, klass, override=DEPRECATED_PARAMETER):
146
145
    if not prefix in transport_list_registry:
147
146
        register_transport_proto(prefix)
148
147
    transport_list_registry.register_transport_provider(prefix, klass)
873
872
            yield self.get(relpath)
874
873
            count += 1
875
874
 
876
 
    def put_bytes(self, relpath, raw_bytes, mode=None):
 
875
    def put_bytes(self, relpath, bytes, mode=None):
877
876
        """Atomically put the supplied bytes into the given location.
878
877
 
879
878
        :param relpath: The location to put the contents, relative to the
880
879
            transport base.
881
 
        :param raw_bytes: A bytestring of data.
 
880
        :param bytes: A bytestring of data.
882
881
        :param mode: Create the file with the given mode.
883
882
        :return: None
884
883
        """
885
 
        if not isinstance(raw_bytes, str):
886
 
            raise TypeError(
887
 
                'raw_bytes must be a plain string, not %s' % type(raw_bytes))
888
 
        return self.put_file(relpath, StringIO(raw_bytes), mode=mode)
 
884
        if not isinstance(bytes, str):
 
885
            raise AssertionError(
 
886
                'bytes must be a plain string, not %s' % type(bytes))
 
887
        return self.put_file(relpath, StringIO(bytes), mode=mode)
889
888
 
890
 
    def put_bytes_non_atomic(self, relpath, raw_bytes, mode=None,
 
889
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
891
890
                             create_parent_dir=False,
892
891
                             dir_mode=None):
893
892
        """Copy the string into the target location.
896
895
        Transport.put_bytes_non_atomic for more information.
897
896
 
898
897
        :param relpath: The remote location to put the contents.
899
 
        :param raw_bytes:   A string object containing the raw bytes to write
900
 
                        into the target file.
 
898
        :param bytes:   A string object containing the raw bytes to write into
 
899
                        the target file.
901
900
        :param mode:    Possible access permissions for new file.
902
901
                        None means do not set remote permissions.
903
902
        :param create_parent_dir: If we cannot create the target file because
905
904
                        create it, and then try again.
906
905
        :param dir_mode: Possible access permissions for new directories.
907
906
        """
908
 
        if not isinstance(raw_bytes, str):
909
 
            raise TypeError(
910
 
                'raw_bytes must be a plain string, not %s' % type(raw_bytes))
911
 
        self.put_file_non_atomic(relpath, StringIO(raw_bytes), mode=mode,
 
907
        if not isinstance(bytes, str):
 
908
            raise AssertionError(
 
909
                'bytes must be a plain string, not %s' % type(bytes))
 
910
        self.put_file_non_atomic(relpath, StringIO(bytes), mode=mode,
912
911
                                 create_parent_dir=create_parent_dir,
913
912
                                 dir_mode=dir_mode)
914
913
 
1783
1782
                 help="Read-only access of branches exported on the web.")
1784
1783
register_transport_proto('https://',
1785
1784
            help="Read-only access of branches exported on the web using SSL.")
1786
 
# The default http implementation is urllib
 
1785
# The default http implementation is urllib, but https uses pycurl if available
1787
1786
register_lazy_transport('http://', 'bzrlib.transport.http._pycurl',
1788
1787
                        'PyCurlTransport')
1789
1788
register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
1790
1789
                        'HttpTransport_urllib')
 
1790
register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
 
1791
                        'HttpTransport_urllib')
1791
1792
register_lazy_transport('https://', 'bzrlib.transport.http._pycurl',
1792
1793
                        'PyCurlTransport')
1793
 
register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
1794
 
                        'HttpTransport_urllib')
1795
1794
 
1796
1795
register_transport_proto('ftp://', help="Access using passive FTP.")
1797
1796
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')