Exemple #1
0
def get_extension_commands():
    extensions = extension_commands()
    extension_names = set()

    for path, specs in extensions.items():
        # Filter out attempts to shadow built-in commands as well as
        # commands which have names which are already used.
        filtered = []
        for spec in specs:
            if spec.name in BUILTIN_COMMAND_NAMES:
                log.wrn(
                    'ignoring project {} extension command {};'.format(
                        spec.project.name, spec.name),
                    'this is a built in command')
                continue
            if spec.name in extension_names:
                log.wrn(
                    'ignoring project {} extension command "{}";'.format(
                        spec.project.name, spec.name),
                    'command "{}" already defined as extension command'.format(
                        spec.name))
                continue
            filtered.append(spec)
            extension_names.add(spec.name)
        extensions[path] = filtered

    return extensions
Exemple #2
0
    def load_extension_specs(self):
        if self.manifest is None:
            # "None" means "extensions could not be determined".
            # Leaving this an empty dict would mean "there are no
            # extensions", which is different.
            self.extensions = None
            return

        path_specs = extension_commands(manifest=self.manifest)
        extension_names = set()

        for path, specs in path_specs.items():
            # Filter out attempts to shadow built-in commands as well as
            # command names which are already used.

            filtered = []
            for spec in specs:
                if spec.name in self.builtins:
                    log.wrn(f'ignoring project {spec.project.name} '
                            f'extension command "{spec.name}"; '
                            'this is a built in command')
                    continue
                if spec.name in extension_names:
                    log.wrn(f'ignoring project {spec.project.name} '
                            f'extension command "{spec.name}"; '
                            f'command "{spec.name}" is '
                            'already defined as extension command')
                    continue

                filtered.append(spec)
                extension_names.add(spec.name)
                self.extensions[spec.name] = spec

            self.extension_groups[path] = filtered