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
  • test/mock_ftplib.py

    r1307 r1343  
    9494    """
    9595    # Used by `MockSession.cwd` and `MockSession.pwd`
    96     current_dir = '/home/sschwarzer'
     96    current_dir = "/home/sschwarzer"
    9797
    9898    # Used by `MockSession.dir`. This is a mapping from absolute path
     
    102102
    103103    # File content to be used (indirectly) with `transfercmd`.
    104     mock_file_content = b''
    105 
    106     def __init__(self, host='', user='', password=''):
     104    mock_file_content = b""
     105
     106    def __init__(self, host="", user="", password=""):
    107107        self.closed = 0
    108108        # Count successful `transfercmd` invocations to ensure that
     
    115115        if DEBUG:
    116116            print(cmd)
    117         if cmd == 'STAT':
    118             return 'MockSession server awaiting your commands ;-)'
    119         elif cmd.startswith('TYPE '):
     117        if cmd == "STAT":
     118            return "MockSession server awaiting your commands ;-)"
     119        elif cmd.startswith("TYPE "):
    120120            return
    121         elif cmd.startswith('SITE CHMOD'):
     121        elif cmd.startswith("SITE CHMOD"):
    122122            raise ftplib.error_perm("502 command not implemented")
    123123        else:
     
    128128
    129129    def _remove_trailing_slash(self, path):
    130         if path != '/' and path.endswith('/'):
     130        if path != "/" and path.endswith("/"):
    131131            path = path[:-1]
    132132        return path
     
    163163        if path not in self.dir_contents:
    164164            raise ftplib.error_perm
    165         dir_lines = self.dir_contents[path].split('\n')
     165        dir_lines = self.dir_contents[path].split("\n")
    166166        for line in dir_lines:
    167167            if callback is None:
     
    173173        assert self._transfercmds == 1
    174174        self._transfercmds = self._transfercmds - 1
    175         return '2xx'
     175        return "2xx"
    176176
    177177    def transfercmd(self, cmd):
     
    190190        # Fail if path isn't available (this name is hard-coded here
    191191        # and has to be used for the corresponding tests).
    192         if (cmd, path) == ('RETR', 'notthere'):
     192        if (cmd, path) == ("RETR", "notthere"):
    193193            raise ftplib.error_perm
    194194        assert self._transfercmds == 0
     
    205205
    206206    dir_contents = {
    207       '/': """\
     207      "/": """\
    208208drwxr-xr-x   2 45854    200           512 May  4  2000 home""",
    209209
    210       '/home': """\
     210      "/home": """\
    211211drwxr-sr-x   2 45854    200           512 May  4  2000 sschwarzer
    212212-rw-r--r--   1 45854    200          4605 Jan 19  1970 older
     
    217217drwxr-sr-x   2 45854    200           512 May  4  2000 file_name_test""",
    218218
    219       '/home/python': """\
     219      "/home/python": """\
    220220lrwxrwxrwx   1 45854    200             7 Jan 19  2002 link_link -> ../link
    221221lrwxrwxrwx   1 45854    200            14 Jan 19  2002 bad_link -> /home/bad_link""",
    222222
    223       '/home/sschwarzer': """\
     223      "/home/sschwarzer": """\
    224224total 14
    225225drwxr-sr-x   2 45854    200           512 May  4  2000 chemeng
     
    233233drwxr-sr-x   6 45854    200           512 Sep 20  1999 scios2""",
    234234
    235       '/home/dir with spaces': """\
     235      "/home/dir with spaces": """\
    236236total 1
    237237-rw-r--r--   1 45854    200          4604 Jan 19 23:11 file with spaces""",
    238238
    239       '/home/file_name_test': """\
     239      "/home/file_name_test": """\
    240240drwxr-sr-x   2 45854    200           512 May 29  2000 ä
    241241drwxr-sr-x   2 45854    200           512 May 29  2000 empty_ä
     
    243243lrwxrwxrwx   2 45854    200             6 May 29  2000 ü -> ä""",
    244244
    245       '/home/file_name_test/ä': """\
     245      "/home/file_name_test/ä": """\
    246246-rw-r--r--   1 45854    200          4604 Jan 19 23:11 ö
    247247-rw-r--r--   1 45854    200          4604 Jan 19 23:11 o""",
    248248
    249       '/home/file_name_test/empty_ä': """\
     249      "/home/file_name_test/empty_ä": """\
    250250""",
    251251      # Fail when trying to write to this directory (the content isn't
    252252      # relevant).
    253       'sschwarzer': "",
     253      "sschwarzer": "",
    254254    }
    255255
     
    258258
    259259    dir_contents = {
    260       '/': """\
     260      "/": """\
    26126110-23-01  03:25PM       <DIR>          home""",
    262262
    263       '/home': """\
     263      "/home": """\
    26426410-23-01  03:25PM       <DIR>          msformat""",
    265265
    266       '/home/msformat': """\
     266      "/home/msformat": """\
    26726710-23-01  03:25PM       <DIR>          WindowsXP
    26826812-07-01  02:05PM       <DIR>          XPLaunch
     
    27027007-17-00  02:08PM                89264 O2KKeys.exe""",
    271271
    272       '/home/msformat/XPLaunch': """\
     272      "/home/msformat/XPLaunch": """\
    27327310-23-01  03:25PM       <DIR>          WindowsXP
    27427412-07-01  02:05PM       <DIR>          XPLaunch
     
    27727707-17-00  02:08PM                89264 O2KKeys.exe""",
    278278
    279       '/home/msformat/XPLaunch/empty': "total 0",
     279      "/home/msformat/XPLaunch/empty": "total 0",
    280280    }
Note: See TracChangeset for help on using the changeset viewer.