mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
added a basic validator check
This commit is contained in:
parent
c2f94afde4
commit
8e6ba54ccb
2 changed files with 35 additions and 3 deletions
22
etl/src/etl/utils/logger.py
Normal file
22
etl/src/etl/utils/logger.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
class Logger:
|
||||
def __init__(self, name, level=logging.INFO):
|
||||
# Create a custom logger
|
||||
self.logger = logging.getLogger(name)
|
||||
self.logger.setLevel(level)
|
||||
|
||||
# Create handlers
|
||||
c_handler = logging.StreamHandler()
|
||||
c_handler.setLevel(level)
|
||||
|
||||
# Create formatters and add it to handlers
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
c_handler.setFormatter(formatter)
|
||||
|
||||
# Add handlers to the logger
|
||||
self.logger.addHandler(c_handler)
|
||||
|
||||
def get_logger(self):
|
||||
return self.logger
|
||||
|
|
@ -1,12 +1,22 @@
|
|||
import os
|
||||
from utils.logger import Logger
|
||||
|
||||
class RetroHomeFileStructureValidator():
|
||||
def __init__(self, source_loc_path):
|
||||
self.source_path = source_loc_path
|
||||
self.correct_names = []
|
||||
self.incorrect_names = []
|
||||
self.logger = Logger(name='RetroHomeFileStructureValidator').get_logger()
|
||||
self.innocent = []
|
||||
self.guilty = []
|
||||
self.validate()
|
||||
|
||||
def validate(self):
|
||||
print("nothing to validate")
|
||||
self.logger.info(f"Starting File Structure Validation on '{self.source_path}'")
|
||||
|
||||
for filepath in os.listdir(self.source_path):
|
||||
if os.path.isdir(os.path.join(self.source_path, filepath)):
|
||||
self.logger.info(f"Its a file {filepath}")
|
||||
else:
|
||||
self.logger.warning(f"Found a file when expecting directory. Ignoring file {filepath}")
|
||||
|
||||
def valid_name(name):
|
||||
pass
|
||||
Loading…
Add table
Reference in a new issue