Skip to content
Extraits de code Groupes Projets
Valider be54440c rédigé par cbay's avatar cbay
Parcourir les fichiers

import_logs: added include_path options.

parent a163b75a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -377,6 +377,14 @@ class Configuration(object): ...@@ -377,6 +377,14 @@ class Configuration(object):
'--exclude-path-from', dest='exclude_path_from', '--exclude-path-from', dest='exclude_path_from',
help="Each line from this file is a path to exclude" help="Each line from this file is a path to exclude"
) )
option_parser.add_option(
'--include-path', dest='included_paths', action='append', default=[],
help="Paths to include. Can be specified multiple times. If not specified, all paths are included."
)
option_parser.add_option(
'--include-path-from', dest='include_path_from',
help="Each line from this file is a path to include"
)
option_parser.add_option( option_parser.add_option(
'--useragent-exclude', dest='excluded_useragents', '--useragent-exclude', dest='excluded_useragents',
action='append', default=[], action='append', default=[],
...@@ -510,6 +518,12 @@ class Configuration(object): ...@@ -510,6 +518,12 @@ class Configuration(object):
if self.options.excluded_paths: if self.options.excluded_paths:
logging.debug('Excluded paths: %s', ' '.join(self.options.excluded_paths)) logging.debug('Excluded paths: %s', ' '.join(self.options.excluded_paths))
if self.options.include_path_from:
paths = [path.strip() for path in open(self.options.include_path_from).readlines()]
self.options.included_paths.extend(path for path in paths if len(path) > 0)
if self.options.included_paths:
logging.debug('Included paths: %s', ' '.join(self.options.included_paths))
if self.options.hostnames: if self.options.hostnames:
logging.debug('Accepted hostnames: %s', ', '.join(self.options.hostnames)) logging.debug('Accepted hostnames: %s', ', '.join(self.options.hostnames))
else: else:
...@@ -1399,6 +1413,12 @@ class Parser(object): ...@@ -1399,6 +1413,12 @@ class Parser(object):
for excluded_path in config.options.excluded_paths: for excluded_path in config.options.excluded_paths:
if fnmatch.fnmatch(hit.path, excluded_path): if fnmatch.fnmatch(hit.path, excluded_path):
return False return False
# By default, all paths are included.
if config.options.included_paths:
for included_path in config.options.included_paths:
if fnmatch.fnmatch(hit.path, included_path):
return True
return False
return True return True
@staticmethod @staticmethod
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter