mooch.settings 0.0.1.dev1__py3-none-any.whl → 0.0.1.dev2__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.
mooch/settings/file.py CHANGED
@@ -17,17 +17,19 @@ UPDATED_KEY = "metadata.updated"
17
17
  class File:
18
18
  def __init__(self, settings_filepath: Path) -> None:
19
19
  self._filepath = settings_filepath
20
- self.create_file_if_not_exists()
21
-
22
- def create_file_if_not_exists(self) -> None:
23
- """Create the settings file if it does not exist."""
24
20
  if not self._filepath.exists():
25
- data = {}
26
- set_nested(data, NOTICE_KEY, NOTICE)
27
- set_nested(data, CREATED_KEY, datetime.now(tz=timezone.utc).isoformat())
28
- set_nested(data, UPDATED_KEY, datetime.now(tz=timezone.utc).isoformat())
21
+ self.create_file_and_directories()
22
+
23
+ def create_file_and_directories(self) -> None:
24
+ """Create the settings file and directories."""
25
+ # Ensure the parent directory exists
26
+ self._filepath.parent.mkdir(parents=True, exist_ok=True)
27
+ data = {}
28
+ set_nested(data, NOTICE_KEY, NOTICE)
29
+ set_nested(data, CREATED_KEY, datetime.now(tz=timezone.utc).isoformat())
30
+ set_nested(data, UPDATED_KEY, datetime.now(tz=timezone.utc).isoformat())
29
31
 
30
- self.save(data)
32
+ self.save(data)
31
33
 
32
34
  def load(self) -> dict[str, Any]:
33
35
  """Load the settings from the file."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mooch.settings
3
- Version: 0.0.1.dev1
3
+ Version: 0.0.1.dev2
4
4
  Summary: Python settings management package (mooch.settings). Uses a TOML file.
5
5
  Author-email: Nick Stuer <nickstuer@duck.com>
6
6
  Project-URL: Homepage, https://github.com/nickstuer/mooch.settings
@@ -1,10 +1,10 @@
1
1
  mooch/__init__.py,sha256=_ZVUSDxucTCJe9q2wP1tI31qEX3m4QGcH7kn3BRv6ic,112
2
2
  mooch/settings/__init__.py,sha256=Vs0DYdXwvsEU21Umpj893RoX2iSrL7n4Qb-5X4GYtiI,69
3
- mooch/settings/file.py,sha256=aYwSe6PUhgZki9IF6mKsXVb3VkxEPVoQ2u8PzDoTAJY,1403
3
+ mooch/settings/file.py,sha256=Q3lpANh8bvhZZ3iEGeQ7zpOn5Q7-7t6ZZbPZelv9NlM,1496
4
4
  mooch/settings/settings.py,sha256=fL229LnQjte7UP5_cMFaM1YnqKh7LLV8sgWJkgW18jk,2152
5
5
  mooch/settings/utils.py,sha256=V-aFKlrLaDfuJed4Yn-1pxlIM8jzdr4xRrNflBxLfXc,665
6
- mooch_settings-0.0.1.dev1.dist-info/licenses/LICENSE,sha256=FU8uKPcPjgV4M_aaYQPSM5abrktGqLFX2VEUk9oBYIE,1067
7
- mooch_settings-0.0.1.dev1.dist-info/METADATA,sha256=-K9SCr6DNS-IqsZvLlmUjp9fYRM6TwtR2pwmEGViwdU,2999
8
- mooch_settings-0.0.1.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- mooch_settings-0.0.1.dev1.dist-info/top_level.txt,sha256=BbCxYfdneRNeyhPyAVvt8IEDA_Px7BIm5zhH6hEmsAo,6
10
- mooch_settings-0.0.1.dev1.dist-info/RECORD,,
6
+ mooch_settings-0.0.1.dev2.dist-info/licenses/LICENSE,sha256=FU8uKPcPjgV4M_aaYQPSM5abrktGqLFX2VEUk9oBYIE,1067
7
+ mooch_settings-0.0.1.dev2.dist-info/METADATA,sha256=J6cril1SRUnV49K_si062bA10B8VR_AVY3qf7wDzozE,2999
8
+ mooch_settings-0.0.1.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ mooch_settings-0.0.1.dev2.dist-info/top_level.txt,sha256=BbCxYfdneRNeyhPyAVvt8IEDA_Px7BIm5zhH6hEmsAo,6
10
+ mooch_settings-0.0.1.dev2.dist-info/RECORD,,