Get a list of Artifacts from yaml.
324600
def ArtifactsFromYaml(self, yaml_content):
    """"""
    raw_list = yaml.ParseMany(yaml_content)

    # TODO(hanuszczak): I am very sceptical about that "doing the right thing"
    # below. What are the real use cases?

    # Try to do the right thing with json/yaml formatted as a list.
    if (isinstance(raw_list, list) and len(raw_list) == 1 and
        isinstance(raw_list[0], list)):
      raw_list = raw_list[0]

    # Convert json into artifact and validate.
    valid_artifacts = []
    for artifact_dict in raw_list:
      # In this case we are feeding parameters directly from potentially
      # untrusted yaml/json to our RDFValue class. However, safe_load ensures
      # these are all primitive types as long as there is no other
      # deserialization involved, and we are passing these into protobuf
      # primitive types.
      try:
        artifact_value = rdf_artifacts.Artifact(**artifact_dict)
        valid_artifacts.append(artifact_value)
      except (TypeError, AttributeError, type_info.TypeValueError) as e:
        name = artifact_dict.get("name")
        raise rdf_artifacts.ArtifactDefinitionError(
            name, "invalid definition", cause=e)

    return valid_artifacts
1277113
def extract_deps(bundles, log=None):
    """"""
    def _flatten(bundle):
        deps = []
        if hasattr(bundle, 'npm'):
            deps.append(bundle.npm)
        for content in bundle.contents:
            if isinstance(content, BundleBase):
                deps.extend(_flatten(content))
        return deps

    flatten_deps = []
    for bundle in bundles:
        flatten_deps.extend(_flatten(bundle))

    packages = defaultdict(list)
    for dep in flatten_deps:
        for pkg, version in dep.items():
            packages[pkg].append(version)

    deps = {}
    for package, versions in packages.items():
        deps[package] = semver.max_satisfying(versions, '*', True)

        if log and len(versions) > 1:
            log('Warn: {0} version {1} resolved to: {2}'.format(
                repr(package), versions, repr(deps[package])
            ))

    return deps
893055
def get_tools(self) -> list:
        """"""
        tools = "flake8,pylint,vulture,pyroma,isort,yapf,safety,dodgy,pytest,pypi".split(
            ",")
        print("Available tools: {0}".format(",".join(tools)))
        answer = ask_list("What tools would you like to use?",
                          ["flake8", "pytest"])

        if any(tool not in tools for tool in answer):
            print("Invalid answer, retry.")
            self.get_tools()
        return answer
920580
def artifacts(self):
        
        if self._artifact_manager is None:
            self._artifact_manager = ArtifactManager(session=self._session)
        return self._artifact_manager
352203
def ReadAllArtifacts(self):
    """"""
    artifacts = []

    for artifact in itervalues(self.artifacts):
      artifacts.append(artifact.Copy())

    return artifacts
65256
def get_docs_sources_from_ES(self):
        """"""
        docs = [doc for doc, _, _, get_from_ES in self.doc_to_update if get_from_ES]
        if docs:
            documents = self.docman.elastic.mget(body={"docs": docs}, realtime=True)
            return iter(documents["docs"])
        else:
            return iter([])
1025511
def _parse_args(arg):
    '''
    
    '''
    yaml_args = salt.utils.args.yamlify_arg(arg)

    if yaml_args is None:
        return []
    elif not isinstance(yaml_args, list):
        return [yaml_args]
    else:
        return yaml_args
1352714
def get_yaml_files_at_env_root(self):
        """"""
        yaml_files = glob.glob(
            os.path.join(self.env_root, '*.yaml')
        )
        yml_files = glob.glob(
            os.path.join(self.env_root, '*.yml')
        )
        return yaml_files + yml_files
