generated from Hazel/python-project
Compare commits
4 Commits
4f252a83cc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cf219d917 | |||
| 25c601ecee | |||
| 96bb1fce8e | |||
| adef56790f |
21
README.md
21
README.md
@@ -1,3 +1,22 @@
|
||||
# Json-Unescape
|
||||
|
||||
Unescape json string, which is escaped for json. This is usually necessarry for webscraping.
|
||||
Unescape json string, which is escaped for json. This is usually necessarry for webscraping.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install json-unescape
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
>>> from json_unescape import escape_json, unescape_json
|
||||
|
||||
>>> escape_json('{"foo": "bar,,,eee"}')
|
||||
'{"key": "{\\"foo\\": \\"bar,,,eee\\"}"}'
|
||||
|
||||
>>> unescape_json(escape_json('{"key": "{\\"foo\\": \\"bar,,,eee\\"}"}'))
|
||||
'{"foo": "bar,,,eee"}'
|
||||
```
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
__version__ = "0.0.0"
|
||||
__version__ = "0.0.1"
|
||||
__name__ = "json_unescape"
|
||||
@@ -0,0 +1,10 @@
|
||||
import json
|
||||
|
||||
|
||||
def escape_json(json_str: str) -> str:
|
||||
nested_object: dict = {"key": json_str}
|
||||
return json.dumps(nested_object)
|
||||
|
||||
def unescape_json(json_str: str) -> str:
|
||||
nested_json_string: str = '{"key": ' + json_str + '}'
|
||||
return json.loads(nested_json_string)["key"]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
from .__about__ import __name__, __version__
|
||||
|
||||
|
||||
def cli():
|
||||
print(f"Running {__name__} version {__version__} from __main__.py")
|
||||
@@ -12,9 +12,6 @@ classifiers = [
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
json-unescape = "json_unescape.__main__:cli"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling", "hatch-requirements-txt"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
20
release
Executable file
20
release
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# install build tools
|
||||
pip install build
|
||||
pip install twine
|
||||
pip install hatch
|
||||
|
||||
|
||||
# increment version in pyproject.toml
|
||||
hatch version micro
|
||||
git add json_unescape/__about__.py
|
||||
git commit -m "bump version"
|
||||
git push
|
||||
|
||||
# build package
|
||||
python3 -m build --wheel
|
||||
|
||||
# upload to pypi
|
||||
python3 -m twine upload dist/*
|
||||
python3 -m twine upload --skip-existing --repository gitea dist/*
|
||||
Reference in New Issue
Block a user