Skip to content

Commit

Permalink
wmllint, wmlindent, wmltools: fixed dir being used as variable name
Browse files Browse the repository at this point in the history
In Python, dir is an in-built function
  • Loading branch information
Elvish-Hunter committed Aug 5, 2015
1 parent 39ffd1e commit 90919e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions data/tools/wesnoth/wmltools.py
Expand Up @@ -100,17 +100,17 @@ def __init__(self, dirpath, exclude=None):
self.forest = []
self.dirpath = dirpath
roots = ["campaigns", "add-ons"]
for dir in dirpath:
for directory in dirpath:
subtree = []
rooted = False
if os.path.isdir(dir): # So we skip .cfgs in a UMC mirror
oldmain = os.path.join(os.path.dirname(dir), os.path.basename(dir) + '.cfg')
if os.path.isdir(directory): # So we skip .cfgs in a UMC mirror
oldmain = os.path.join(os.path.dirname(directory), os.path.basename(directory) + '.cfg')
if os.path.isfile(oldmain):
subtree.append(oldmain)
base = os.path.basename(os.path.dirname(os.path.abspath(dir)))
base = os.path.basename(os.path.dirname(os.path.abspath(directory)))
if base in roots or base == "core":
rooted = True
for root, dirs, files in os.walk(dir):
for root, dirs, files in os.walk(directory):
dirs.sort()
dirlist = [x for x in dirs]
# Split out individual campaigns/add-ons into their own subtrees
Expand Down Expand Up @@ -177,9 +177,9 @@ def flatten(self):
return allfiles
def generator(self):
"Return a generator that walks through all files."
for (dir, tree) in zip(self.dirpath, self.forest):
for (directory, tree) in zip(self.dirpath, self.forest):
for filename in tree:
yield (dir, filename)
yield (directory, filename)

def iswml(filename):
"Is the specified filename WML?"
Expand Down
10 changes: 5 additions & 5 deletions data/tools/wmlindent
Expand Up @@ -217,14 +217,14 @@ def reindent(name, infp, outfp):
if indent != "" and seen_wml:
print('wmlindent: "%s". line %d: end of file with indent nonzero.' % (name, countlines), file=sys.stderr)

def allwmlfiles(dir):
def allwmlfiles(directory):
"Get names of all WML files under dir, or dir itself if not a directory."
datafiles = []
if not os.path.isdir(dir):
if dir.endswith(".cfg"):
datafiles.append(dir)
if not os.path.isdir(directory):
if directory.endswith(".cfg"):
datafiles.append(directory)
else:
for root, dirs, files in os.walk(dir):
for root, dirs, files in os.walk(directory):
if wmltools.vcdir in dirs:
dirs.remove(wmltools.vcdir)
for name in files:
Expand Down
24 changes: 12 additions & 12 deletions data/tools/wmllint
Expand Up @@ -2599,17 +2599,17 @@ def interesting(fn):
"Is a file interesting for conversion purposes?"
return fn.endswith(".cfg") or is_map(fn) or issave(fn)

def allcfgfiles(dir):
"Get the names of all interesting files under dir."
def allcfgfiles(directory):
"Get the names of all interesting files under directory."
datafiles = []
if not os.path.isdir(dir):
if interesting(dir):
if not os.path.exists(dir):
print("wmllint: %s does not exist" % dir, file=sys.stderr)
if not os.path.isdir(directory):
if interesting(directory):
if not os.path.exists(directory):
print("wmllint: %s does not exist" % directory, file=sys.stderr)
else:
datafiles.append(dir)
datafiles.append(directory)
else:
for root, dirs, files in os.walk(dir):
for root, dirs, files in os.walk(directory):
for vcsubdir in vctypes:
if vcsubdir in dirs:
dirs.remove(vcsubdir)
Expand Down Expand Up @@ -2891,9 +2891,9 @@ In your case, your system interprets your arguments as:
if not arguments:
arguments = ["."]

for dir in arguments:
for directory in arguments:
ofp = None
for fn in allcfgfiles(dir):
for fn in allcfgfiles(directory):
if verbose >= 2:
print(fn + ":")
backup = fn + "-bak"
Expand Down Expand Up @@ -2961,9 +2961,9 @@ In your case, your system interprets your arguments as:
print("# Spell-checking with", checker)
for word in declared_spellings["GLOBAL"]:
d.add_to_session(word.lower())
for dir in arguments:
for directory in arguments:
ofp = None
for fn in allcfgfiles(dir):
for fn in allcfgfiles(directory):
if verbose >= 2:
print(fn + ":")
spellcheck(fn, d)
Expand Down

0 comments on commit 90919e1

Please sign in to comment.