|
@@ -36,18 +36,23 @@ class Plugin(core.api.Plugin, core.api.Parent, core.api.IConfigurable, core.api.
|
|
help="If the option is set (True), sub-directories are not processed [default: %default]")
|
|
help="If the option is set (True), sub-directories are not processed [default: %default]")
|
|
parser.add_option("--general.exclude-files", default=r'^[.]',
|
|
parser.add_option("--general.exclude-files", default=r'^[.]',
|
|
help="Defines the pattern to exclude files from processing [default: %default]")
|
|
help="Defines the pattern to exclude files from processing [default: %default]")
|
|
- parser.add_option("--general.proctime.on", action="store_true", default=False,
|
|
|
|
- help="If the option is set (True), the tool measures processing time per every file [default: %default]")
|
|
|
|
|
|
+ parser.add_option("--general.proctime-on", action="store_true", default=False,
|
|
|
|
+ help="If the option is set (True), the tool measures processing time per file [default: %default]")
|
|
|
|
+ parser.add_option("--general.procerrors-on", action="store_true", default=False,
|
|
|
|
+ help="If the option is set (True), the tool counts number of processing/parsing errors per file [default: %default]")
|
|
|
|
|
|
def configure(self, options):
|
|
def configure(self, options):
|
|
self.non_recursively = options.__dict__['general.non_recursively']
|
|
self.non_recursively = options.__dict__['general.non_recursively']
|
|
self.add_exclude_rule(re.compile(options.__dict__['general.exclude_files']))
|
|
self.add_exclude_rule(re.compile(options.__dict__['general.exclude_files']))
|
|
- self.is_proctime_enabled = options.__dict__['general.proctime.on']
|
|
|
|
|
|
+ self.is_proctime_enabled = options.__dict__['general.proctime_on']
|
|
|
|
+ self.is_procerrors_enabled = options.__dict__['general.procerrors_on']
|
|
|
|
|
|
def initialize(self):
|
|
def initialize(self):
|
|
|
|
+ namespace = self.get_plugin_loader().get_database_loader().create_namespace('general')
|
|
if self.is_proctime_enabled == True:
|
|
if self.is_proctime_enabled == True:
|
|
- namespace = self.get_plugin_loader().get_database_loader().create_namespace('general')
|
|
|
|
- namespace.add_field('proctime', self.measure_proctime_type)
|
|
|
|
|
|
+ namespace.add_field('proctime', float)
|
|
|
|
+ if self.is_procerrors_enabled == True:
|
|
|
|
+ namespace.add_field('procerrors', int)
|
|
|
|
|
|
def run(self, args):
|
|
def run(self, args):
|
|
if len(args) == 0:
|
|
if len(args) == 0:
|
|
@@ -91,9 +96,11 @@ class DirectoryReader():
|
|
checksum = binascii.crc32(text) & 0xffffffff # to match python 3
|
|
checksum = binascii.crc32(text) & 0xffffffff # to match python 3
|
|
|
|
|
|
(data, is_updated) = plugin.get_plugin_loader().get_database_loader().create_file_data(full_path, checksum, text)
|
|
(data, is_updated) = plugin.get_plugin_loader().get_database_loader().create_file_data(full_path, checksum, text)
|
|
- parser.process(plugin, data, is_updated)
|
|
|
|
|
|
+ procerrors = parser.process(plugin, data, is_updated)
|
|
if plugin.is_proctime_enabled == True:
|
|
if plugin.is_proctime_enabled == True:
|
|
data.set_data('general', 'proctime', time.time() - ts)
|
|
data.set_data('general', 'proctime', time.time() - ts)
|
|
|
|
+ if plugin.is_procerrors_enabled == True and procerrors != None and procerrors != 0:
|
|
|
|
+ data.set_data('general', 'procerrors', procerrors)
|
|
plugin.get_plugin_loader().get_database_loader().save_file_data(data)
|
|
plugin.get_plugin_loader().get_database_loader().save_file_data(data)
|
|
logging.debug("-" * 60)
|
|
logging.debug("-" * 60)
|
|
else:
|
|
else:
|