def activate_multiple(self, objects, iobjects): ## Do case-insentive matching ## As a special case, understand '**/' prefix as recurive def get_subcatalog_matches(subcatalog, pat, recursive, paths): if len(paths) > 1000: raise OperationError("Globbing wayy too many objects") for content in subcatalog.content_source().get_leaves(): if recursive and content.has_content(): get_subcatalog_matches(content, pat, recursive, paths) else: if re.match(pat, str(content), flags=re.I): paths.append(content) paths = [] for iobj in iobjects: glob = iobj.object if glob.startswith('**/'): glob = glob[3:] recursive = True else: recursive = False pat = fnmatch.translate(glob) for obj in objects: get_subcatalog_matches(obj, pat, recursive, paths) if paths: return MultipleLeaf(paths)
def _make_retvalue(res, values): "Construct a return value for type res" if res == RESULT_SOURCE: return values[0] if len(values) == 1 else MultiSource(values) if res == RESULT_OBJECT: return values[0] if len(values) == 1 else MultipleLeaf(values) if res == RESULT_ASYNC: # Register all tasks now, and return None upwards for task in values: self.output_debug("Registering async task", task) self.task_runner.add_task(task) return None
def _exec_no_show_result(composedleaf): pretty.print_debug(__name__, "Evaluating command", composedleaf) obj, action, iobj = composedleaf.object ret = commandexec.activate_action(None, *composedleaf.object) result_type = commandexec.parse_action_result(action, ret) if result_type == commandexec.RESULT_OBJECT: return ret if result_type == commandexec.RESULT_SOURCE: leaves = list(ret.get_leaves()) if not leaves: return if len(leaves) == 1: return leaves[0] else: return MultipleLeaf(leaves)
def __init__(self, paths): files = [FileLeaf(path) for path in paths] MultipleLeaf.__init__(self, files, _("Clipboard Files"))
def __init__(self, paths): files = [FileLeaf(path) for path in paths] MultipleLeaf.__init__(self, files, _("Selected Files"))