forked from LiveCarta/LiveCartaMeta
first commit
This commit is contained in:
21
components/FileComponent.py
Normal file
21
components/FileComponent.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from models.File import File
|
||||
|
||||
|
||||
class FileComponent(BaseModel):
|
||||
|
||||
local_files_path: str
|
||||
|
||||
def get_parsed_files(self, source_name):
|
||||
files = [{"file": self.local_files_path + f.file_path, "hash": f.file_hash}
|
||||
for f in File.objects(source=source_name)]
|
||||
return files
|
||||
|
||||
def add_parsed_file(self, source, path, hash, time):
|
||||
return File(source=source, file_path=path, file_hash=hash, file_updated_at=time).save()
|
||||
|
||||
def remove_file(self, file):
|
||||
os.remove(file)
|
||||
Reference in New Issue
Block a user