pgserviceparser 2.2.0__tar.gz → 2.3.0__tar.gz

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.
Files changed (25) hide show
  1. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/PKG-INFO +2 -2
  2. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/docs/mkdocs.yml +1 -1
  3. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser/__init__.py +13 -2
  4. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser.egg-info/PKG-INFO +2 -2
  5. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/test/test_lib.py +19 -0
  6. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.github/dependabot.yml +0 -0
  7. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.github/workflows/docs_builder.yml +0 -0
  8. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.github/workflows/release.yml +0 -0
  9. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.github/workflows/test.yml +0 -0
  10. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.github/workflows/wheel.yml +0 -0
  11. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.gitignore +0 -0
  12. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/.pre-commit-config.yaml +0 -0
  13. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/LICENSE +0 -0
  14. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/README.md +0 -0
  15. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/docs/docs/exceptions.md +0 -0
  16. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/docs/docs/index.md +0 -0
  17. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser/exceptions.py +0 -0
  18. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser.egg-info/SOURCES.txt +0 -0
  19. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser.egg-info/dependency_links.txt +0 -0
  20. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser.egg-info/requires.txt +0 -0
  21. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pgserviceparser.egg-info/top_level.txt +0 -0
  22. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/pyproject.toml +0 -0
  23. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/setup.cfg +0 -0
  24. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/test/__init__.py +0 -0
  25. {pgserviceparser-2.2.0 → pgserviceparser-2.3.0}/test/data/service_base.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pgserviceparser
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: A package parsing the PostgreSQL connection service file
5
5
  Author-email: David Signer <info@opengis.ch>, Julien Moura <julien.moura@oslandia.com>, Germán Carrillo <info@opengis.ch>, Denis Rouzaud <info@opengis.ch>
6
6
  License: MIT License
@@ -12,4 +12,4 @@ markdown_extensions:
12
12
 
13
13
  nav:
14
14
  - pgserviceparser: index.md
15
- - exceptions: excpetions.md
15
+ - exceptions: exceptions.md
@@ -6,12 +6,15 @@ from pathlib import Path
6
6
  from typing import Optional
7
7
 
8
8
  # package
9
- from pgserviceparser.exceptions import ServiceFileNotFound, ServiceNotFound
9
+ from .exceptions import ServiceFileNotFound, ServiceNotFound
10
10
 
11
11
 
12
- def conf_path() -> Path:
12
+ def conf_path(create_if_missing: Optional[bool] = False) -> Path:
13
13
  """Returns the path found for the pg_service.conf on the system as string.
14
14
 
15
+ Args:
16
+ create_if_missing: Whether to create the file (and eventually its parent folders) if the file does not exist.
17
+
15
18
  Returns:
16
19
  path to the pg_service.conf file as string
17
20
  """
@@ -26,6 +29,14 @@ def conf_path() -> Path:
26
29
  else: # Linux or Darwin (Mac)
27
30
  pg_config_path = Path("~/.pg_service.conf").expanduser()
28
31
 
32
+ if create_if_missing and not pg_config_path.exists():
33
+ # Make sure all parent directories exist
34
+ if not pg_config_path.parent.exists():
35
+ pg_config_path.parent.mkdir(parents=True, exist_ok=True)
36
+
37
+ # Finally, make sure the file itself exists
38
+ Path.touch(pg_config_path)
39
+
29
40
  return pg_config_path
30
41
 
31
42
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pgserviceparser
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: A package parsing the PostgreSQL connection service file
5
5
  Author-email: David Signer <info@opengis.ch>, Julien Moura <julien.moura@oslandia.com>, Germán Carrillo <info@opengis.ch>, Denis Rouzaud <info@opengis.ch>
6
6
  License: MIT License
@@ -123,6 +123,25 @@ class TestLib(unittest.TestCase):
123
123
  self.assertIn("service_tmp", service_names())
124
124
  remove_service("service_tmp")
125
125
 
126
+ def test_missing_file(self):
127
+ another_service_file_path = PGSERVICEPARSER_SRC_PATH / "test" / "data" / "new_folder" / "pgservice.conf"
128
+ os.environ["PGSERVICEFILE"] = str(another_service_file_path)
129
+
130
+ self.assertEqual(another_service_file_path, conf_path())
131
+ self.assertFalse(another_service_file_path.exists())
132
+ self.assertFalse(another_service_file_path.parent.exists())
133
+
134
+ self.assertEqual(another_service_file_path, conf_path(create_if_missing=True))
135
+ self.assertTrue(another_service_file_path.exists())
136
+ self.assertTrue(another_service_file_path.parent.exists())
137
+
138
+ os.environ["PGSERVICEFILE"] = str(self.service_file_path)
139
+
140
+ def tearDown(self):
141
+ new_folder_path = self.service_file_path.parent / "new_folder"
142
+ if new_folder_path.exists():
143
+ shutil.rmtree(new_folder_path)
144
+
126
145
 
127
146
  if __name__ == "__main__":
128
147
  unittest.main()
File without changes