Explorar o código

[changed] added qsrc extension.

3xpurt %!s(int64=6) %!d(string=hai) anos
pai
achega
cd51022e71

+ 0 - 0
locations/basement → locations/basement.qsrc


+ 0 - 0
locations/fist → locations/fist.qsrc


+ 0 - 0
locations/fisting → locations/fisting.qsrc


+ 0 - 0
locations/fisting1 → locations/fisting1.qsrc


+ 0 - 0
locations/fisting2 → locations/fisting2.qsrc


+ 0 - 0
locations/mod_basement → locations/mod_basement.qsrc


+ 0 - 0
locations/mod_basement_readme → locations/mod_basement_readme.qsrc


+ 0 - 0
locations/mod_basement_setup → locations/mod_basement_setup.qsrc


+ 1 - 1
txtmerge.py

@@ -25,7 +25,7 @@ for location in root.iter('Location'):
     iname = iname.replace("$","_")
 
     try:
-        ifile = io.open(os.path.join(idir,iname), 'rt', encoding='utf-8')
+        ifile = io.open(os.path.join(idir,iname + '.qsrc'), 'rt', encoding='utf-8')
         text = ifile.read()
 
         # make sure there's a line at the end of file

+ 46 - 0
txtsplit.py

@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# usage: txtsplit.py <input_file_name> <output_dir>
+# splits a txt2gam file into individual location files
+# encoded in utf-8, for git to better handle
+
+import os
+import sys
+import re
+import io
+import xml.etree.ElementTree as ET
+
+assert len(sys.argv) == 3, "usage:\ntxtsplit.py <input_file_name> <output_dir>"
+iname = str(sys.argv[1])
+odir = str(sys.argv[2])
+
+# read the project xml file first
+# let's do this later in order to implement directory structure
+"""
+tree = ET.parse('basement.qproj')
+root = tree.getroot()
+"""
+
+ifile = io.open(iname, 'rt', encoding='utf-16')
+
+counter = 1
+
+oname = None
+firstline = ifile.readline().replace(u'\ufeff','')
+match = re.search(ur'^#\s(\$?[_.\w]+)$', firstline)
+if match:
+    oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+    counter += 1
+assert oname, "file is in the wrong format, must start with a location name"
+
+ofile = io.open(oname, 'w', encoding='utf-8')
+ofile.write(firstline)
+
+for line in ifile:
+    match = re.search(ur'^#\s(\$?[_.\w]+)$', line)
+    if match:
+        ofile.close()
+        oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+        counter += 1
+        ofile = io.open(oname, 'w', encoding='utf-8')
+    ofile.write(line)
+        

+ 3 - 3
txtsplit3.py

@@ -16,7 +16,7 @@ odir = str(sys.argv[2])
 # read the project xml file first
 # let's do this later in order to implement directory structure
 """
-tree = ET.parse('GirlLife.qproj')
+tree = ET.parse('basement.qproj')
 root = tree.getroot()
 """
 
@@ -28,7 +28,7 @@ oname = None
 firstline = ifile.readline().replace(u'\ufeff','')
 match = re.search('^#\s(\$?[_.\w]+)$', firstline)
 if match:
-    oname = os.path.join(odir, match.group(1).replace("$","_") )
+    oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
     counter += 1
 assert oname, "file is in the wrong format, must start with a location name"
 
@@ -39,7 +39,7 @@ for line in ifile:
     match = re.search('^#\s(\$?[_.\w]+)$', line)
     if match:
         ofile.close()
-        oname = os.path.join(odir, match.group(1).replace("$","_") )
+        oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
         counter += 1
         ofile = io.open(oname, 'w', encoding='utf-8')
     ofile.write(line)