Exemplo n.º 1
0
def join(conf, in_dir, target):
    print("*Joining...")
    s = Saxon(conf["saxon"])
    if os.path.isdir(in_dir):
        s.join(emptympx, joinColxsl, target)
    else:
        print(f"input dir '{in_dir}' does not exist")
Exemplo n.º 2
0
def lvlup(conf, in_fn, output):
    """TODO: Replace with generic xsl plugin"""
    print("*Levelling up...")  # Syd says with 2l
    s = Saxon(conf["saxon"])
    if os.path.isfile(in_fn):
        s.transform(in_fn, lvlupxsl, output)
    else:
        print(f"Input file missing {in_fn}")
Exemplo n.º 3
0
 def _mk_datenblatt(self, path, overwrite=False):
     s = Saxon(self.saxon)
     xsl_fn = os.path.join(self.lib, "lido2datenblatt.xsl")
     base = os.path.basename(path)
     out = f"3-lido/{base}.blatt.html"
     if overwrite is True and os.path.exists(out):
         os.unlink(out)
     s.dirTransform(path, xsl_fn, out)
Exemplo n.º 4
0
    def __init__(self, saxon, source, xsl, outpath):
        destdir = os.path.dirname(outpath)  #check
        #print (destdir)
        self.mkdir(destdir)

        if os.path.isfile(outpath):
            print("%s exists already, no overwrite" % outpath)
        else:
            sn = Saxon(saxon)
            sn.transform(source, xsl, outpath)
Exemplo n.º 5
0
 def _mk_html(self, path, overwrite=False):
     """
     current problems: 
     - this step is in string order, not numeric objId
     objId/12345789
     - it's pretty slow to transform individual liko files like this, since
     I fire up separate a saxon process for every lido file
     """
     s = Saxon(self.saxon)
     xsl_fn = os.path.join(self.lib, "lido2html.xsl")
     base = os.path.basename(path)
     new = f"{base}.html"
     if not os.path.exists(new) or overwrite is True:
         s.dirTransform(path, xsl_fn, new)
Exemplo n.º 6
0
def mk_html(conf, indir, outdir):
    """CURRENTLY NOT USED
    current problems:
    - this step is in string order, not numeric objId
    objId/12345789
    - it's pretty slow to transform individual lido files like this, since
    I fire up separate a saxon process for every lido file
    """
    s = Saxon(conf["saxon"])
    xsl_fn = os.path.realpath(os.path.join(__file__, "../../xsl", "lido2html.xsl"))
    for path in glob.iglob(indir + "/*.lido", recursive=True):
        base = os.path.basename(path)
        new = os.path.join(outdir, f"{base}.html")
        if not os.path.exists(new) is True:
            s.dirTransform(path, xsl_fn, new)
Exemplo n.º 7
0
    def transform(self):
        """from mpx to lido"""

        print("TRANSFORMING TO LIDO")
        lock_fn = "3-lido/lido.lock"
        if os.path.exists(lock_fn):
            print(f"Lock file exists, no overwrite ({lock_fn})")
        else:
            self._write_lock(lock_fn)
            s = Saxon(
                self.saxon)  #lib is where my xsl files are, so a short cut
            xsl_fn = os.path.join(self.lib, "mpx2lido.xsl")
            #seem to need asyncio to see progressing output as usual and capturing it
            #s.dirTransform("2-MPX/vfix.mpx", xsl_fn, "3-lido/o.lido", "3-lido/report.log")
            s.dirTransform("2-MPX/vfix.mpx", xsl_fn, "3-lido/o.lido")
Exemplo n.º 8
0
def mk_mpx (conf):
    print ('*Looking for input...')
    o = Xls2xml(conf) 
    o.mv2zero() # moves files to 0-IN

    print ('*First conversion...')
    o.transformAll() #input from 0-IN output to 1-XML  

    print ('*Joining...')
    s = Saxon(conf, conf['lib'])
    if os.path.isdir(conf['onedir']): 
        s.join (conf['emptympx'], conf['joinColxsl'], conf['joinmpx'])

    print ('*Levelling up...') #Syd says with 2l
    if os.path.isfile(conf['joinmpx']): 
        s.dirTransform(conf['joinmpx'], conf['lvlupxsl'], conf['lvlupmpx']) 

    test_mpx.main(conf['lvlupmpx'])
