aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-18 04:37:08 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-18 04:37:08 +0000
commit6616879d158b4347a6b951421701d8a042ed089a (patch)
tree5c5039ce851a60511c551716041ffd6c30506fa0
parenta0a986ef75556aee3ca4e932b80496d33b032945 (diff)
downloadusdx-6616879d158b4347a6b951421701d8a042ed089a.tar.gz
usdx-6616879d158b4347a6b951421701d8a042ed089a.tar.xz
usdx-6616879d158b4347a6b951421701d8a042ed089a.zip
- backup file extension changed from .old to .bak
- backup files are only created for files that changed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2546 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rwxr-xr-xgame/languages/update.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/game/languages/update.py b/game/languages/update.py
index 74b4b774..7447b19e 100755
--- a/game/languages/update.py
+++ b/game/languages/update.py
@@ -111,17 +111,31 @@ def update(lang):
print (" -" + m.group(1))
outList.append(";UNUSED: " + m.group(1) + "=" + m.group(2))
- oldLang = lang + ".old"
- if (os.path.exists(oldLang)):
- os.remove(oldLang)
- os.rename(lang, oldLang)
+ # check if file changed
+ changed = False
+ if (len(outList) != len(translation)):
+ changed = True
+ else:
+ # search for a changed line
+ for i in range(len(outList)):
+ if (outList[i] != translation[i]):
+ changed = True
+ break
+
+ # write changes
+ if changed:
+ # create a backup first
+ oldLang = lang + ".bak"
+ if (os.path.exists(oldLang)):
+ os.remove(oldLang)
+ os.rename(lang, oldLang)
- f = open(lang, 'wb')
- for line in outList:
- # binary mode does not convert "\n" to the os specific line-ending.
- # Use os.linesep instead.
- f.write(line + os.linesep)
- f.close()
+ f = open(lang, 'wb')
+ for line in outList:
+ # binary mode does not convert "\n" to the os specific line-ending.
+ # Use os.linesep instead.
+ f.write(line + os.linesep)
+ f.close()
if len(sys.argv) >= 2:
# update specific language file passed as command-line argument