[Pkg-mozext-commits] [adblock-plus] 177/464: Added localeTools methods required to rewrite locales
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit eb0ffbe59ffc3df102dddb8abd60040a628d03d3
Author: Wladimir Palant <trev at adblockplus.org>
Date: Wed Dec 7 20:29:53 2011 +0100
Added localeTools methods required to rewrite locales
---
localeTools.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/localeTools.py b/localeTools.py
index 36fce9b..46ad15d 100644
--- a/localeTools.py
+++ b/localeTools.py
@@ -62,3 +62,22 @@ def generateStringEntry(key, value, path):
return '<!ENTITY %s "%s">\n' % (cgi.escape(key, True), cgi.escape(value, True))
else:
return '%s=%s\n' % (key, value)
+
+def appendToFile(path, key, value):
+ fileHandle = codecs.open(path, 'ab', encoding='utf-8')
+ fileHandle.write(generateStringEntry(key, value, path))
+ fileHandle.close()
+
+def removeFromFile(path, key):
+ fileHandle = codecs.open(path, 'rb', encoding='utf-8')
+ data = fileHandle.read()
+ fileHandle.close()
+
+ if path.endswith('.dtd'):
+ data = re.sub(r'<!ENTITY\s+%s\s+"[^"]*">\s*' % key, '', data, re.S)
+ else:
+ data = re.sub(r'(^|\n)%s=[^\n]*\n' % key, r'\1', data, re.S)
+
+ fileHandle = codecs.open(path, 'wb', encoding='utf-8')
+ fileHandle.write(data)
+ fileHandle.close()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list