def main(): usage = """usage: %prog [options] sqlstatement Type %(table)s as a token for the language table name This will run the sql query on all language tables""" parser = GlobalOptionsParser(usage=usage) (options, args) = parser.parse_args() parser.check_args(1, args) session = LionDB(options.config, options.trace, options.app) sql = args[0] request = "SELECT langid FROM languages" session.execute_query(request) all_langs = session.cursor.fetchall() if parser.safety_check("run this query on each language table") == False: exit(1) for l in all_langs: request = sql % {"table": session.make_table_name(l[0])} try: session.execute_query(request) if session.cursor.rowcount > 0: for r in session.cursor.fetchall(): for field in r: print field except Exception, e: print "Exception: %s" % e
def main(): usage = """usage: %prog [options] langid """ parser = GlobalOptionsParser(usage=usage) (options, args) = parser.parse_args() parser.check_args(1, args) session = LionDB(options.config, options.trace, options.app) langid = args[0] table = session.make_table_name(langid) session.execute_query("SELECT remarks, xmlid, textstring from %s" % table) results = session.cursor.fetchall() skipped = 0 changed = 0 for remarks, xmlid, textstring in results: if remarks != None and remarks != "": request = """UPDATE %s SET textstring="%s" WHERE xmlid="%s" """ % (table, remarks, xmlid) # print request session.execute_query(request) changed +=1 else: print "skipping %s (text = %s)" % (xmlid, textstring) skipped +=1 print "Skipped %d, Changed %d" % (skipped, changed)
def main(): """For whatever""" usage = """usage: %prog [options] xmlfile""" parser = GlobalOptionsParser(usage=usage) (options, args) = parser.parse_args() parser.check_args(1, args) session = LionDB(options.config, options.trace, options.app) minidom.Document = amisxml.AmisUiDoc doc = minidom.parse(args[0]) doc.set_session(session) all_xml_ids = doc.get_all_text_ids() session.execute_query("SELECT langid FROM languages") all_langs = session.cursor.fetchall() count = 0 # make the list of IDs that are to be preserved request = "SELECT xmlid, textstring FROM eng_US" #"%s" % session.make_table_name(l[0]) session.execute_query(request) all_table_ids = session.cursor.fetchall() preserve_list = [] for id, txt in all_table_ids: if id not in all_xml_ids: count += 1 preserve_list.append(id) print id, txt print "Of %d IDs in the DB, %d were not found" % (len(all_table_ids), count) # now mark each item in that list as preserve = 1 for each language for l in all_langs: table = session.make_table_name(l[0]) for id in preserve_list: request = """UPDATE %s SET preserve=1 WHERE xmlid="%s" """ % ( table, id) session.execute_query(request)
def main(): """For whatever""" usage = """usage: %prog [options] xmlfile""" parser = GlobalOptionsParser(usage=usage) (options, args) = parser.parse_args() parser.check_args(1, args) session = LionDB(options.config, options.trace, options.app) minidom.Document = amisxml.AmisUiDoc doc = minidom.parse(args[0]) doc.set_session(session) all_xml_ids = doc.get_all_text_ids() session.execute_query("SELECT langid FROM languages") all_langs = session.cursor.fetchall() count = 0 # make the list of IDs that are to be preserved request = "SELECT xmlid, textstring FROM eng_US" #"%s" % session.make_table_name(l[0]) session.execute_query(request) all_table_ids = session.cursor.fetchall() preserve_list = [] for id, txt in all_table_ids: if id not in all_xml_ids: count += 1 preserve_list.append(id) print id, txt print "Of %d IDs in the DB, %d were not found" % (len(all_table_ids), count) # now mark each item in that list as preserve = 1 for each language for l in all_langs: table = session.make_table_name(l[0]) for id in preserve_list: request = """UPDATE %s SET preserve=1 WHERE xmlid="%s" """ % (table, id) session.execute_query(request)
def main(): """which are the top-level accelerators?""" usage = """usage: %prog [options] langid""" parser = GlobalOptionsParser(usage=usage) (options, args) = parser.parse_args() parser.check_args(1, args) session = LionDB(options.config, options.trace, options.app) table = session.make_table_name(args[0]) # top level menu items request = "SELECT xmlid, textstring FROM %s WHERE istoplevel=1 and role=\"MENUITEM\"" % table session.execute_query(request) menuitems = session.cursor.fetchall() accels = [] for id, text in menuitems: request = "SELECT textstring, audiouri, xmlid FROM %s WHERE target=\"%s\" and role=\"ACCELERATOR\"" % \ (table, id) session.execute_query(request) info = (text, id), session.cursor.fetchone() accels.append(info) for a in accels: print "Item: %s (id=%s)" % (a[0][0], a[0][1]) print "Shortcut: %s (id=%s)" % (a[1][0], a[1][2]) print "Audio file: %s" % a[1][1] print ""