# # Metrix++, Copyright 2009-2019, Metrix++ Project # Link: https://github.com/metrixplusplus/metrixplusplus # # This file is a part of Metrix++ Tool. # import logging import cgi import mpp.api import mpp.utils class Plugin(mpp.api.Plugin, mpp.api.IConfigurable, mpp.api.IRunable): def declare_configuration(self, parser): parser.add_option("-m", "--mode", default='dumphtml', choices=['dumphtml'], help="'dumphtml' - prints html code with code highlights for each given path [default: %default]") def configure(self, options): self.mode = options.__dict__['mode'] def run(self, args): loader = self.get_plugin('mpp.dbf').get_loader() if self.mode == 'dumphtml': return dumphtml(args, loader) assert(False) def dumphtml(args, loader): exit_code = 0 result = "" result += '
' for path in args: path = mpp.utils.preprocess_path(path) data = loader.load_file_data(path) if data == None: mpp.utils.report_bad_path(path) exit_code += 1 continue file_name = data.get_path() fh = open(file_name, 'r') if fh == None: logging.error("can not open file '" + path + "' for reading") exit_code += 1 continue text = fh.read() fh.close() # TODO fix highlightning of markers # result += '