Automatically generate .lst file replacements
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2867 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+19
-12
@@ -33,20 +33,27 @@ def get_resources(d):
|
|||||||
result.append(line[1])
|
result.append(line[1])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def create_map(d):
|
||||||
|
resources = get_resources(d)
|
||||||
|
resmap = process(resources)
|
||||||
|
keys = []
|
||||||
|
result = []
|
||||||
|
for r in resmap:
|
||||||
|
key = r.split(':')[0]
|
||||||
|
if key in keys:
|
||||||
|
result.append("# ERROR: DUPLICATE KEY %s" % key)
|
||||||
|
else:
|
||||||
|
keys.append(key)
|
||||||
|
result.append(r)
|
||||||
|
return result
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
d = os.path.join(os.path.pardir, os.path.pardir, "sc2", "content")
|
d = os.path.join(os.path.pardir, os.path.pardir, "sc2", "content")
|
||||||
else:
|
else:
|
||||||
d = sys.argv[1]
|
d = sys.argv[1]
|
||||||
resources = get_resources(d)
|
target = os.path.join(d, "uqm.rmp")
|
||||||
resmap = process(resources)
|
print target
|
||||||
keys = []
|
print "-"*len(target)
|
||||||
for r in resmap:
|
for l in create_map(d):
|
||||||
key = r.split(':')[0]
|
print l
|
||||||
if key in keys:
|
|
||||||
print "# ERROR: DUPLICATE KEY %s" % key
|
|
||||||
else:
|
|
||||||
keys.append(key)
|
|
||||||
print r
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import explorer
|
||||||
|
import stridgen
|
||||||
|
|
||||||
|
def process (res):
|
||||||
|
result = []
|
||||||
|
for ((a, b, c), d) in res:
|
||||||
|
mapline = stridgen.makeid(d)
|
||||||
|
if mapline is None:
|
||||||
|
mapline = "ERROR"
|
||||||
|
result.append("%3d %3d %3d %s" % (a, b, c, mapline))
|
||||||
|
return result
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
d = os.path.join(os.path.pardir, os.path.pardir, "sc2", "content")
|
||||||
|
else:
|
||||||
|
d = sys.argv[1]
|
||||||
|
pkgnames = explorer.get_lists(d)
|
||||||
|
packages = [explorer.read_list(x) for x in pkgnames]
|
||||||
|
for (name, pkg) in zip(pkgnames, packages):
|
||||||
|
newpkg = os.path.splitext(name)[0]+'.ls2'
|
||||||
|
print newpkg
|
||||||
|
print '-'*len(newpkg)
|
||||||
|
newvals = process(pkg)
|
||||||
|
for l in newvals:
|
||||||
|
print l
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user