mirror of
https://git.zavage.net/Zavage-Software/smileyface.git
synced 2025-05-09 18:59:19 -06:00
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import datetime
|
|
import os
|
|
|
|
from smileyface import myutil, structs
|
|
|
|
|
|
class LocalFs:
|
|
def __init__(self, ctx, datalayer):
|
|
self.ctx = ctx
|
|
self.datalayer = datalayer
|
|
|
|
def create_db_table(self):
|
|
self.datalayer.create_tables()
|
|
|
|
def load_md5s(self):
|
|
paks_dir = self.ctx.config["app"]["project_dir"]
|
|
maps_dir = os.path.join(paks_dir, "files", "maps")
|
|
print(maps_dir)
|
|
self._load_md5_one_dir(maps_dir)
|
|
|
|
muts_dir = os.path.join(paks_dir, "files", "mutators")
|
|
print(muts_dir)
|
|
self._load_md5_one_dir(muts_dir)
|
|
|
|
def _load_md5_one_dir(self, dirname):
|
|
for fn in os.listdir(dirname):
|
|
fullpath = os.path.join(dirname, fn)
|
|
print(fn)
|
|
md5sum = myutil.md5_file(fullpath)
|
|
print(md5sum)
|
|
|
|
record = structs.FilePak()
|
|
record.fullpath = fullpath
|
|
record.filename = fn
|
|
record.md5sum = md5sum
|
|
record.record_created_at = datetime.datetime.now()
|
|
record.record_updated_at = datetime.datetime.now()
|
|
|
|
self.datalayer.insert_filepak_record(record)
|
|
|
|
def print_invalid_filepaks(self):
|
|
filepaks = self.datalayer.query_invalid_filepaks()
|
|
for pak in filepaks:
|
|
print(pak)
|