sync cleanup

This commit is contained in:
tmshv committed 2020-02-29 01:19:04 +03:00
1 parent 263f18a1df
commit de20ed726f
4 files changed
+2 -43

No files matched your search

-1
View File
@@ -91,7 +91,6 @@ provider_root = value('provider')['root'] # env('SYNC_PROVIDER', 'fs')
f = abs_fn(provider_root)
dir_documents = './Documents'
dir_articles = './Articles'
dir_pages = './Pages'
+1 -7
View File
@@ -3,7 +3,7 @@ from tempfile import mkstemp
import settings
from db import collection
from sync.data import scan_subdirs, request
from sync.data import request
from sync.models import Model
from sync.models.DocumentPreviewImage import DocumentPreviewImage
from utils.hash import hash_str, md5
@@ -25,12 +25,6 @@ class Document(Model):
async def delete(query):
return store.find_one_and_delete(query)
@staticmethod
async def scan(provider):
scan_dir = settings.dir_documents
paths = scan_subdirs(provider, '.pdf', scan_dir)
return [Document.read_path(provider, path) for path in paths]
@staticmethod
def read_path(provider, path):
name = os.path.basename(path)
+1 -8
View File
@@ -7,7 +7,7 @@ from typing import Optional, List
import settings
from db import collection
from sync.data import request, list_images
from sync.data import request
from sync.models import Model
from utils.hash import md5, hash_str
from utils.image import image_magick_resize
@@ -54,13 +54,6 @@ class Image(Model):
return img
@staticmethod
async def scan(provider):
scan_path = settings.dir_images
documents = list_images(provider, scan_path)
return [Image.read_path(provider, i) for i in documents]
@staticmethod
def read_path(provider, path):
return Image(
-27
View File
@@ -1,27 +0,0 @@
import unittest
import settings
from sync.data import scan_subdirs
from sync.data.fs import FSProvider
class MyTestCase(unittest.TestCase):
def test_document(self):
p = FSProvider(settings.dir_documents)
documents = scan_subdirs(p, '.pdf')
# documents = lmap(
# lambda document: create_document(p, document),
# documents
# )
self.assertEqual(True, True)
def test_scan(self):
p = FSProvider(settings.dir_documents)
documents = scan_subdirs(p, '.pdf')
self.assertIsInstance(documents, list)
if __name__ == '__main__':
unittest.main()