diff options
-rw-r--r-- | paramiko/config.py | 12 | ||||
-rw-r--r-- | sites/www/changelog.rst | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index 96ec9ef7..30e000e7 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -56,7 +56,7 @@ class SSHConfig (object): host = {"host": ['*'], "config": {}} for line in file_obj: line = line.rstrip('\r\n').lstrip() - if (line == '') or (line[0] == '#'): + if not line or line.startswith('#'): continue if '=' in line: # Ensure ProxyCommand gets properly split @@ -90,7 +90,7 @@ class SSHConfig (object): else: host['config'][key] = [value] elif key not in host['config']: - host['config'].update({key: value}) + host['config'][key] = value self._config.append(host) def lookup(self, hostname): @@ -111,8 +111,10 @@ class SSHConfig (object): :param str hostname: the hostname to lookup """ - matches = [config for config in self._config if - self._allowed(hostname, config['host'])] + matches = [ + config for config in self._config + if self._allowed(config['host'], hostname) + ] ret = {} for match in matches: @@ -128,7 +130,7 @@ class SSHConfig (object): ret = self._expand_variables(ret, hostname) return ret - def _allowed(self, hostname, hosts): + def _allowed(self, hosts, hostname): match = False for host in hosts: if host.startswith('!') and fnmatch.fnmatch(hostname, host[1:]): diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 1ca3dfef..0cbc933f 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,8 @@ Changelog ========= +* :support:`378 backported` Minor code cleanup in the SSH config module + courtesy of Olle Lundberg. * :release:`1.13.2 <2014-08-25>` * :bug:`376` Be less aggressive about expanding variables in ``ssh_config`` files, which results in a speedup of SSH config parsing. Credit to Olle |