baldwin 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl

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.
baldwin/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
- """Manage a home directory with Git."""
2
- __version__ = '0.0.7'
1
+ """baldwin module."""
2
+ __version__ = '0.0.8'
baldwin/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ """Main entry point for the Baldwin CLI."""
2
+ from .main import baldwin as main
3
+
4
+ main()
baldwin/lib.py CHANGED
@@ -1,13 +1,13 @@
1
1
  """Baldwin library."""
2
2
  from collections.abc import Iterable
3
3
  from dataclasses import dataclass
4
- from datetime import UTC, datetime
4
+ from datetime import datetime, timezone
5
5
  from importlib import resources
6
6
  from itertools import chain
7
7
  from pathlib import Path
8
8
  from shlex import quote
9
9
  from shutil import which
10
- from typing import Literal
10
+ from typing import Any, Literal
11
11
  import logging
12
12
  import os
13
13
  import subprocess as sp
@@ -15,6 +15,7 @@ import subprocess as sp
15
15
  from binaryornot.check import is_binary
16
16
  from git import Actor, Repo
17
17
  import platformdirs
18
+ import tomlkit
18
19
 
19
20
  log = logging.getLogger(__name__)
20
21
 
@@ -76,7 +77,7 @@ def auto_commit() -> None:
76
77
  if items_to_remove:
77
78
  repo.index.remove(items_to_remove)
78
79
  if items_to_add or items_to_remove or len(repo.index.diff('HEAD')) > 0:
