2023-06-04 04:28:07 +02:00
|
|
|
import os
|
|
|
|
from .filetypes import FILETYPES
|
2023-06-17 01:01:27 +02:00
|
|
|
from .utils import move_source
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
RESERVED = ['__HOTDIR__.md']
|
|
|
|
def watch_for_changes(directory):
|
|
|
|
for raw_doc in os.listdir(directory):
|
|
|
|
if os.path.isdir(f"{directory}/{raw_doc}") or raw_doc in RESERVED: continue
|
|
|
|
|
|
|
|
filename, fileext = os.path.splitext(raw_doc)
|
|
|
|
if filename in ['.DS_Store'] or fileext == '': continue
|
|
|
|
|
|
|
|
if fileext not in FILETYPES.keys():
|
2023-06-17 01:01:27 +02:00
|
|
|
print(f"{fileext} not a supported file type for conversion. Removing from hot directory.")
|
|
|
|
move_source(new_destination_filename=raw_doc, failed=True)
|
2023-06-04 04:28:07 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
FILETYPES[fileext](
|
|
|
|
directory=directory,
|
|
|
|
filename=filename,
|
|
|
|
ext=fileext,
|
|
|
|
)
|