mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-26 17:22:57 +00:00
Removed a lot of trailing whitespaces. Shouldn't be anymore in python scripts.
This commit is contained in:
parent
5f3fdc7f4f
commit
2288ef0939
@ -93,7 +93,7 @@ Select the add-on you want to install from the list and click "OK". The download
|
||||
src = root_dir + "images/misc/missing-image.png"
|
||||
imgurl = "icons/missing-image.png"
|
||||
images_to_tc.append( (src, path + "/" + imgurl) )
|
||||
|
||||
|
||||
type = v("type", "none")
|
||||
size = float(v("size", "0"))
|
||||
name = v("title", "unknown")
|
||||
|
@ -12,16 +12,15 @@
|
||||
# but WITHOUT ANY WARRANTY.
|
||||
#
|
||||
# See the COPYING file for more details.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
# Meta-Macro syntax:
|
||||
# #meta-macro BASENAME [{NORMAL_PARAM, OPTIONAL_PARAM} [...]]
|
||||
#
|
||||
# NORMAL_PARAM: Macro parameter that will be passed unmodified to the base
|
||||
# macro
|
||||
# OPTIONAL_PARAM: Macro parameter that will sometimes be passed to the base
|
||||
# OPTIONAL_PARAM: Macro parameter that will sometimes be passed to the base
|
||||
# macro and sometimes be replaced with a default value. The script will
|
||||
# create one macro for each possible combination of optional parameters
|
||||
#
|
||||
@ -48,7 +47,7 @@ def printUsage():
|
||||
-r Replace the input file(s) with the resulting output. Previously generated
|
||||
expansions will be removed. Implies -i if nothing else is specified.
|
||||
|
||||
If no options are specified, only the expanded sections will be printed to
|
||||
If no options are specified, only the expanded sections will be printed to
|
||||
stdout"""
|
||||
|
||||
insert = False
|
||||
@ -76,7 +75,7 @@ if insert and append:
|
||||
print "Error: cannot use -i and -a at the same time"
|
||||
printUsage()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
if len(args) == 0:
|
||||
printUsage()
|
||||
@ -90,7 +89,7 @@ for filename in args:
|
||||
changed = False
|
||||
output = []
|
||||
appended = []
|
||||
|
||||
|
||||
autogenerated = False
|
||||
for line in content:
|
||||
if line.strip() == "#The following code is autogenerated\
|
||||
@ -108,7 +107,7 @@ for filename in args:
|
||||
basename = elems[0]
|
||||
params = []
|
||||
optional_params = []
|
||||
|
||||
|
||||
for param in elems[1:]:
|
||||
split_param = param.split('=')
|
||||
if len(split_param) == 3:
|
||||
@ -116,7 +115,7 @@ for filename in args:
|
||||
elif len(split_param) != 1:
|
||||
print "Error in line:\n" + line
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
params.append(split_param)
|
||||
|
||||
base_macro_suffix = "_" + "".join(optional_params)
|
||||
@ -127,7 +126,7 @@ for filename in args:
|
||||
if append:
|
||||
result.append("#generated from: " + line.strip())
|
||||
result.append("#Please do not modify")
|
||||
|
||||
|
||||
for i in range(2**len(optional_params) - 2, -1, -1):
|
||||
enabled_map = dict([(param, i & (1<<index) != 0) for index, param in enumerate(optional_params)])
|
||||
|
||||
@ -151,11 +150,11 @@ for filename in args:
|
||||
|
||||
if len(suffix) > 0:
|
||||
suffix = "_"+suffix
|
||||
|
||||
|
||||
result.append("#define " + basename + suffix + " " + " ".join(params_external))
|
||||
result.append(" {" + basename + base_macro_suffix + " " + " ".join(params_internal) + "}")
|
||||
result.append("#enddef")
|
||||
|
||||
|
||||
result.append("#end of generated code")
|
||||
changed = True
|
||||
|
||||
@ -173,7 +172,7 @@ for filename in args:
|
||||
if append:
|
||||
for line in appended:
|
||||
print line
|
||||
|
||||
|
||||
elif replace and changed:
|
||||
f = open(filename, 'w')
|
||||
for line in output:
|
||||
|
@ -45,4 +45,3 @@ for line in sys.stdin:
|
||||
print >>sys.stderr, "Malformed line: %s" % `line`
|
||||
sys.exit(1)
|
||||
entry[key] = value
|
||||
|
||||
|
@ -12,7 +12,7 @@ The Python Imaging Library must be available for this tool to work
|
||||
|
||||
import sys, Image
|
||||
|
||||
# Extract a color table list from the images
|
||||
# Extract a color table list from the images
|
||||
colortables = []
|
||||
for filename in sys.argv[1:]:
|
||||
img = Image.open(filename).convert("RGB")
|
||||
@ -32,7 +32,7 @@ for i in range(1, len(colortables)):
|
||||
for (n, rgb) in colortables[i][1]:
|
||||
if rgb not in basecolors:
|
||||
exiguous.append((n, rgb))
|
||||
exiguous.sort(lambda (an, argb), (bn, brgb): cmp(argb, brgb))
|
||||
exiguous.sort(lambda (an, argb), (bn, brgb): cmp(argb, brgb))
|
||||
subtracted.append((colortables[i][0], exiguous))
|
||||
|
||||
print "Base colors:"
|
||||
@ -41,8 +41,3 @@ for (filename, colors) in subtracted:
|
||||
print filename + ":"
|
||||
for (n, rgb) in colors:
|
||||
print `rgb` + " * " + `n`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -65,9 +65,9 @@ if __name__ == "__main__":
|
||||
n = 0
|
||||
id_list = []
|
||||
indent = 8
|
||||
|
||||
|
||||
for name in files:
|
||||
out[name] = []
|
||||
out[name] = []
|
||||
lineno = 0
|
||||
scenario_id = None
|
||||
inside = False
|
||||
|
@ -7,7 +7,7 @@ import os
|
||||
import getopt
|
||||
import re
|
||||
|
||||
overwrite = False
|
||||
overwrite = False
|
||||
defaultValue = 4
|
||||
suffix = ''
|
||||
|
||||
@ -56,7 +56,7 @@ def getIndent(itemText, subitemText):
|
||||
if item[0] == ' ' and subitem[0] == ' ':
|
||||
return (len(subitem) - len(item)) * ' '
|
||||
return '\t'
|
||||
|
||||
|
||||
class wikiAi:
|
||||
def __init__(self):
|
||||
self.start = ""
|
||||
@ -100,7 +100,7 @@ class wikiSide:
|
||||
break
|
||||
searchStart = aiDetail.end()
|
||||
aiDetail = ai_block.search(sideContent, searchStart)
|
||||
|
||||
|
||||
|
||||
def updateAi(self, sides):
|
||||
if not len(self.ai):
|
||||
@ -125,7 +125,7 @@ class wikiSide:
|
||||
updateDescription(self.ai[0], sides)
|
||||
if self.ai[0].full_description != self.ai[0].updated_description:
|
||||
self.updated_description = self.updated_description.replace(self.ai[0].full_description, self.ai[0].updated_description, 1)
|
||||
|
||||
|
||||
def getCurrentAiNumber(self):
|
||||
return len(self.ai) - 1
|
||||
|
||||
@ -238,7 +238,7 @@ Example of use:
|
||||
./scoutDefault.py -f 2p_Blitz.cfg -O
|
||||
Run the script on 2p_Blitz.cfg and delete previous value"""
|
||||
|
||||
recursive = False
|
||||
recursive = False
|
||||
entryPoint = os.getcwd()
|
||||
entryFile = os.listdir(os.getcwd())
|
||||
resourcesFile = {}
|
||||
@ -253,7 +253,7 @@ for (option, parameter) in opts:
|
||||
printUsage()
|
||||
sys.exit(0)
|
||||
elif option == '-R':
|
||||
recursive = True
|
||||
recursive = True
|
||||
elif option == '-O':
|
||||
overwrite = False
|
||||
elif option == '-d':
|
||||
|
@ -15,7 +15,7 @@ select ends the program; Selecting a file takes you to a main screen.
|
||||
For command help on the main screen, click the Help button.
|
||||
|
||||
Can be started with a map image, in which case we are editing a new journey.
|
||||
Can be started with a .cfg file, in which case it will look for
|
||||
Can be started with a .cfg file, in which case it will look for
|
||||
track information enclosed in special comments that look like this:
|
||||
|
||||
# trackplacer: tracks begin
|
||||
@ -334,7 +334,7 @@ class JourneyTracks:
|
||||
if len(neighbors) >= 2 and neighbors[0][0] != len(neighbors)-1:
|
||||
closest = neighbors[0]
|
||||
next_closest = neighbors[1]
|
||||
# If the neighbors are adjacent, insert between them
|
||||
# If the neighbors are adjacent, insert between them
|
||||
if abs(closest[0] - next_closest[0]) == 1:
|
||||
self.selected_track().insert(max(closest[0], next_closest[0]), (action, x, y))
|
||||
self.modified += 1
|
||||
@ -471,7 +471,7 @@ class TrackController:
|
||||
if track_id in self.editor.visible_set:
|
||||
self.editor.visible_set.remove(track_id)
|
||||
if track_id == self.editor.journey.selected_id:
|
||||
self.editor.track_select(w, self.editor.visible_set[-1])
|
||||
self.editor.track_select(w, self.editor.visible_set[-1])
|
||||
# FIXME: This redraw fails when we delete the last track.
|
||||
self.editor.redraw(self.editor.drawing_area)
|
||||
self.editor.journey.remove_track(track_id)
|
||||
@ -486,7 +486,7 @@ class TracksEditor:
|
||||
def __init__(self, path=None, verbose=False, force_save=False):
|
||||
self.verbose = verbose
|
||||
self.force_save = force_save
|
||||
# Initialize our info about the map and track
|
||||
# Initialize our info about the map and track
|
||||
self.journey = JourneyTracks()
|
||||
self.last_read = None
|
||||
self.journey.read(path)
|
||||
@ -544,7 +544,7 @@ class TracksEditor:
|
||||
vbox.pack_start(toolbar, expand = False)
|
||||
toolbar.show()
|
||||
|
||||
# Toolbar widget has a fit when we try to pack these separately.
|
||||
# Toolbar widget has a fit when we try to pack these separately.
|
||||
radiobox1 = gtk.ToolItem()
|
||||
radiobox = gtk.HBox()
|
||||
radiobox1.add(radiobox)
|
||||
@ -756,7 +756,7 @@ class TracksEditor:
|
||||
self.log("Redrawing action=%s" % ((na, nx, ny),))
|
||||
self.draw_feature(widget,
|
||||
(na, nx, ny),
|
||||
save_select == self.journey.selected_id)
|
||||
save_select == self.journey.selected_id)
|
||||
self.journey.set_selected_track(save_select)
|
||||
|
||||
def draw_feature(self, widget, (action, x, y), selected):
|
||||
@ -879,7 +879,7 @@ class TracksEditor:
|
||||
state = event.state
|
||||
|
||||
# This code enables dragging icons wit h the middle button.
|
||||
if state & gtk.gdk.BUTTON2_MASK and self.pixmap != None:
|
||||
if state & gtk.gdk.BUTTON2_MASK and self.pixmap != None:
|
||||
if self.selected is not None:
|
||||
(action, lx, ly) = self.journey[self.selected]
|
||||
self.erase_feature(widget, (action, lx, ly))
|
||||
@ -897,7 +897,7 @@ class TracksEditor:
|
||||
def quit(self, w):
|
||||
if self.journey.has_unsaved_changes():
|
||||
self.quit_check = gtk.Dialog(title="Really quit?",
|
||||
parent=None,
|
||||
parent=None,
|
||||
flags=gtk.DIALOG_MODAL,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
@ -957,11 +957,11 @@ class TracksEditor:
|
||||
% self.last_read
|
||||
elif os.stat(filename).st_mtime > self.time_last_io:
|
||||
confirmation_required = "File has changed "\
|
||||
"since last read or written."
|
||||
"since last read or written."
|
||||
if confirmation_required:
|
||||
confirmation_required += "\nReally overwrite %s?" % filename
|
||||
save_check = gtk.Dialog(title="Really overwrite?",
|
||||
parent=None,
|
||||
parent=None,
|
||||
flags=gtk.DIALOG_MODAL,
|
||||
buttons=(gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_REJECT,
|
||||
@ -980,7 +980,7 @@ class TracksEditor:
|
||||
try:
|
||||
self.journey.write(filename)
|
||||
if not self.journey.mapfile:
|
||||
self.journey.mapfile = filename
|
||||
self.journey.mapfile = filename
|
||||
self.time_last_io = time.time()
|
||||
except IOError:
|
||||
w = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
|
||||
@ -1116,7 +1116,7 @@ class TracksEditor:
|
||||
def properties_handler(self, w):
|
||||
"Display a dialog for editing track properties."
|
||||
w = gtk.Dialog(title="Track properties editor",
|
||||
parent=None,
|
||||
parent=None,
|
||||
flags=gtk.DIALOG_MODAL,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
@ -1205,7 +1205,7 @@ if __name__ == "__main__":
|
||||
if e.lineno:
|
||||
sys.stderr.write(('"%s", line %d: ' % (e.path, e.lineno)) + e.message + "\n")
|
||||
else:
|
||||
sys.stderr.write(e.path + ": " + e.message + "\n")
|
||||
sys.stderr.write(e.path + ": " + e.message + "\n")
|
||||
else:
|
||||
while True:
|
||||
try:
|
||||
|
@ -1,3 +1,3 @@
|
||||
# When Python looks for a package, it considers all directories with
|
||||
# a file named __init__.py inside them. Therefore we need this file.
|
||||
# When Python looks for a package, it considers all directories with
|
||||
# a file named __init__.py inside them. Therefore we need this file.
|
||||
# Any code put in here would get executed on "import wesnoth".
|
||||
|
@ -46,8 +46,8 @@ def write_table_row(out, unit, color, name = None):
|
||||
"draw_weapon_anim",
|
||||
"sheath_weapon_anim"
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
needed = {}
|
||||
for at in anim_types: needed[at] = True
|
||||
|
||||
@ -60,7 +60,7 @@ def write_table_row(out, unit, color, name = None):
|
||||
if abil.get_all(tag = "leadership"):
|
||||
needed["leading_anim"] = True
|
||||
if abil.get_all(tag = "teleport"):
|
||||
needed["teleport"] = True
|
||||
needed["teleport"] = True
|
||||
|
||||
if name == None: name = unit.id
|
||||
|
||||
@ -118,7 +118,7 @@ def put_units(f, us):
|
||||
""".lstrip())
|
||||
|
||||
f.write("</tr>\n")
|
||||
|
||||
|
||||
def by_race(u1, u2):
|
||||
r1 = u1.rid
|
||||
r2 = u2.rid
|
||||
@ -154,15 +154,14 @@ td.none {border: solid 1px; background-color: #ffffff;}
|
||||
""".lstrip())
|
||||
f.write("<h1>animation statistics</h1>\n")
|
||||
f.write("<i>total frames (number of animations)</i>\n")
|
||||
|
||||
|
||||
f.write("<h2>Mainline</h2>\n")
|
||||
us = [x for x in wesnoth.unit_lookup.values() if x.campaign == "mainline"]
|
||||
put_units(f, us)
|
||||
|
||||
|
||||
f.write("<h2>Campaigns and Addons</h2>\n")
|
||||
us = [x for x in wesnoth.unit_lookup.values() if x.campaign != "mainline"]
|
||||
put_units(f, us)
|
||||
|
||||
f.write("</body></html>")
|
||||
f.close()
|
||||
|
||||
f.close()
|
||||
|
@ -32,7 +32,7 @@ class ImageCollector:
|
||||
self.verbose = 0
|
||||
self.datadir = datadir
|
||||
self.userdir = userdir
|
||||
|
||||
|
||||
if not self.datadir: self.datadir = get_datadir(wesnoth_exe)
|
||||
if not self.userdir: self.userdir = get_userdir(wesnoth_exe)
|
||||
|
||||
@ -70,7 +70,7 @@ class ImageCollector:
|
||||
ipath, error = self.find_image(path, campaign)
|
||||
if ipath in self.ipaths:
|
||||
return self.ipaths[ipath], False
|
||||
|
||||
|
||||
name = "%05d_" % self.id
|
||||
name += os.path.basename(path)
|
||||
self.id += 1
|
||||
@ -82,7 +82,7 @@ class ImageCollector:
|
||||
else:
|
||||
self.notfound[(campaign, path)] = name
|
||||
return name, True
|
||||
|
||||
|
||||
def add_image(self, campaign, path):
|
||||
name, error = self.add_image_check(campaign, path)
|
||||
return name
|
||||
@ -126,7 +126,7 @@ class WesnothList:
|
||||
self.campaign_lookup = {}
|
||||
self.parser = wmlparser2.Parser(wesnoth_exe, config_dir,
|
||||
data_dir, no_preprocess = False)
|
||||
|
||||
|
||||
|
||||
def add_terrains(self):
|
||||
"""
|
||||
@ -207,7 +207,7 @@ class WesnothList:
|
||||
Find all addon eras and campaigns.
|
||||
"""
|
||||
self.parser.parse_text("{multiplayer}{~add-ons}", "MULTIPLAYER")
|
||||
|
||||
|
||||
cn = 0
|
||||
for campaign in self.parser.get_all(tag = "campaign"):
|
||||
cid = self.add_campaign(campaign)
|
||||
@ -226,7 +226,7 @@ class WesnothList:
|
||||
image_collector.add_binary_paths_from_WML("addons",
|
||||
self.parser.root)
|
||||
return cn, en, un
|
||||
|
||||
|
||||
def add_mainline_units(self):
|
||||
self.parser.parse_text("{core/units.cfg}")
|
||||
return self.add_units("mainline")
|
||||
@ -235,17 +235,17 @@ class WesnothList:
|
||||
campaign = self.campaign_lookup[cname]
|
||||
define = campaign.get_text_val("define")
|
||||
self.parser.parse_text("{campaigns}", define + ",NORMAL")
|
||||
|
||||
|
||||
image_collector.add_binary_paths_from_WML(cname,
|
||||
self.parser.root)
|
||||
|
||||
|
||||
return self.add_units(cname)
|
||||
|
||||
def add_addon_campaign_units(self, cname, image_collector):
|
||||
campaign = self.campaign_lookup[cname]
|
||||
define = campaign.get_text_val("define")
|
||||
self.parser.parse_text("{~add-ons}", define)
|
||||
|
||||
|
||||
image_collector.add_binary_paths_from_WML(cname,
|
||||
self.parser.root)
|
||||
|
||||
@ -309,7 +309,7 @@ class WesnothList:
|
||||
movetype = self.get_unit_value(unit, "movement_type")
|
||||
try: unit.movetype = self.movetype_lookup[movetype]
|
||||
except KeyError: unit.movetype = None
|
||||
|
||||
|
||||
unit.advance = []
|
||||
advanceto = unit.get_text_val("advances_to")
|
||||
# Add backwards compatibility for 1.4
|
||||
@ -397,7 +397,7 @@ class UnitForest:
|
||||
valid list of children in unit.child_ids, also fill in unit.parent_ids
|
||||
and update the unit.children shortcut.
|
||||
"""
|
||||
|
||||
|
||||
# Complete the network
|
||||
for uid, u in self.lookup.items():
|
||||
for cid in u.child_ids:
|
||||
@ -411,7 +411,7 @@ class UnitForest:
|
||||
for uid, u in self.lookup.items():
|
||||
if not u.parent_ids:
|
||||
self.trees[uid] = u
|
||||
|
||||
|
||||
# Sanity check because some argGRRxxx addons have units who advance to
|
||||
# themselves.
|
||||
|
||||
@ -432,15 +432,15 @@ class UnitForest:
|
||||
recurse(u, already)
|
||||
|
||||
def update(self):
|
||||
self.create_network()
|
||||
|
||||
self.create_network()
|
||||
|
||||
self.breadth = sum([x.update_breadth() for x in self.trees.values()])
|
||||
return self.breadth
|
||||
|
||||
def get_children(self, uid):
|
||||
un = self.lookup[uid]
|
||||
return un.child_ids
|
||||
|
||||
|
||||
def get_parents(self, uid):
|
||||
un = self.lookup[uid]
|
||||
return un.parent_ids
|
||||
@ -462,9 +462,8 @@ class UnitNode:
|
||||
self.breadth = 1
|
||||
else:
|
||||
self.breadth = sum([x.update_breadth() for x in self.children])
|
||||
return self.breadth
|
||||
return self.breadth
|
||||
|
||||
class GroupNode:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
# When Python looks for a package, it considers all directories with
|
||||
# a file named __init__.py inside them. Therefore we need this file.
|
||||
# When Python looks for a package, it considers all directories with
|
||||
# a file named __init__.py inside them. Therefore we need this file.
|
||||
# Any code put in here would get executed on "import wesnoth".
|
||||
|
@ -57,9 +57,9 @@ def blacklist_if_faulty(wml, d):
|
||||
return False
|
||||
|
||||
def check_runaway():
|
||||
|
||||
|
||||
campaigns = {}
|
||||
|
||||
|
||||
udir = get_userdir() + "/data/add-ons"
|
||||
g.p = wmlparser2.Parser(options.wesnoth, options.config_dir,
|
||||
options.data_dir, no_preprocess = False)
|
||||
@ -68,11 +68,11 @@ def check_runaway():
|
||||
return "'" + name.replace("'", "'\\''") + "'"
|
||||
|
||||
def move(f, t, name):
|
||||
|
||||
|
||||
if os.path.exists(f + "/" + name + ".cfg"):
|
||||
com = "mv " + f + "/" + bash(name + ".cfg") + " " + t + "/"
|
||||
shell(com)
|
||||
|
||||
|
||||
com = "mv " + f + "/" + bash(name) + " " + t + "/"
|
||||
shell(com)
|
||||
|
||||
@ -84,8 +84,8 @@ def check_runaway():
|
||||
|
||||
print("__________\nTesting " + name)
|
||||
move(options.runaway, udir, name)
|
||||
|
||||
|
||||
|
||||
|
||||
ok = True
|
||||
try:
|
||||
g.p.parse_text("{~add-ons}")
|
||||
@ -97,7 +97,7 @@ def check_runaway():
|
||||
if pu:
|
||||
print("Found runaway [+units]!")
|
||||
ok = False
|
||||
|
||||
|
||||
names = []
|
||||
for units in u + pu:
|
||||
for un in units.get_all(tag = "unit_type"):
|
||||
@ -111,7 +111,7 @@ def check_runaway():
|
||||
print("***")
|
||||
print("")
|
||||
ok = False
|
||||
|
||||
|
||||
if ok:
|
||||
campaigns[name] = g.p.get_all(tag = "campaign")
|
||||
|
||||
@ -123,12 +123,12 @@ def check_runaway():
|
||||
|
||||
print("\n%d/%d addons passed runaway test. Trying to parse them." % (
|
||||
len(passed), len(total)))
|
||||
|
||||
|
||||
parsed = []
|
||||
for name in passed:
|
||||
print("__________\nParsing " + name)
|
||||
move(options.runaway, udir, name)
|
||||
|
||||
|
||||
ok = True
|
||||
campaign = campaigns[name]
|
||||
if campaign and campaign[0].get_text_val("define", None):
|
||||
@ -145,13 +145,13 @@ def check_runaway():
|
||||
|
||||
if ok:
|
||||
parsed.append(name)
|
||||
|
||||
|
||||
|
||||
|
||||
print("\n%d/%d addons could be parsed. Moving them to the add-ons folder.\n" % (
|
||||
len(parsed), len(total)))
|
||||
for name in parsed:
|
||||
move(options.runaway, udir, name)
|
||||
|
||||
|
||||
print("\nSome addons may have failed simply because of unmet "
|
||||
"dependencies, as this test considers each one in isolation. "
|
||||
"TODO: Someone should fix this or tell me how to fix it.")
|
||||
@ -172,11 +172,11 @@ def main():
|
||||
"this script will then move them into the add-ons folder "
|
||||
"making sure there are no run-away units.")
|
||||
options, args = p.parse_args()
|
||||
|
||||
|
||||
if not options.wesnoth:
|
||||
sys.stderr.write("No Wesnoth executable given.\n")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if options.runaway:
|
||||
check_runaway()
|
||||
sys.exit(0)
|
||||
|
@ -110,9 +110,9 @@ class CampaignClient:
|
||||
return None
|
||||
|
||||
self.length = l = struct.unpack("!i", packet)[0]
|
||||
|
||||
|
||||
sys.stderr.write("Receiving %d bytes.\n" % self.length)
|
||||
|
||||
|
||||
packet = ""
|
||||
while len(packet) < l and not self.canceled:
|
||||
r = self.sock.recv(l - len(packet))
|
||||
@ -122,9 +122,9 @@ class CampaignClient:
|
||||
self.counter = len(packet)
|
||||
if self.canceled:
|
||||
return None
|
||||
|
||||
|
||||
sys.stderr.write("Received %d bytes.\n" % len(packet))
|
||||
|
||||
|
||||
if packet.startswith("\x1F\x8B"):
|
||||
if self.verbose:
|
||||
sys.stderr.write("GZIP compression found...\n")
|
||||
@ -363,7 +363,7 @@ class CampaignClient:
|
||||
|
||||
def get_campaign_raw_async(self, name):
|
||||
"""
|
||||
This is like get_campaign_raw, but returns immediately,
|
||||
This is like get_campaign_raw, but returns immediately,
|
||||
doing server communications in a background thread.
|
||||
"""
|
||||
class MyThread(threading.Thread):
|
||||
@ -392,7 +392,7 @@ class CampaignClient:
|
||||
|
||||
def put_campaign_async(self, *args):
|
||||
"""
|
||||
This is like put_campaign, but returns immediately,
|
||||
This is like put_campaign, but returns immediately,
|
||||
doing server communications in a background thread.
|
||||
"""
|
||||
class MyThread(threading.Thread):
|
||||
@ -421,8 +421,8 @@ class CampaignClient:
|
||||
|
||||
def unpackdir(self, data, path, i = 0, verbose = False):
|
||||
"""
|
||||
Call this to unpack a campaign contained in a WML object
|
||||
to the filesystem. The data parameter is the WML object,
|
||||
Call this to unpack a campaign contained in a WML object
|
||||
to the filesystem. The data parameter is the WML object,
|
||||
path is the path under which it will be placed.
|
||||
"""
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim: tabstop=4: shiftwidth=4: expandtab: softtabstop=4: autoindent:
|
||||
# $Id$
|
||||
# $Id$
|
||||
"""
|
||||
Copyright (C) 2007 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
@ -10,11 +10,11 @@
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
This library provides an interface to svn, the interface is build upon
|
||||
the command line svn tool.
|
||||
the command line svn tool.
|
||||
"""
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ the command line svn tool.
|
||||
# call to __execute
|
||||
|
||||
import os, shutil, logging
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import Popen, PIPE
|
||||
class error(Exception):
|
||||
"""Base class for exceptions in this module."""
|
||||
pass
|
||||
@ -32,7 +32,7 @@ class error(Exception):
|
||||
|
||||
class SVN:
|
||||
"""Initializes a SVN object.
|
||||
|
||||
|
||||
Checkout the root of the local checkout eg /src/wesnoth
|
||||
do not include a trailing slash!
|
||||
"""
|
||||
@ -43,8 +43,8 @@ class SVN:
|
||||
self.checkout_path = checkout
|
||||
|
||||
"""Makes a new checkout.
|
||||
|
||||
repo The repo to checkout eg
|
||||
|
||||
repo The repo to checkout eg
|
||||
http://svn.gna.org/svn/wesnoth/trunk.
|
||||
returns Nothing.
|
||||
"""
|
||||
@ -52,7 +52,7 @@ class SVN:
|
||||
|
||||
logging.debug("checkout repo = '%s'", repo)
|
||||
|
||||
out, err = self.__execute(["svn", "co", "--non-interactive",
|
||||
out, err = self.__execute(["svn", "co", "--non-interactive",
|
||||
repo, self.checkout_path])
|
||||
|
||||
if(err != ""):
|
||||
@ -64,7 +64,7 @@ class SVN:
|
||||
|
||||
After deleting a local file and committing that change the file remains.
|
||||
msg The commit message.
|
||||
files Optional list with files/directories to commit if
|
||||
files Optional list with files/directories to commit if
|
||||
ommitted all modifications are send.
|
||||
returns True if committed, False if nothing to commit.
|
||||
"""
|
||||
@ -135,13 +135,13 @@ class SVN:
|
||||
logging.debug("export to '%s'", target)
|
||||
|
||||
command = ["svn", "export", self.checkout_path, target]
|
||||
|
||||
|
||||
# execute
|
||||
out, err = self.__execute(command)
|
||||
|
||||
return (err == "")
|
||||
|
||||
|
||||
|
||||
|
||||
"""Add an item to the repo.
|
||||
|
||||
@ -172,10 +172,10 @@ class SVN:
|
||||
self.__svn_remove(self.checkout_path + "/" + item)
|
||||
|
||||
"""Copies local files to an svn checkout.
|
||||
|
||||
|
||||
src Directory with the source files.
|
||||
exclude List with names to ignore.
|
||||
returns True if the copy resulted in a modified checkout,
|
||||
returns True if the copy resulted in a modified checkout,
|
||||
False otherwise.
|
||||
"""
|
||||
def copy_to_svn(self, src, exclude):
|
||||
@ -185,7 +185,7 @@ class SVN:
|
||||
|
||||
# Check whether the status of the repo is clean.
|
||||
out, err = self.__execute(["svn", "st", self.checkout_path])
|
||||
|
||||
|
||||
# If not clean or an error bail out.
|
||||
if(err != ""):
|
||||
raise error("status failed with message:" + err)
|
||||
@ -214,7 +214,7 @@ class SVN:
|
||||
|
||||
# Check whether the status of the repo is clean.
|
||||
out, err = self.__execute(["svn", "st", self.checkout_path])
|
||||
|
||||
|
||||
# If not clean or an error bail out.
|
||||
if(err != ""):
|
||||
raise error("status failed with message:" + err)
|
||||
@ -303,10 +303,10 @@ class SVN:
|
||||
if not os.path.isdir(src + "/" + dir):
|
||||
# dest only
|
||||
self.__dir_remove(dest + "/" + dir, not(src_svn))
|
||||
|
||||
|
||||
# If a file exists in the src but not in the dest, it needs to be copied.
|
||||
|
||||
# If a file doesn't exist in the src but does in the dest, it needs to be
|
||||
# If a file doesn't exist in the src but does in the dest, it needs to be
|
||||
# deleted.
|
||||
|
||||
# If a file exists in both it needs to be copied.
|
||||
@ -326,7 +326,7 @@ class SVN:
|
||||
|
||||
"""Gets a list with files and directories.
|
||||
|
||||
The function always ignores .svn entries. Items which aren't a directory
|
||||
The function always ignores .svn entries. Items which aren't a directory
|
||||
are assumed a file.
|
||||
dir The directory to get the info from.
|
||||
exclude List with names to ignore.
|
||||
@ -350,7 +350,7 @@ class SVN:
|
||||
# Ignore exclude list.
|
||||
if(exclude != None and item in exclude):
|
||||
continue
|
||||
|
||||
|
||||
# An item is either a directory or not, in the latter case it's
|
||||
# assumed to be a file.
|
||||
if(os.path.isdir(dir + "/" + item)):
|
||||
@ -386,11 +386,11 @@ class SVN:
|
||||
# copy files
|
||||
for file in files:
|
||||
self.__file_add(src + "/" + file, dest + "/" + file, src_svn)
|
||||
|
||||
|
||||
# copy dirs
|
||||
for dir in dirs:
|
||||
self.__dir_add(src + "/" + dir, dest + "/" + dir, src_svn, exclude)
|
||||
|
||||
|
||||
"""Removes a directory.
|
||||
|
||||
file The directory to remove.
|
||||
@ -418,7 +418,7 @@ class SVN:
|
||||
returns Nothing.
|
||||
"""
|
||||
def __file_add(self, src, dest, src_svn):
|
||||
|
||||
|
||||
logging.debug("__file_add src = '%s' dest = '%s' src_svn = '%s'",
|
||||
src, dest, src_svn)
|
||||
|
||||
@ -477,4 +477,3 @@ class SVN:
|
||||
logging.debug("===== stderr ====\n\n\n%s\n\n\n===== stderr ====", err)
|
||||
|
||||
return out, err
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4: shiftwidth=4: expandtab: softtabstop=4: autoindent:
|
||||
# $Id$
|
||||
# $Id$
|
||||
"""
|
||||
Copyright (C) 2007 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
@ -11,7 +11,7 @@
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
This utility provides two tools
|
||||
@ -34,8 +34,8 @@ class tempdir:
|
||||
def __init__(self):
|
||||
self.path = tempfile.mkdtemp()
|
||||
logging.debug("created tempdir '%s'", self.path)
|
||||
|
||||
# for some reason we need to need a variable to shutil otherwise the
|
||||
|
||||
# for some reason we need to need a variable to shutil otherwise the
|
||||
#__del__() will fail. This is caused by import of campaignserver_client
|
||||
# or libsvn, according to esr it's a bug in Python.
|
||||
self.dummy = shutil
|
||||
@ -48,14 +48,14 @@ if __name__ == "__main__":
|
||||
|
||||
"""Download an addon from the server.
|
||||
|
||||
server The url of the addon server eg
|
||||
server The url of the addon server eg
|
||||
add-ons.wesnoth.org:15005.
|
||||
addon The name of the addon.
|
||||
path Directory to unpack the campaign in.
|
||||
returns Nothing.
|
||||
"""
|
||||
def extract(server, addon, path):
|
||||
|
||||
|
||||
logging.debug("extract addon server = '%s' addon = '%s' path = '%s'",
|
||||
server, addon, path)
|
||||
|
||||
@ -65,14 +65,14 @@ if __name__ == "__main__":
|
||||
|
||||
"""Get a list of addons on the server.
|
||||
|
||||
server The url of the addon server eg
|
||||
server The url of the addon server eg
|
||||
add-ons.wesnoth.org:15005.
|
||||
translatable_only If True only returns translatable addons.
|
||||
returns A dictonary with the addon as key and the translatable
|
||||
status as value.
|
||||
"""
|
||||
def list(server, translatable_only):
|
||||
|
||||
|
||||
logging.debug("list addons server = '%s' translatable_only = %s",
|
||||
server, translatable_only)
|
||||
|
||||
@ -97,7 +97,7 @@ if __name__ == "__main__":
|
||||
|
||||
"""Get the timestamp of a campaign on the server.
|
||||
|
||||
server The url of the addon server eg
|
||||
server The url of the addon server eg
|
||||
add-ons.wesnoth.org:15005.
|
||||
addon The name of the addon.
|
||||
returns The timestamp of the campaign, -1 if not on the server.
|
||||
@ -122,8 +122,8 @@ if __name__ == "__main__":
|
||||
return -1
|
||||
|
||||
"""Upload a addon from the server to wescamp.
|
||||
|
||||
server The url of the addon server eg
|
||||
|
||||
server The url of the addon server eg
|
||||
add-ons.wesnoth.org:15005.
|
||||
addon The name of the addon.
|
||||
temp_dir The directory where the unpacked campaign can be stored.
|
||||
@ -132,7 +132,7 @@ if __name__ == "__main__":
|
||||
def upload(server, addon, temp_dir, svn_dir):
|
||||
|
||||
logging.debug("upload addon to wescamp server = '%s' addon = '%s' "
|
||||
+ "temp_dir = '%s' svn_dir = '%s'",
|
||||
+ "temp_dir = '%s' svn_dir = '%s'",
|
||||
server, addon, temp_dir, svn_dir)
|
||||
|
||||
# Is the addon in the list with campaigns to be translated.
|
||||
@ -148,8 +148,8 @@ if __name__ == "__main__":
|
||||
# If the directory in svn doesn't exist we need to create and commit it.
|
||||
message = "wescamp.py automatic update"
|
||||
if(os.path.isdir(svn_dir + "/" + addon) == False):
|
||||
|
||||
logging.info("Creating directory in svn '%s'.",
|
||||
|
||||
logging.info("Creating directory in svn '%s'.",
|
||||
svn_dir + "/" + addon)
|
||||
|
||||
svn = libsvn.SVN(svn_dir)
|
||||
@ -167,7 +167,7 @@ if __name__ == "__main__":
|
||||
# Translation needs to be prevented from the campaign to overwrite
|
||||
# the ones in wescamp.
|
||||
# The other files are present in wescamp and shouldn't be deleted.
|
||||
if(svn.copy_to_svn(temp_dir, ["translations", "po", "campaign.def",
|
||||
if(svn.copy_to_svn(temp_dir, ["translations", "po", "campaign.def",
|
||||
"config.status", "Makefile"])):
|
||||
|
||||
svn.commit("wescamp_client: automatic update of addon '"
|
||||
@ -178,8 +178,8 @@ if __name__ == "__main__":
|
||||
addon)
|
||||
|
||||
"""Update the translations from wescamp to the server.
|
||||
|
||||
server The url of the addon server eg
|
||||
|
||||
server The url of the addon server eg
|
||||
add-ons.wesnoth.org:15005.
|
||||
addon The name of the addon.
|
||||
temp_dir The directory where the unpacked campaign can be stored.
|
||||
@ -196,10 +196,10 @@ if __name__ == "__main__":
|
||||
def download(server, addon, temp_dir, svn_dir, password, stamp = None):
|
||||
|
||||
logging.debug("download addon from wescamp server = '%s' addon = '%s' "
|
||||
+ "temp_dir = '%s' svn_dir = '%s' password is not shown",
|
||||
+ "temp_dir = '%s' svn_dir = '%s' password is not shown",
|
||||
server, addon, temp_dir, svn_dir)
|
||||
|
||||
# update the wescamp checkout for the translation,
|
||||
# update the wescamp checkout for the translation,
|
||||
svn = libsvn.SVN(wescamp + "/" + addon)
|
||||
|
||||
# The result of the update can be ignored, no changes when updating
|
||||
@ -207,7 +207,7 @@ if __name__ == "__main__":
|
||||
svn.update()
|
||||
|
||||
# test whether the svn has a translations dir, if not we can stop
|
||||
if(os.path.isdir(wescamp + "/"
|
||||
if(os.path.isdir(wescamp + "/"
|
||||
+ addon + "/" + addon + "/translations") == False):
|
||||
|
||||
logging.info("Wescamp has no translations directory so we can stop.")
|
||||
@ -232,12 +232,12 @@ if __name__ == "__main__":
|
||||
# send it unconditionally.
|
||||
wml = libwml.CampaignClient(server)
|
||||
if(stamp == None):
|
||||
wml.put_campaign("", addon, "", password, "", "", "",
|
||||
wml.put_campaign("", addon, "", password, "", "", "",
|
||||
temp_dir + "/" + addon + ".cfg", temp_dir + "/" + addon + "/")
|
||||
logging.info("New version of addon '%s' downloaded.", addon)
|
||||
else:
|
||||
if(stamp == get_timestamp(server, addon)):
|
||||
wml.put_campaign("", addon, "", password, "", "", "",
|
||||
wml.put_campaign("", addon, "", password, "", "", "",
|
||||
temp_dir + "/" + addon + ".cfg", temp_dir + "/" + addon + "/")
|
||||
logging.info("New version of addon '%s' downloaded.", addon)
|
||||
return True
|
||||
@ -251,7 +251,7 @@ if __name__ == "__main__":
|
||||
|
||||
svn = libsvn.SVN(wescamp)
|
||||
|
||||
svn.update(None, addon)
|
||||
svn.update(None, addon)
|
||||
|
||||
svn.remove(addon)
|
||||
|
||||
@ -259,27 +259,27 @@ if __name__ == "__main__":
|
||||
|
||||
optionparser = optparse.OptionParser("%prog [options]")
|
||||
|
||||
optionparser.add_option("-l", "--list", action = "store_true",
|
||||
optionparser.add_option("-l", "--list", action = "store_true",
|
||||
help = "List available addons. Usage [SERVER [PORT] [VERBOSE]")
|
||||
|
||||
optionparser.add_option("-L", "--list-translatable", action = "store_true",
|
||||
optionparser.add_option("-L", "--list-translatable", action = "store_true",
|
||||
help = "List addons available for translation. "
|
||||
+ "Usage [SERVER [PORT] [VERBOSE]")
|
||||
|
||||
optionparser.add_option("-u", "--upload",
|
||||
optionparser.add_option("-u", "--upload",
|
||||
help = "Upload a addon to wescamp. Usage: 'addon' WESCAMP-CHECKOUT "
|
||||
+ "[SERVER [PORT]] [TEMP-DIR] [VERBOSE]")
|
||||
|
||||
optionparser.add_option("-U", "--upload-all", action = "store_true",
|
||||
optionparser.add_option("-U", "--upload-all", action = "store_true",
|
||||
help = "Upload all addons to wescamp. Usage WESCAMP-CHECKOUT "
|
||||
+ " [SERVER [PORT]] [VERBOSE]")
|
||||
|
||||
optionparser.add_option("-d", "--download",
|
||||
optionparser.add_option("-d", "--download",
|
||||
help = "Download the translations from wescamp and upload to the addon "
|
||||
+ "server. Usage 'addon' WESCAMP-CHECKOUT PASSWORD [SERVER [PORT]] "
|
||||
+ "[TEMP-DIR] [VERBOSE]")
|
||||
|
||||
optionparser.add_option("-D", "--download-all", action = "store_true",
|
||||
optionparser.add_option("-D", "--download-all", action = "store_true",
|
||||
help = "Download all translations from wescamp and upload them to the "
|
||||
+ "addon server. Usage WESCAMP-CHECKOUT PASSWORD [SERVER [PORT]] "
|
||||
+ " [VERBOSE]")
|
||||
@ -288,32 +288,32 @@ if __name__ == "__main__":
|
||||
help = "Erase an addon from wescamp. Usage 'addon' WESCAMP-CHECKOUT "
|
||||
+ "[VERBOSE]")
|
||||
|
||||
optionparser.add_option("-s", "--server",
|
||||
optionparser.add_option("-s", "--server",
|
||||
help = "Server to connect to [localhost]")
|
||||
|
||||
optionparser.add_option("-p", "--port",
|
||||
help = "Port on the server to connect to ['']")
|
||||
optionparser.add_option("-p", "--port",
|
||||
help = "Port on the server to connect to ['']")
|
||||
|
||||
optionparser.add_option("-t", "--temp-dir", help = "Directory to store the "
|
||||
+ "tempory data, if omitted a tempdir is created and destroyed after "
|
||||
+ "usage, if specified the data is left in the tempdir. ['']")
|
||||
|
||||
optionparser.add_option("-w", "--wescamp-checkout",
|
||||
help = "The directory containing the wescamp checkout root. ['']")
|
||||
optionparser.add_option("-w", "--wescamp-checkout",
|
||||
help = "The directory containing the wescamp checkout root. ['']")
|
||||
|
||||
optionparser.add_option("-v", "--verbose", action = "store_true",
|
||||
optionparser.add_option("-v", "--verbose", action = "store_true",
|
||||
help = "Show more verbose output. [FALSE]")
|
||||
|
||||
optionparser.add_option("-P", "--password",
|
||||
optionparser.add_option("-P", "--password",
|
||||
help = "The master password for the addon server. ['']")
|
||||
|
||||
options, args = optionparser.parse_args()
|
||||
|
||||
if(options.verbose):
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='[%(levelname)s] %(message)s')
|
||||
else:
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
format='[%(levelname)s] %(message)s')
|
||||
|
||||
server = "localhost"
|
||||
@ -413,7 +413,7 @@ if __name__ == "__main__":
|
||||
except IOError, e:
|
||||
print "Unexpected error occured: " + str(e)
|
||||
error = True
|
||||
|
||||
|
||||
if(error):
|
||||
sys.exit(1)
|
||||
|
||||
@ -468,7 +468,7 @@ if __name__ == "__main__":
|
||||
|
||||
timestamp = 0
|
||||
while(True): # upload loop
|
||||
|
||||
|
||||
# get the upload timestamp of the addon
|
||||
timestamp = get_timestamp(server, k)
|
||||
|
||||
@ -481,7 +481,7 @@ if __name__ == "__main__":
|
||||
break
|
||||
else:
|
||||
logging.warning("Addon '%s' has been modified on "
|
||||
+ "the campaign server, force another"
|
||||
+ "the campaign server, force another"
|
||||
+ "wescamp sync", k)
|
||||
|
||||
# Create a new temp dir for every download.
|
||||
@ -502,7 +502,7 @@ if __name__ == "__main__":
|
||||
except IOError, e:
|
||||
print "Unexpected error occured: " + str(e)
|
||||
error = True
|
||||
|
||||
|
||||
if(error):
|
||||
sys.exit(1)
|
||||
|
||||
@ -527,5 +527,3 @@ if __name__ == "__main__":
|
||||
|
||||
else:
|
||||
optionparser.print_help()
|
||||
|
||||
|
||||
|
@ -179,7 +179,7 @@ class DataSub(Data):
|
||||
|
||||
def write_file(self, f, indent=0, textdomain=""):
|
||||
f.write(self.make_string( indent, textdomain))
|
||||
|
||||
|
||||
def make_string(self, indent = 0, textdomain = ""):
|
||||
"""Write the data object to the given file object."""
|
||||
ifdef = 0
|
||||
@ -496,7 +496,7 @@ class DataSub(Data):
|
||||
"""Gets all macros matching the name"""
|
||||
return [macro for macro in self.get_all(name)
|
||||
if isinstance(macro, DataMacro)]
|
||||
|
||||
|
||||
def get_all_macros(self):
|
||||
"""Gets all macros"""
|
||||
return [macro for macro in self.data
|
||||
|
@ -3,20 +3,20 @@ wmliterator.py -- Python routines for navigating a Battle For Wesnoth WML tree
|
||||
Author: Sapient (Patrick Parker), 2007
|
||||
|
||||
Purpose:
|
||||
The WmlIterator class can be used to analyze and search the structure of WML
|
||||
files non-invasively (i.e. preserving existing line structure), and its main
|
||||
The WmlIterator class can be used to analyze and search the structure of WML
|
||||
files non-invasively (i.e. preserving existing line structure), and its main
|
||||
use is to determine when a transformation of deprecated content needs to take
|
||||
place. (I wrote it was because wmllint was trying to do a lot of things with
|
||||
place. (I wrote it was because wmllint was trying to do a lot of things with
|
||||
regular expressions which really required a more algorithmic approach. Also,
|
||||
wmllint was often inconsistent with correct handling of comments and values
|
||||
wmllint was often inconsistent with correct handling of comments and values
|
||||
inside strings.)
|
||||
|
||||
|
||||
Limitations:
|
||||
The WmlIterator does not attempt to expand macros, only to recognize them as
|
||||
The WmlIterator does not attempt to expand macros, only to recognize them as
|
||||
another level of nesting. Also, the handling of multiple assignment syntax
|
||||
is somewhat limited (for similar reasons). Adding seamless support for these
|
||||
would be ideal, but it presents a design challenge since the iteration is
|
||||
supposed to be non-invasive. Thus, the current behavior is considered good
|
||||
is somewhat limited (for similar reasons). Adding seamless support for these
|
||||
would be ideal, but it presents a design challenge since the iteration is
|
||||
supposed to be non-invasive. Thus, the current behavior is considered good
|
||||
enough for now.
|
||||
"""
|
||||
|
||||
@ -208,7 +208,7 @@ Important Attributes:
|
||||
|
||||
def parseElements(self, text):
|
||||
"""Remove any closed scopes, return a list of element names
|
||||
and list of new unclosed scopes
|
||||
and list of new unclosed scopes
|
||||
Element Types:
|
||||
tags: one of "[tag_name]" or "[/tag_name]"
|
||||
[tag_name] - opens a scope
|
||||
@ -332,7 +332,7 @@ Important Attributes:
|
||||
self.span = 1
|
||||
self.element = ""
|
||||
return self
|
||||
|
||||
|
||||
def seek(self, lineno, clearEnd=True):
|
||||
"""Move the iterator to a specific line number"""
|
||||
if clearEnd:
|
||||
|
@ -75,7 +75,7 @@ class Parser:
|
||||
self.macro_callback = None
|
||||
self.macro_not_found_callback = None
|
||||
self.no_macros = False
|
||||
|
||||
|
||||
# If set to a function, the function is called with the current
|
||||
# textdomain and string as arguments for any translatable string, and
|
||||
# is expected to return a translation.
|
||||
@ -282,8 +282,8 @@ class Parser:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
||||
|
||||
|
||||
|
||||
quotation = line.find('"', line_start)
|
||||
while quotation >= 0:
|
||||
in_string = True
|
||||
@ -292,7 +292,7 @@ class Parser:
|
||||
line_start = string_end + 1
|
||||
in_string = False
|
||||
quotation = line.find('"', line_start)
|
||||
|
||||
|
||||
if not in_string:
|
||||
end = line.find(string, line_start)
|
||||
if end >= 0:
|
||||
@ -354,10 +354,10 @@ class Parser:
|
||||
|
||||
preserve = macro
|
||||
macro = macro[:-1] # Get rid of final }
|
||||
|
||||
|
||||
if self.macro_callback:
|
||||
if not self.macro_callback(macro): return None
|
||||
|
||||
|
||||
# If the macro starts with ~, assume a file in userdata.
|
||||
if macro[0] == "~":
|
||||
if self.user_dir:
|
||||
@ -470,7 +470,7 @@ class Parser:
|
||||
# Ignore () within strings
|
||||
if c == '"':
|
||||
in_string = not in_string
|
||||
|
||||
|
||||
if not in_string:
|
||||
if c == "(":
|
||||
balance += 1
|
||||
@ -504,7 +504,7 @@ class Parser:
|
||||
qe = rep.find('"', q + 1)
|
||||
rep = self.gettext(self.textdomain, rep[q + 1:qe])
|
||||
rep = '"' + rep + '"'
|
||||
if self.verbose:
|
||||
if self.verbose:
|
||||
#s = "Replacing {%s} with %s\n" % (macro.params[i], rep)
|
||||
##sys.stderr.write(s.encode("utf8"))
|
||||
pass
|
||||
@ -593,7 +593,7 @@ class Parser:
|
||||
variables += [variable]
|
||||
variable = ""
|
||||
else:
|
||||
variable += c
|
||||
variable += c
|
||||
else:
|
||||
if c == "<" and self.peek_next() == "<":
|
||||
self.read_next() #skip the rest of the opening
|
||||
@ -673,7 +673,7 @@ class Parser:
|
||||
if name: params += [name]
|
||||
if sep == "\n": break
|
||||
self.read_while(" ")
|
||||
|
||||
|
||||
text = self.read_lines_until("#enddef")
|
||||
if text == None:
|
||||
raise Error(self, "#define without #enddef")
|
||||
@ -746,7 +746,7 @@ class Parser:
|
||||
raise Error(self, "#else without #ifdef")
|
||||
|
||||
self.read_until("\n")
|
||||
|
||||
|
||||
# We seen an #else - that means we are at the end of a
|
||||
# conditional preprocessor block which has executed. So
|
||||
# we should now ignore everything up to the #endif.
|
||||
@ -921,7 +921,7 @@ if __name__ == "__main__":
|
||||
print "gettext: '%s' '%s'" % (domain, x)
|
||||
return x
|
||||
wmlparser.gettext = gt
|
||||
|
||||
|
||||
wmlparser.do_preprocessor_logic = True
|
||||
|
||||
if options.execute:
|
||||
@ -940,4 +940,3 @@ if __name__ == "__main__":
|
||||
xmlify(data, True)
|
||||
else:
|
||||
data.debug(show_contents = options.contents, use_color = options.color)
|
||||
|
||||
|
@ -428,7 +428,7 @@ class Parser:
|
||||
self.handle_command(rawline[compos + 1:-1])
|
||||
else:
|
||||
self.parse_line_without_commands(rawline)
|
||||
|
||||
|
||||
if self.keep_temp_dir is None and self.temp_dir:
|
||||
print("removing " + self.temp_dir)
|
||||
shutil.rmtree(self.temp_dir, ignore_errors = True)
|
||||
@ -713,4 +713,3 @@ code = <<
|
||||
print '</root>';
|
||||
else:
|
||||
print(p.root.debug())
|
||||
|
||||
|
@ -101,7 +101,7 @@ class Forest:
|
||||
if exclude:
|
||||
self.forest[i] = filter(lambda x: not re.search(exclude, x), self.forest[i])
|
||||
self.forest[i] = filter(lambda x: not x.endswith("-bak"), self.forest[i])
|
||||
# Compute cliques (will be used later for visibility checks)
|
||||
# Compute cliques (will be used later for visibility checks)
|
||||
self.clique = {}
|
||||
counter = 0
|
||||
for tree in self.forest:
|
||||
@ -318,7 +318,7 @@ class Reference:
|
||||
class CrossRef:
|
||||
macro_reference = re.compile(r"\{([A-Z_][A-Za-z0-9_:]*)(?!\.)\b")
|
||||
file_reference = re.compile(r"[A-Za-z0-9{}.][A-Za-z0-9_/+{}.@-]*\.(" + "|".join(resource_extensions) + ")(?=(~.*)?)")
|
||||
tag_parse = re.compile("\s*([a-z_]+)\s*=(.*)")
|
||||
tag_parse = re.compile("\s*([a-z_]+)\s*=(.*)")
|
||||
def mark_matching_resources(self, pattern, fn, n):
|
||||
"Mark all definitions matching a specified pattern with a reference."
|
||||
pattern = pattern.replace("+", r"\+")
|
||||
@ -518,7 +518,7 @@ class CrossRef:
|
||||
dfp = open(filename)
|
||||
for line in dfp:
|
||||
self.xref[line.strip()] = True
|
||||
dfp.close()
|
||||
dfp.close()
|
||||
# Next, decorate definitions with all references from the filelist.
|
||||
self.unresolved = []
|
||||
self.missing = []
|
||||
@ -800,7 +800,7 @@ class Translations:
|
||||
except TranslationError, e:
|
||||
sys.stderr.write(str(e))
|
||||
self.translations[t] = Translation(textdomain, "C", self.topdir)
|
||||
result = self.translations[t].get(key, default)
|
||||
result = self.translations[t].get(key, default)
|
||||
return result
|
||||
|
||||
## Namespace management
|
||||
|
@ -128,7 +128,7 @@ if __name__ == "__main__":
|
||||
|
||||
print "Unpacking %s..." % name
|
||||
cs.unpackdir(decoded, cdir, verbose = options.verbose)
|
||||
|
||||
|
||||
|
||||
info = os.path.join(dirname, "_info.cfg")
|
||||
try:
|
||||
@ -248,7 +248,7 @@ if __name__ == "__main__":
|
||||
if options.verbose:
|
||||
print "Not downloading", name, \
|
||||
"because it is already up-to-date."
|
||||
|
||||
|
||||
elif options.unpack:
|
||||
cs = CampaignClient(address)
|
||||
data = file(options.unpack).read()
|
||||
@ -321,7 +321,7 @@ if __name__ == "__main__":
|
||||
for field in ["title", "author", "passphrase", "description",
|
||||
"version", "icon", "type", "email", "translate"]:
|
||||
stuff[field] = pbl.get_text_val(field)
|
||||
|
||||
|
||||
mythread = cs.put_campaign_async(name, cfgfile, wmldir, ign, stuff)
|
||||
|
||||
pcounter = 0
|
||||
@ -362,7 +362,7 @@ if __name__ == "__main__":
|
||||
sys.stdout.write(" ? " + dirname + " - has no " +
|
||||
"version info on the server.\n")
|
||||
elif srev == lrev:
|
||||
sys.stdout.write(" " + dirname +
|
||||
sys.stdout.write(" " + dirname +
|
||||
" - is up to date.\n")
|
||||
elif sversion == lversion:
|
||||
sys.stdout.write(" # " + dirname + " - is version " +
|
||||
@ -378,7 +378,7 @@ if __name__ == "__main__":
|
||||
" is available.\n")
|
||||
if options.update: get(dirname, sversion, srev, cdir)
|
||||
else:
|
||||
sys.stdout.write(" ? " + dirname +
|
||||
sys.stdout.write(" ? " + dirname +
|
||||
" - is installed but has no " +
|
||||
"version info.\n")
|
||||
if options.update: get(dirname, sversion, srev, cdir)
|
||||
|
@ -163,7 +163,7 @@ def relevant_macros():
|
||||
"Compute indices of (X, Y) pairs in formals of all mainline macros."
|
||||
# Cross-reference all files.
|
||||
here = os.getcwd()
|
||||
pop_to_top("wmlflip")
|
||||
pop_to_top("wmlflip")
|
||||
cref = CrossRef(scopelist())
|
||||
os.chdir(here)
|
||||
|
||||
@ -180,7 +180,7 @@ def relevant_macros():
|
||||
if arg == "Y" or arg.endswith("_Y"):
|
||||
have_y = i
|
||||
if have_x is not None and have_y is not None:
|
||||
relevant[name] = (have_x, have_y)
|
||||
relevant[name] = (have_x, have_y)
|
||||
return relevant
|
||||
|
||||
def transformables(filename, relevant, verbose):
|
||||
@ -238,7 +238,7 @@ if __name__ == '__main__':
|
||||
mapfile = None
|
||||
translate = False
|
||||
(options, arguments) = getopt.getopt(sys.argv[1:], "m:txyv")
|
||||
|
||||
|
||||
for (switch, val) in options:
|
||||
if switch in ('-h', '--help'):
|
||||
sys.stderr.write(__doc__)
|
||||
@ -293,7 +293,7 @@ if __name__ == '__main__':
|
||||
# Compute the target coordinate pairs
|
||||
target = []
|
||||
for (x, y) in source:
|
||||
|
||||
|
||||
# Note: This is the *only* part of this code that is
|
||||
# specific to a particular transform. The rest of the
|
||||
# code doesn't care how the target pairs are derived
|
||||
|
@ -132,7 +132,7 @@ def reindent(name, infp, outfp):
|
||||
elif "wmlindent: closer" in line:
|
||||
tag = line.split('"')[1]
|
||||
if verbose and not quiet:
|
||||
print >>sys.stderr, "wmlindent: declaring outdent exception for %s" % tag
|
||||
print >>sys.stderr, "wmlindent: declaring outdent exception for %s" % tag
|
||||
closer_prefixes.append(tag)
|
||||
# Implement passthrough mode
|
||||
if "wmlindent: start ignoring" in line:
|
||||
@ -150,7 +150,7 @@ def reindent(name, infp, outfp):
|
||||
# Detect things we can't handle
|
||||
if multitag.search(line):
|
||||
raise bailout(name, countlines, "multiple tags on the line")
|
||||
# Strip each line, unless we're in something like a multiline string.
|
||||
# Strip each line, unless we're in something like a multiline string.
|
||||
if dostrip:
|
||||
transformed = line.strip() + "\n"
|
||||
else:
|
||||
|
@ -26,7 +26,7 @@
|
||||
# * unbalanced tags
|
||||
# * strings that need a translation mark and should not have them
|
||||
# * strings that have a translation mark and should not
|
||||
# * translatable strings containing macro references
|
||||
# * translatable strings containing macro references
|
||||
# * filter references by id= not matched by an actual unit
|
||||
# * abilities or traits without matching special notes, or vice-versa
|
||||
# * consistency between recruit= and recruitment_pattern= instances
|
||||
@ -117,7 +117,7 @@
|
||||
# A comment containing "no spellcheck" disables spellchecking on the
|
||||
# line where it occurs.
|
||||
#
|
||||
# A comment of the form
|
||||
# A comment of the form
|
||||
#
|
||||
# #wmllint: match {ABILITY_FOO} with {SPECIAL_NOTES_IOO}
|
||||
#
|
||||
@ -531,7 +531,7 @@ def validate_on_pop(tagstack, closer, filename, lineno):
|
||||
# Detect a malformation that will cause the game to barf while attempting
|
||||
# to deserialize an empty unit. The final "and attributes" ias a blatant
|
||||
# hack; some compaigns like to generate entire side declarations with
|
||||
# macros.
|
||||
# macros.
|
||||
if "scenario" in ancestors and closer == "side" and "type" not in attributes and ("no_leader" not in attributes or attributes["no_leader"] != "yes") and "multiplayer" not in ancestors and attributes:
|
||||
print '"%s", line %d: [side] without type attribute' % (filename, lineno)
|
||||
# This assumes that conversion will always happen in units/ files.
|
||||
@ -666,7 +666,7 @@ translatables = (\
|
||||
"source",
|
||||
"story",
|
||||
"summary",
|
||||
"text",
|
||||
"text",
|
||||
"title",
|
||||
"title2",
|
||||
"tooltip",
|
||||
@ -976,7 +976,7 @@ def global_sanity_check(filename, lines):
|
||||
# Check if it's a death event
|
||||
fields = parse_attribute(nav.text)
|
||||
if fields:
|
||||
(key, prefix, value, comment) = fields
|
||||
(key, prefix, value, comment) = fields
|
||||
if key == 'name' and value == 'die':
|
||||
die_event = True
|
||||
elif die_event and not filter_subject and parent == "[filter]":
|
||||
@ -991,7 +991,7 @@ def global_sanity_check(filename, lines):
|
||||
# Who is speaking?
|
||||
fields = parse_attribute(nav.text)
|
||||
if fields:
|
||||
(key, prefix, value, comment) = fields
|
||||
(key, prefix, value, comment) = fields
|
||||
if key in ("id", "speaker"):
|
||||
if deathcheck and (value == filter_subject) or (value == "unit"):
|
||||
print '"%s", line %d: %s speaks in his/her death event' % (filename, nav.lineno+1, value)
|
||||
@ -1092,7 +1092,7 @@ def global_sanity_check(filename, lines):
|
||||
# Interpret magic comments for setting the usage pattern of units.
|
||||
# This copes with some wacky UtBS units that are defined with
|
||||
# variant-spawning macros. The prototype comment looks like this:
|
||||
#wmllint: usage of "Desert Fighter" is fighter
|
||||
#wmllint: usage of "Desert Fighter" is fighter
|
||||
m = re.match('# *wmllint: usage of "([^"]*)" is +(.*)', lines[i])
|
||||
if m:
|
||||
usage[m.group(1)] = m.group(2).strip()
|
||||
@ -1240,7 +1240,7 @@ def global_sanity_check(filename, lines):
|
||||
# FIXME: This test is rather bogus as is.
|
||||
# Doing a better job would require tokenizing to pick up the
|
||||
# string boundaries. I'd do it, but AI0867 is already working
|
||||
# on a parser-based wmllint.
|
||||
# on a parser-based wmllint.
|
||||
if '{' in value and "+" not in value and value.find('{') > value.find("_"):
|
||||
print '"%s", line %d: macro reference in translatable string'\
|
||||
% (filename, i+1)
|
||||
@ -1252,7 +1252,7 @@ def global_sanity_check(filename, lines):
|
||||
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'): # FIXME: check this someday
|
||||
pass
|
||||
@ -1287,7 +1287,7 @@ def global_sanity_check(filename, lines):
|
||||
% (filename, i+1, value)
|
||||
if markcheck and has_tr_mark and not ("wmllint: ignore" in comment or "wmllint: noconvert" in comment):
|
||||
print '"%s", line %d: %s should not have a translation mark' \
|
||||
% (filename, i+1, key)
|
||||
% (filename, i+1, key)
|
||||
lines[i] = lines[i].replace("_", "", 1)
|
||||
# Now that we know who's present, register all these names as spellings
|
||||
declared_spellings[filename] = map(lambda x: x.lower(), present)
|
||||
@ -1316,7 +1316,7 @@ def global_sanity_check(filename, lines):
|
||||
|
||||
def condition_match(p, q):
|
||||
"Do two condition-states match?"
|
||||
# The empty condition state is represented by None
|
||||
# The empty condition state is represented by None
|
||||
if p is None or q is None or (p == q):
|
||||
return True
|
||||
# Past this point it's all about handling cases with negation
|
||||
@ -1481,15 +1481,15 @@ def hack_syntax(filename, lines):
|
||||
if lines[i].startswith("#"):
|
||||
pass
|
||||
elif "{DOT_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("DOT_CENTERED", "NEW_JOURNEY")
|
||||
lines[i] = lines[i].replace("DOT_CENTERED", "NEW_JOURNEY")
|
||||
elif "{DOT_WHITE_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("DOT_WHITE_CENTERED", "OLD_JOURNEY")
|
||||
elif "{CROSS_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("CROSS_CENTERED", "NEW_BATTLE")
|
||||
lines[i] = lines[i].replace("CROSS_CENTERED", "NEW_BATTLE")
|
||||
elif "{CROSS_WHITE_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("CROSS_WHITE_CENTERED", "OLD_BATTLE")
|
||||
elif "{FLAG_RED_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("FLAG_RED_CENTERED", "NEW_REST")
|
||||
lines[i] = lines[i].replace("FLAG_RED_CENTERED", "NEW_REST")
|
||||
elif "{FLAG_WHITE_CENTERED" in lines[i]:
|
||||
lines[i] = lines[i].replace("FLAG_WHITE_CENTERED", "OLD_REST")
|
||||
elif "{DOT " in lines[i] or "CROSS" in lines[i]:
|
||||
@ -1668,7 +1668,7 @@ def translator(filename, mapxforms, textxform):
|
||||
lineno += 1
|
||||
# Check for one certain error condition
|
||||
if line.count("{") and line.count("}"):
|
||||
refname = line[line.find("{"):line.rfind("}")]
|
||||
refname = line[line.find("{"):line.rfind("}")]
|
||||
# Ignore all-caps macro arguments.
|
||||
if refname == refname.upper():
|
||||
pass
|
||||
@ -1784,7 +1784,7 @@ def translator(filename, mapxforms, textxform):
|
||||
for i in range(len(outmap)):
|
||||
outmap[i] = [outmap[i][0]] + outmap[i] + [outmap[i][-1]]
|
||||
# Strip villages out of the edges
|
||||
outermap(lambda n: re.sub(r"\^V[a-z]+", "", n), outmap)
|
||||
outermap(lambda n: re.sub(r"\^V[a-z]+", "", n), outmap)
|
||||
# Strip keeps out of the edges
|
||||
outermap(lambda n: re.sub(r"K([a-z]+)", r"C\1", n), outmap)
|
||||
# Strip the starting positions out of the edges
|
||||
@ -1810,7 +1810,7 @@ def translator(filename, mapxforms, textxform):
|
||||
if refre:
|
||||
mapfile = refre.group(1)
|
||||
if not mapfile.endswith(".map") and is_map(mapfile):
|
||||
newline = newline.replace(mapfile, mapfile + ".map")
|
||||
newline = newline.replace(mapfile, mapfile + ".map")
|
||||
newdata.append(newline + terminator)
|
||||
if newline != line:
|
||||
if verbose > 0:
|
||||
@ -1838,7 +1838,7 @@ def translator(filename, mapxforms, textxform):
|
||||
tagstack.append((tag, {}))
|
||||
else:
|
||||
if len(tagstack) == 0:
|
||||
print '"%s", line %d: closer [/%s] with tag stack empty.' % (filename, lineno+1, tag)
|
||||
print '"%s", line %d: closer [/%s] with tag stack empty.' % (filename, lineno+1, tag)
|
||||
elif tagstack[-1][0] != tag:
|
||||
print '"%s", line %d: unbalanced [%s] closed with [/%s].' % (filename, lineno+1, tagstack[-1][0], tag)
|
||||
else:
|
||||
@ -2026,7 +2026,7 @@ def inner_spellcheck(nav, value, spelldict):
|
||||
if re.match("s+h+", lowered):
|
||||
continue
|
||||
nav.printError('possible misspelling "%s"' % token)
|
||||
|
||||
|
||||
|
||||
def spellcheck(fn, d):
|
||||
"Spell-check a file using an Enchant dictionary object."
|
||||
@ -2111,7 +2111,7 @@ def allcfgfiles(dir):
|
||||
datafiles.append(dir)
|
||||
else:
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for vcsubdir in vctypes:
|
||||
for vcsubdir in vctypes:
|
||||
if vcsubdir in dirs:
|
||||
dirs.remove(vcsubdir)
|
||||
for name in files:
|
||||
@ -2167,7 +2167,7 @@ if __name__ == '__main__':
|
||||
stripcr = False
|
||||
verbose = 0
|
||||
dospellcheck = True
|
||||
progress = False
|
||||
progress = False
|
||||
for (switch, val) in options:
|
||||
if switch in ('-h', '--help'):
|
||||
help()
|
||||
@ -2244,10 +2244,10 @@ if __name__ == '__main__':
|
||||
line = re.sub(r"user_description\s*=", "description=", line)
|
||||
# Alas, WML variable references cannot be converted so
|
||||
# automatically.
|
||||
if ".description" in line:
|
||||
if ".description" in line:
|
||||
print '"%s", line %d: .description may need hand fixup' % \
|
||||
(filename, lineno)
|
||||
if ".user_description" in line:
|
||||
if ".user_description" in line:
|
||||
print '"%s", line %d: .user_description may need hand fixup' % \
|
||||
(filename, lineno)
|
||||
# In unit type definitions
|
||||
|
@ -18,15 +18,15 @@ class TextOutput(file):
|
||||
def write(self, text):
|
||||
self.text_ctrl.AppendText(text+"\n")
|
||||
self.text_ctrl.Refresh()
|
||||
|
||||
|
||||
def writelines(self, list):
|
||||
for text in list:
|
||||
self.text_ctrl.AppendText(text+"\n")
|
||||
self.text_ctrl.Refresh()
|
||||
|
||||
|
||||
def fileno(self):
|
||||
return 1
|
||||
|
||||
|
||||
def clear(self):
|
||||
self.text_ctrl.Clear()
|
||||
|
||||
@ -51,9 +51,9 @@ class MainFrame(wx.Frame):
|
||||
self.Bind(wx.EVT_BUTTON, self.button_browse, self.choose_file)
|
||||
self.Bind(wx.EVT_BUTTON, self.button_convert, self.Convert)
|
||||
# end wxGlade
|
||||
|
||||
|
||||
self.text_output = TextOutput(self.Output)
|
||||
|
||||
|
||||
self.process = None
|
||||
self.Bind(wx.EVT_IDLE, self.on_idle)
|
||||
self.Bind(wx.EVT_END_PROCESS, self.subprocess_finished)
|
||||
@ -97,7 +97,7 @@ class MainFrame(wx.Frame):
|
||||
sizer_3.SetSizeHints(self)
|
||||
self.Layout()
|
||||
# end wxGlade
|
||||
|
||||
|
||||
def start_wmllint(self,output,\
|
||||
arguments,\
|
||||
clean = False,\
|
||||
@ -109,7 +109,7 @@ class MainFrame(wx.Frame):
|
||||
stripcr = False,\
|
||||
spell_check = False,\
|
||||
verbose = 0):
|
||||
|
||||
|
||||
cmd = "python -u wmllint"
|
||||
if clean:
|
||||
cmd+=" -c"
|
||||
@ -127,7 +127,7 @@ class MainFrame(wx.Frame):
|
||||
cmd+=" -v"
|
||||
for path in arguments:
|
||||
cmd+=" "+path
|
||||
|
||||
|
||||
self.text_output.write("Executing \""+cmd+"\".")
|
||||
|
||||
self.process = wx.Process(self)
|
||||
@ -139,9 +139,9 @@ class MainFrame(wx.Frame):
|
||||
self.process.Kill(self.wmllint_pid)
|
||||
else:
|
||||
self.text_output.clear()
|
||||
|
||||
|
||||
path = self.path_ctrl.GetValue()
|
||||
|
||||
|
||||
clean = False
|
||||
diffs = False
|
||||
dryrun = False
|
||||
@ -151,7 +151,7 @@ class MainFrame(wx.Frame):
|
||||
stripcr = False
|
||||
spell_check = False
|
||||
verbose = 0
|
||||
|
||||
|
||||
mode = self.action_choice.GetStringSelection()
|
||||
if(mode == "Clean"):
|
||||
clean = True
|
||||
@ -161,21 +161,21 @@ class MainFrame(wx.Frame):
|
||||
dryrun = True
|
||||
if(mode == "Revert"):
|
||||
revert = True
|
||||
|
||||
|
||||
spell_check = self.spell_check.GetValue()
|
||||
stripcr = self.unix_endings.GetValue()
|
||||
|
||||
|
||||
verbose = self.verbosity.GetSelection()
|
||||
|
||||
|
||||
if not os.path.exists(path):
|
||||
self.text_output.write("Path could not be found.")
|
||||
return
|
||||
|
||||
|
||||
self.start_wmllint(self.text_output, [path], clean, diffs, dryrun, future, revert,\
|
||||
stringfreeze, stripcr, spell_check, verbose)
|
||||
|
||||
|
||||
self.set_running(True)
|
||||
|
||||
|
||||
def set_running(self, val):
|
||||
if val == True:
|
||||
self.Convert.SetLabel("Stop")
|
||||
@ -193,11 +193,11 @@ class MainFrame(wx.Frame):
|
||||
self.verbosity.Enable(True)
|
||||
self.path_ctrl.Enable(True)
|
||||
self.choose_file.Enable(True)
|
||||
|
||||
|
||||
def subprocess_finished(self, event):
|
||||
self.set_running(False)
|
||||
self.process = None
|
||||
|
||||
|
||||
|
||||
def button_browse(self, event): # wxGlade: MainFrame.<event_handler>
|
||||
dir_dialog = wx.DirDialog(self)
|
||||
@ -206,7 +206,7 @@ class MainFrame(wx.Frame):
|
||||
self.path_ctrl.SetValue(path)
|
||||
dir_dialog.Show(False)
|
||||
del dir_dialog
|
||||
|
||||
|
||||
def on_idle(self, evt):
|
||||
if self.process is not None:
|
||||
stream = self.process.GetInputStream()
|
||||
|
@ -32,7 +32,7 @@ but not in a campaign directory. "Near" for a unit under a
|
||||
data/campaign directory means anywhere in that same campaign
|
||||
directory, but not in core data or any other campaign directory.
|
||||
|
||||
The --revert option generates commands used to revert the result of a
|
||||
The --revert option generates commands used to revert the result of a
|
||||
specified move, undoing version-control operations as needed.
|
||||
|
||||
The --delete option removes a unit and its associated resources.
|
||||
@ -55,7 +55,7 @@ Here is an example:
|
||||
|
||||
wmlmove Heir_To_The_Throne::Elvish_Lord Heir_To_The_Throne::Elvish_High_Lord Heir_To_The_Throne::Elvish_Lady core::elves
|
||||
|
||||
'''
|
||||
'''
|
||||
|
||||
import sys, os, time, re, getopt, sre_constants
|
||||
from wesnoth.wmltools import *
|
||||
@ -119,7 +119,7 @@ if __name__ == "__main__":
|
||||
sys.stderr.write("wmlmove: can't find %s to move it.\n" % src)
|
||||
sys.exit(1)
|
||||
srclist.append(src)
|
||||
|
||||
|
||||
# Validate the destination.
|
||||
if not delete:
|
||||
uclass = None
|
||||
@ -132,7 +132,7 @@ if __name__ == "__main__":
|
||||
if dstdir == None:
|
||||
sys.stderr.write("wmlmove: invalid namespace %s\n" % dstdir)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# Cross-reference all files.
|
||||
cref = CrossRef(scopelist())
|
||||
|
||||
|
@ -125,7 +125,7 @@ class HTMLOutput:
|
||||
self.translation = Translation(options.transdir, isocode)
|
||||
self.isocode = isocode
|
||||
global_htmlout = self
|
||||
|
||||
|
||||
def translate(self, string, domain):
|
||||
return self.translation.translate(string, domain)
|
||||
|
||||
@ -380,9 +380,9 @@ class HTMLOutput:
|
||||
if not name: name = ability.name
|
||||
anames.append(name)
|
||||
return anames
|
||||
|
||||
|
||||
def get_recursive_attacks(self, this_unit):
|
||||
|
||||
|
||||
def copy_attributes(copy_from, copy_to):
|
||||
for c in copy_from.data:
|
||||
if isinstance(c, wmlparser2.AttributeNode):
|
||||
@ -401,7 +401,7 @@ class HTMLOutput:
|
||||
copy_attributes(attack, attacks[i])
|
||||
else:
|
||||
attacks.append(attack)
|
||||
|
||||
|
||||
return attacks
|
||||
|
||||
def write_units(self):
|
||||
@ -413,7 +413,7 @@ class HTMLOutput:
|
||||
for i in range(6):
|
||||
write("<col class=\"col%d\" />" % i)
|
||||
write("</colgroup>")
|
||||
|
||||
|
||||
pic = image_collector.add_image("mainline",
|
||||
"../../../images/misc/leader-crown.png")
|
||||
crownimage = os.path.join("../pics", pic)
|
||||
@ -478,7 +478,7 @@ class HTMLOutput:
|
||||
|
||||
write('<div class="pic">')
|
||||
image = self.pic(u, u)
|
||||
|
||||
|
||||
write('<a href=\"%s\">' % link)
|
||||
|
||||
if crown == u" ♚":
|
||||
@ -487,21 +487,21 @@ class HTMLOutput:
|
||||
write("</div>")
|
||||
else:
|
||||
write('<img src="%s" alt="(image)" />' % image)
|
||||
|
||||
|
||||
write('</a>\n</div>\n')
|
||||
write("<div class=\"attributes\">")
|
||||
write("%s%s<br />" % (_("Cost: "), cost))
|
||||
write("%s%s<br />" % (_("HP: "), hp))
|
||||
write("%s%s<br />" % (_("MP: "), mp))
|
||||
write("%s%s<br />" % (_("XP: "), xp))
|
||||
|
||||
|
||||
# Write info about abilities.
|
||||
anames = self.get_abilities(u)
|
||||
if anames:
|
||||
write("\n<div style=\"clear:both\">")
|
||||
write(", ".join(anames))
|
||||
write("</div>")
|
||||
|
||||
|
||||
# Write info about attacks.
|
||||
write("\n<div style=\"clear:both\">")
|
||||
attacks = self.get_recursive_attacks(u)
|
||||
@ -661,7 +661,7 @@ class HTMLOutput:
|
||||
if val == "alignment": x = _(x)
|
||||
write("<td>%s</td>" % x)
|
||||
write("</tr>\n")
|
||||
|
||||
|
||||
# Write info about abilities.
|
||||
anames = self.get_abilities(unit)
|
||||
|
||||
@ -681,7 +681,7 @@ class HTMLOutput:
|
||||
|
||||
aid = attack.get_text_val("name")
|
||||
aname = T(attack, "description")
|
||||
|
||||
|
||||
icon = attack.get_text_val("icon")
|
||||
if not icon:
|
||||
icon = "attacks/%s.png" % aid
|
||||
@ -841,7 +841,7 @@ def generate_campaign_report(out_path, isocode, campaign, wesnoth):
|
||||
def generate_era_report(out_path, isocode, eid, wesnoth):
|
||||
path = os.path.join(out_path, isocode)
|
||||
if not os.path.isdir(path): os.mkdir(path)
|
||||
|
||||
|
||||
output = MyFile(os.path.join(path, "%s.html" % eid), "w")
|
||||
html = HTMLOutput(isocode, output, eid, wesnoth)
|
||||
html.target = "%s.html" % eid
|
||||
@ -900,7 +900,7 @@ def parse_game():
|
||||
options.config_dir,
|
||||
options.data_dir,
|
||||
options.transdir)
|
||||
|
||||
|
||||
def p(x): sys.stdout.write(x); sys.stdout.flush()
|
||||
def pn(x): print(x)
|
||||
|
||||
@ -936,9 +936,9 @@ def parse_game():
|
||||
p(" Parsing %s units ... " % cname)
|
||||
n = stuff.add_campaign_units(cname, image_collector)
|
||||
pn("%d units found." % n)
|
||||
|
||||
|
||||
mainline_campaigns = set(stuff.campaign_lookup.keys())
|
||||
|
||||
|
||||
stuff.is_mainline_unit = {}
|
||||
for uid in stuff.unit_lookup.keys():
|
||||
stuff.is_mainline_unit[uid] = True
|
||||
@ -958,7 +958,7 @@ def parse_game():
|
||||
pn("%d units found." % n)
|
||||
|
||||
stuff.find_unit_factions()
|
||||
|
||||
|
||||
return stuff
|
||||
|
||||
def generate_report(stuff, isocode):
|
||||
@ -970,7 +970,7 @@ def generate_report(stuff, isocode):
|
||||
* Each addon era's units sorted by faction
|
||||
* Each addon campaign's units sorted by race
|
||||
"""
|
||||
|
||||
|
||||
print "Generating report for %s." % (isocode)
|
||||
reset_errors()
|
||||
|
||||
@ -993,7 +993,7 @@ def generate_report(stuff, isocode):
|
||||
generate_single_unit_reports(options.output, isocode, stuff)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
# We change the process name to "wmlunits"
|
||||
try:
|
||||
import ctypes
|
||||
@ -1004,7 +1004,7 @@ if __name__ == '__main__':
|
||||
|
||||
global options
|
||||
global image_collector
|
||||
|
||||
|
||||
gc.disable()
|
||||
|
||||
op = optparse.OptionParser()
|
||||
@ -1067,7 +1067,7 @@ if __name__ == '__main__':
|
||||
else: r = "none"
|
||||
u.rid = r
|
||||
u.id = u.get_text_val("id")
|
||||
|
||||
|
||||
# Write a list with all unit ids, just for fun.
|
||||
uids = wesnoth.unit_lookup.keys()
|
||||
def by_race(u1, u2):
|
||||
@ -1090,7 +1090,7 @@ if __name__ == '__main__':
|
||||
f.write("</ul>")
|
||||
f.write("</body></html>")
|
||||
f.close()
|
||||
|
||||
|
||||
# Write animation statistics
|
||||
f = MyFile(os.path.join(options.output, "animations.html"), "w")
|
||||
animations.write_table(f, wesnoth)
|
||||
|
@ -25,7 +25,7 @@ def allcfgfiles(dir):
|
||||
datafiles.append(dir)
|
||||
else:
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for vcsubdir in vctypes:
|
||||
for vcsubdir in vctypes:
|
||||
if vcsubdir in dirs:
|
||||
dirs.remove(vcsubdir)
|
||||
for name in files:
|
||||
@ -181,7 +181,7 @@ msgstr ""
|
||||
print "Passthrough for", nav
|
||||
opener_stack.append((nav.element, fn, nav.lineno))
|
||||
translatables.append((nav.text.lstrip(), opener_stack[:]))
|
||||
opener_stack.pop()
|
||||
opener_stack.pop()
|
||||
elif verbose > 1:
|
||||
print "Unhandled", nav
|
||||
# Gather a list describing the context of every
|
||||
@ -204,7 +204,7 @@ msgstr ""
|
||||
for nav in WmllintIterator(lines, fn):
|
||||
handle_element(nav, fn)
|
||||
opener_stack.pop()
|
||||
|
||||
|
||||
# Debugging output
|
||||
if verbose:
|
||||
print "Translatables:"
|
||||
@ -237,4 +237,3 @@ msgstr ""
|
||||
print ""
|
||||
except KeyboardInterrupt:
|
||||
print >>sys.stderr, "wmlxgettext: aborted."
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user