Exemplo n.º 9
0
def xsl(conf, in_fn, xsl, out_fn):
    print("*XSL Transform...")
    #    print (f"conf:{conf} in_fn:{in_fn}, xsl:{xsl}, out_fn:{out_fn}")
    s = Saxon(conf["saxon"])
    new_xsl = os.path.join(xsl_dir, xsl)
    s.transform(in_fn, new_xsl, out_fn)
Exemplo n.º 10
0
        update_xlsx (conf) #create/update vindex and translate.xslx with terms mpx
        try:
            Gtrans ("../translate.xlsx") #translate sheets in translate
        except: pass
    update_vfix (conf) #updates only if vfix file doesn't exist yet
    if not args.short:
        translate (conf) # run ONLY after vindex has been applied 
    #for saving data to github 
    cp_data2() 
    vok2vok ('../..', '../../../data2/mpxvoc.xml') # work on new data2 dir

    if args.cmd is not None:
        if args.cmd == 'shf':
            print ('*Converting to SHF csv format...')
            if os.path.isfile(conf['vfixmpx']):
                s = Saxon(conf, conf['lib'])
                s.dirTransform(conf['vfixmpx'], conf['shfxsl'], conf['shfnpx'])
                n = Npx2csv (conf['shfnpx'])
                #you might need to prepare or delete the cache file manually
                tf = Tif_finder('../../../.tif_cache.json')
                tf.search_mpx(conf['lvlupmpx'], conf['tifdir'])
                tshf.main(conf['vfixmpx'], conf ['shfnpx'])
        elif args.cmd == 'boris':
            print ('*Working on Boris Test...')
            if os.path.isfile(conf['lvlupmpx']):
                rc = ResourceCp (conf['lvlupmpx']) 
                rc.boris_test('boris_test')
        elif args.cmd == 'datenblatt':
            """this datenblatt is made directly from mpx; 
            other one is made from lido. Use LidoMaker.Py instead"""
    
Exemplo n.º 11
0
import sys
from pathlib import Path
adir = Path(__file__).parent
sys.path.append(str(adir))  # what the heck?
from Saxon import Saxon

saxon_path = "C:\m3\SaxonHE10-5J\saxon-he-10.5.jar"

adate = str(Path.cwd().name)
label = str(Path.cwd().parent.name)

s = Saxon(saxon_path)
out_fn = f"{label}{adate}.zpx"

s.join(
    list(Path(".").glob("*-clean-*.xml"))[0],
    "C:/m3/Pipeline/src/xsl/join-zpx.xsl", out_fn)
Exemplo n.º 12
0
import os, sys, argparse

lib=os.path.realpath(os.path.join(__file__,'../../lib'))

if os.getlogin() == 'User':
    saxon= "C:/Program Files/Saxonica/SaxonHE9.9N/bin/Transform.exe",
elif os.getlogin() == 'mauri':
    saxon= "C:/Program Files/Saxonica/SaxonHE9.9N/bin/Transform.exe",

sys.path.append (lib)
from Saxon import Saxon

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument('-i', '--input', required=True)
    parser.add_argument('-x', '--xsl', required=True)
    parser.add_argument('-o', '--output', required=False)
    args = parser.parse_args()

    if not args.output:
        args.output='out.lido'
    
    s=Saxon(saxon) #lib is where my xsl files are, so a short cut
    s.dirTransform(args.input, args.xsl, args.output)
Exemplo n.º 13
0
def join(conf, in_dir, target):
    print("*Joining...")
    s = Saxon(conf["saxon"])
    s.join(emptyMpx, joinColXsl, target)