Editorial changes & Fixes from QuLogic

This commit is contained in:
Sam Manzi 2016-04-19 09:15:05 +10:00
parent 5dc5615bfd
commit 3f86dd3e25
No known key found for this signature in database
GPG Key ID: F4A16068AE36B402
3 changed files with 76 additions and 93 deletions

View File

@ -219,7 +219,6 @@ class DbState(Callback):
fname = os.path.join(dirpath, "lock") fname = os.path.join(dirpath, "lock")
with open(fname, 'r', encoding='utf8') as ifile: with open(fname, 'r', encoding='utf8') as ifile:
locked_by = ifile.read().strip() locked_by = ifile.read().strip()
ifile.close()
except (OSError, IOError): except (OSError, IOError):
pass pass
return (dirpath, locked, locked_by, backend) return (dirpath, locked, locked_by, backend)

View File

@ -436,7 +436,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def __log_error(self): def __log_error(self):
mypath = os.path.join(self.get_save_path(),DBRECOVFN) mypath = os.path.join(self.get_save_path(),DBRECOVFN)
with open(mypath, "w") as ofile: ofile = open(mypath, "w")
ofile.close()
try: try:
clear_lock_file(self.get_save_path()) clear_lock_file(self.get_save_path())
except: except:

View File

@ -113,7 +113,6 @@ def tests():
print ('Please, install %(program)s for listing groups of messages' print ('Please, install %(program)s for listing groups of messages'
% {'program': msgattribCmd}) % {'program': msgattribCmd})
try: try:
print("\n===='xgettext' =(generate a new template)==============\n") print("\n===='xgettext' =(generate a new template)==============\n")
os.system('''%(program)s -V''' % {'program': xgettextCmd}) os.system('''%(program)s -V''' % {'program': xgettextCmd})
@ -127,12 +126,10 @@ def tests():
except: except:
print ('Please, install python') print ('Please, install python')
def TipsParse(filename, mark): def TipsParse(filename, mark):
""" """
Experimental alternative to 'intltool-extract' for 'tips.xml'. Experimental alternative to 'intltool-extract' for 'tips.xml'.
""" """
from xml.etree import ElementTree from xml.etree import ElementTree
tree = ElementTree.parse(filename) tree = ElementTree.parse(filename)
@ -189,7 +186,6 @@ def HolidaysParse(filename, mark):
""" """
Experimental alternative to 'intltool-extract' for 'holidays.xml'. Experimental alternative to 'intltool-extract' for 'holidays.xml'.
""" """
from xml.etree import ElementTree from xml.etree import ElementTree
tree = ElementTree.parse(filename) tree = ElementTree.parse(filename)
@ -213,7 +209,6 @@ def HolidaysParse(filename, mark):
msgid "Jewish Holidays" msgid "Jewish Holidays"
msgid "Yom Kippur" msgid "Yom Kippur"
''' '''
with open('../data/holidays.xml.in.h', 'w') as holidays: with open('../data/holidays.xml.in.h', 'w') as holidays:
for key in ellist: for key in ellist:
if key.attrib.get(mark): if key.attrib.get(mark):
@ -230,7 +225,6 @@ def XmlParse(filename, mark):
""" """
Experimental alternative to 'intltool-extract' for 'file.xml.in'. Experimental alternative to 'intltool-extract' for 'file.xml.in'.
""" """
from xml.etree import ElementTree from xml.etree import ElementTree
tree = ElementTree.parse(filename) tree = ElementTree.parse(filename)
@ -261,7 +255,6 @@ def XmlParse(filename, mark):
''' '''
with open(filename + '.h', 'w') as head: with open(filename + '.h', 'w') as head:
for key in root.iter(): for key in root.iter():
if key.tag == '{http://www.freedesktop.org/standards/shared-mime-info}%s' % mark: if key.tag == '{http://www.freedesktop.org/standards/shared-mime-info}%s' % mark:
comment = 'char *s = N_("%s");\n' % key.text comment = 'char *s = N_("%s");\n' % key.text
@ -276,7 +269,6 @@ def XmlParse(filename, mark):
print ('Wrote %s' % filename) print ('Wrote %s' % filename)
root.clear() root.clear()
def DesktopParse(filename): def DesktopParse(filename):
""" """
Experimental alternative to 'intltool-extract' for 'gramps.desktop'. Experimental alternative to 'intltool-extract' for 'gramps.desktop'.
@ -297,7 +289,6 @@ def DesktopParse(filename):
"Manage genealogical information, "Manage genealogical information,
perform genealogical research and analysis" perform genealogical research and analysis"
''' '''
with open('../data/gramps.desktop.in.h', 'w') as desktop: with open('../data/gramps.desktop.in.h', 'w') as desktop:
with open(filename) as f: with open(filename) as f:
@ -336,7 +327,6 @@ def KeyParse(filename, mark):
msgid "Gramps XML database" msgid "Gramps XML database"
msgid "GEDCOM" msgid "GEDCOM"
''' '''
with open('../data/gramps.keys.in.h', 'w') as key: with open('../data/gramps.keys.in.h', 'w') as key:
with open(filename) as f: with open(filename) as f:
@ -409,7 +399,6 @@ def main():
choices=[file for file in os.listdir('.') if file.endswith('.po')], choices=[file for file in os.listdir('.') if file.endswith('.po')],
help="list fuzzy messages") help="list fuzzy messages")
args = parser.parse_args() args = parser.parse_args()
namespace, extra = parser.parse_known_args() namespace, extra = parser.parse_known_args()
@ -505,7 +494,6 @@ def listing(name, extensionlist):
files = [file.strip() for file in f if file and not file[0]=='#'] files = [file.strip() for file in f if file and not file[0]=='#']
with open(name, 'w') as temp: with open(name, 'w') as temp:
for entry in files: for entry in files:
for ext in extensionlist: for ext in extensionlist:
if entry.endswith(ext): if entry.endswith(ext):
@ -544,7 +532,6 @@ def extract_xml():
Extract translation strings from XML based, keys, mime and desktop Extract translation strings from XML based, keys, mime and desktop
files. Own XML files parsing and custom translation marks. files. Own XML files parsing and custom translation marks.
""" """
HolidaysParse('../data/holidays.xml.in', '_name') HolidaysParse('../data/holidays.xml.in', '_name')
TipsParse('../data/tips.xml.in', '_tip') TipsParse('../data/tips.xml.in', '_tip')
XmlParse('../data/gramps.xml.in', '_comment') XmlParse('../data/gramps.xml.in', '_comment')
@ -557,6 +544,7 @@ def create_template():
Create a new file for template, if it does not exist. Create a new file for template, if it does not exist.
""" """
with open('gramps.pot', 'w') as template: with open('gramps.pot', 'w') as template:
pass
def extract_glade(): def extract_glade():
""" """
@ -610,7 +598,6 @@ def extract_gtkbuilder():
files = ['../gramps/plugins/importer/importgedcom.glade', '../gramps/gui/glade/rule.glade'] files = ['../gramps/plugins/importer/importgedcom.glade', '../gramps/gui/glade/rule.glade']
with open('gtklist.h', 'w') as temp: with open('gtklist.h', 'w') as temp:
for filename in files: for filename in files:
tree = ElementTree.parse(filename) tree = ElementTree.parse(filename)
root = tree.getroot() root = tree.getroot()
@ -680,7 +667,6 @@ def merge(args):
""" """
Merge messages with 'gramps.pot' Merge messages with 'gramps.pot'
""" """
for arg in args: for arg in args:
if arg == 'all': if arg == 'all':
continue continue
@ -693,7 +679,6 @@ def check(args):
""" """
Check the translation file Check the translation file
""" """
for arg in args: for arg in args:
if arg == 'all': if arg == 'all':
continue continue
@ -708,14 +693,12 @@ def untranslated(arg):
""" """
List untranslated messages List untranslated messages
""" """
os.system('''%(msgattrib)s --untranslated %(lang.po)s''' % {'msgattrib': msgattribCmd, 'lang.po': arg[0]}) os.system('''%(msgattrib)s --untranslated %(lang.po)s''' % {'msgattrib': msgattribCmd, 'lang.po': arg[0]})
def fuzzy(arg): def fuzzy(arg):
""" """
List fuzzy messages List fuzzy messages
""" """
os.system('''%(msgattrib)s --only-fuzzy --no-obsolete %(lang.po)s''' % {'msgattrib': msgattribCmd, 'lang.po': arg[0]}) os.system('''%(msgattrib)s --only-fuzzy --no-obsolete %(lang.po)s''' % {'msgattrib': msgattribCmd, 'lang.po': arg[0]})
if __name__ == "__main__": if __name__ == "__main__":