diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-18 18:41:39 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-19 00:18:02 +0100 | 
| commit | 494aada27e305658ce60b0815fd992857222682b (patch) | |
| tree | 17e9fbf51fc054d18ddcd7fabc87e8684daf4eb4 /misc/simple_ooo_replace.py | |
| parent | f384337ef0d9d2e40d09204f18c4a486e925132c (diff) | |
| download | Ishtar-494aada27e305658ce60b0815fd992857222682b.tar.bz2 Ishtar-494aada27e305658ce60b0815fd992857222682b.zip | |
Configure for publications on pypi, descriptions, etc.
Diffstat (limited to 'misc/simple_ooo_replace.py')
| -rwxr-xr-x | misc/simple_ooo_replace.py | 79 | 
1 files changed, 0 insertions, 79 deletions
| diff --git a/misc/simple_ooo_replace.py b/misc/simple_ooo_replace.py deleted file mode 100755 index 62cbab7a5..000000000 --- a/misc/simple_ooo_replace.py +++ /dev/null @@ -1,79 +0,0 @@ -import os -import shutil -import sys -from zipfile import ZipFile, ZIP_DEFLATED - -rpl_lst = [ -    ('adminact_associated_file_general_contractor_attached_to_name', -     'adminact_associated_file_corporation_general_contractor_name'), -    ('adminact_associated_file_general_contractor_' -     'attached_to_address', -     'adminact_associated_file_corporation_general_contractor_' -     'address'), -    ('adminact_associated_file_general_contractor_' -     'address_complement', -     'adminact_associated_file_corporation_general_contractor_' -     'address_complement '), -    ('adminact_associated_file_general_contractor_' -     'attached_to_postal_code', -     'adminact_associated_file_corporation_general_contractor_' -     'postal_code '), -    ('adminact_associated_file_general_contractor_attached_to_town', -     'adminact_associated_file_corporation_general_contractor_town', -     ), -    ('adminact_associated_file_address', -     'adminact_associated_file_get_locality', -     ) -] - -context = dict(rpl_lst) - - -def value_replace(content): -    value = content -    modified = False -    for key in context: -        if key in value: -            modified = True -            value = value.replace(key, context[key]) -    return value, modified - - -def replace(directory, infile): -    print("Processing {}".format(infile)) -    outfile = "PREPROCESS--" + infile -    infile = directory + os.sep + infile -    outfile = directory + os.sep + outfile - -    inzip = ZipFile(infile, 'r', ZIP_DEFLATED) -    outzip = ZipFile(outfile, 'w', ZIP_DEFLATED) - -    values = {} -    idx = 0 -    for xml_file in ('content.xml', 'styles.xml'): -        content = inzip.read(xml_file) -        values[xml_file], modified = value_replace(content) -        if modified: -            idx += 1 - -    for f in inzip.infolist(): -        if f.filename in values: -            outzip.writestr(f.filename, values[f.filename]) -        else: -            outzip.writestr(f, inzip.read(f.filename)) - -    inzip.close() -    outzip.close() -    # replace original by PREPROCESS -    shutil.move(outfile, infile) -    return idx - -directory = sys.argv[-1] -idx = 0 - - -for fle in os.listdir(directory): -    if fle.endswith('.odt'): -        idx += replace(directory, fle) - -print("{} modifications".format(idx)) | 
