From 4c50fb154dd5767d4e889e15068ad9639588adfb Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 30 Jul 2019 23:33:26 +0200 Subject: [PATCH] [DEV] add a path filter in the island request --- island/__init__.py | 10 ++++++++++ island/env.py | 20 ++++++++++++++++++++ island/manifest.py | 3 +++ 3 files changed, 33 insertions(+) diff --git a/island/__init__.py b/island/__init__.py index 8972ee4..c071567 100755 --- a/island/__init__.py +++ b/island/__init__.py @@ -75,6 +75,7 @@ my_args.add("v", "verbose", list=[ ], desc="display debug level (verbose) default =2") my_args.add("c", "color", desc="Display message in color") my_args.add("n", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest") +my_args.add("F", "filter", haveParam=True, desc="Filter the action on a list of path or subpath: -f library") my_args.add("f", "folder", haveParam=False, desc="Display the folder instead of the git repository name") my_args.add("w", "wait", haveParam=True, desc="Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + str(env.get_wait_between_sever_command()) + ")") my_args.set_stop_at(actions.get_list_of_action()) @@ -144,6 +145,10 @@ def parse_generic_arg(argument, active): else: debug.disable_color() return True + elif argument.get_option_name() == "filter": + if active == True: + env.set_filter_command(str(argument.get_arg())) + return True elif argument.get_option_name() == "no-fetch-manifest": if active == False: env.set_fetch_manifest(False) @@ -185,6 +190,11 @@ if os.path.isfile(config_file) == True: debug.debug(" get default config 'get_default_wait' val='" + str(data) + "'") parse_generic_arg(arg_element.ArgElement("wait", str(data)), True) + if "get_default_filter" in dir(configuration_file): + data = configuration_file.get_default_filter() + debug.debug(" get default config 'get_default_filter' val='" + str(data) + "'") + parse_generic_arg(arg_element.ArgElement("filter", str(data)), True) + # parse default unique argument: diff --git a/island/env.py b/island/env.py index b843c88..7e68370 100644 --- a/island/env.py +++ b/island/env.py @@ -47,6 +47,26 @@ def get_wait_between_sever_command(): global wait_between_sever_command return wait_between_sever_command +filter_command = "" + +def set_filter_command(val): + global filter_command + filter_command = val + +def get_filter_command(): + global filter_command + return filter_command + +def need_process_with_filter(data): + global filter_command + if filter_command == "": + return True + if len(data) < len(filter_command): + return False + if data[:len(filter_command)] == filter_command: + return True + return False + display_folder_instead_of_git_name = True def set_display_folder_instead_of_git_name(val): diff --git a/island/manifest.py b/island/manifest.py index 4d52e31..3cc3c2c 100644 --- a/island/manifest.py +++ b/island/manifest.py @@ -243,6 +243,9 @@ class Manifest(): # add all local project for elem in self.projects: debug.verbose("parse element " + str(elem)) + if env.need_process_with_filter(elem["name"]) == False: + debug.info("Filter repository: " + str(elem["name"])) + continue conf = RepoConfig() conf.name = elem["name"] conf.path = self._create_path_with_elem(elem)