79
- repo.index.commit(f'Automatic commit @ {datetime.now(tz=UTC).isoformat()}',
80
+ repo.index.commit(f'Automatic commit @ {datetime.now(tz=timezone.utc).isoformat()}',
80
81
  committer=Actor('Auto-commiter', 'hgit@tat.sh'))
81
82
 
82
83
 
@@ -136,6 +137,14 @@ def get_git_path() -> Path:
136
137
  return platformdirs.user_data_path('home-git', roaming=True)
137
138
 
138
139
 
140
+ def get_config() -> tomlkit.TOMLDocument | dict[str, Any]:
141
+ """Get the configuration (TOML file)."""
142
+ config_file = platformdirs.user_config_path('baldwin', roaming=True) / 'config.toml'
143
+ if not config_file.exists():
144
+ return {}
145
+ return tomlkit.loads(config_file.read_text())
146
+
147
+
139
148
  def get_repo() -> Repo:
140
149
  """
141
150
  Get a :py:class:`git.Repo` object.
@@ -167,14 +176,15 @@ def format_(filenames: Iterable[Path | str] | None = None,
167
176
  for d in repo.index.diff(None) if d.a_path is not None),
168
177
  *(x for x in (Path.home() / y for y in repo.untracked_files)
169
178
  if x.is_file() and not is_binary(str(x))))
170
- if not (filenames := list(filenames)):
179
+ if not (filenames := list(filenames)) or not (prettier := which('prettier')):
171
180
  return
172
- with resources.path('baldwin.resources', 'prettier.config.json') as config_file:
173
- if not (prettier := which('prettier')):
174
- return
181
+ with resources.path('baldwin.resources', 'prettier.config.json') as default_config_file:
182
+ config_file = get_config().get('baldwin', {
183
+ 'prettier_config': str(default_config_file)
184
+ }).get('prettier_config')
175
185
  # Detect plugins
176
- node_modules_path = (Path(prettier).resolve(strict=True).parent / '..' /
177
- '..').resolve(strict=True)
186
+ node_modules_path = (Path(prettier).resolve(strict=True).parent /
187
+ '../..').resolve(strict=True)
178
188
  cmd_prefix = (prettier, '--config', str(config_file), '--write',
179
189
  '--no-error-on-unmatched-pattern', '--ignore-unknown', '--log-level',
180
190
  log_level, *chain(*(('--plugin', str(fp))
baldwin/main.py CHANGED
@@ -3,23 +3,23 @@ import logging
3
3
  import click
4
4
 
5
5
  from .lib import (
6
- auto_commit,
6
+ auto_commit as auto_commit_,
7
7
  format_,
8
- git,
9
- init,
10
- install_units,
8
+ git as git_,
9
+ init as init_,
10
+ install_units as install_units_,
11
11
  repo_info,
12
12
  set_git_env_vars,
13
13
  )
14
14
 
15
15
  log = logging.getLogger(__name__)
16
16
 
17
- __all__ = ('baldwin_main', 'git_main')
17
+ __all__ = ('baldwin', 'git')
18
18
 
19
19
 
20
20
  @click.group(context_settings={'help_option_names': ('-h', '--help')})
21
21
  @click.option('-d', '--debug', help='Enable debug logging.', is_flag=True)
22
- def baldwin_main(*, debug: bool = False) -> None:
22
+ def baldwin(*, debug: bool = False) -> None:
23
23
  """Manage a home directory with Git."""
24
24
  set_git_env_vars()
25
25
  logging.basicConfig(level=logging.DEBUG if debug else logging.ERROR)
@@ -30,31 +30,31 @@ def baldwin_main(*, debug: bool = False) -> None:
30
30
  'ignore_unknown_options': True
31
31
  })
32
32
  @click.argument('args', nargs=-1, type=click.UNPROCESSED)
33
- def git_main(args: tuple[str, ...]) -> None:
33
+ def git(args: tuple[str, ...]) -> None:
34
34
  """Wrap git with git-dir and work-tree passed."""
35
- git(args)
35
+ git_(args)
36
36
 
37
37
 
38
38
  @click.command(context_settings={'help_option_names': ('-h', '--help')})
39
- def init_main() -> None:
39
+ def init() -> None:
40
40
  """Start tracking a home directory."""
41
- init()
41
+ init_()
42
42
 
43
43
 
44
44
  @click.command(context_settings={'help_option_names': ('-h', '--help')})
45
- def auto_commit_main() -> None:
45
+ def auto_commit() -> None:
46
46
  """Automated commit of changed and untracked files."""
47
- auto_commit()
47
+ auto_commit_()
48
48
 
49
49
 
50
50
  @click.command(context_settings={'help_option_names': ('-h', '--help')})
51
- def format_main() -> None:
51
+ def format() -> None: # noqa: A001
52
52
  """Format changed and untracked files."""
53
53
  format_()
54
54
 
55
55
 
56
56
  @click.command(context_settings={'help_option_names': ('-h', '--help')})
57
- def info_main() -> None:
57
+ def info() -> None:
58
58
  """Get basic information about the repository."""
59
59
  data = repo_info()
60
60
  click.echo(f'git-dir path: {data.git_dir_path}')
@@ -62,14 +62,14 @@ def info_main() -> None:
62
62
 
63
63
 
64
64
  @click.command(context_settings={'help_option_names': ('-h', '--help')})
65
- def install_units_main() -> None:
65
+ def install_units() -> None:
66
66
  """Install systemd units for automatic committing."""
67
- install_units()
67
+ install_units_()
68
68
 
69
69
 
70
- baldwin_main.add_command(auto_commit_main, 'auto-commit')
71
- baldwin_main.add_command(format_main, 'format')
72
- baldwin_main.add_command(git_main, 'git')
73
- baldwin_main.add_command(info_main, 'info')
74
- baldwin_main.add_command(init_main, 'init')
75
- baldwin_main.add_command(install_units_main, 'install-units')
70
+ baldwin.add_command(auto_commit)
71
+ baldwin.add_command(format)
72
+ baldwin.add_command(git)
73
+ baldwin.add_command(info)
74
+ baldwin.add_command(init)
75
+ baldwin.add_command(install_units)
baldwin/py.typed ADDED
File without changes
@@ -0,0 +1,18 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 baldwin authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction,
7
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
8
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or
12
+ substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
18
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,26 +1,33 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: baldwin
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: Simple tracking of your home directory with easy-to-read diffs.
5
5
  License: MIT
6
6
  Keywords: command line,file management,git,version control
7
7
  Author: Andrew Udvare
8
8
  Author-email: audvare@gmail.com
9
- Requires-Python: >=3.12,<4
9
+ Requires-Python: >=3.10,<3.14
10
10
  Classifier: Development Status :: 2 - Pre-Alpha
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: MIT License
13
13
  Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
14
16
  Classifier: Programming Language :: Python :: 3.12
15
17
  Classifier: Programming Language :: Python :: 3.13
16
18
  Classifier: Typing :: Typed
19
+ Provides-Extra: erdantic
17
20
  Requires-Dist: binaryornot (>=0.4.4,<0.5.0)
18
21
  Requires-Dist: click (>=8.1.8,<9.0.0)
22
+ Requires-Dist: erdantic (<2.0) ; extra == "erdantic"
19
23
  Requires-Dist: gitpython (>=3.1.44,<4.0.0)
20
24
  Requires-Dist: platformdirs (>=4.3.6,<5.0.0)
25
+ Requires-Dist: tomlkit (>=0.13.2,<0.14.0)
26
+ Requires-Dist: typing-extensions (>=4.13.1,<5.0.0)
21
27
  Project-URL: Documentation, https://baldwin.readthedocs.org
28
+ Project-URL: Homepage, https://tatsh.github.io/baldwin/
29
+ Project-URL: Issues, https://github.com/Tatsh/baldwin/issues
22
30
  Project-URL: Repository, https://github.com/Tatsh/baldwin
23
- Project-URL: issues, https://github.com/Tatsh/baldwin/issues
24
31
  Description-Content-Type: text/markdown
25
32
 
26
33
  # Simple home directory versioning
@@ -32,7 +39,7 @@ Description-Content-Type: text/markdown
32
39
  ![PyPI - Version](https://img.shields.io/pypi/v/baldwin)
33
40
  ![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/baldwin)
34
41
  ![GitHub](https://img.shields.io/github/license/Tatsh/baldwin)
35
- ![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/baldwin/v0.0.7/master)
42
+ ![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/baldwin/v0.0.8/master)
36
43
 
37
44
  This is a conversion of my simple scripts to version my home directory with very specific excludes
38
45
  and formatting every file upon commit so that readable diffs can be generated.
@@ -0,0 +1,13 @@
1
+ baldwin/__init__.py,sha256=F--2vlUtecqV6dfCulqfPca9vSmeZCWcSlq3MltMgfQ,44
2
+ baldwin/__main__.py,sha256=7xKOM7FqRjhwJgK30RfKKpTNZCw0DJp5EiKo2KhtqSY,86
3
+ baldwin/lib.py,sha256=U3NLmy9VGk_pC_veb3r4pHqvDJSwuRIikewWnAZxUvQ,7942
4
+ baldwin/main.py,sha256=PrSKsF5zdG9VzWvZUpBkmfhpkweTbVnb8kNroiMSlNA,2030
5
+ baldwin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ baldwin/resources/default_gitattributes.txt,sha256=uGoWTSVgPmdGB2EUIROkTz3FikGpNGhdS95SuuvoCRo,984
7
+ baldwin/resources/default_gitignore.txt,sha256=oyxukNyK6F778C2jc7oIwosP7ou1WTdbuWwkpgGZtJA,3022
8
+ baldwin/resources/prettier.config.json,sha256=-Hher3B02YflULYn0IYOG_a-rDxpaaaQ0QXD30-5IgQ,387
9
+ baldwin-0.0.8.dist-info/LICENSE.txt,sha256=Y6e04wkVzxa82z5bhkF3-38WGKbISh0E28Eo0IxiOBU,1082
10
+ baldwin-0.0.8.dist-info/METADATA,sha256=2KKR3CwsxeSDUqAQEuU2uQ9ChdL_3pOwkfR4HBMrBSM,4819
11
+ baldwin-0.0.8.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
12
+ baldwin-0.0.8.dist-info/entry_points.txt,sha256=16CO-Z2MW3o6hkxwJplFgnyJuHuTngwrPqCNdSQAOcc,65
13
+ baldwin-0.0.8.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ bw=baldwin.main:baldwin
3
+ hgit=baldwin.main:git
4
+
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 baldwin authors
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
13
- all 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
21
- THE SOFTWARE.
@@ -1,11 +0,0 @@
1
- baldwin/__init__.py,sha256=XBpZev4nqfkkKQd5YUoqlcJK0kO9lxPH48gypaHnU7c,62
2
- baldwin/lib.py,sha256=_-lFY5lXRDRMYpUgWvAuC-3ljYwMDSLaUvWjOX1QIWE,7494
3
- baldwin/main.py,sha256=08a70OZLyRBamntbCdhhBNKSk9mywu_2M085I_mDa-s,2131
4
- baldwin/resources/default_gitattributes.txt,sha256=uGoWTSVgPmdGB2EUIROkTz3FikGpNGhdS95SuuvoCRo,984
5
- baldwin/resources/default_gitignore.txt,sha256=oyxukNyK6F778C2jc7oIwosP7ou1WTdbuWwkpgGZtJA,3022
6
- baldwin/resources/prettier.config.json,sha256=-Hher3B02YflULYn0IYOG_a-rDxpaaaQ0QXD30-5IgQ,387
7
- baldwin-0.0.7.dist-info/LICENSE.txt,sha256=TDfksi5bdmmL5cu6tAiN1iL7k38hWR2KbUg0JkASPO4,1082
8
- baldwin-0.0.7.dist-info/METADATA,sha256=thCF46_lMihnW2-ONI3bOjyJgY2qCgcw0Qmw3c1EGbU,4487
9
- baldwin-0.0.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
10
- baldwin-0.0.7.dist-info/entry_points.txt,sha256=1PNIgkO4Pmvb8BFPHPNzNHJtfRMqkbzaUWpBWPPmEhs,75
11
- baldwin-0.0.7.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- [console_scripts]
2
- bw=baldwin.main:baldwin_main
3
- hgit=baldwin.main:git_main
4
-