def convert_pstoascii(): """Konvertiert die PDF-Dokumente in schlechtes Ascii. Unixspezifisch, verwendet Systemaufruf fuer das Programm: pstoascii. """ import ebkus.db.sql sql.opendb() dokl = DokumentList(where = 'mtyp = %s' % cc('mimetyp', 'pdf'), order = 'fall_id,id') grdokl = GruppendokumentList(where = 'mtyp = %s' % cc('mimetyp', 'pdf'), order = 'gruppe_id,id') for d in grdokl: gruppe_path = get_gruppe_path(d['gruppe_id']) dateil = os.listdir('%s' % gruppe_path) if '%s.txt' % d['id'] not in dateil and '%s.pdf' % d['id'] in dateil: os.system('ps2ascii %s/%s.pdf %s/%s.txt' % (gruppe_path,d['id'],gruppe_path,d['id'])) for d in dokl: fall = Fall(d['fall_id']) akte_path = get_akte_path(fall['akte_id']) dateil = os.listdir('%s' % akte_path) if '%s.txt' % d['id'] not in dateil and '%s.pdf' % d['id'] in dateil: os.system('ps2ascii %s/%s.pdf %s/%s.txt' % (akte_path,d['id'],akte_path,d['id'])) sql.closedb()
def convert_pstoascii(): """Konvertiert die PDF-Dokumente in schlechtes Ascii. Unixspezifisch, verwendet Systemaufruf fuer das Programm: pstoascii. """ import ebkus.db.sql sql.opendb() dokl = DokumentList(where="mtyp = %s" % cc("mimetyp", "pdf"), order="fall_id,id") grdokl = GruppendokumentList(where="mtyp = %s" % cc("mimetyp", "pdf"), order="gruppe_id,id") for d in grdokl: gruppe_path = get_gruppe_path(d["gruppe_id"]) dateil = os.listdir("%s" % gruppe_path) if "%s.txt" % d["id"] not in dateil and "%s.pdf" % d["id"] in dateil: os.system("ps2ascii %s/%s.pdf %s/%s.txt" % (gruppe_path, d["id"], gruppe_path, d["id"])) for d in dokl: fall = Fall(d["fall_id"]) akte_path = get_akte_path(fall["akte_id"]) dateil = os.listdir("%s" % akte_path) if "%s.txt" % d["id"] not in dateil and "%s.pdf" % d["id"] in dateil: os.system("ps2ascii %s/%s.pdf %s/%s.txt" % (akte_path, d["id"], akte_path, d["id"])) sql.closedb()
def read_strkat(file_name, opendb=False): dyn_pos = 0 gesamt_pos = 0 if opendb: sql.opendb() line = None neuliste = [] if file_name.lower().endswith('.gz'): import gzip f = gzip.GzipFile(file_name) else: f = open(file_name) del_old_strkat() while line != '': line = f.readline() line = re.sub(r'\'', '\\\'', line) line = re.sub(r'\"', '\'', line) if line != '': neuliste = schreibe_daten(line) str_nr = neuliste[0] str_name = neuliste[1] hsnr = neuliste[2] if hsnr == '': hsnr = '\'---\'' bez = neuliste[4] plz = neuliste[9] planungsr = neuliste[20] write_strassen_to_db(str_nr, str_name, hsnr, bez, plz, planungsr) dyn_pos = dyn_pos + 1 if dyn_pos == 10000: gesamt_pos = gesamt_pos + 10000 print " Status: " + str(gesamt_pos) + " von ca. 385000 Datensaetzen fertig importiert." dyn_pos = 0 #print "Strassenkatalog wurde erfolgreich importiert." ##************************************************************************* ## Anlegen eines Indexes für die schnellere Suche im Strassenkat ## Index wird über 10 Zeichen des Strassennamens angelegt. Wunsch von Huber. ## brehmea 15.08.2002 ##************************************************************************* #print "Lege Index fuer Strassenkatalog an." sql_query = "ALTER TABLE strassenkat ADD INDEX (str_name(10))" sql.execute(sql_query) #print "Index fuer Strassenkatalog wurde erfolgreich angelegt." f.close() if opendb: sql.closedb()
def generate_schema(schema_str, test): opendb() init_new_db(schema_str, test) closedb()
def generate_schema(schema_str, test): from ebkus.db.sql import opendb, closedb opendb() init_new_db(schema_str, test) closedb()
ebapi.Akte()._test_consistency() ebapi.Leistung()._test_consistency() ebapi.Einrichtungskontakt()._test_consistency() ebapi.Anmeldung()._test_consistency() ebapi.Bezugsperson()._test_consistency() ebapi.Zustaendigkeit()._test_consistency() ebapi.Fall()._test_consistency() ebapi.Mitarbeiter()._test_consistency() ebapi.Dokument()._test_consistency() ebapi.Gruppe()._test_consistency() ebapi.Gruppendokument()._test_consistency() ebapi.FallGruppe()._test_consistency() ebapi.BezugspersonGruppe()._test_consistency() ebapi.MitarbeiterGruppe()._test_consistency() ebapi.Code()._test_consistency() ebapi.Kategorie()._test_consistency() ebapi.Jugendhilfestatistik()._test_consistency() ebapi.Fachstatistik()._test_consistency() ebapi.Fachstatistikleistung()._test_consistency() ebapi.Fachstatistikkindproblem()._test_consistency() ebapi.Fachstatistikelternproblem()._test_consistency() ## höchstens eine Anmeldung/Fall ## höchstens ein aktueller Fall ## genau eine offene Zuständigkeit für einen offenen Fall sql.closedb()
def generate_ebapi(schema_str): opendb() f = gen_api(schema_str) closedb() # f ist StringIO Objekt return f