yamer 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yamer-1.0.0/LICENSE +21 -0
- yamer-1.0.0/PKG-INFO +38 -0
- yamer-1.0.0/README.md +21 -0
- yamer-1.0.0/pyproject.toml +3 -0
- yamer-1.0.0/setup.cfg +34 -0
- yamer-1.0.0/src/yamer/__init__.py +3 -0
- yamer-1.0.0/src/yamer/cli.py +50 -0
- yamer-1.0.0/src/yamer/convert.py +47 -0
- yamer-1.0.0/src/yamer.egg-info/PKG-INFO +38 -0
- yamer-1.0.0/src/yamer.egg-info/SOURCES.txt +13 -0
- yamer-1.0.0/src/yamer.egg-info/dependency_links.txt +1 -0
- yamer-1.0.0/src/yamer.egg-info/entry_points.txt +2 -0
- yamer-1.0.0/src/yamer.egg-info/requires.txt +1 -0
- yamer-1.0.0/src/yamer.egg-info/top_level.txt +1 -0
yamer-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asinerum Conlang Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
yamer-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yamer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: YAML to/from JSON File Conversion Tool
|
|
5
|
+
Home-page: https://github.com/asinerum/yamer
|
|
6
|
+
Author: Asinerum Conlang Project
|
|
7
|
+
Author-email: asinerum.com@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: formatize>=1.0.19
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# YAML vs JSON File Conversion Tool
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
```bash
|
|
22
|
+
pip install yamer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Sample Usage [Nov 25, 2026]
|
|
26
|
+
```bash
|
|
27
|
+
yamer -f some_file.yaml
|
|
28
|
+
yamer -f another_file.json
|
|
29
|
+
yamer -e some_file,another_file
|
|
30
|
+
yamer -d ./data -t json
|
|
31
|
+
yamer -t json
|
|
32
|
+
yamer -n yes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Detailed tips, tricks, and examples, can be found at project's repository
|
|
36
|
+
https://github.com/asinerum/yamer
|
|
37
|
+
|
|
38
|
+
(C)2026 Asinerum Conlang Project
|
yamer-1.0.0/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# YAML vs JSON File Conversion Tool
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
```bash
|
|
5
|
+
pip install yamer
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Sample Usage [Nov 25, 2026]
|
|
9
|
+
```bash
|
|
10
|
+
yamer -f some_file.yaml
|
|
11
|
+
yamer -f another_file.json
|
|
12
|
+
yamer -e some_file,another_file
|
|
13
|
+
yamer -d ./data -t json
|
|
14
|
+
yamer -t json
|
|
15
|
+
yamer -n yes
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Detailed tips, tricks, and examples, can be found at project's repository
|
|
19
|
+
https://github.com/asinerum/yamer
|
|
20
|
+
|
|
21
|
+
(C)2026 Asinerum Conlang Project
|
yamer-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = yamer
|
|
3
|
+
version = 1.0.0
|
|
4
|
+
author = Asinerum Conlang Project
|
|
5
|
+
author_email = asinerum.com@gmail.com
|
|
6
|
+
description = YAML to/from JSON File Conversion Tool
|
|
7
|
+
long_description = file: README.md
|
|
8
|
+
long_description_content_type = text/markdown
|
|
9
|
+
url = https://github.com/asinerum/yamer
|
|
10
|
+
license = MIT
|
|
11
|
+
classifiers =
|
|
12
|
+
Programming Language :: Python :: 3
|
|
13
|
+
License :: OSI Approved :: MIT License
|
|
14
|
+
Operating System :: OS Independent
|
|
15
|
+
|
|
16
|
+
[options]
|
|
17
|
+
package_dir =
|
|
18
|
+
= src
|
|
19
|
+
packages = find:
|
|
20
|
+
python_requires = >=3.7
|
|
21
|
+
install_requires =
|
|
22
|
+
formatize >= 1.0.19
|
|
23
|
+
|
|
24
|
+
[options.packages.find]
|
|
25
|
+
where = src
|
|
26
|
+
|
|
27
|
+
[options.entry_points]
|
|
28
|
+
console_scripts =
|
|
29
|
+
yamer = yamer.cli:main
|
|
30
|
+
|
|
31
|
+
[egg_info]
|
|
32
|
+
tag_build =
|
|
33
|
+
tag_date = 0
|
|
34
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Usage:
|
|
3
|
+
yamer (-h|--help)
|
|
4
|
+
yamer [-f <file_name>] [-d <dir_name>] [-t <file_type>] [-e <name_list>] [-n <notice>]
|
|
5
|
+
|
|
6
|
+
Arguments:
|
|
7
|
+
-f, --file File path to be converted [default: null],
|
|
8
|
+
this must come with a valid YAML/JSON name.
|
|
9
|
+
If the file is missing [at default],
|
|
10
|
+
entire working folder will be processed.
|
|
11
|
+
-d, --dir Files directory [default: working folder].
|
|
12
|
+
-t, --type Files type, can be yaml [at default] or json,
|
|
13
|
+
used when [--file] is not set.
|
|
14
|
+
-e, --exclude List of excluded files [default: null],
|
|
15
|
+
comes without files extension.
|
|
16
|
+
-n, --notice Print notice to stdout [default: no].
|
|
17
|
+
<file_name> The input file path, eg. "./some.yaml".
|
|
18
|
+
<dir_name> The input dir path, eg. "./data".
|
|
19
|
+
<file_type> The input file extension, eg. "json".
|
|
20
|
+
<name_list> The file names list, eg. "some,one,two".
|
|
21
|
+
<notice> Should be any string, eg. "yes" or "1".
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .convert import *
|
|
25
|
+
|
|
26
|
+
def main():
|
|
27
|
+
import argparse
|
|
28
|
+
parser = argparse.ArgumentParser(description='YAML/JSON File Conversion')
|
|
29
|
+
parser.add_argument('-f', '--file', type=str, default='', help=f'single file path to be converted')
|
|
30
|
+
parser.add_argument('-d', '--dir', type=str, default='./', help=f'files directory to be processed')
|
|
31
|
+
parser.add_argument('-t', '--type', type=str, default='yaml', help=f'file type setting: yaml/json')
|
|
32
|
+
parser.add_argument('-e', '--exclude', type=str, default='', help=f'excluded files list')
|
|
33
|
+
parser.add_argument('-n', '--notice', type=str, default='', help=f'print notice to stdout')
|
|
34
|
+
args = parser.parse_args()
|
|
35
|
+
excludes = args.exclude.split(",")
|
|
36
|
+
notice = True if args.notice else False
|
|
37
|
+
file = args.file if args.file.startswith(args.dir) else (args.dir + args.file if args.file else None)
|
|
38
|
+
try:
|
|
39
|
+
if file:
|
|
40
|
+
Yaml(file).convert(notice=notice)
|
|
41
|
+
print("Converting done")
|
|
42
|
+
elif args.dir:
|
|
43
|
+
convert_full_folder(args.dir, args.type.lower(), excludes=excludes, notice=notice)
|
|
44
|
+
else:
|
|
45
|
+
print("Nothing done, unknown reason")
|
|
46
|
+
except Exception as e:
|
|
47
|
+
print(f"Error: {e}")
|
|
48
|
+
|
|
49
|
+
if __name__ == '__main__':
|
|
50
|
+
main()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
source_path: must be a valid YAML/JSON file, eg. "./data/some.yaml"
|
|
3
|
+
target_path: can be specified or got from source_path automatically
|
|
4
|
+
Sample usage:
|
|
5
|
+
> Yaml("./some.yaml").convert()
|
|
6
|
+
> Yaml("./more.json").convert()
|
|
7
|
+
> convert_full_folder(excludes=["some", "more"])
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import yaml, json
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
ENCODINGSIG = 'utf-8-sig'
|
|
14
|
+
|
|
15
|
+
YAML = "yaml"
|
|
16
|
+
JSON = "json"
|
|
17
|
+
CONVERTS = {YAML: JSON, JSON: YAML}
|
|
18
|
+
|
|
19
|
+
class Yaml:
|
|
20
|
+
def __init__(self, source_path: str, target_path: str=None):
|
|
21
|
+
self.source = source_path
|
|
22
|
+
source_file = Path(source_path)
|
|
23
|
+
self.type = source_file.suffix.lstrip(".").lower()
|
|
24
|
+
self.target = target_path if target_path else str(source_file.with_suffix(f".{CONVERTS[self.type]}"))
|
|
25
|
+
def read(self) -> any:
|
|
26
|
+
with open(self.source, encoding=ENCODINGSIG) as file:
|
|
27
|
+
if self.type == YAML:
|
|
28
|
+
data = yaml.load(file, yaml.Loader)
|
|
29
|
+
else:
|
|
30
|
+
data = json.load(file)
|
|
31
|
+
return data
|
|
32
|
+
def write(self, data, indent=2, notice: bool=True):
|
|
33
|
+
with open(self.target, "w", encoding=ENCODINGSIG) as file:
|
|
34
|
+
if self.type == YAML:
|
|
35
|
+
json.dump(data, file, indent=2, ensure_ascii=False)
|
|
36
|
+
else:
|
|
37
|
+
yaml.dump(data, file, default_flow_style=False, sort_keys=False)
|
|
38
|
+
if notice: print(f"Writing: {self.target}")
|
|
39
|
+
def convert(self, indent=2, notice: bool=True):
|
|
40
|
+
self.write(self.read(), indent=indent, notice=notice)
|
|
41
|
+
|
|
42
|
+
def convert_full_folder(folder_path: str="./", source_type: str=YAML, excludes: list=[], notice=False):
|
|
43
|
+
folder = Path(folder_path)
|
|
44
|
+
for file in folder.glob(f"*.{source_type}"):
|
|
45
|
+
if file.is_file() and file.name not in [f"{item}.{source_type}" for item in excludes]:
|
|
46
|
+
Yaml(str(file)).convert(notice=notice)
|
|
47
|
+
print("All convertings done")
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yamer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: YAML to/from JSON File Conversion Tool
|
|
5
|
+
Home-page: https://github.com/asinerum/yamer
|
|
6
|
+
Author: Asinerum Conlang Project
|
|
7
|
+
Author-email: asinerum.com@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: formatize>=1.0.19
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# YAML vs JSON File Conversion Tool
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
```bash
|
|
22
|
+
pip install yamer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Sample Usage [Nov 25, 2026]
|
|
26
|
+
```bash
|
|
27
|
+
yamer -f some_file.yaml
|
|
28
|
+
yamer -f another_file.json
|
|
29
|
+
yamer -e some_file,another_file
|
|
30
|
+
yamer -d ./data -t json
|
|
31
|
+
yamer -t json
|
|
32
|
+
yamer -n yes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Detailed tips, tricks, and examples, can be found at project's repository
|
|
36
|
+
https://github.com/asinerum/yamer
|
|
37
|
+
|
|
38
|
+
(C)2026 Asinerum Conlang Project
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
src/yamer/__init__.py
|
|
6
|
+
src/yamer/cli.py
|
|
7
|
+
src/yamer/convert.py
|
|
8
|
+
src/yamer.egg-info/PKG-INFO
|
|
9
|
+
src/yamer.egg-info/SOURCES.txt
|
|
10
|
+
src/yamer.egg-info/dependency_links.txt
|
|
11
|
+
src/yamer.egg-info/entry_points.txt
|
|
12
|
+
src/yamer.egg-info/requires.txt
|
|
13
|
+
src/yamer.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
formatize>=1.0.19
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yamer
|