[docs]defqueue_existing(profile,path):""" Adds files found in a watched folder to a processing queue. This is called when the monitor first starts, to handle the case of files which exist prior to startup. If files are found, they are first sorted by modification timestamp, using a lexical sort on the filename as a tie-breaker, and then added to the queue in that order. :param profile: Monitor configuration profile for which the folder is to be watched. The profile is expected to already have a queue attached; any existing files will be added to this queue. :param path: Folder path which is to be checked for files. """paths=[os.path.join(path,p)forpinos.listdir(path)]paths=sorted(paths,key=lambdap:(os.path.getmtime(p),p))forpathinpaths:# Only process normal files.ifnotos.path.isfile(path):continue# If using locks, don't process "in transit" files.ifprofile.watch_locksandpath.endswith(u'.lock'):continuelog.debug(u"queuing existing file: {0}".format(path))profile.queue.put(path)