repos-cmp/repos_cmp/utils.py
Ivan A. Melnikov b446b5f37c Add some code
Python code copyed from port-compare commit
153130a18f2ce80d8f9646ab94b0f9eeb0e994de
with minor modifications.

Runner script added
2023-05-19 13:47:29 +04:00

40 lines
890 B
Python

import json
import logging
import os
import sys
LOG = logging.getLogger(__name__)
def readline_setup():
import atexit
import readline
readline.parse_and_bind('tab:complete')
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
def logging_setup(loglevel=logging.INFO):
logging.basicConfig(
format='%(asctime)s %(levelname)-5s %(name)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
stream=sys.stderr, level=loglevel)
def interactive_setup(readline=True, loglevel=logging.INFO):
logging_setup()
if readline:
readline_setup()
config = sys.argv[1]
LOG.info("Loading configuraition file: %s", config)
with open(config, 'r') as f:
return json.load(f)