How to use the pyaml.dumps function in pyaml

To help you get started, we’ve selected a few pyaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github citrix / citrix-adc-ansible-modules / test / utils.py View on Github external
testdir = os.path.join(testdir, testcase)

    if not os.path.exists(testdir):
        os.makedirs(testdir)

    test_log = os.path.join(testdir, 'test.log')
    inventory_file = os.path.join(testdir, 'inventory.txt')
    play_yml = os.path.join(testdir, 'play.yml')

    # Remove stale logs
    if os.path.exists(test_log):
        os.remove(test_log)

    # Write dict to proper yaml playbook
    with open(play_yml, 'w') as fh:
        fh.write(pyaml.dumps(play_dict))

    # Write the inventory
    with open(inventory_file, 'w') as fh:
        fh.write(inventory)


    actual_command = 'ANSIBLE_LOG_PATH="%s" ansible-playbook -i %s -M %s %s -vvv' % (test_log, inventory_file, ansible_module_path,  play_yml)
    print(actual_command)
    retval = subprocess.call(actual_command, shell=True)

    # Parse json return object from verbose log output
    with open(test_log, 'r') as fh:
        json_lines = []
        in_json = False
        for line in fh:
            if not in_json:
github bioconda / bioconda-utils / bioconda_utils / bioconductor_skeleton.py View on Github external
d['requirements']['build'] = ["PLACEHOLDER"]

            d['test']['commands'] = ['''LD_LIBRARY_PATH="${BUILD_PREFIX}/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib64" $R -e "library('{{ name }}')"''']


        if self.extra:
            d['extra'] = self.extra

        if self._cb3_build_reqs:
            d['requirements']['build'] = []
        else:
            d['build']['noarch'] = 'generic'
        for k, v in self._cb3_build_reqs.items():
            d['requirements']['build'].append(k + '_' + "PLACEHOLDER")

        rendered = pyaml.dumps(d, width=1e6).decode('utf-8')

        # Add Suggests: and SystemRequirements:
        renderedsplit = rendered.split('\n')
        idx = renderedsplit.index('requirements:')
        if self.packages[self.package].get('SystemRequirements', None):
            renderedsplit.insert(idx, '# SystemRequirements: {}'.format(self.packages[self.package]['SystemRequirements']))
        if self.packages[self.package].get('Suggests', None):
            renderedsplit.insert(idx, '# Suggests: {}'.format(self.packages[self.package]['Suggests']))
        # Fix the core dependencies if this needsX
        if self.needsX:
            idx = renderedsplit.index('  build:') + 1
            renderedsplit.insert(idx, "    - xorg-libxfixes  # [linux]")
            renderedsplit.insert(idx, "    - {{ cdt('libxxf86vm') }}  # [linux]")
            renderedsplit.insert(idx, "    - {{ cdt('libxdamage') }}  # [linux]")
            renderedsplit.insert(idx, "    - {{ cdt('libselinux') }}  # [linux]")
            renderedsplit.insert(idx, "    - {{ cdt('mesa-dri-drivers') }}  # [linux]")
github galaxyproject / planemo / planemo / bioconda_scripts / bioconductor_skeleton.py View on Github external
package=self.package)]),
                )),
            ),
            (
                'about', OrderedDict((
                    ('home', self.url),
                    ('license', self.license),
                    ('summary', self.description['description']),
                )),
            ),
        ))
        if self.depends_on_gcc:
            d['requirements']['build'].append('GCC_PLACEHOLDER')
            d['requirements']['build'].append('LLVM_PLACEHOLDER')

        rendered = pyaml.dumps(d).decode('utf-8')
        rendered = rendered.replace('GCC_PLACEHOLDER', 'gcc  # [linux]')
        rendered = rendered.replace('LLVM_PLACEHOLDER', 'llvm  # [osx]')
        return rendered
github mediatum / mediatum / bin / manage.py View on Github external
def result_proxy_to_yaml(resultproxy):
    rows = resultproxy.fetchall()
    as_list = [OrderedDict(sorted(r.items(), key=lambda e:e[0])) for r in rows]
    formatted = pyaml.dumps(as_list)
    return formatted