forked from LiveCarta/LiveCartaMeta
21 lines
566 B
Python
21 lines
566 B
Python
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) |