PYTHONBREAKPOINT = 0 #disallow breakpoints from unicode import latin1_to_ascii import json import pdb import re import os import sys import time import glob from pprint import pprint, pformat import gzip import csv import platform import inspect from functools import partial import os.path #Globals HTTPHEADER = 'https://www.lutemusic.org/' currOS = platform.platform() if currOS.find('Windows') == 0: #LOCALBASE = 'C:/website/' LOCALBASE = 'A:/test/' else: LOCALBASE = '/ssd/home/sarge/prog/python/fron' CURRDIR = re.sub('\\\\+', '/', os.getcwd()) + '/' FACHEAD = LOCALBASE + "facsimiles/" def join_with_fslash(s1, s2): return(s1 + '/' + s2) # end join_with_fslash # Walk the main directory tree def walk_tree(FACHEAD): count = 0 # of image directories processed. sDir = sDir.replace("\\", '/') oldDir = "" for root, dirs, files in os.walk(sDir): # Only when changing root directories do we collect a list of .ft3 files root = root.replace("\\", '/') if root == oldDir: continue # Now we have a new "old directory" oldDir = root count += 1 indexfile = CURRDIR + 'dir.inx' finx = open(indexfile) # Get a list of image files in this directory images = [f for f in files if f.endswith('.png') or f.endswith('tif') or f.endswith('.jpg')] # we don't bother with other image types for i in range(len(images)): finx.write(HTTPHEADER + images[i]) finx.close() # Process each image file in the list. # end for fname in images # end if root != oldDir # After walking the directories. print(']', end= "", file=Fronimo.flJson) Fronimo.flJson.close() Fronimo.flTsv.close() return count # end walk_tree def main(): firstArg = sys.argv.pop(0) if firstArg.find('tft.py') != -1: do_tft() elif firstArg.find('dft.py') != -1: do_dft() elif firstArg.find('cft.py') != -1: do_cft() else: do_eft() # end main if __name__ == "__main__": main()