is_normal_mj_file.py 571 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/env python3
import argparse

import sys
from os.path import dirname, realpath
p = dirname(realpath(__file__))
sys.path.append(p)
from preproc.preprocessor import PreProcessor, PreProcessorError, is_importable_file
import logging

parser = argparse.ArgumentParser(description="Is normal MiniJava file?", add_help=True)
parser.add_argument("file", metavar="FILE", help="File to check")
file = parser.parse_args().file

try:
    ret = is_importable_file(file)
    sys.exit(1 if ret else 0)
except PreProcessorError as ex:
    logging.exception("")
    sys.exit(1)