sync update: + data provider; refactoring; documents update

This commit is contained in:
tmshv committed 2016-08-05 02:04:06 +03:00
1 parent 144e69e6c4
commit 927674e53e
9 files changed
+311 -229

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import os
from glob import glob
from shutil import copyfile
from sync.data import Provider
from utils.hash import hash_file
class FSProvider(Provider):
def open(self, path, mode):
return open(self.get_abs(path), mode)
def scan(self, path):
return os.scandir(self.get_abs(path))
def glob(self, pattr):
return glob(self.get_abs(pattr))
def hash(self, path):
return hash_file(self.get_abs(path))
def copy(self, path, out):
file = self.get_abs(path)
return copyfile(file, out)
def size(self, path):
file = self.get_abs(path)
return os.path.getsize(file)