Ignore:
Timestamp:
Aug 4, 2013, 5:29:02 PM (6 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use double quotes (") for strings.

I used to have a rule to put "identifier-like" strings in single
quotes (') and other strings in double quotes. For example, dictionary
keys would usually be in single quotes, but error messages in double
quotes.

Unfortunately, there are many border cases, so over time I've become
tired of thinking about when I should use one kind of quotes or the
other. So everything is in double quotes now. Also, I guess most
people are rather used to double quotes for strings and thus will
welcome the change. :-)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1319 r1343  
    1919import ftputil.tool
    2020
    21 __all__ = ['FTPHost']
     21__all__ = ["FTPHost"]
    2222
    2323
     
    4040    #
    4141    #   host = FTPHost(ftp_server, user, password)
    42     #   f = host.open('index.html')
     42    #   f = host.open("index.html")
    4343    #   host.getcwd()   # would block!
    4444    #
     
    7676        # that this is, strictly speaking, dependent on the server OS
    7777        # but it seems to work at least with Unix and Windows servers.
    78         self.curdir, self.pardir, self.sep = '.', '..', '/'
     78        self.curdir, self.pardir, self.sep = ".", "..", "/"
    7979        # Set default time shift (used in `upload_if_newer` and
    8080        # `download_if_newer`).
     
    114114        # this `FTPHost` object, use the same factory for this
    115115        # `FTPHost` object's child sessions.
    116         factory = kwargs.pop('session_factory', ftplib.FTP)
     116        factory = kwargs.pop("session_factory", ftplib.FTP)
    117117        # pylint: disable=W0142
    118118        with ftputil.error.ftplib_error_to_ftp_os_error:
     
    349349        try:
    350350            # May raise `FTPIOError` if directory isn't writable.
    351             file_ = self.open(helper_file_name, 'w')
     351            file_ = self.open(helper_file_name, "w")
    352352            file_.close()
    353353        except ftputil.error.FTPIOError:
    354354            raise ftputil.error.TimeShiftError(
    355                     '''couldn't write helper file in directory "{0}"'''.
     355                    """couldn't write helper file in directory '{0}'""".
    356356                    format(self.getcwd()))
    357357        # If everything worked up to here it should be possible to stat
     
    405405        `target`.
    406406        """
    407         if 'length' in kwargs:
    408             max_chunk_size = kwargs['length']
     407        if "length" in kwargs:
     408            max_chunk_size = kwargs["length"]
    409409            warnings.warn(("Parameter name `length` will be removed in "
    410410                           "ftputil 2.6, use `max_chunk_size` instead"),
     
    417417        #XXX Should we allow mode "a" at all? We don't support appending!
    418418        # Invalid mode values are handled when a file object is made.
    419         if mode == 'b':
    420             return 'rb', 'wb'
     419        if mode == "b":
     420            return "rb", "wb"
    421421        else:
    422             return 'r', 'w'
     422            return "r", "w"
    423423
    424424    def _upload_files(self, source_path, target_path, mode):
     
    437437        return source_file, target_file
    438438
    439     def upload(self, source, target, mode='', callback=None):
     439    def upload(self, source, target, mode="", callback=None):
    440440        """
    441441        Upload a file from the local source (name) to the remote
    442         target (name). The argument `mode` is an empty string or 'a' for
    443         text copies, or 'b' for binary copies.
     442        target (name). The argument `mode` is an empty string or "a" for
     443        text copies, or "b" for binary copies.
    444444        """
    445445        target = ftputil.tool.as_unicode(target)
     
    448448                                        conditional=False, callback=callback)
    449449
    450     def upload_if_newer(self, source, target, mode='', callback=None):
     450    def upload_if_newer(self, source, target, mode="", callback=None):
    451451        """
    452452        Upload a file only if it's newer than the target on the
     
    476476        return source_file, target_file
    477477
    478     def download(self, source, target, mode='', callback=None):
     478    def download(self, source, target, mode="", callback=None):
    479479        """
    480480        Download a file from the remote source (name) to the local
    481         target (name). The argument mode is an empty string or 'a' for
    482         text copies, or 'b' for binary copies.
     481        target (name). The argument mode is an empty string or "a" for
     482        text copies, or "b" for binary copies.
    483483        """
    484484        source = ftputil.tool.as_unicode(source)
     
    487487                                        conditional=False, callback=callback)
    488488
    489     def download_if_newer(self, source, target, mode='', callback=None):
     489    def download_if_newer(self, source, target, mode="", callback=None):
    490490        """
    491491        Download a file only if it's newer than the target on the
Note: See TracChangeset for help on using the changeset viewer.