当前位置: 首页>>代码示例>>Python>>正文


Python yaml.load_all方法代码示例

本文整理汇总了Python中yaml.load_all方法的典型用法代码示例。如果您正苦于以下问题:Python yaml.load_all方法的具体用法?Python yaml.load_all怎么用?Python yaml.load_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yaml的用法示例。


在下文中一共展示了yaml.load_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gtfobins

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def gtfobins(bin_name: str):
    """Search binaries from GTFOBins within command line

    Arguments:
        bin_name {[type]} -- Name of the binary to get info about

    """

    bins = get_bins()

    if bin_name in bins:
        r = requests.get(RAW_URL.format(bin_name)).text
        data = list(yaml.load_all(r, Loader=yaml.SafeLoader))[0]

        parse(data)
    else:
        print(colors("[!] Binary not found on GTFObins: ", 91)) 
开发者ID:mzfr,项目名称:gtfo,代码行数:19,代码来源:gtfobins.py

示例2: lolbas

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def lolbas(name: str):
    """Search binaries from LOLBAS within command line

    Arguments:
        name {[type]} -- Name of the exe to get info about

    Keyword Arguments:
        cmd {str} -- get only the code section (default: {False})
    """

    exes = get_exe()
    if name in exes.keys():
        url = RAW_URL + exes[name] + '.md'
        r = requests.get(url).text
        data = list(yaml.load_all(r, Loader=yaml.SafeLoader))[0]
        parse(data)
    else:
        print(colors("[!] Binary not found on LOLBAS", 91))
        #TODO: Match user input and make suggestion for search
        print(colors("[!] Make sure to provide name with proper extension", 91)) 
开发者ID:mzfr,项目名称:gtfo,代码行数:22,代码来源:lolbas.py

示例3: load

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def load(self, ymlfile=None):
        """Load and process the YAML file"""
        if ymlfile is not None:
            self.ymlfile = ymlfile

        try:
            # If yaml should be 'cleaned' of document references
            if self._clean:
                self.data = self.process(self.ymlfile)
            else:
                with open(self.ymlfile, 'rb') as stream:
                    for data in yaml.load_all(stream, Loader=yaml.Loader):
                        self.data.append(data)

            self.loaded = True
        except ScannerError as e:
            msg = "YAML formattting error - '" + self.ymlfile + ": '" + str(e) + "'"
            raise util.YAMLError(msg) 
开发者ID:NASA-AMMOS,项目名称:AIT-Core,代码行数:20,代码来源:val.py

示例4: get_deployer_notes

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def get_deployer_notes(stig_id):
    """Read deployer notes based on the STIG ID."""
    filename = "{0}/rhel7/{1}.rst".format(METADATA_DIR, stig_id)

    # Does this deployer note exist?
    if not os.path.isfile(filename):
        return False

    # Read the note and parse it with YAML
    with open(filename, 'r') as f:
        rst_file = f.read()

    # Split the RST into frontmatter and text
    # NOTE(mhayden): Can't use the standard yaml.load_all() here at it will
    #                have scanner errors in documents that have colons (:).
    yaml_boundary = re.compile(r'^-{3,}$', re.MULTILINE)
    _, metadata, text = yaml_boundary.split(rst_file, 2)

    # Assemble the metadata and the text from the deployer note.
    post = yaml.safe_load(metadata)
    post['content'] = text

    return post 
开发者ID:openstack,项目名称:ansible-hardening,代码行数:25,代码来源:metadata-docs-rhel7.py

示例5: get_chart_templates

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def get_chart_templates(
            self, template_name, name, release_name, namespace, chart,
            disable_hooks, values):
        # returns some info

        LOG.info("Template( %s ) : %s ", template_name, name)

        stub = ReleaseServiceStub(self.channel)
        release_request = InstallReleaseRequest(
            chart=chart,
            values=values,
            name=name,
            namespace=namespace,
            wait=False)

        templates = stub.InstallRelease(
            release_request, self.timeout, metadata=self.metadata)

        for template in yaml.load_all(getattr(templates.release, 'manifest',
                                              [])):
            if template_name == template.get('metadata', None).get('name',
                                                                   None):
                LOG.info(template_name)
                return template 
开发者ID:airshipit,项目名称:armada,代码行数:26,代码来源:tiller.py

