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

[((233, 254), 'os.listdir', 'os.listdir', (['directory'], {}), '(directory)\n', (243, 254), False, 'import os, zipfile\n'), ((633, 668), 'os.path.basename', 'os.path.basename', (['full_path_to_fgdb'], {}), '(full_path_to_fgdb)\n', (649, 668), False, 'import os, zipfile\n'), ((687, 776), 'zipfile.ZipFile', 'zipfile.ZipFile', (['outFile'], {'mode': '"""w"""', 'compression': 'zipfile.ZIP_DEFLATED', 'allowZip64': '(True)'}), "(outFile, mode='w', compression=zipfile.ZIP_DEFLATED,\n    allowZip64=True)\n", (702, 776), False, 'import os, zipfile\n'), ((805, 834), 'os.listdir', 'os.listdir', (['full_path_to_fgdb'], {}), '(full_path_to_fgdb)\n', (815, 834), False, 'import os, zipfile\n'), ((914, 948), 'os.path.join', 'os.path.join', (['full_path_to_fgdb', 'f'], {}), '(full_path_to_fgdb, f)\n', (926, 948), False, 'import os, zipfile\n'), ((961, 980), 'os.path.basename', 'os.path.basename', (['f'], {}), '(f)\n', (977, 980), False, 'import os, zipfile\n')]