Skip to content

Commit 8db884d

Browse files
committed
Moved utils/lib/toml.py to src lib/data, created pkg.py
1 parent 9ad026e commit 8db884d

12 files changed

Lines changed: 46 additions & 40 deletions

File tree

remove-json-keys/noxfile.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
import nox
66

77
paths = sn(root=Path(__file__).parent)
8-
sys.path.insert(0, str(paths.root / 'utils'))
8+
sys.path.insert(0, str(paths.root / 'src'))
99

10-
from lib import toml # type: ignore
10+
from remove_json_keys.lib import pkg # type: ignore
1111

1212
def session(func) : return nox.session(venv_backend='none')(func)
1313

14-
pkg = sn(dir=paths.root.name)
15-
pkg.name = pkg.dir.replace('-', '_')
14+
project = sn(dir=paths.root.name)
15+
project.name = project.dir.replace('-', '_')
1616

1717
# SESSIONS
1818

1919
@session
20-
def test(session) : session.run('py', '-m', pkg.name, *session.posargs, env={ 'PYTHONPATH': 'src' })
20+
def test(session) : session.run('py', '-m', project.name, *session.posargs, env={ 'PYTHONPATH': 'src' })
2121
@session
22-
def test_help(session) : session.run('py', '-m', pkg.name, '--help', *session.posargs, env={ 'PYTHONPATH': 'src' })
22+
def test_help(session) : session.run('py', '-m', project.name, '--help', *session.posargs, env={ 'PYTHONPATH': 'src' })
2323
@session
24-
def test_build(session) : session.run('pip', 'install', '-e', '.') ; session.run(pkg.dir, *session.posargs)
24+
def test_build(session) : session.run('pip', 'install', '-e', '.') ; session.run(project.dir, *session.posargs)
2525

