Saravanan666/pypi-org huggingface dataset:
Package: yaml-config-override
YAML CONFIG OVERRIDEWhy?YAML Config Override is an extremely lightweight command line interface to your YAML configuration file.
Just create a yaml config file, and yaml_config_override will add command line arguments to it automatically. No need to write hundreds of argparse lines!Installation:pipinstallyaml_config_overrideExample?Suppose you have a YAML filetest.yaml:outer:x:0inner:y:1eveninner:z:abcthen you can use it in the codemain.py:fromyaml_config_overrideimportadd_argumentsimportyamlfrompathlibimportPathmy_config_path='test.yaml'conf=yaml.safe_load(Path(my_config_path).read_text())conf=add_arguments(conf)print(conf)Now you can call main.py as follows:python main.py --outer.x 2 --outer.inner.eveninner.z helloYour program output will be:{'outer': {'x': 2, 'inner': {'y': 1, 'eveninner': {'z': 'hello'}}}}Alternatively if you want to pass the config file as a command line argument you can modify the code as follows:fromyaml_config_overrideimportadd_argumentsconf=add_arguments()Now you call main.py as :python main.py --config test.yaml --outer.x 2 --outer.inner.eveninner.z hello
Package: yaml-config-reader
Yaml configThe package gives object like access for config files in yaml formatUsingyaml_config- root package.open_configThe function for configuration an object from a file.The function accepts an unlimited number of arguments. Each argument is a path to the intended configuration file.
The function iterates through all paths in the order in which they were passed to the function. The config that was found first will be used. If the arguments run out and the file is not found, an error will be called.The function returns the configuration as an pythondict.cut_protocolThe function truncates the protocol at the passed url.The function takes a url in string format as an argument.The function returns clear domain without protocol.DevelopingRunning testspytestUpdatingWriting new codeUpdating version insetup.pyRunningpython -m buildfor buildPushing to pypi viapython -m twine upload  dist/*
Package: yaml-configuration
yaml_configurationThis module offers easy configuration for a other modules or startup
scripts. It offers an easy way to load and save config files and read
and write config values to it. Also trying to read a config value by
passing an optional default value if the real config value is not
present is supported.UsageThe class DefaultConfig provides the basic functionality of the package.
A custom configuration class is meant to derive from it.importosimportloggingfrompytestimportraisesfromyaml_configuration.configimportDefaultConfig,ConfigErrordefread_file(file_path,filename):file_path=os.path.join(file_path,filename)withopen(file_path,'r')asfile_pointer:file_content=file_pointer.read()returnfile_contentclassBasicConfig(DefaultConfig):def__init__(self,config_string,config_file,logger_object=None):super(BasicConfig,self).__init__(config_string,logger_object)# this is already done in the init# self.load(config_file, path=os.path.dirname(__file__))if__name__=='__main__':config_file="basic_config.yaml"config_string=read_file(os.path.dirname(__file__),config_file)basic_config=BasicConfig(config_string,config_file,logging.getLogger("TestLogger"))basic_config.set_config_value("number_value",10)basic_config.set_config_value("string_value","test_string")assertbasic_config.get_config_value("string_value")=="test_string"assertbasic_config.get_config_value("not_existing_config_value",default=42)==42withraises(ConfigError):ifnotbasic_config.get_config_value("value_that_should_exist"):raiseConfigError("The config value with key 'value_that_should_exist' should exist")
Package: yamlconf-wmf
This library provides a means to read yaml configuration files and propagate
default values in reasonable ways.  Nothing complicated.Installation:pip install yamlconfigExample:>>> import yamlconf
>>>
>>> doc = yamlconf.loads("""
... test: demo_test
...
... tests:
...     defaults:
...         foo: 5
...     demo_test:
...         bar: 6
... """)
>>>
>>> doc['tests'][doc['test']]['foo']
5
>>> doc['tests'][doc['test']]['bar']
6Functions:load(file-like) : Returns adictwith defaults propagatedloads(string) : Returns adictwith defaults propagatedload_module(class-path) : Imports and returns
Package: yamldb
YamlDBYamlDB is an easy to use file-based database using YAML as the format for the
data represented in the file. This makes it possible to quickly change and add
values in the file itself while it can then be loaded and used as a dict in your
application.It has the ability to use a dot notations for the keys instead of nested brackets.
It also creates parents if they do not exist.Note: you must be using python 3.8 or newerpipinstallyamldbdb=YamlDB(filename="data.yml")db["a"]="1"db["b.c"]="2"d=db.get("a.b.c.d",default=3)db.load()reloadsthefiledb.delete("b.c")deletesthekeyb.ctosavethestateyouhavetoalsocalldb.save()db.save()savesthecurrentdbintothefiledb.search("a.*.c")quriesthedbsee:https://jmespath.org/tutorial.htmlDevelopment and testsThe best way to contribute is with issues and pull requests. You will need to check out the development version such asgitclonehttps://github.com/cloudmesh/yamldb.gitcdyamldb
pipinstall-rrequirements.txt
pipinstall-rrequirements-dev.txt
pipinstall-e.Then you can run the a test withpytest-v--capture=notests/test_config.pyAlternativesjmespath:https://jmespath.org/TinyDB:https://tinydb.readthedocs.io/en/latest/index.htmlnosqlite:https://github.com/shaunduncan/nosqliteMongoDB:  This is quite a big package and we developed yamldb to replace it when mongo is not needed.AcknowledgmentsContinued work was in part funded by the NSF
CyberTraining: CIC: CyberTraining for Students and Technologies
from Generation Z with the award numbers 1829704 and 2200409.
Package: yamldict
Yamldictis a library that allows accessing YAML content as a kind
of a dictionary. Its primary purpose is to allow reading and writing
YAML content with ease.To achieve that it has the following features:FeaturesEasy creation of complex structures from string or files:myyaml=yamldict.create("""
- "item 1"
- "item 2"
""")Not a dictionary. That means a property such asgetis still
accessible from the object and isn’t a method on a dictionary.>>>x=yamldict.YamlDict()>>>x.get="x">>>xYamlDict(){'get':'x'}Accessible via properties, or indexes:assertmyyaml["item"]==myyaml.itemHandles chained missing properties without creating them unless
asked:>>>myyaml=yamldict.YamlDict()>>>assertnotmyyaml.this.property.doesnt.exist>>>myyamlYamlDict(){}>>>myyaml.some.other.property="3">>>myyamlYamlDict(){'some':{'other':{'property':'3'}}}It supports deep copying.It’s integrated as a PyYaml serializer.It supports pickle serialization.Type support, so you don’t need to do anything in projects using
mypy.
Package: yamldiff
yamldiffA semantic YAML diff utility.yamldiff file1.yaml file2.yamlwill show recursively the values that are added removed or modified
from file1.yaml to file2.yaml.The values of data type such as lists are compared by the whole value
(i.e.) must match exactly, but it is possible to refine the diff
output by
considering them unordered sets instead:$ cat file1.yaml 
a_key : a value

a_list: 
    - {id: 1, val: uno}
    - {id: 2, val: dos}
    - {id: 3, val: tres}
$ cat file2.yaml 
a_key : another value

abother_key: some value
a_list: 
    - {id: 1, val: uno}
    - {id: 2, val: dos}
    - {id: 3, val: cuatro}
$ python yamldiff.py file1.yaml file2.yaml 
# Added keys:
+ abother_key: some value
# Modified keys:
a_key:
    - a value
    + another value
a_list:
    - [{id: 1, val: uno}, {id: 2, val: dos}, {id: 3, val: tres}]
    + [{id: 1, val: uno}, {id: 2, val: dos}, {id: 3, val: cuatro}]
$ python yamldiff.py file1.yaml file2.yaml --set-keys a_list
# Added keys:
+ abother_key: some value
# Modified keys:
a_key:
    - a value
    + another value
a_list:
    # Removed keys:
    - {id: 3, val: tres}
    # Added keys:
    + {id: 3, val: cuatro}It is also possible to treat list as key value pairs, by specifying
the element of the list items to index on:$ python yamldiff.py file1.yaml file2.yaml --set-keys a_list:id
# Added keys:
+ abother_key: some value
# Modified keys:
a_key:
    - a value
    + another value
a_list:
    # Modified keys:
    # Matching:
    {id: 3}
        # Modified keys:
        val:
            - tres
            + cuatro
Package: yamldoc
Documentation Engine for YAMLThis package converts a YAML file into markdown, formatting values and associated metadata in adoxygen-like way. To get started, check out thedocumentationandtutorials.InstallationpipinstallyamldocThis will install the python package, which contains a command line interfaceyamldoc. To see usage instructions, invoke the--helpflag:yamldoc-hPhilosophyMany programs and utilities use YAML (YAML Ain't Markup Language) as a human and machine readable interface to configuration parameters and other values. More broadly, many kinds of data can be stored in YAML with minimal effort from the user. However, often a configuration file accumulates a highly specific set of configurations marked up with vague, difficult to interpret comments. It is the goal of this package to provide an easy interface for developers to document data in their YAML files as well as the expected types from aJSON YAML schema validator. Doing so will allow a transparent interface between the developer's expectations and the user's configurations.Specific Application to SnakemakeThis package was designed specifically to document the possible configuration options of aSnakemakepipeline. In this application, the developer of the pipeline encodes many different specific options that the user may configure at run time, but these are often poorly documented. When they are, it is easy for the documentation to fall out of sync with the actual options in the configuration file.yamldocautomatically documents all configuration paramters as well as taking types from a schema file. The package will also read any comments that are present above each paramter and insert them into a parameter table for easy reference.For more details on using YAML to configure Snakemake pipelines, seehere.Example FilesFor a minimal example ofyamldoc, see the files in/test/yamland/test/schema.UsageFor a basic report, point the command line interface to a YAML file.yamldoctest/yaml/basic.yamlYou can also include type information from a schema file.yamldoctest/yaml/basic.yaml-stest/schema/basic.schemaOther Optionsyamldocdefaults to using#'as a special marker, but you can choose this character yourself if you wish. Just set it on the command line at parse-time:yamldoctest/yaml/basic.yaml-c"YOURCHAR"yamldocalso includes support for certain special declarations in the schema file. Right now these include:_yamldoc_title: This specifies the overall title of the markdown page generated._yamldoc_description: A description to follow the title.These are picked out of the schema file and reported.
Package: yamldown
# YamldownThis library allows users to load and read “YAMLdown” files. That is,
Markdown (primarily for github) with YAML embedded inside. Github markdown
already renders YAML style text in markdown as a table. This library parses
a yamldown file into its respective YAML and markdown.## Installationpip install yamldownFor local installation and development, you can run the make file:sauron@orthanc:[~]$ cd yamldownsauron@orthanc:[yamldown]$ makeThis will create a virtual environemntenv, install everything inrequirements.txtand insetup.py, run tests, and run mypy, python 3’s type
checker. Be sure to activate the virtual environment when local developing:source env/bin/activateor. env/bin/activateTo undo your activated virtual environment, just run the commanddeactivate## UsageImporting the yamldown module will let youloadanddumpyamldown files.loadreceives a file-like object (backed by text in yamldown format) and
returns a tuple, first a dictionary with the containing YAML, and second a
string with the contents of the Markdown. In this way the yaml can be utilized.Example:$ python3
>>> import io
>>> import yamldown
>>> s = “””
…—
… things:
…   - hello
…   - world
… foo: bar
… —
… This is some markdown text”””
>>> f = io.StringIO(s)
>>> yml, md = yamldown.load(f)
>>> print(yml)
{‘things’: [‘hello’, ‘world’], ‘foo’: ‘bar’}
>>>print(md)
This is some markdown textTo write out a yamldown file,dumptakes a dictionary with your yaml data
and a string of markdown and outputs a string. The order in which the yaml
appears in the document can be specified with theyamlfirstoption:Truefor if the yaml should appear first (like in the above example) andFalseto
appear last.Example:$ python3
>>> import yamldown
>>> yml = {‘things’: [‘hello’, ‘world’], ‘foo’: ‘bar’}
>>> md = “This is some markdown text”
>>> print(yamldown.dump(yml, md))
—
foo: bar
things:
- hello
- world—
This is some markdown text
Package: yaml_dump
# yaml dumpUnicode as utf8Keep order of OrderedDict# INSTALLpip install yaml_dump# USAGEfrom yaml_dump import yaml_dump
print(yaml_dump(dict(a=1,b=[1,2,3],c=”한글”)))# EXAMPLE OUTPUTa: 1
b:
- 1
- 2
- 3
c: 한글History0.1.0 (2017-01-11)First release on PyPI.
Package: yamlen
Yamlen - a Thin PyYAML WrapperFeaturesContextual tag construction.ExamplesCreate a Loader>>> from yamlen import Loader
>>> loader = Loader()Load YAML documents in Streams>>> from io import StringIO

>>> stream = StringIO("foo")
>>> loader.load(stream)
'foo'

>>> stream = StringIO("foo\n---\nbar")
>>> list(loader.load_all(stream))
['foo', 'bar']Load YAML Documents in Files.>>> import os
>>> from tempfile import TemporaryDirectory

>>> with TemporaryDirectory() as dir_path:
...     path = os.path.join(dir_path, "example.yml")
...     with open(path, "w") as f:
...         _ = f.write("foo")
...     loader.load_from_path(path)
'foo'

>>> with TemporaryDirectory() as dir_path:
...     path = os.path.join(dir_path, "example.yml")
...     with open(path, "w") as f:
...         _ = f.write("foo\n---\nbar")
...     list(loader.load_all_from_path(path))
['foo', 'bar']Contextual tag construction: include another YAML file.>>> from yamlen.tag.impl.inclusion import InclusionTag
>>> loader.add_tag("!include", InclusionTag())>>> with TemporaryDirectory() as dir_path:
...     foo_path = os.path.join(dir_path, "foo.yml")
...     bar_path = os.path.join(dir_path, "bar.yml")
...     with open(foo_path, "w") as f:
...         _ = f.write(f"!include ./bar.yml")
...     with open(bar_path, "w") as f:
...         _ = f.write("bar")
...     loader.load_from_path(foo_path)
'bar'LicenseCopyright (c) 2021 Yu Mochizuki
Package: yamlenv
Interpolate YaML files with environmental variables and other YaML
files.Given a YaML string like:a:${A}b:2and an environmental variable$Awith valuehello,yamlenv.loadwould return:{a:'hello',b:2}Including YAML literals as environment variables is also
supported - so if the environment variable$Awas set tofalse,yamlenv.loadwould return:{a:False,b:2}Default values are supported:yamlenv.load('''
    a: ${A:-hello}
    b: 2
''')=={'a':'hello','b':2}As in Bash, defaulting can be done with either:-(to not allow empty
defaults) or with-to allow empty values.The environmental variable can be embedded in a larger string, too:yamlenv.load('''
    a: foo ${A:-bar} baz
    b: 2
''')=={'a':'foo bar baz','b':2}More than one environmental variable can appear in a string:yamlenv.load('''
    a: foo ${A:-bar} ${B:-baz}
    b: 2
''')=={'a':'foo bar baz','b':2}YaML files can include other YaML files, too. E.g. ifb.yamlcontains “2”, then:yamlenv.load('''
    a: 1
    b: !include b.yaml
''')=={'a':1'b':2}The included YaML file can be as complex as necessary.More examples are available in the tests.
Package: yaml-env-var-parser
yaml_env_var_parserImplementation of PyYAML Reader with env var parsing.Inspired by envyaml:https://github.com/thesimj/envyamlThe Reader is the very first step of the PyYAML parsing process and this is where the environment variable is being parsed.The environment variable parsing can beanywherein the yaml file, the parsing is done in the very early stages of the PyYAML loading process. It is possible toinjecta YAML structure using itThe code below is an example of what I mean beanywere:import os
from yaml_env_var_parser import load

# env vars are replaced on keys
os.environ['MY_KEY'] = 'key'
# they might also be YAML tags
os.environ['TIMESTAMP_TAG'] = '!!timestamp'
# this will inject `another_key` into the yaml data
os.environ['MY_COMPLEX_DATA'] = """"simple_data"
another_key: "its possible to create new keys with env vars. we might call it YAML INJECTION"
"""
yaml_data_str = """
${MY_KEY}: "data"
complex_data: ${MY_COMPLEX_DATA}
timestamp_tag: ${TIMESTAMP_TAG} 2022-01-01 00:00:00
"""
parsed = load(yaml_data_str)
print(parsed)Output:{'key': 'data', 'complex_data': 'simple_data', 'another_key': 'its possible to create new keys with env vars. we might call it YAML INJECTION', 'timestamp_tag': datetime.datetime(2022, 1, 1, 0, 0)}The keyanother_keydoes not exist inyaml_data_stryaml str definition but it is added from the environment variable${MY_COMPLEX_DATA}MIT LicenseCopyright (c) 2022 NiltonDuartePermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Package: yaml-error-report
yaml-error-reportGenerate rich console errors reports for YAML (and JSON, since its a YAML subset) documents.
This is aimed at console tools which want to present the user with useful errors messages if a YAML or JSON document fails some internal validation.Uses PyYaml to extract location (line, column, position in stream) information for nodes in a YAML or JSON document.
This information can then be used to create user friendly error reports.Can be combined withjsonschema, to greatly improve error messages.
Seeexamples\with_jsonschema.Installationpip install yaml-error-reportUsage# calc.ymlname:calcmethods:-name:sumdescription:"Sumsxandy"request:-name:"x"type:Int36-name:"y"type:Int32response:Int32# windows only: needed to make coloured output workimportcoloramacolorama.init()fromyaml_error_reportimportpath_to_location,error_report# extract the text location of the offending nodeloc=path_to_location("calc.yml",["methods",0,"request",0,"type"])# create the error reporterror=error_report("YAML Validation Error","Int36 is not a valid type",loc)print(error)outputs (nicely coloured on terminals)YAML Validation Error
   --> calc.yml:8:14
   7|         - name: "x"
   8|           type: Int36
                      ^^^^^ Int36 is not a valid type
   9|         - name: "y"
  10|           type: Int32
Package: yaml-expressions
YAML Jinja2 expressionsRenders Jinja2 expressions inside YAML file.Installpip install yaml-expressionsExamplesLoad template from filecfg/cfg.yml:cfg:test:"{{test}}"fromyeximportYexyex=Yex('./cfg/')print(yex.render('cfg.yml',test='passed'))Output:{'cfg': {'test': 'passed'}}Load template from stringfromyeximportYexresult=Yex('test: {{test}}')(test='passed')# orresult={'test':'passed'}>Yex('test: {{test}}')# orresult=Yex('test: {{test}}').render(test='passed')print(result)Output:{'test': 'passed'}Another examplesDescribe SEO checklist, generate reporttests_tpl="""tests:title: {{ 20 < (title | length) < 70 }}description: {{ 20 < (description | length) < 160 }}"""report_tpl="""report: >Test results:Title: {{ 'ok' if tests.title else 'fail' }}({{ title[:10] }}...)Description: {{ 'ok' if tests.description else 'fail' }}({{ description[:10] }}...)"""data={'title':'t'*130,'description':'d'*120,}results=Yex.render_text(tests_tpl,data)report=Yex.render_text(report_tpl,**results,**data)print(report.get('report'))Output:Test results:
  Title: fail
    (tttttttttt...)
  Description: ok
    (dddddddddd...)Render HTML pages from prepared configtemplate="""meta:{% for k, v in meta.items() %}{{ k }}: >-{{ v }}{% endfor %}data:{% for k, v in data.items() %}{{ k }}: >-{{ v }}{% endfor %}"""data=[{'meta':{'title':'Hello, world 1!',},'data':{'content':"""<h1>Wellcome to our site!</h1><p>Glad to see you!</p>"""}},{'meta':{'title':'Hello, world 2!',},'data':{'content':"""<h1>Wellcome to our site!</h1><p>Glad to see you!</p>"""}},]content_page_template="""<title>{{meta.title}}</title><div>{{data.content}}</div>"""content_page=Yex(content_page_template)forcfginYex(template).generate(data):print(content_page.render_content(cfg))Output:<title>Hello, world 1!</title>
    <div><h1>Wellcome to our site!</h1>
    <p>Glad to see you!</p>
    </div>
<title>Hello, world 2!</title>
    <div><h1>Wellcome to our site!</h1>
    <p>Glad to see you!</p>
    </div>
Package: yaml-extensions
Extensions for PyYAMLInclusionsThis implements a simple inclusion interface. If used, any inclusions will be
assumed to be relative paths to the YAML file being loaded, if the location can
be determined, otherwise relative to the current working directory.fromyaml_extensions.inclusionsimportInclusionSafeLoaderwithopen("outer.yaml","r")asyaml_fp:my_yaml=yaml.load(yaml_fp,loader=InclusionSafeLoader)This allowsouter.yamlto be split into two files, e.g.:outer.yamlfizz:buzz:!include"inner.yaml"inner.yamlbar:bell:51will become:{"fizz":{"buzz":{"bar":{"bell":51}}}}
Package: yamlfix
yamlfixA simple opinionated yaml formatter that keeps your comments!HelpSeedocumentationfor more details.InstallingpipinstallyamlfixContributingFor guidance on setting up a development environment, and how to make a
contribution toyamlfix, seeContributing to yamlfix.Donations<a href="https://liberapay.com/Lyz/donate"><img alt="Donate using
Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
orIf you are using some of my open-source tools, have enjoyed them, and want to
say "thanks", this is a very strong way to do it.If your product/company depends on these tools, you can sponsor me to ensure I
keep happily maintaining them.If these tools are helping you save money, time, effort, or frustrations; or
they are helping you make money, be more productive, efficient, secure, enjoy a
bit more your work, or get your product ready faster, this is a great way to
show your appreciation. Thanks for that!And by sponsoring me, you are helping make these tools, that already help you,
sustainable and healthy.LicenseGPLv3