1141171
def render_fetch_maven_artifacts(self):
        """"""
        phase = 'prebuild_plugins'
        plugin = 'fetch_maven_artifacts'
        if not self.dj.dock_json_has_plugin_conf(phase, plugin):
            return

        koji_hub = self.spec.kojihub.value
        koji_root = self.spec.kojiroot.value

        if not koji_hub and not koji_root:
            logger.info('Removing %s because kojihub and kojiroot were not specified', plugin)
            self.dj.remove_plugin(phase, plugin)
            return

        self.dj.dock_json_set_arg(phase, plugin, 'koji_hub', koji_hub)
        self.dj.dock_json_set_arg(phase, plugin, "koji_root", koji_root)

        if self.spec.artifacts_allowed_domains.value:
            self.dj.dock_json_set_arg(phase, plugin, 'allowed_domains',
                                      self.spec.artifacts_allowed_domains.value)
365079
def yaml_to_job_list(yaml_file, base_dir):
    """"""
    yaml_dict = get_yaml_dict(yaml_file)
    job_list = []
    for key, value in yaml_dict.items():
        job_list.append((value, rel_to_cwd(base_dir, key)))

    return job_list
1216718
async def get_artifacts(self):
        
        host_manager = await self.env.connect(self._host_manager,
                                              timeout=TIMEOUT)
        artifacts = await host_manager.get_artifacts()
        return artifacts
390204
def Handle(self, args, token=None):
    """"""

    # Get all artifacts that aren't Bootstrap and aren't the base class.
    artifacts_list = sorted(
        artifact_registry.REGISTRY.GetArtifacts(
            reload_datastore_artifacts=True),
        key=lambda art: art.name)

    total_count = len(artifacts_list)

    if args.count:
      artifacts_list = artifacts_list[args.offset:args.offset + args.count]
    else:
      artifacts_list = artifacts_list[args.offset:]

    descriptors = self.BuildArtifactDescriptors(artifacts_list)
    return ApiListArtifactsResult(items=descriptors, total_count=total_count)
706072
def GetArtifactsDependenciesClosure(name_list, os_name=None):
  """"""

  artifacts = set(REGISTRY.GetArtifacts(os_name=os_name, name_list=name_list))

  dependencies = set()
  for art in artifacts:
    dependencies.update(GetArtifactDependencies(art, recursive=True))
  if dependencies:
    artifacts.update(
        set(
            REGISTRY.GetArtifacts(
                os_name=os_name, name_list=list(dependencies))))

  return artifacts
1091727
def list(self, path=None, with_metadata=False, include_partitions=False):
        """"""

        l = {}
        for upstream in [self.alternate, self.upstream]:

            for k, v in upstream.list(path, with_metadata, include_partitions).items():
                upstreams = (l[k]['caches'] if k in l else []) + \
                    v.get('caches', upstream.repo_id)

                l[k] = v
                l[k]['caches'] = upstreams

        return l
498229
def get_artifact(self):
        """"""
        self.artifact[self.parser.name] = self.parser.get_artifact()
        return self.artifact
1198695
def extract_front_matter(source)
      fm_regex = /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m

      return [{}, source] unless match = source.match(fm_regex)

      source = source.sub(fm_regex, "")

      begin
        data = (YAML.safe_load(match[1]) || {}).inject({}) do |memo, (k, v)|
          memo[k.to_sym] = v
          memo
        end
      rescue *YAML_ERRORS => e
        puts "YAML Exception: #{e.message}"
        return false
      end

      [data, source]
    rescue
      [{}, source]
    end
1266324
def list_all(self):
        '''
        
        '''
        if isinstance(self.minion.opts['reactor'], six.string_types):
            log.debug('Reading reactors from yaml %s', self.opts['reactor'])
            try:
                with salt.utils.files.fopen(self.opts['reactor']) as fp_:
                    react_map = salt.utils.yaml.safe_load(fp_)
            except (OSError, IOError):
                log.error('Failed to read reactor map: "%s"', self.opts['reactor'])
            except Exception:
                log.error(
                    'Failed to parse YAML in reactor map: "%s"',
                    self.opts['reactor']
                )
        else:
            log.debug('Not reading reactors from yaml')
            react_map = self.minion.opts['reactor']
        return react_map