2626
@session
27-
def debug(session) : session.run('py', '-m', pkg.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
27+
def debug(session) : session.run('py', '-m', project.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
2828

2929
@session
3030
def bump_patch(session) : session.run('py', 'utils/bump.py', '--patch', *session.posargs)
@@ -51,8 +51,8 @@ def clean(session) : session.run('py', 'utils/clean.py')
5151
# HELPERS
5252

5353
def push_bump(session):
54-
new_ver = toml.read('pyproject.toml')['project']['version']
54+
new_ver = pkg.get_ver()
5555
session.run('git', 'pull')
5656
session.run('git', 'add', '.')
57-
session.run('git', 'commit', '-m', f'Bumped {pkg.dir} versions to {new_ver}')
57+
session.run('git', 'commit', '-m', f'Bumped {project.dir} versions to {new_ver}')
5858
session.run('git', 'push')

remove-json-keys/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ license-files = [
2020
dependencies = [
2121
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
2222
"json5>=0.9.0,<1.0.0",
23+
"tomli>=2.0.0,<3.0.0",
24+
"tomli-w>=0.1.0,<2.0.0",
2325
]
2426
requires-python = ">=3.6,<4.0"
2527
keywords = [
@@ -70,6 +72,4 @@ remove-json = "remove_json_keys.__main__:main"
7072
[project.optional-dependencies]
7173
dev = [
7274
"nox>=2026.2.9",
73-
"tomli>=2.0.0,<3.0.0",
74-
"tomli-w>=0.1.0,<2.0.0",
7575
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import csv, file, json, sns, url
1+
from . import csv, file, json, sns, toml, url
22

3-
__all__ = ['csv', 'file', 'json', 'sns', 'url']
3+
__all__ = ['csv', 'file', 'json', 'sns', 'toml', 'url']
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pathlib import Path
2+
3+
from . import data
4+
5+
def get_ver() : return data.toml.read(Path(__file__).parent.parent / 'pyproject.toml')

remove-json-keys/utils/bump.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
from pathlib import Path
33
from types import SimpleNamespace as sn
44

5-
from lib import toml
6-
75
paths = sn(root=Path(__file__).parent.parent)
86
paths.pyproject = paths.root / 'pyproject.toml'
9-
paths.readme = paths.root / 'docs' / 'README.md'
10-
paths.msgs = paths.root / 'utils' / 'data' / 'messages.json'
7+
paths.readme = paths.root / 'docs/README.md'
8+
paths.msgs = paths.root / 'utils/data/messages.json'
119
sys.path.insert(0, str(paths.root / 'src'))
1210

1311
from remove_json_keys.lib import data, log # type: ignore
@@ -35,7 +33,7 @@ def bump_pyproject_vers(pyproject, project, new_ver):
3533

3634
# Bump project.version
3735
pyproject['project']['version'] = new_ver
38-
toml.write(paths.pyproject, pyproject)
36+
data.toml.write(paths.pyproject, pyproject)
3937
log.success(msgs.log_BUMPED_PROJECT_VER.format(prev_ver=project.version, **locals()))
4038

4139
# Bump project.urls['Releases']
@@ -44,7 +42,7 @@ def bump_pyproject_vers(pyproject, project, new_ver):
4442
log.data(f'{msgs.log_GENERATED_CLOG_URL}: {changelog_url}')
4543
log.info(f'{msgs.log_UPDATING_CLOG_URL_IN} pyproject.toml...')
4644
pyproject['project']['urls']['Changelog'] = changelog_url
47-
toml.write(paths.pyproject, pyproject)
45+
data.toml.write(paths.pyproject, pyproject)
4846
log.success(msgs.log_BUMPED_CLOG_URL_VER_TAG.format(**locals()))
4947

5048
def update_readme_vers(new_ver):
@@ -64,7 +62,7 @@ def main():
6462

6563
# Init project data
6664
log.info(f'{msgs.log_LOADING_PYPROJECT.format(pyproject_path=paths.pyproject)}...')
67-
pyproject = toml.read(paths.pyproject)
65+
pyproject = data.toml.read(paths.pyproject)
6866
project = sn(**pyproject['project'])
6967

7068
# Update files

translate-messages/noxfile.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
import nox
66

77
paths = sn(root=Path(__file__).parent)
8-
sys.path.insert(0, str(paths.root / 'utils'))
8+
sys.path.insert(0, str(paths.root / 'src'))
99

10-
from lib import toml # type: ignore
10+
from translate_messages.lib import pkg # type: ignore
1111

1212
def session(func) : return nox.session(venv_backend='none')(func)
1313

14-
pkg = sn(dir=paths.root.name)
15-
pkg.name = pkg.dir.replace('-', '_')
14+
project = sn(dir=paths.root.name)
15+
project.name = project.dir.replace('-', '_')
1616

1717
# SESSIONS
1818

1919
@session
20-
def test(session) : session.run('py', '-m', pkg.name, *session.posargs, env={ 'PYTHONPATH': 'src' })
20+
def test(session) : session.run('py', '-m', project.name, *session.posargs, env={ 'PYTHONPATH': 'src' })
2121
@session
22-
def test_help(session) : session.run('py', '-m', pkg.name, '--help', *session.posargs, env={ 'PYTHONPATH': 'src' })
22+
def test_help(session) : session.run('py', '-m', project.name, '--help', *session.posargs, env={ 'PYTHONPATH': 'src' })
2323
@session
24-
def test_build(session) : session.run('pip', 'install', '-e', '.') ; session.run(pkg.dir, *session.posargs)
24+
def test_build(session) : session.run('pip', 'install', '-e', '.') ; session.run(project.dir, *session.posargs)
2525

2626
@session
27-
def debug(session) : session.run('py', '-m', pkg.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
27+
def debug(session) : session.run('py', '-m', project.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
2828

2929
@session
3030
def bump_patch(session) : session.run('py', 'utils/bump.py', '--patch', *session.posargs)
@@ -51,8 +51,8 @@ def clean(session) : session.run('py', 'utils/clean.py')
5151
# HELPERS
5252

5353
def push_bump(session):
54-
new_ver = toml.read('pyproject.toml')['project']['version']
54+
new_ver = pkg.get_ver()
5555
session.run('git', 'pull')
5656
session.run('git', 'add', '.')
57-
session.run('git', 'commit', '-m', f'Bumped {pkg.dir} versions to {new_ver}')
57+
session.run('git', 'commit', '-m', f'Bumped {project.dir} versions to {new_ver}')
5858
session.run('git', 'push')

translate-messages/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ license-files = [
2020
dependencies = [
2121
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
2222
"json5>=0.9.0,<1.0.0",
23+
"tomli>=2.0.0,<3.0.0",
24+
"tomli-w>=0.1.0,<2.0.0",
2325
"translate>=3.8.0,<4.0.0",
2426
]
2527
requires-python = ">=3.6,<4.0"
@@ -82,6 +84,4 @@ translate-messages = "translate_messages.__main__:main"
8284
[project.optional-dependencies]
8385
dev = [
8486
"nox>=2026.2.9",
85-
"tomli>=2.0.0,<3.0.0",
86-
"tomli-w>=0.1.0,<2.0.0",
8787
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import csv, file, json, sns, url
1+
from . import csv, file, json, sns, toml, url
22

3-
__all__ = ['csv', 'file', 'json', 'sns', 'url']
3+
__all__ = ['csv', 'file', 'json', 'sns', 'toml', 'url']

translate-messages/utils/lib/toml.py renamed to translate-messages/src/translate_messages/lib/data/toml.py

File renamed without changes.

0 commit comments

Comments
 (0)