-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
"public_name": "buildlib" | ||
"interal_name": "buildlib" | ||
"version": "2.0.1" | ||
"license": "unlicensed" | ||
"author": "Felix Meyer-Wolters" | ||
"author_email": "[email protected]" | ||
"maintainer": "Felix Meyer-Wolters" | ||
"maintainer_email": "[email protected]" | ||
"url": "https://github.com/feluxe/buildlib" | ||
"description": "A library to help build projects." | ||
"keywords": ["build", "library"] | ||
|
||
"pypi": | ||
"install_requires": ["headlines", "prmt", "ruamel.yaml", "cmdi", "sty", "requests"] | ||
"tests_require": [] | ||
"packages": ["buildlib"] | ||
"package_dir": {"buildlib": "buildlib"} | ||
"package_data": {} | ||
"py_modules": [] | ||
"data_files": [] | ||
"classifiers": [] | ||
"platforms": "" | ||
"entry_points": {"console_scripts": [] | ||
, "gui_scripts": [] | ||
} | ||
|
||
public_name: buildlib | ||
interal_name: buildlib | ||
version: 2.0.2 | ||
license: unlicensed | ||
author: Felix Meyer-Wolters | ||
author_email: [email protected] | ||
maintainer: Felix Meyer-Wolters | ||
maintainer_email: [email protected] | ||
url: https://github.com/feluxe/buildlib | ||
description: A library to help build projects. | ||
keywords: [build, library] | ||
pypi: | ||
install_requires: [headlines, prmt, oyaml, cmdi, sty, requests] | ||
tests_require: [] | ||
packages: [buildlib] | ||
package_dir: {buildlib: buildlib} | ||
package_data: {} | ||
py_modules: [] | ||
data_files: [] | ||
classifiers: [] | ||
platforms: '' | ||
entry_points: | ||
console_scripts: [] | ||
gui_scripts: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
import ruamel.yaml as yaml | ||
import oyaml as yaml | ||
import sys | ||
from typing import Any | ||
|
||
|
||
def loadfile( | ||
file: str, | ||
keep_order: bool = False | ||
) -> dict: | ||
def loadfile(file: str, safe=False) -> dict: | ||
""" | ||
Load yaml file. | ||
""" | ||
with open(file, 'r') as stream: | ||
if keep_order: | ||
return yaml.load(stream.read(), Loader=yaml.RoundTripLoader) | ||
else: | ||
return yaml.safe_load(stream.read()) | ||
|
||
|
||
def savefile( | ||
data: Any, | ||
file: str, | ||
default_style: str = '"' | ||
) -> None: | ||
if safe: | ||
with open(file, 'r') as f: | ||
return yaml.safe_load(f.read()) | ||
else: | ||
with open(file, 'r') as f: | ||
return yaml.load(f.read()) | ||
|
||
|
||
def savefile(data: Any, file: str, **kwargs) -> None: | ||
""" | ||
Save data to yaml file. | ||
""" | ||
with open(file, 'w') as yaml_file: | ||
yaml.dump(data, yaml_file, Dumper=yaml.RoundTripDumper, | ||
default_style=default_style) | ||
with open(file, 'w') as f: | ||
yaml.dump(data=data, stream=f, **kwargs) | ||
|
||
|
||
def pprint_yaml(data: Any) -> None: | ||
lines: list = yaml.round_trip_dump( | ||
data, indent=4, | ||
|
||
lines: list = yaml.dump( | ||
data, | ||
indent=4, | ||
block_seq_indent=4, | ||
).splitlines(True) | ||
|
||
print(''.join([line for line in lines])) |