Kaydet (Commit) 599b65de authored tarafından Georg Brandl's avatar Georg Brandl

Use augassign.

üst db902ac0
...@@ -275,7 +275,7 @@ def split(p): ...@@ -275,7 +275,7 @@ def split(p):
# set i to index beyond p's last slash # set i to index beyond p's last slash
i = len(p) i = len(p)
while i and p[i-1] not in seps: while i and p[i-1] not in seps:
i = i - 1 i -= 1
head, tail = p[:i], p[i:] # now tail has no slashes head, tail = p[:i], p[i:] # now tail has no slashes
# remove trailing slashes from head, unless it's all slashes # remove trailing slashes from head, unless it's all slashes
head2 = head head2 = head
...@@ -366,7 +366,7 @@ def expanduser(path): ...@@ -366,7 +366,7 @@ def expanduser(path):
return path return path
i, n = 1, len(path) i, n = 1, len(path)
while i < n and path[i] not in _get_bothseps(path): while i < n and path[i] not in _get_bothseps(path):
i = i + 1 i += 1
if 'HOME' in os.environ: if 'HOME' in os.environ:
userhome = os.environ['HOME'] userhome = os.environ['HOME']
...@@ -435,21 +435,21 @@ def expandvars(path): ...@@ -435,21 +435,21 @@ def expandvars(path):
pathlen = len(path) pathlen = len(path)
try: try:
index = path.index(c) index = path.index(c)
res = res + c + path[:index + 1] res += c + path[:index + 1]
except ValueError: except ValueError:
res = res + path res += path
index = pathlen - 1 index = pathlen - 1
elif c == percent: # variable or '%' elif c == percent: # variable or '%'
if path[index + 1:index + 2] == percent: if path[index + 1:index + 2] == percent:
res = res + c res += c
index = index + 1 index += 1
else: else:
path = path[index+1:] path = path[index+1:]
pathlen = len(path) pathlen = len(path)
try: try:
index = path.index(percent) index = path.index(percent)
except ValueError: except ValueError:
res = res + percent + path res += percent + path
index = pathlen - 1 index = pathlen - 1
else: else:
var = path[:index] var = path[:index]
...@@ -461,11 +461,11 @@ def expandvars(path): ...@@ -461,11 +461,11 @@ def expandvars(path):
value = '%' + var + '%' value = '%' + var + '%'
if isinstance(path, bytes): if isinstance(path, bytes):
value = value.encode('ascii') value = value.encode('ascii')
res = res + value res += value
elif c == dollar: # variable or '$$' elif c == dollar: # variable or '$$'
if path[index + 1:index + 2] == dollar: if path[index + 1:index + 2] == dollar:
res = res + c res += c
index = index + 1 index += 1
elif path[index + 1:index + 2] == brace: elif path[index + 1:index + 2] == brace:
path = path[index+2:] path = path[index+2:]
pathlen = len(path) pathlen = len(path)
...@@ -483,23 +483,23 @@ def expandvars(path): ...@@ -483,23 +483,23 @@ def expandvars(path):
value = '${' + var + '}' value = '${' + var + '}'
if isinstance(path, bytes): if isinstance(path, bytes):
value = value.encode('ascii') value = value.encode('ascii')
res = res + value res += value
except ValueError: except ValueError:
if isinstance(path, bytes): if isinstance(path, bytes):
res = res + b'${' + path res += b'${' + path
else: else:
res = res + '${' + path res += '${' + path
index = pathlen - 1 index = pathlen - 1
else: else:
var = '' var = ''
index = index + 1 index += 1
c = path[index:index + 1] c = path[index:index + 1]
while c and c in varchars: while c and c in varchars:
if isinstance(path, bytes): if isinstance(path, bytes):
var = var + c.decode('ascii') var += c.decode('ascii')
else: else:
var = var + c var += c
index = index + 1 index += 1
c = path[index:index + 1] c = path[index:index + 1]
if var in os.environ: if var in os.environ:
value = os.environ[var] value = os.environ[var]
...@@ -507,12 +507,12 @@ def expandvars(path): ...@@ -507,12 +507,12 @@ def expandvars(path):
value = '$' + var value = '$' + var
if isinstance(path, bytes): if isinstance(path, bytes):
value = value.encode('ascii') value = value.encode('ascii')
res = res + value res += value
if c: if c:
index = index - 1 index -= 1
else: else:
res = res + c res += c
index = index + 1 index += 1
return res return res
...@@ -529,7 +529,7 @@ def normpath(path): ...@@ -529,7 +529,7 @@ def normpath(path):
# collapse initial backslashes # collapse initial backslashes
if path.startswith(sep): if path.startswith(sep):
prefix = prefix + sep prefix += sep
path = path.lstrip(sep) path = path.lstrip(sep)
comps = path.split(sep) comps = path.split(sep)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment