first running version

master
Nicolò Balzarotti 2018-08-20 11:27:32 +02:00
commit 28911accee
1 changed files with 30 additions and 0 deletions

30
src/run.py Normal file
View File

@ -0,0 +1,30 @@
import os
import config
def scan(path: str, ignore_excluded: bool = False):
path = os.path.expanduser(path)
if config.verbosity > 0:
print("Scanning: " + path)
for root, subdirs, files in os.walk(path):
if (not ignore_excluded) and isexcluded(root):
if config.verbosity > 1:
print("Ignoring: " + root)
continue
if len(files) > config.maxmimum_file_number:
if config.verbosity > 0:
print("Too many " + "(" + str(len(files)) + ")" +
" files in: " + root)
return True
def isexcluded(path: str):
dirname = os.path.basename(path) in config.excluded_dir_names
dirnameinside = any(map(lambda x: "/" + x + "/" in path,
config.excluded_dir_names))
fullname = any(map(lambda l: path.startswith(l), excluded))
return dirname or fullname or dirnameinside
excluded = list(map(os.path.expanduser, config.excluded_dirs))
list(map(scan, config.watched_dirs))