AIL-framework/tools/file_dir_importer.py

41 lines
1007 B
Python
Raw Permalink Normal View History

2018-05-04 13:53:29 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2023-05-22 15:31:48 +02:00
"""
DIR/File Importer Helper
================
2023-05-22 15:31:48 +02:00
Import Content
2023-05-22 15:31:48 +02:00
"""
2023-05-22 15:31:48 +02:00
import argparse
import os
import sys
2018-04-16 14:50:04 +02:00
2023-05-22 15:31:48 +02:00
sys.path.append(os.environ['AIL_BIN'])
##################################
# Import Project packages
##################################
from importer import FileImporter
if __name__ == "__main__":
2023-05-22 15:31:48 +02:00
parser = argparse.ArgumentParser(description='Directory or file importer')
parser.add_argument('-d', '--directory', type=str, help='Root directory to import')
parser.add_argument('-f', '--file', type=str, help='File to import')
args = parser.parse_args()
2023-05-22 15:31:48 +02:00
if not args.directory and not args.file:
parser.print_help()
sys.exit(0)
2023-05-22 15:31:48 +02:00
if args.directory:
dir_path = args.directory
dir_importer = FileImporter.DirImporter()
dir_importer.importer(dir_path)
2023-05-22 15:31:48 +02:00
if args.file:
file_path = args.file
file_importer = FileImporter.FileImporter()
file_importer.importer(file_path)