import os, zipfile

# Zip files.
def zipfiles(directory):
  
    # File extension to zip.
    #ext = ('.gdb', '.csv')
    ext = ('.gdb')
    
    # Iterate over all files and check for desired extentions for zipping.
    for file in os.listdir(directory):
        if file.endswith(ext):
            #: Zip it.
            input_fgdb_name = file.rsplit( ".", 1)[0]
            output_zipped_fgdb_name = "/" + input_fgdb_name + "_gdb.zip"
            full_path_to_fgdb = directory + "/" + file

            print("   Zipping " + str(full_path_to_fgdb))

            outFile = f'{full_path_to_fgdb[0:-4]}_gdb.zip'
            gdbName = os.path.basename(full_path_to_fgdb)

            with zipfile.ZipFile(outFile,mode='w',compression=zipfile.ZIP_DEFLATED,allowZip64=True) as myzip:
                for f in os.listdir(full_path_to_fgdb):
                    if f[-5:] != '.lock':
                        myzip.write(os.path.join(full_path_to_fgdb,f),gdbName+'\\'+os.path.basename(f))

        else:
            continue

[((11, 16, 11, 37), 'os.listdir', 'os.listdir', ({(11, 27, 11, 36): 'directory'}, {}), '(directory)', False, 'import os, zipfile\n'), ((21, 22, 21, 57), 'os.path.basename', 'os.path.basename', ({(21, 39, 21, 56): 'full_path_to_fgdb'}, {}), '(full_path_to_fgdb)', False, 'import os, zipfile\n'), ((23, 17, 23, 99), 'zipfile.ZipFile', 'zipfile.ZipFile', (), '', False, 'import os, zipfile\n'), ((24, 25, 24, 54), 'os.listdir', 'os.listdir', ({(24, 36, 24, 53): 'full_path_to_fgdb'}, {}), '(full_path_to_fgdb)', False, 'import os, zipfile\n'), ((26, 36, 26, 69), 'os.path.join', 'os.path.join', ({(26, 49, 26, 66): 'full_path_to_fgdb', (26, 67, 26, 68): 'f'}, {}), '(full_path_to_fgdb, f)', False, 'import os, zipfile\n'), ((26, 83, 26, 102), 'os.path.basename', 'os.path.basename', ({(26, 100, 26, 101): 'f'}, {}), '(f)', False, 'import os, zipfile\n')]