summaryrefslogtreecommitdiff
path: root/paramiko/config.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-08-26 12:50:10 -0700
committerJeff Forcier <jeff@bitprophet.org>2014-08-26 12:50:10 -0700
commitb641c69a80e2bd4737c636e7edd0918d6753c3d0 (patch)
tree5c2094d542c91a0c035d539b6e21dc6356901b4b /paramiko/config.py
parent9014c735fc94d133c5d9aada93d43f1f5d1145f2 (diff)
downloadparamiko-b641c69a80e2bd4737c636e7edd0918d6753c3d0.tar.gz
Backport #378 to 1.13, closes #378
Diffstat (limited to 'paramiko/config.py')
-rw-r--r--paramiko/config.py12
1 files changed, 7 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:]):