[sync] updated
This commit is contained in:
1 parent
40a5d09e78
commit
f38ddf8bd0
12 files changed
+285
-46
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user