Author: esr
Date: Sun Mar  9 00:11:45 2008
New Revision: 24432

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24432&view=rev
Log:
Small refactoring step.

Modified:
    trunk/data/tools/wesnoth/wmltools.py
    trunk/data/tools/wmllint

Modified: trunk/data/tools/wesnoth/wmltools.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmltools.py?rev=24432&r1=24431&r2=24432&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmltools.py (original)
+++ trunk/data/tools/wesnoth/wmltools.py Sun Mar  9 00:11:45 2008
@@ -7,6 +7,39 @@
 
 resource_extensions = ("png", "jpg", "ogg", "wav", "map", "mask")
 image_reference = r"[A-Za-z0-9{}.][A-Za-z0-9_/+{}.-]*\.(png|jpg)(?=(~.*)?)"
+
+def string_strip(value):
+    "String-strip the value"
+    if value.startswith('"'):
+        value = value[1:]
+        if value.endswith('"'):
+            value = value[:-1]
+    if value.startswith("'"):
+        value = value[1:]
+        if value.endswith("'"):
+            value = value[:-1]
+    return value
+
+def parse_attribute(str):
+    "Parse a WML key-value pair from a line."
+    if '=' not in str:
+        return None
+    where = str.find("=")
+    leader = str[:where]
+    after = str[where+1:]
+    after = after.lstrip()
+    if "#" in after:
+        where = after.find("#")
+        while after[where-1] in (" ", "\t"):
+            where -= 1
+        value = after[:where+1]
+        comment = after[where:]
+    else:
+        value = after.rstrip()
+        comment = ""
+    # Return four fields: stripped key, part of line before value,
+    # value, trailing whitespace and comment.
+    return (leader.strip(), leader+"=", string_strip(value), comment)
 
 class Forest:
     "Return an iterable directory forest object."

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=24432&r1=24431&r2=24432&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Sun Mar  9 00:11:45 2008
@@ -568,40 +568,7 @@
 trait_note = dict(notepairs)
 note_trait = dict(map(lambda p: (p[1], p[0]), notepairs))
 
-def string_strip(value):
-    "String-strip the value"
-    if value.startswith('"'):
-        value = value[1:]
-        if value.endswith('"'):
-            value = value[:-1]
-    if value.startswith("'"):
-        value = value[1:]
-        if value.endswith("'"):
-            value = value[:-1]
-    return value
-
-def parse_attribute(str):
-    "Parse a WML key-value pair from a line."
-    if '=' not in str:
-        return None
-    where = str.find("=")
-    leader = str[:where]
-    after = str[where+1:]
-    after = after.lstrip()
-    if "#" in after:
-        where = after.find("#")
-        while after[where-1] in (" ", "\t"):
-            where -= 1
-        value = after[:where+1]
-        comment = after[where:]
-    else:
-        value = after.rstrip()
-        comment = ""
-    # Return four fields: stripped key, part of line before value,
-    # value, trailing whitespace and comment.
-    return (leader.strip(), leader+"=", string_strip(value), comment)
-
-# This needs to match the list of usagge types in ai_python.cpp
+# This needs to match the list of usage types in ai_python.cpp
 usage_types = ("scout", "fighter", "mixed fighter", "archer", "healer")
 
 # These are accumulated by sanity_check() and examined by sanity_postcheck() 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to