ocrd_cis/aio/aio.py
def unpack(fromdir, todir):
    '''extract all zips into temp dir'''
    n = 1
    _, _, files = os.walk(fromdir).__next__()

    #for checking if zips are already unpacked
    if os.path.exists(todir):
        _, dirs, _ = os.walk(todir).__next__()
    else:
        dirs = []

    for file in files:
        if '.zip' in file and file not in dirs:
            if n == 0:
                break
            n -= 1
            # skip -- missing page dir or corrupt xml
            exclude = ['anton_locusGalat_1800.zip', 'dorn_uppedat_1507.zip']
            if file in exclude:
                continue
            filedir = os.path.join(fromdir, file)
            resdir = os.path.join(todir, file)
            if os.path.isdir(resdir[0:-4]):
                print("{dir} exists - skipping...".format(dir=resdir[0:-4]))
                continue
            with ZipFile(filedir, 'r') as myzip:
                print("unpacking {file} to {todir}"
                      .format(file=file, todir=todir))
                myzip.extractall(todir)
extract all zips into temp dir
extract all zips into temp dir
extract all zips into temp dir
def unpack(fromdir, todir):
    n = 1
    _, _, files = os.walk(fromdir).__next__()
    if os.path.exists(todir):
        _, dirs, _ = os.walk(todir).__next__()
    else:
        dirs = []
    for file in files:
        if '.zip' in file and file not in dirs:
            if n == 0:
                break
            n -= 1
            exclude = ['anton_locusGalat_1800.zip', 'dorn_uppedat_1507.zip']
            if file in exclude:
                continue
            filedir = os.path.join(fromdir, file)
            resdir = os.path.join(todir, file)
            if os.path.isdir(resdir[0:-4]):
                print("{dir} exists - skipping...".format(dir=resdir[0:-4]))
                continue
            with ZipFile(filedir, 'r') as myzip:
                print("unpacking {file} to {todir}"
                      .format(file=file, todir=todir))
                myzip.extractall(todir)
def unpack ( fromdir , todir ) : n = 1 _ , _ , files = os . walk ( fromdir ) . __next__ ( ) if os . path . exists ( todir ) : _ , dirs , _ = os . walk ( todir ) . __next__ ( ) else : dirs = [ ] for file in files : if '.zip' in file and file not in dirs : if n == 0 : break n -= 1 exclude = [ 'anton_locusGalat_1800.zip' , 'dorn_uppedat_1507.zip' ] if file in exclude : continue filedir = os . path . join ( fromdir , file ) resdir = os . path . join ( todir , file ) if os . path . isdir ( resdir [ 0 : - 4 ] ) : print ( "{dir} exists - skipping..." . format ( dir = resdir [ 0 : - 4 ] ) ) continue with ZipFile ( filedir , 'r' ) as myzip : print ( "unpacking {file} to {todir}" . format ( file = file , todir = todir ) ) myzip . extractall ( todir )
extract all zips into temp dir
extract all zips into temp dir
'''extract all zips into temp dir''' #for checking if zips are already unpacked # skip -- missing page dir or corrupt xml
fromdir
todir