示例6: test_update_dictionary_valid

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def test_update_dictionary_valid(self):
        expected = "{}/templates/override-{}-expected.yaml".format(
            self.basepath, '01')
        merge = "{}/templates/override-{}.yaml".format(self.basepath, '01')

        with open(self.base_manifest) as f, open(expected) as e, open(
                merge) as m:
            merging_values = list(yaml.safe_load_all(m.read()))
            documents = list(yaml.safe_load_all(f.read()))
            doc_path = ['chart', 'blog-1']
            ovr = Override(documents)
            ovr.update_documents(merging_values)
            ovr_doc = ovr.find_manifest_document(doc_path)
            expect_doc = list(yaml.load_all(e.read()))[0]

            self.assertEqual(ovr_doc, expect_doc) 
开发者ID:airshipit,项目名称:armada,代码行数:18,代码来源:test_override.py

示例7: test_set_list_valid

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def test_set_list_valid(self):
        expected = "{}/templates/override-{}-expected.yaml".format(
            self.basepath, '03')

        with open(self.base_manifest) as f, open(expected) as e:
            documents = list(yaml.safe_load_all(f.read()))
            doc_path = ['manifest', 'simple-armada']
            override = (
                'manifest:simple-armada:chart_groups=\
                         blog-group3,blog-group4', )
            ovr = Override(documents, override)
            ovr.update_manifests()
            ovr_doc = ovr.find_manifest_document(doc_path)
            target_docs = list(yaml.load_all(e.read()))
            expected_doc = [
                x for x in target_docs
                if x.get('schema') == 'armada/Manifest/v1'
            ][0]
            self.assertEqual(expected_doc.get('data'), ovr_doc.get('data')) 
开发者ID:airshipit,项目名称:armada,代码行数:21,代码来源:test_override.py

示例8: load_yaml

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def load_yaml(file_name):
    """Load the contents of a YAML file.

    :param file_name: File name
    :type file_name: str or unicode
    :return: content (list of dictionaries, one per YAML document
    in the file) or None if file is empty
    :rtype: list of dict
    :raises IOError: if the file is not found
    :raises FileContentError: if there is a problem parsing YAML
    """
    with open(file_name, 'r') as f:
        try:
            content = [data for data in yaml.load_all(f)]
        except yaml.YAMLError as e:
            raise FileContentError(file_name, e)
    return content 
开发者ID:recipy,项目名称:recipy,代码行数:19,代码来源:file_utils.py

示例9: get_data

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def get_data(self):
        index = {'REQUEST_Headers': {}, 'RESPONSE_Headers': {}}
        doc = {}
        for yaml_file in self.files:
            f = open(yaml_file, encoding='utf-8')
            cont =f.read()
            y = yaml.load_all(cont)
            for api in y:
                if api.get('Name'):
                    doc[api['Name'].upper()] = api
                elif api.get('Title'):
                    index = api

        for name,api in doc.items():
            if not api['REQUEST'].get('Headers'):
                api['REQUEST']['Headers'] = {}
            api['REQUEST']['Headers'] = dict(index['REQUEST_Headers'], **api['REQUEST']['Headers'])
            if api['Method'] == 'GET':
                api['REQUEST']['Headers'].pop('Content-Type')

        return doc 
开发者ID:tonglei100,项目名称:doo,代码行数:23,代码来源:data.py

示例10: get_chart_templates

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def get_chart_templates(self, template_name, name, release_name, namespace,
                            chart, disable_hooks, values):
        # returns some info

        LOG.info("Template( %s ) : %s ", template_name, name)

        stub = ReleaseServiceStub(self.channel)
        release_request = InstallReleaseRequest(
            chart=chart,
            dry_run=True,
            values=values,
            name=name,
            namespace=namespace,
            wait=False)

        templates = stub.InstallRelease(
            release_request, self.timeout, metadata=self.metadata)

        for template in yaml.load_all(
                getattr(templates.release, 'manifest', [])):
            if template_name == template.get('metadata', None).get(
                    'name', None):
                LOG.info(template_name)
                return template 
开发者ID:att-comdev,项目名称:armada,代码行数:26,代码来源:tiller.py

