sync update: moving to ./sync.py as entry point
This commit is contained in:
1 parent
6f144fb6de
commit
13a3a02613
8 files changed
+456
-83
No files matched your search
@@ -4,18 +4,31 @@ from glob import glob
|
||||
from shutil import copyfile
|
||||
|
||||
from sync.data import Provider
|
||||
from utils.fn import lmap
|
||||
from utils.hash import hash_file
|
||||
|
||||
|
||||
class FSProvider(Provider):
|
||||
def open(self, path, mode):
|
||||
return open(self.get_abs(path), mode)
|
||||
def open(self, path):
|
||||
return open(self.get_abs(path), 'rb')
|
||||
|
||||
def scan(self, path):
|
||||
return os.scandir(self.get_abs(path))
|
||||
return lmap(
|
||||
self.get_rel,
|
||||
map(
|
||||
lambda i: i.path,
|
||||
os.scandir(self.get_abs(path))
|
||||
)
|
||||
)
|
||||
|
||||
def glob(self, pattr):
|
||||
return glob(self.get_abs(pattr))
|
||||
return lmap(self.get_rel, glob(self.get_abs(pattr)))
|
||||
|
||||
def type_filter(self, path, ext):
|
||||
return list(filter(
|
||||
lambda fn: os.path.splitext(fn)[1] == ext,
|
||||
self.scan(path)
|
||||
))
|
||||
|
||||
def hash(self, path):
|
||||
return hash_file(self.get_abs(path))
|
||||
@@ -28,3 +41,6 @@ class FSProvider(Provider):
|
||||
file = self.get_abs(path)
|
||||
return os.path.getsize(file)
|
||||
|
||||
def is_dir(self, path):
|
||||
return os.path.isdir(self.get_abs(path))
|
||||
|
||||
Reference in new issue
Block a user