#!/usr/bin/env python3
+import logging
import os
from uuid import uuid4
import kiosk_constants
+
+logger = logging.getLogger(__file__)
+
+
class file_writer:
"""Helper context to write a pages file."""
self.xforms = [file_writer.remove_tricky_unicode]
self.xforms.extend(transformations)
self.f = None
+ logger.info(f"Writing {self.temp_filename}...")
@staticmethod
def remove_tricky_unicode(x: str) -> str:
def __exit__(self, exc_type, exc_value, exc_traceback):
self.close()
+ logger.info(f"Copying {self.temp_filename} to {self.full_filename}")
cmd = f'/bin/mv -f {self.temp_filename} "{self.full_filename}"'
os.system(cmd)
print(cmd)
# Test
-#def toupper(x):
+# def toupper(x):
# return x.upper()
-#with file_writer("test", transformations=[toupper]) as fw:
+# with file_writer("test", transformations=[toupper]) as fw:
# fw.write(u"Another test!!")