[sync] updated
This commit is contained in:
1 parent
40a5d09e78
commit
f38ddf8bd0
12 files changed
+285
-46
No files matched your search
@@ -1,7 +1,12 @@
|
||||
from sync.models import Model
|
||||
from utils.fn import lmap
|
||||
|
||||
|
||||
class Sync:
|
||||
@staticmethod
|
||||
def compile(document):
|
||||
return document.bake()
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -22,6 +27,9 @@ class Sync:
|
||||
if isinstance(document, list):
|
||||
return lmap(self.update, document)
|
||||
|
||||
if isinstance(document, Model):
|
||||
return self.update(self.compile(document))
|
||||
|
||||
q = {'id': document['id']}
|
||||
try:
|
||||
self.collection.update_one(q, {'$set': document}, upsert=True)
|
||||
@@ -30,9 +38,6 @@ class Sync:
|
||||
pass
|
||||
return None
|
||||
|
||||
def compile(self, document):
|
||||
return document
|
||||
|
||||
def query(self, q):
|
||||
return self.collection.find(q)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from tempfile import mkstemp
|
||||
|
||||
from sync.core import Sync
|
||||
from utils.fn import last_good, lmap
|
||||
from utils.hash import hash_file, hash_str
|
||||
from utils.hash import hash_str
|
||||
from utils.image import create_image
|
||||
from utils.image.resize import image_magick_pdf_to_img
|
||||
from utils.text.transform import url_encode_text, url_encode_file
|
||||
|
||||
Reference in new issue
Block a user