示例11: test_update_dictionary_valid

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def test_update_dictionary_valid(self):
        expected = "{}/templates/override-{}-expected.yaml".format(
            self.basepath, '01')
        merge = "{}/templates/override-{}.yaml".format(self.basepath, '01')

        with open(self.base_manifest) as f, open(expected) as e, open(
                merge) as m:
            merging_values = list(yaml.safe_load_all(m.read()))
            documents = list(yaml.safe_load_all(f.read()))
            doc_path = ['chart', 'blog-1']
            ovr = Override(documents)
            ovr.update_document(merging_values)
            ovr_doc = ovr.find_manifest_document(doc_path)
            expect_doc = list(yaml.load_all(e.read()))[0]

            self.assertEqual(ovr_doc, expect_doc) 
开发者ID:att-comdev,项目名称:armada,代码行数:18,代码来源:test_override.py

示例12: test_set_list_valid

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def test_set_list_valid(self):
        expected = "{}/templates/override-{}-expected.yaml".format(
            self.basepath, '03')

        with open(self.base_manifest) as f, open(expected) as e:
            documents = list(yaml.safe_load_all(f.read()))
            doc_path = ['manifest', 'simple-armada']
            override = ('manifest:simple-armada:chart_groups=\
                         blog-group3,blog-group4',)
            ovr = Override(documents, override)
            ovr.update_manifests()
            ovr_doc = ovr.find_manifest_document(doc_path)
            target_docs = list(yaml.load_all(e.read()))
            expected_doc = [x
                            for x
                            in target_docs
                            if x.get('schema') == 'armada/Manifest/v1'][0]
            self.assertEqual(expected_doc.get('data'), ovr_doc.get('data')) 
开发者ID:att-comdev,项目名称:armada,代码行数:20,代码来源:test_override.py

示例13: helm_template

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def helm_template(config):
    with tempfile.NamedTemporaryFile() as temp:
        with open(temp.name, "w") as values:
            values.write(config)
        helm_cmd = "helm template -f {0} ./".format(temp.name)
        result = yaml.load_all(check_output(helm_cmd.split()))

        results = {}
        for r in result:
            if r:
                kind = r["kind"].lower()
                if kind not in results:
                    results[kind] = {}
                results[kind][r["metadata"]["name"]] = r

        if os.environ.get("DEBUG"):
            print(json.dumps(results, indent=4, sort_keys=True))
        return results 
开发者ID:elastic,项目名称:helm-charts,代码行数:20,代码来源:helpers.py

示例14: read_yaml_file

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def read_yaml_file(path):
        """Open the yaml file and load it to the variable.
        Return created list"""
        if path == 'config.yml':
            wrn = "Use 'load_config' or 'ATCConfig' instead for config"
            # Warning will not show, 
            # unless captured by logging facility or python called with -Wd
            warnings.warn(message=wrn,
                          category=DeprecationWarning)
            return ATCConfig(path).config

        with open(path) as f:
            yaml_fields = yaml.load_all(f.read(), Loader=yaml.FullLoader)

        buff_results = [x for x in yaml_fields]
        if len(buff_results) > 1:
            result = buff_results[0]
            result['additions'] = buff_results[1:]
        else:
            result = buff_results[0]
        return result 
开发者ID:atc-project,项目名称:atomic-threat-coverage,代码行数:23,代码来源:atcutils.py

示例15: load_camera_from_calibr

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import load_all [as 别名]
def load_camera_from_calibr(f):
    s = open(f).read()

    y = list(yaml.load_all(s))[0]

    K0 = Camera.buildK(y['cam0']['intrinsics'])
    C0 = Camera(K0, np.eye(3), np.zeros((3,)))

    K1 = Camera.buildK(y['cam1']['intrinsics'])
    M = y['cam1']['T_cn_cnm1'][:3]
    R1 = np.asarray([k[:3] for k in M])
    t1 = np.asarray([k[3] for k in M])
    C1 = Camera(K1, R1, t1)

    dist0 = np.asarray(y['cam0']['distortion_coeffs'])
    dist1 = np.array(y['cam1']['distortion_coeffs'])
    return C0, C1, dist0, dist1 
开发者ID:ppwwyyxx,项目名称:Stereo-Pose-Machines,代码行数:19,代码来源:calibr.py


注:本文中的yaml.load_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。