Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added argument functionality #14

Merged
merged 6 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions jsonmerge_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,38 @@
@author: GRENTOR
"""
import os
import argparse
import logging
#from tqdm import tqdm
from merge_files import Merge

parser = argparse.ArgumentParser(description="link-check is a broken link identifier")
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument('-ip',
help="Input prefix",
required=True)
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument('-op',
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
help="Output prefix",
required=True)
parser.add_argument('-maxFileSize',
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
help="The maximum file size (in bytes) that each merged file should have",
required=True)
parser.add_argument('-filepath',
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
help="Path to directory where all json files are stored",
required=True)
parser.add_argument('-log_level',
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
help="The logging level - defaults to INFO [INFO, DEBUG, ERROR]",
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
default="INFO")
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved

args = parser.parse_args()
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
logger = logging.getLogger(__name__)
def configure_logger():
"""
configures the logger object
"""
logging.basicConfig(filename='output.log', level=logging.INFO)
logging.basicConfig(filename='output.log')
if not logger.handlers:
# Prevent logging from propagating to the root logger
logger.setLevel(args.log_level)
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
logger.propagate = 0
log_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
stream_handler = logging.StreamHandler()
Expand Down Expand Up @@ -51,14 +72,14 @@ def main():
"""
try:
configure_logger()
data_dir = input('Folder Path: ')
data_dir = args.filepath
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
if not os.path.exists(data_dir):
raise FolderNotFoundError
input_prefix = input('I/P Prefix: ')
input_prefix = args.ip
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
if not os.path.isfile('{}{}'.format(path_creator(data_dir, input_prefix), '1.json')):
raise FileNotFoundError
output_prefix = input('O/P Prefix: ')
max_file_size = int(input('Max File Size: '))
output_prefix = args.op
max_file_size = int(args.maxFileSize)
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved

merge = Merge(path_creator(data_dir, input_prefix),
path_creator(data_dir, output_prefix),
MLJBrackett marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jsonmerge
genson
argparse