wmllint-1.4: map, str and dir are Python internal function

Added underscores to distinguish variable names.
This commit is contained in:
Elvish_Hunter 2015-08-30 11:06:22 +02:00
parent e5bcb79ac8
commit 2bc6aadd49

View file

@ -388,26 +388,26 @@ conversion1 = {
max_len = max(len(elem) for elem in conversion1.values()) max_len = max(len(elem) for elem in conversion1.values())
width = max_len+2 width = max_len+2
def neighborhood(x, y, map): def neighborhood(x, y, map_):
"Returns list of original location+adjacent locations from a hex map" "Returns list of original location+adjacent locations from a hex map"
odd = (x) % 2 odd = (x) % 2
adj = [map[y][x]]; adj = [map_[y][x]];
if x > 0: if x > 0:
adj.append(map[y][x-1]) adj.append(map_[y][x-1])
if x < len(map[y])-1: if x < len(map_[y])-1:
adj.append(map[y][x+1]) adj.append(map_[y][x+1])
if y > 0: if y > 0:
adj.append(map[y-1][x]) adj.append(map_[y-1][x])
if y < len(map)-1: if y < len(map_)-1:
adj.append(map[y+1][x]) adj.append(map_[y+1][x])
if x > 0 and y > 0 and not odd: if x > 0 and y > 0 and not odd:
adj.append(map[y-1][x-1]) adj.append(map_[y-1][x-1])
if x < len(map[y])-1 and y > 0 and not odd: if x < len(map_[y])-1 and y > 0 and not odd:
adj.append(map[y-1][x+1]) adj.append(map_[y-1][x+1])
if x > 0 and y < len(map)-1 and odd: if x > 0 and y < len(map_)-1 and odd:
adj.append(map[y+1][x-1]) adj.append(map_[y+1][x-1])
if x < len(map[y])-1 and y < len(map)-1 and odd: if x < len(map_[y])-1 and y < len(map_)-1 and odd:
adj.append(map[y+1][x+1]) adj.append(map_[y+1][x+1])
return adj return adj
def maptransform1(filename, baseline, inmap, y): def maptransform1(filename, baseline, inmap, y):
@ -584,13 +584,13 @@ def string_strip(value):
value = value[:-1] value = value[:-1]
return value return value
def parse_attribute(str): def parse_attribute(str_):
"Parse a WML key-value pair from a line." "Parse a WML key-value pair from a line."
if '=' not in str: if '=' not in str_:
return None return None
where = str.find("=") where = str_.find("=")
leader = str[:where] leader = str_[:where]
after = str[where+1:] after = str_[where+1:]
after = after.lstrip() after = after.lstrip()
if "#" in after: if "#" in after:
where = after.find("#") where = after.find("#")
@ -1986,17 +1986,17 @@ def interesting(fn):
or ("maps" in fn and fn[-4:] not in ignore) \ or ("maps" in fn and fn[-4:] not in ignore) \
or is_map(fn) or is_map(fn)
def allcfgfiles(dir): def allcfgfiles(dir_):
"Get the names of all interesting files under dir." "Get the names of all interesting files under dir."
datafiles = [] datafiles = []
if not os.path.isdir(dir): if not os.path.isdir(dir_):
if interesting(dir): if interesting(dir_):
if not os.path.exists(dir): if not os.path.exists(dir_):
print("wmllint: %s does not exist" % dir, file=sys.stderr) print("wmllint: %s does not exist" % dir_, file=sys.stderr)
else: else:
datafiles.append(dir) datafiles.append(dir_)
else: else:
for root, dirs, files in os.walk(dir): for root, dirs, files in os.walk(dir_):
if vcdir in dirs: if vcdir in dirs:
dirs.remove(vcdir) dirs.remove(vcdir)
for name in files: for name in files:
@ -2105,8 +2105,8 @@ if __name__ == '__main__':
print(explain[:-1] + ".") print(explain[:-1] + ".")
fileconversions = [filemoves[x] for x in versions[:-1]] fileconversions = [filemoves[x] for x in versions[:-1]]
def hasdigit(str): def hasdigit(str_):
for c in str: for c in str_:
if c in "0123456789": if c in "0123456789":
return True return True
return False return False
@ -2231,13 +2231,13 @@ if __name__ == '__main__':
if not arguments: if not arguments:
arguments = ["."] arguments = ["."]
for dir in arguments: for dir_ in arguments:
ofp = None ofp = None
if "older" in versions: if "older" in versions:
lock_terrain_coding = None lock_terrain_coding = None
else: else:
lock_terrain_coding = "newstyle" lock_terrain_coding = "newstyle"
for fn in allcfgfiles(dir): for fn in allcfgfiles(dir_):
if verbose >= 2: if verbose >= 2:
print(fn + ":") print(fn + ":")
backup = fn + "-bak" backup = fn + "-bak"