Skip to content

Commit

Permalink
remove yaml module
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-black-tea committed Apr 16, 2023
1 parent 8b4476e commit 17c8ce2
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 290 deletions.
1 change: 1 addition & 0 deletions .github/scripts/prepare-publish-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyyaml
53 changes: 53 additions & 0 deletions .github/scripts/prepare-publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
@author : Hu Ji
@file : perpare.py
@time : 2023/04/16
@site :
@software: PyCharm
,----------------, ,---------,
,-----------------------, ," ,"|
," ,"| ," ," |
+-----------------------+ | ," ," |
| .-----------------. | | +---------+ |
| | | | | | -==----'| |
| | $ sudo rm -rf / | | | | | |
| | | | |/----|`---= | |
| | | | | ,/|==== ooo | ;
| | | | | // |(((( [33]| ,"
| `-----------------' |," .;'| |(((( | ,"
+-----------------------+ ;; | | |,"
/_)______________(_/ //' | +---------+
___________________________/___ `,
/ oooooooooooooooo .o. oooo /, \,"-----------
/ ==ooooooooooooooo==.o. ooo= // ,`\--{)B ,"
/_==__==========__==_ooo__ooo=_/' /___________,"
"""
import json
import os
import re

import yaml

if __name__ == '__main__':
root_path = os.path.abspath(os.path.join(__file__, "..", "..", "..", "src", "linktools"))

version = os.environ["VERSION"]
if version.startswith("v"):
version = version[len("v"):]

patten = re.compile(r"^__version__\s+=\s*\"\S*\"$")
with open(os.path.join(root_path, "version.py"), "rt") as fd:
file_data = fd.read()
with open(os.path.join(root_path, "version.py"), "wt") as fd:
for line in file_data.splitlines(keepends=True):
fd.write(patten.sub(f"__version__ = \"{version}\"", line))

with open(os.path.join(root_path, "assets", "tools.yml"), "rb") as fd:
file_data = yaml.safe_load(fd)
with open(os.path.join(root_path, "assets", "tools.json"), "wt") as fd:
json.dump(file_data, fd, indent=2, ensure_ascii=True)
os.remove(os.path.join(root_path, "assets", "tools.yml"))
6 changes: 4 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
- name: Get previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Replace version
run: ver=${{ steps.previoustag.outputs.tag }} && new_ver=${ver#v} && sed -i "s/__RELEASE_VERSION__/${new_ver}/g" src/linktools/version.py
- name: Prepare package
run: |
pip install -r .github/scripts/prepare-publish-requirements.txt
VERSION=${{ steps.previoustag.outputs.tag }} python .github/scripts/prepare-publish.py
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish package
Expand Down
1 change: 0 additions & 1 deletion requirements.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"install_requires": [
"rich",
"pyyaml",
"filelock>=3.4.0"
],
"extras_require": {
Expand Down
1 change: 0 additions & 1 deletion src/linktools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@
from . import utils
from . import decorator
from ._logging import LogHandler
from ._config import Config
from ._tools import ToolContainer, ToolExecError, Tool
from ._environ import BaseEnviron, environ
229 changes: 0 additions & 229 deletions src/linktools/_config.py

This file was deleted.

Loading

0 comments on commit 17c8ce2

Please sign in to comment.