[sync] updated

This commit is contained in:
tmshv committed 2016-09-13 00:17:41 +03:00
1 parent 40a5d09e78
commit f38ddf8bd0
12 files changed
+285 -46

No files matched your search

+29 -3
View File
@@ -1,6 +1,8 @@
import os
from io import BytesIO
from utils.fn import combine, lmap
class Provider:
def __init__(self, root):
@@ -29,12 +31,36 @@ class Provider:
return 0
def get_abs(self, path):
abs = os.path.join(self.root, path)
return os.path.normpath(abs)
a = os.path.join(self.root, path)
return os.path.normpath(a)
def get_rel(self, path):
rel = os.path.relpath(path, self.root)
return rel
def is_dir(self, path):
return False
return False
def scan_subdirs(provider, ext, path='.'):
"""
Creates flat list of files with specific ext
It iterates only one level of sub directories
:param provider: instance of Provider
:param ext: file extension like .jpg of .pdf for file filtering
:param path: optional path prefix
:return: list of files relative to provider.root
"""
items = provider.scan(path)
items = list(filter(
lambda i: provider.is_dir(i),
items
))
items = lmap(
lambda folder: provider.type_filter(folder, ext),
items
)
items = combine(items)
return items