wmllint, wmlindent, wmltools: fixed dir being used as variable name

In Python, dir is an in-built function
This commit is contained in:
Elvish_Hunter 2015-08-04 15:10:59 +02:00
parent 39ffd1e37d
commit 90919e12c6
3 changed files with 24 additions and 24 deletions

View file

@ -100,17 +100,17 @@ class Forest:
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
@ -177,9 +177,9 @@ class Forest:
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?"

View file

@ -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:

View file

@ -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)
@ -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"
@ -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)