diff --git a/data/tools/wesnoth/wmliterator.py b/data/tools/wesnoth/wmliterator.py index fbdfd4bdcda..5e56cb8d6e3 100644 --- a/data/tools/wesnoth/wmliterator.py +++ b/data/tools/wesnoth/wmliterator.py @@ -420,7 +420,7 @@ Important Attributes: self.element, nextScopes = self.parseElements(self.text) self.nextScopes = [] for elem in nextScopes: - # remember scopes by storing a copy of the iterator + # remember scopes by storing a copy of the iterator copyItor = self.copy() copyItor.element = elem self.nextScopes.append(copyItor) diff --git a/data/tools/wesnoth/wmltools.py b/data/tools/wesnoth/wmltools.py index b42e89c200c..774398024bb 100644 --- a/data/tools/wesnoth/wmltools.py +++ b/data/tools/wesnoth/wmltools.py @@ -107,7 +107,7 @@ class Forest: for directory in dirpath: subtree = [] rooted = False - if os.path.isdir(directory): # So we skip .cfgs in a UMC mirror + 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) @@ -320,7 +320,7 @@ def actualtype(a): elif a in ("lawful", "neutral", "chaotic", "liminal"): atype = "alignment" elif a.startswith("{") or a.endswith("}") or a.startswith("$"): - atype = None # Can't tell -- it's a macro expansion + atype = None # Can't tell -- it's a macro expansion elif re.match(image_reference, a) or a == "unit_image": atype = "image" elif re.match(r"(\*|[A-Z][a-z]+)\^([A-Z][a-z\\|/]+\Z)?", a): @@ -541,7 +541,7 @@ class CrossRef: name = tokens[1] here = Reference(namespace, filename, n+1, line, args=tokens[2:]) here.hash = hashlib.md5() - here.docstring = line.lstrip()[8:] # Strip off #define_ + here.docstring = line.lstrip()[8:] # Strip off #define_ state = "macro_header" continue elif state != 'outside' and line.strip().endswith("#enddef"): @@ -947,9 +947,9 @@ def vcunmove(src, dst): "Revert the result of a previous move (before commit)." (path, base) = os.path.split(src) if os.path.exists(os.path.join(path, ".git")): - return "git checkout %s" % dst # Revert the add at the destination - return "git rm " + dst # Remove the moved copy - return "git checkout %s" % src # Revert the deletion + return "git checkout %s" % dst # Revert the add at the destination + return "git rm " + dst # Remove the moved copy + return "git checkout %s" % src # Revert the deletion else: return "echo 'cannot unmove %s from %s, .git is missing'" % (src, dst) @@ -965,7 +965,7 @@ def vcundelete(src): "Revert the result of a previous delete (before commit)." (path, base) = os.path.split(src) if os.path.exists(os.path.join(path, ".git")): - return "git checkout %s" % src # Revert the deletion + return "git checkout %s" % src # Revert the deletion else: return "echo 'cannot undelete %s, .git is missing'" % src diff --git a/data/tools/wmlindent b/data/tools/wmlindent index fe93f8272b1..bcfd9e3d242 100755 --- a/data/tools/wmlindent +++ b/data/tools/wmlindent @@ -115,7 +115,7 @@ def reindent(name, infp, outfp): lasttag = "" countlines = 0 countblanks = 0 - multitag = re.compile(r"\[a-z]].*\[[a-z]") # Avoid triggering on arrays + multitag = re.compile(r"\[a-z]].*\[[a-z]") # Avoid triggering on arrays for line in infp: countlines += 1 # User may declare indentation exceptions @@ -265,7 +265,7 @@ def convertor(linefilter, arglist, exclude): if dryrun: os.remove(filename + ".out") else: - os.remove(filename) # For Windows portability + os.remove(filename) # For Windows portability # There's a tiny window open if you keyboard- # interrupt here. It's unavoidable, because # there's no known way to do an atomic rename diff --git a/data/tools/wmllint b/data/tools/wmllint index 53b23bd5100..e43e9f240bf 100755 --- a/data/tools/wmllint +++ b/data/tools/wmllint @@ -589,7 +589,7 @@ linechanges = ( ("flat/grass-r3", "flat/grass3"), ("flat/grass-r2", "flat/grass2"), ("flat/grass-r1", "flat/grass1"), - ("second_value=", "value_second="), # Correct earlier wmllint error + ("second_value=", "value_second="), # Correct earlier wmllint error (".stones", ".petrifies"), ("stones=", "petrifies="), # Changes just before 1.9.1 @@ -625,7 +625,7 @@ linechanges = ( ('FLAG_VARIANT ragged','FLAG_VARIANT6 ragged'), ('FLAG_VARIANT "ragged"','FLAG_VARIANT6 ragged'), - # Changed in 1.11.15. + # Changed in 1.11.15. ("fight_on_without_leader=yes","defeat_condition=no_units_left"), ("fight_on_without_leader=no","defeat_condition=no_leader_left"), ("remove_from_carryover_on_leaders_loss=yes","remove_from_carryover_on_defeat=yes"), @@ -693,7 +693,7 @@ def validate_on_pop(tagstack, closer, filename, lineno): def within(tag): "Did the specified tag lead one of our enclosing contexts?" - if type(tag) == type(()): # Can take a list. + if type(tag) == type(()): # Can take a list. for t in tag: if within(t): return True @@ -704,7 +704,7 @@ def within(tag): def under(tag): "Did the specified tag lead the latest context?" - if type(tag) == type(()): # Can take a list. + if type(tag) == type(()): # Can take a list. for t in tag: if within(t): return True @@ -754,7 +754,7 @@ notepairs = [ ("{ABILITY_FEEDING}", "{SPECIAL_NOTES_FEEDING}"), ("{WEAPON_SPECIAL_BERSERK}", "{SPECIAL_NOTES_BERSERK}"), ("{WEAPON_SPECIAL_BACKSTAB}", "{SPECIAL_NOTES_BACKSTAB}"), - ("{WEAPON_SPECIAL_PLAGUE", "{SPECIAL_NOTES_PLAGUE}"), # No } deliberately + ("{WEAPON_SPECIAL_PLAGUE", "{SPECIAL_NOTES_PLAGUE}"), # No } deliberately ("{WEAPON_SPECIAL_SLOW}", "{SPECIAL_NOTES_SLOW}"), ("{WEAPON_SPECIAL_PETRIFY}", "{SPECIAL_NOTES_PETRIFY}"), ("{WEAPON_SPECIAL_MARKSMAN}", "{SPECIAL_NOTES_MARKSMAN}"), @@ -955,7 +955,7 @@ def pangoize(message, filename, line): if oldstyle not in message: continue where = message.find(oldstyle) - if message[where - 1] != '"': # Start of string only + if message[where - 1] != '"': # Start of string only continue if message.strip()[-1] != '"': print('"%s", line %d: %s highlight at start of multiline string requires manual fix.' % (filename, line, oldstyle)) @@ -971,7 +971,7 @@ def pangoize(message, filename, line): if "<" in message or ">" in message: reduced = pangostrip(message) if "<" in reduced or ">" in reduced: - if message == reduced: # No pango markup + if message == reduced: # No pango markup here = message.find('<') if message[here:here+4] != "<": message = message[:here] + "<" + message[here+1:] @@ -1301,7 +1301,7 @@ def global_sanity_check(filename, lines): print('"%s", line %d: side number %s is out of sequence (%d expected)' \ % (filename, num, value, sidecount)) except ValueError: - pass # Ignore ill-formed integer literals + pass # Ignore ill-formed integer literals except TypeError: pass # Sanity check ellipses @@ -1671,13 +1671,13 @@ def global_sanity_check(filename, lines): # print('"%s", line %d: extraneous space in translatable string'\ # % (filename, i+1)) # Check correctness of translation marks and descriptions - if key.startswith("#"): # FIXME: parse_attribute is confused. + if key.startswith("#"): # FIXME: parse_attribute is confused. pass elif key.startswith("{"): pass - elif key == 'letter': # May be led with _s for void + elif key == 'letter': # May be led with _s for void pass - elif key in ('name', 'male_name', 'female_name', 'value'): # FIXME: check this someday + elif key in ('name', 'male_name', 'female_name', 'value'): # FIXME: check this someday pass elif key == "variation_name": if markcheck and not has_tr_mark: @@ -1740,7 +1740,7 @@ def global_sanity_check(filename, lines): if not no_text: if not textdomains: print('"%s", line 1: no textdomain string' % filename) - elif textdomains[0] == 1: # Multiples are OK if first is on line 1 + elif textdomains[0] == 1: # Multiples are OK if first is on line 1 pass elif len(textdomains) > 1: print('"%s", line %d: multiple textdomain strings on lines %s' % \ @@ -2140,7 +2140,7 @@ def is_map(filename): "Is this file a map?" return filename.endswith(".map") -if 0: # Not used, as there are currently no defined map transforms +if 0: # Not used, as there are currently no defined map transforms class maptransform_error: "Error object to be thrown by maptransform." def __init__(self, infile, inline, type): @@ -2160,7 +2160,7 @@ if 0: # Not used, as there are currently no defined map transforms raise maptransform_error(filename, baseline+y+1, "unrecognized map element at line %d" % (y,)) -tagstack = [] # For tracking tag nesting +tagstack = [] # For tracking tag nesting def outermap(func, inmap): "Apply a transformation based on neighborhood to the outermost ring." @@ -2324,7 +2324,7 @@ def translator(filename, mapxforms, textxform): newdata.append(newline + terminator) fields = newline.split("#") trimmed = fields[0] - destringed = re.sub('"[^"]*"', '', trimmed) # Ignore string literals + destringed = re.sub('"[^"]*"', '', trimmed) # Ignore string literals comment = "" if len(fields) > 1: comment = fields[1] @@ -2399,7 +2399,7 @@ def translator(filename, mapxforms, textxform): if transformed[i] == '\n': if singleline: singleline = False - if not display_state and quotecount % 2 and transformed[i:i+2] != "\n\n" and transformed[i-1:i+1] != "\n\n": + if not display_state and quotecount % 2 and transformed[i:i+2] != "\n\n" and transformed[i-1:i+1] != "\n\n": print('"%s", line %d: nonstandard word-wrap style within message' % (filename, linecount)) linecount += 1 elif transformed[i-7:i] == "message" and transformed[i] == '=': @@ -2620,7 +2620,7 @@ def allcfgfiles(directory): for name in files: if interesting(os.path.join(root, name)): datafiles.append(os.path.join(root, name)) - datafiles.sort() # So diffs for same campaigns will cluster in reports + datafiles.sort() # So diffs for same campaigns will cluster in reports return map(os.path.normpath, datafiles) def help(): diff --git a/data/tools/wmlscope b/data/tools/wmlscope index a70b00e8e25..694132bc65f 100755 --- a/data/tools/wmlscope +++ b/data/tools/wmlscope @@ -330,9 +330,9 @@ sudo apt-get install python-pil""", file=sys.stderr) if entry.docstring: lines = entry.docstring.split("\n") header = lines.pop(0).split() - if lines and not lines[-1]: # Ignore trailing blank lines + if lines and not lines[-1]: # Ignore trailing blank lines lines.pop() - if not lines: # Ignore definitions without a docstring + if not lines: # Ignore definitions without a docstring continue outstr += "\n