in Utf8Test.py [0:0]
def main():
# Arg Parse
parser = argparse.ArgumentParser(description='Utf8Test.py ')
parser.add_argument('--RootDir', '--rootdir', '--Rootdir', dest="RootDir", help="Path to Root Directory to search md files to test.", required=True, type=Valid_Dir)
parser.add_argument('-o', "--OutputLog", '--outputlog', dest="OutputLog", help="Create an output log file")
parser.add_argument("--debug", dest="debug", help="Output all debug messages to console", action="store_true", default=False)
args = parser.parse_args()
if(args.debug):
logging.getLogger().handlers[0].setLevel(logging.DEBUG)
# setup file based logging if outputReport specified
if(args.OutputLog):
if(len(args.OutputLog) < 2):
logging.critical("the output log file parameter is invalid")
return -2
# setup file based logging
filelogger = logging.FileHandler(filename=args.OutputLog, mode='w')
filelogger.setLevel(logging.DEBUG)
filelogger.setFormatter(formatter)
logging.getLogger('').addHandler(filelogger)
logging.info("Log Started: " + datetime.datetime.strftime(datetime.datetime.now(), "%A, %B %d, %Y %I:%M%p"))
error = 0
count = 0
EC = EncodingCheck()
for root, dirs, files in os.walk(args.RootDir):
for f in files:
if f.lower().endswith(".md"):
count += 1
p = os.path.join(root, f)
logging.info("Checking File: {%s}" % p)
if not EC.TestMdEncodingOk(p, "utf-8"):
error += 1
logging.info("Finished Processing {0} md files. Found {1} files with errors.".format(count, error))
return error