prettyconf 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 (33) hide show
  1. {prettyconf-2.2.0 → prettyconf-2.3.0}/AUTHORS.md +1 -0
  2. prettyconf-2.3.0/PKG-INFO +61 -0
  3. {prettyconf-2.2.0 → prettyconf-2.3.0}/README.rst +5 -9
  4. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/casts.py +25 -13
  5. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/configuration.py +6 -6
  6. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/loaders.py +37 -30
  7. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/parsers.py +21 -20
  8. prettyconf-2.3.0/prettyconf.egg-info/PKG-INFO +61 -0
  9. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf.egg-info/SOURCES.txt +10 -6
  10. prettyconf-2.3.0/prettyconf.egg-info/requires.txt +3 -0
  11. prettyconf-2.3.0/pyproject.toml +63 -0
  12. prettyconf-2.3.0/setup.cfg +4 -0
  13. prettyconf-2.3.0/tests/test_casts.py +130 -0
  14. prettyconf-2.3.0/tests/test_cfgfile.py +70 -0
  15. prettyconf-2.3.0/tests/test_commandline.py +37 -0
  16. prettyconf-2.3.0/tests/test_config.py +68 -0
  17. prettyconf-2.3.0/tests/test_envfile.py +66 -0
  18. prettyconf-2.3.0/tests/test_envvar.py +47 -0
  19. prettyconf-2.3.0/tests/test_filediscover.py +107 -0
  20. prettyconf-2.3.0/tests/test_parameterstore.py +105 -0
  21. prettyconf-2.2.0/CHANGES.txt +0 -140
  22. prettyconf-2.2.0/MANIFEST.in +0 -14
  23. prettyconf-2.2.0/PKG-INFO +0 -58
  24. prettyconf-2.2.0/prettyconf.egg-info/PKG-INFO +0 -58
  25. prettyconf-2.2.0/prettyconf.egg-info/requires.txt +0 -3
  26. prettyconf-2.2.0/requirements.txt +0 -9
  27. prettyconf-2.2.0/setup.cfg +0 -16
  28. prettyconf-2.2.0/setup.py +0 -63
  29. {prettyconf-2.2.0 → prettyconf-2.3.0}/LICENSE.txt +0 -0
  30. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/__init__.py +0 -0
  31. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf/exceptions.py +0 -0
  32. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf.egg-info/dependency_links.txt +0 -0
  33. {prettyconf-2.2.0 → prettyconf-2.3.0}/prettyconf.egg-info/top_level.txt +0 -0
@@ -8,3 +8,4 @@
8
8
  - [Osvaldo Santana Neto](https://github.com/osantana)
9
9
  - [Roel Adriaans](https://github.com/RoelAdriaans)
10
10
  - [Ronaldo Duarte](https://github.com/ronaldotd)
11
+ - [Christian Hartung](https://github.com/hartungstenio)
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: prettyconf
3
+ Version: 2.3.0
4
+ Summary: Separation of settings from code.
5
+ Author-email: Osvaldo Santana Neto <prettyconf@osantana.me>
6
+ License-Expression: MIT
7
+ Project-URL: Source, https://github.com/osantana/prettyconf
8
+ Project-URL: Download, https://github.com/osantana/prettyconf/releases
9
+ Keywords: asyncio,dispatcher,message,microservices,tasks
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Flask
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Programming Language :: Python
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/x-rst
27
+ License-File: LICENSE.txt
28
+ License-File: AUTHORS.md
29
+ Provides-Extra: aws
30
+ Requires-Dist: boto3<2.0.0,>=1.28.0; extra == "aws"
31
+ Dynamic: license-file
32
+
33
+ prettyconf
34
+ ==========
35
+
36
+ |Coverage Status| |Docs| |Codacy|
37
+
38
+ Pretty Conf is a Python library created to make easy the separation of
39
+ configuration and code following the recomendations of `12 Factor`_'s topic
40
+ about configs.
41
+
42
+ It is strongly inspired in `python-decouple`_ and both provides a similar
43
+ API.
44
+
45
+
46
+ Documentation
47
+ -------------
48
+
49
+ You can find ``prettyconf`` documentation at `Read the Docs`_ website.
50
+
51
+
52
+ .. _`12 Factor`: http://12factor.net/
53
+ .. _`Read the Docs`: http://prettyconf.readthedocs.org/
54
+ .. _`python-decouple`: https://github.com/henriquebastos/python-decouple
55
+
56
+ .. |Coverage Status| image:: https://coveralls.io/repos/osantana/prettyconf/badge.svg?branch=main
57
+ :target: https://coveralls.io/r/osantana/prettyconf?branch=main
58
+ .. |Docs| image:: https://readthedocs.org/projects/prettyconf/badge/?version=latest
59
+ :target: https://readthedocs.org/projects/prettyconf/?badge=latest
60
+ .. |Codacy| image:: https://app.codacy.com/project/badge/Grade/e5caa8df7068427b829fb1f9760de3bc
61
+ :target: https://app.codacy.com/gh/osantana/prettyconf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
@@ -1,7 +1,7 @@
1
1
  prettyconf
2
2
  ==========
3
3
 
4
- |Build Status| |Coverage Status| |Docs| |Codacy| |Landscape|
4
+ |Coverage Status| |Docs| |Codacy|
5
5
 
6
6
  Pretty Conf is a Python library created to make easy the separation of
7
7
  configuration and code following the recomendations of `12 Factor`_'s topic
@@ -21,13 +21,9 @@ You can find ``prettyconf`` documentation at `Read the Docs`_ website.
21
21
  .. _`Read the Docs`: http://prettyconf.readthedocs.org/
22
22
  .. _`python-decouple`: https://github.com/henriquebastos/python-decouple
23
23
 
24
- .. |Build Status| image:: https://circleci.com/gh/osantana/prettyconf.svg?style=svg
25
- :target: https://circleci.com/gh/osantana/prettyconf
26
- .. |Coverage Status| image:: https://coveralls.io/repos/osantana/prettyconf/badge.svg?branch=master
27
- :target: https://coveralls.io/r/osantana/prettyconf?branch=master
24
+ .. |Coverage Status| image:: https://coveralls.io/repos/osantana/prettyconf/badge.svg?branch=main
25
+ :target: https://coveralls.io/r/osantana/prettyconf?branch=main
28
26
  .. |Docs| image:: https://readthedocs.org/projects/prettyconf/badge/?version=latest
29
27
  :target: https://readthedocs.org/projects/prettyconf/?badge=latest
30
- .. |Codacy| image:: https://api.codacy.com/project/badge/grade/65576e834eb74d529921d8625347a5a1
31
- :target: https://www.codacy.com/app/osantana/prettyconf
32
- .. |Landscape| image:: https://landscape.io/github/osantana/prettyconf/master/landscape.svg?style=flat
33
- :target: https://landscape.io/github/osantana/prettyconf/master
28
+ .. |Codacy| image:: https://app.codacy.com/project/badge/Grade/e5caa8df7068427b829fb1f9760de3bc
29
+ :target: https://app.codacy.com/gh/osantana/prettyconf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
@@ -3,15 +3,25 @@ import json
3
3
  from .exceptions import InvalidConfiguration
4
4
 
5
5
 
6
- class AbstractCast(object):
6
+ class AbstractCast:
7
7
  def __call__(self, value):
8
8
  raise NotImplementedError() # pragma: no cover
9
9
 
10
10
 
11
11
  class Boolean(AbstractCast):
12
12
  default_values = {
13
- "1": True, "true": True, "yes": True, "y": True, "on": True, "t": True,
14
- "0": False, "false": False, "no": False, "n": False, "off": False, "f": False
13
+ '1': True,
14
+ 'true': True,
15
+ 'yes': True,
16
+ 'y': True,
17
+ 'on': True,
18
+ 't': True,
19
+ '0': False,
20
+ 'false': False,
21
+ 'no': False,
22
+ 'n': False,
23
+ 'off': False,
24
+ 'f': False,
15
25
  }
16
26
 
17
27
  def __init__(self, values=None):
@@ -22,19 +32,19 @@ class Boolean(AbstractCast):
22
32
  def __call__(self, value):
23
33
  try:
24
34
  return self.values[str(value).lower()]
25
- except KeyError:
26
- raise InvalidConfiguration("Error casting value {!r} to boolean".format(value))
35
+ except KeyError as ex:
36
+ raise InvalidConfiguration(f'Error casting value {value!r} to boolean') from ex
27
37
 
28
38
 
29
39
  class List(AbstractCast):
30
- def __init__(self, delimiter=",", quotes="\"'"):
40
+ def __init__(self, delimiter=',', quotes='"\''):
31
41
  self.delimiter = delimiter
32
42
  self.quotes = quotes
33
43
 
34
44
  def _parse(self, string):
35
45
  elements = []
36
46
  element = []
37
- quote = ""
47
+ quote = ''
38
48
  for char in string:
39
49
  # open quote
40
50
  if char in self.quotes and not quote:
@@ -44,7 +54,7 @@ class List(AbstractCast):
44
54
 
45
55
  # close quote
46
56
  if char in self.quotes and char == quote:
47
- quote = ""
57
+ quote = ''
48
58
  element.append(char)
49
59
  continue
50
60
 
@@ -53,7 +63,7 @@ class List(AbstractCast):
53
63
  continue
54
64
 
55
65
  if char == self.delimiter:
56
- elements.append("".join(element))
66
+ elements.append(''.join(element))
57
67
  element = []
58
68
  continue
59
69
 
@@ -61,7 +71,7 @@ class List(AbstractCast):
61
71
 
62
72
  # remaining element
63
73
  if element:
64
- elements.append("".join(element))
74
+ elements.append(''.join(element))
65
75
 
66
76
  return self.cast(e.strip() for e in elements)
67
77
 
@@ -93,8 +103,8 @@ class Option(AbstractCast):
93
103
  def __call__(self, value):
94
104
  try:
95
105
  return self.options[value]
96
- except KeyError:
97
- raise InvalidConfiguration("Invalid option {!r}".format(value))
106
+ except KeyError as ex:
107
+ raise InvalidConfiguration(f'Invalid option {value!r}') from ex
98
108
 
99
109
 
100
110
  class JSON(AbstractCast):
@@ -102,4 +112,6 @@ class JSON(AbstractCast):
102
112
  try:
103
113
  return json.loads(value)
104
114
  except json.JSONDecodeError as ex:
105
- raise InvalidConfiguration('Invalid option {!r}'.format(value)) from ex
115
+ raise InvalidConfiguration(f'Invalid option {value!r}') from ex
116
+ except TypeError:
117
+ return value
@@ -2,7 +2,7 @@ import ast
2
2
  import os
3
3
  import sys
4
4
 
5
- from .casts import Boolean, JSON, List, Option, Tuple
5
+ from .casts import JSON, Boolean, List, Option, Tuple
6
6
  from .exceptions import UnknownConfiguration
7
7
  from .loaders import Environment, RecursiveSearch
8
8
 
@@ -17,7 +17,7 @@ def _caller_path():
17
17
  return path
18
18
 
19
19
 
20
- class Configuration(object):
20
+ class Configuration:
21
21
  # Shortcut for standard casts
22
22
  boolean = Boolean()
23
23
  list = List()
@@ -39,11 +39,11 @@ class Configuration(object):
39
39
 
40
40
  def __repr__(self):
41
41
  loaders = ', '.join([repr(loader) for loader in self.loaders])
42
- return '{}(loaders=[{}])'.format(self.__class__.__name__, loaders)
42
+ return f'{self.__class__.__name__}(loaders=[{loaders}])'
43
43
 
44
44
  def __call__(self, item, cast=lambda v: v, **kwargs):
45
45
  if not callable(cast):
46
- raise TypeError("Cast must be callable")
46
+ raise TypeError('Cast must be callable')
47
47
 
48
48
  if self._recursive_search:
49
49
  self._recursive_search.starting_path = _caller_path()
@@ -55,6 +55,6 @@ class Configuration(object):
55
55
  continue
56
56
 
57
57
  if 'default' not in kwargs:
58
- raise UnknownConfiguration("Configuration '{}' not found".format(item))
58
+ raise UnknownConfiguration(f"Configuration '{item}' not found")
59
59
 
60
- return cast(kwargs["default"])
60
+ return cast(kwargs['default'])
@@ -76,7 +76,7 @@ class CommandLine(AbstractConfigurationLoader):
76
76
  self.configs = get_args(self.parser)
77
77
 
78
78
  def __repr__(self):
79
- return "CommandLine(parser={})".format(self.parser)
79
+ return f'CommandLine(parser={self.parser})'
80
80
 
81
81
  def __contains__(self, item):
82
82
  return item in self.configs
@@ -86,9 +86,9 @@ class CommandLine(AbstractConfigurationLoader):
86
86
 
87
87
 
88
88
  class IniFile(AbstractConfigurationFileLoader):
89
- file_extensions = ("*.ini", "*.cfg")
89
+ file_extensions = ('*.ini', '*.cfg')
90
90
 
91
- def __init__(self, filename, section="settings", var_format=lambda x: x):
91
+ def __init__(self, filename, section='settings', var_format=lambda x: x):
92
92
  """
93
93
  :param str filename: Path to the ``.ini/.cfg`` file.
94
94
  :param str section: Section name inside the config file.
@@ -101,7 +101,7 @@ class IniFile(AbstractConfigurationFileLoader):
101
101
  self._initialized = False
102
102
 
103
103
  def __repr__(self):
104
- return 'IniFile("{}")'.format(self.filename)
104
+ return f'IniFile("{self.filename}")'
105
105
 
106
106
  def _parse(self):
107
107
  if self._initialized:
@@ -110,11 +110,11 @@ class IniFile(AbstractConfigurationFileLoader):
110
110
  with open(self.filename) as inifile:
111
111
  try:
112
112
  self.parser.read_file(inifile)
113
- except (UnicodeDecodeError, MissingSectionHeaderError):
114
- raise InvalidConfigurationFile()
113
+ except (UnicodeDecodeError, MissingSectionHeaderError) as ex:
114
+ raise InvalidConfigurationFile() from ex
115
115
 
116
116
  if not self.parser.has_section(self.section):
117
- raise MissingSettingsSection("Missing [{}] section in {}".format(self.section, self.filename))
117
+ raise MissingSettingsSection(f'Missing [{self.section}] section in {self.filename}')
118
118
 
119
119
  self._initialized = True
120
120
 
@@ -134,12 +134,12 @@ class IniFile(AbstractConfigurationFileLoader):
134
134
 
135
135
  def __getitem__(self, item):
136
136
  if not self.check():
137
- raise KeyError("{!r}".format(item))
137
+ raise KeyError(f'{item!r}')
138
138
 
139
139
  try:
140
140
  return self.parser.get(self.section, self.var_format(item))
141
- except NoOptionError:
142
- raise KeyError("{!r}".format(item))
141
+ except NoOptionError as ex:
142
+ raise KeyError(f'{item!r}') from ex
143
143
 
144
144
 
145
145
  class Environment(AbstractConfigurationLoader):
@@ -154,7 +154,7 @@ class Environment(AbstractConfigurationLoader):
154
154
  self.var_format = var_format
155
155
 
156
156
  def __repr__(self):
157
- return "Environment(var_format={})".format(self.var_format)
157
+ return f'Environment(var_format={self.var_format})'
158
158
 
159
159
  def __contains__(self, item):
160
160
  return self.var_format(item) in os.environ
@@ -166,9 +166,9 @@ class Environment(AbstractConfigurationLoader):
166
166
 
167
167
 
168
168
  class EnvFile(AbstractConfigurationFileLoader):
169
- file_extensions = (".env",)
169
+ file_extensions = ('.env',)
170
170
 
171
- def __init__(self, filename=".env", var_format=str.upper):
171
+ def __init__(self, filename='.env', var_format=str.upper):
172
172
  """
173
173
  :param str filename: Path to the ``.env`` file.
174
174
  :param function var_format: A function to pre-format variable names.
@@ -178,7 +178,7 @@ class EnvFile(AbstractConfigurationFileLoader):
178
178
  self.configs = None
179
179
 
180
180
  def __repr__(self):
181
- return 'EnvFile("{}")'.format(self.filename)
181
+ return f'EnvFile("{self.filename}")'
182
182
 
183
183
  def _parse(self):
184
184
  if self.configs is not None:
@@ -207,13 +207,13 @@ class EnvFile(AbstractConfigurationFileLoader):
207
207
 
208
208
  def __getitem__(self, item):
209
209
  if not self.check():
210
- raise KeyError("{!r}".format(item))
210
+ raise KeyError(f'{item!r}')
211
211
 
212
212
  return self.configs[self.var_format(item)]
213
213
 
214
214
 
215
215
  class RecursiveSearch(AbstractConfigurationLoader):
216
- def __init__(self, starting_path=None, filetypes=((".env", EnvFile), (("*.ini", "*.cfg"), IniFile)), root_path="/"):
216
+ def __init__(self, starting_path=None, filetypes=(('.env', EnvFile), (('*.ini', '*.cfg'), IniFile)), root_path='/'):
217
217
  """
218
218
  :param str starting_path: The path to begin looking for configuration files.
219
219
  :param tuple filetypes: tuple of tuples with configuration loaders, order matters.
@@ -238,17 +238,17 @@ class RecursiveSearch(AbstractConfigurationLoader):
238
238
  @starting_path.setter
239
239
  def starting_path(self, path):
240
240
  if not path:
241
- raise InvalidPath("Invalid starting path")
241
+ raise InvalidPath('Invalid starting path')
242
242
 
243
243
  path = os.path.realpath(os.path.abspath(path))
244
244
  if not path.startswith(self.root_path):
245
- raise InvalidPath("Invalid root path given")
245
+ raise InvalidPath('Invalid root path given')
246
246
  self._starting_path = path
247
247
 
248
248
  @staticmethod
249
249
  def get_filenames(path, patterns):
250
250
  filenames = []
251
- if type(patterns) is str:
251
+ if isinstance(patterns, str):
252
252
  patterns = (patterns,)
253
253
 
254
254
  for pattern in patterns:
@@ -291,7 +291,7 @@ class RecursiveSearch(AbstractConfigurationLoader):
291
291
  return self._config_files
292
292
 
293
293
  def __repr__(self):
294
- return "RecursiveSearch(starting_path={})".format(self.starting_path)
294
+ return f'RecursiveSearch(starting_path={self.starting_path})'
295
295
 
296
296
  def __contains__(self, item):
297
297
  for config_file in self.config_files:
@@ -306,11 +306,18 @@ class RecursiveSearch(AbstractConfigurationLoader):
306
306
  except KeyError:
307
307
  continue
308
308
  else:
309
- raise KeyError("{!r}".format(item))
309
+ raise KeyError(f'{item!r}')
310
310
 
311
311
 
312
312
  class AwsParameterStore(AbstractConfigurationLoader):
313
- def __init__(self, path="/", aws_access_key_id=None, aws_secret_access_key=None, region_name="us-east-1", endpoint_url=None):
313
+ def __init__(
314
+ self,
315
+ path='/',
316
+ aws_access_key_id=None,
317
+ aws_secret_access_key=None,
318
+ region_name='us-east-1',
319
+ endpoint_url=None,
320
+ ):
314
321
  if not boto3:
315
322
  raise RuntimeError(
316
323
  'AwsParameterStore requires [aws] feature. Please install it: "pip install prettyconf[aws]"'
@@ -326,14 +333,14 @@ class AwsParameterStore(AbstractConfigurationLoader):
326
333
 
327
334
  def _store_parameters(self, parameters):
328
335
  for parameter in parameters:
329
- self._parameters[parameter["Name"].split("/")[-1]] = parameter["Value"]
336
+ self._parameters[parameter['Name'].split('/')[-1]] = parameter['Value']
330
337
 
331
338
  def _fetch_parameters(self):
332
339
  if self._fetched:
333
340
  return
334
341
 
335
342
  client = boto3.client(
336
- service_name="ssm",
343
+ service_name='ssm',
337
344
  aws_access_key_id=self.aws_access_key_id,
338
345
  aws_secret_access_key=self.aws_secret_access_key,
339
346
  region_name=self.region_name,
@@ -341,13 +348,13 @@ class AwsParameterStore(AbstractConfigurationLoader):
341
348
  )
342
349
 
343
350
  response = client.get_parameters_by_path(Path=self.path)
344
- next_token = response.get("NextToken")
345
- self._store_parameters(response["Parameters"])
351
+ next_token = response.get('NextToken')
352
+ self._store_parameters(response['Parameters'])
346
353
 
347
354
  while next_token:
348
355
  response = client.get_parameters_by_path(Path=self.path, NextToken=next_token)
349
- next_token = response.get("NextToken")
350
- self._store_parameters(response["Parameters"])
356
+ next_token = response.get('NextToken')
357
+ self._store_parameters(response['Parameters'])
351
358
 
352
359
  self._fetched = True
353
360
 
@@ -360,7 +367,7 @@ class AwsParameterStore(AbstractConfigurationLoader):
360
367
  return super().check()
361
368
 
362
369
  def __repr__(self):
363
- return "AwsParameterStore(path={} region={})".format(self.path, self.region_name)
370
+ return f'AwsParameterStore(path={self.path} region={self.region_name})'
364
371
 
365
372
  def __contains__(self, item):
366
373
  if not self.check():
@@ -370,6 +377,6 @@ class AwsParameterStore(AbstractConfigurationLoader):
370
377
 
371
378
  def __getitem__(self, item):
372
379
  if not self.check():
373
- raise KeyError("{!r}".format(item))
380
+ raise KeyError(f'{item!r}')
374
381
 
375
382
  return self._parameters[item]
@@ -1,16 +1,17 @@
1
- from typing import Union, Tuple, Iterator
1
+ from collections.abc import Iterator
2
+ from typing import Union
2
3
 
3
- STATE_INITIAL = "initial"
4
- STATE_PARSING_KEY = "parsing_key"
5
- STATE_PARSING_VALUE = "parsing_value"
6
- STATE_PARSING_VALUE_ESCAPE = "parsing_value_escape"
7
- STATE_PARSING_COMMENT = "parsing_comment"
4
+ STATE_INITIAL = 'initial'
5
+ STATE_PARSING_KEY = 'parsing_key'
6
+ STATE_PARSING_VALUE = 'parsing_value'
7
+ STATE_PARSING_VALUE_ESCAPE = 'parsing_value_escape'
8
+ STATE_PARSING_COMMENT = 'parsing_comment'
8
9
 
9
- COMMENT = "#"
10
- END_OF_LINE = "\n"
11
- ESCAPE_CHAR = "\\"
12
- SPACES = set(" \n")
13
- QUOTES = set("'\"")
10
+ COMMENT = '#'
11
+ END_OF_LINE = '\n'
12
+ ESCAPE_CHAR = '\\'
13
+ SPACES = set(' \n')
14
+ QUOTES = set('\'"')
14
15
 
15
16
 
16
17
  class BufferedStreamReader:
@@ -46,10 +47,10 @@ class EnvFileParser:
46
47
 
47
48
  self._current_key = []
48
49
  self._current_value = []
49
- self._current_quote = ""
50
+ self._current_quote = ''
50
51
  self._key_parsed = False
51
52
 
52
- def parse_config(self) -> Iterator[Tuple[str, str]]:
53
+ def parse_config(self) -> Iterator[tuple[str, str]]:
53
54
  key = self._current_key
54
55
  value = self._current_value
55
56
 
@@ -94,7 +95,7 @@ class EnvFileParser:
94
95
 
95
96
  return False
96
97
 
97
- def _finish_comment(self, char) -> Union[bool, Tuple[str, str]]:
98
+ def _finish_comment(self, char) -> Union[bool, tuple[str, str]]:
98
99
  if not (self.state == STATE_PARSING_COMMENT and char == END_OF_LINE):
99
100
  return False
100
101
 
@@ -113,7 +114,7 @@ class EnvFileParser:
113
114
  return True
114
115
 
115
116
  if self._current_quote == char:
116
- self._current_quote = ""
117
+ self._current_quote = ''
117
118
  return True
118
119
 
119
120
  self._current_value.append(char)
@@ -137,7 +138,7 @@ class EnvFileParser:
137
138
  if self.state != STATE_PARSING_KEY:
138
139
  return False
139
140
 
140
- if char == "=":
141
+ if char == '=':
141
142
  self.state = STATE_PARSING_VALUE
142
143
  self._key_parsed = True
143
144
  return True
@@ -149,7 +150,7 @@ class EnvFileParser:
149
150
  self._current_key.append(char)
150
151
  return True
151
152
 
152
- def _parse_value(self, char) -> Union[bool, Tuple[str, str]]:
153
+ def _parse_value(self, char) -> Union[bool, tuple[str, str]]:
153
154
  if self.state != STATE_PARSING_VALUE:
154
155
  return False
155
156
 
@@ -157,7 +158,7 @@ class EnvFileParser:
157
158
  self.state = STATE_PARSING_VALUE_ESCAPE
158
159
  return True
159
160
 
160
- if char == " " and not (self._current_value or self._current_quote):
161
+ if char == ' ' and not (self._current_value or self._current_quote):
161
162
  return True
162
163
 
163
164
  if char == END_OF_LINE:
@@ -180,8 +181,8 @@ class EnvFileParser:
180
181
  self._current_value.extend([ESCAPE_CHAR, char])
181
182
  return True
182
183
 
183
- def _return_current_config(self) -> Tuple[str, str]:
184
- key, value = "".join(self._current_key), "".join(self._current_value)
184
+ def _return_current_config(self) -> tuple[str, str]:
185
+ key, value = ''.join(self._current_key), ''.join(self._current_value)
185
186
  self._reset_state()
186
187
  return key.rstrip(), value.rstrip()
187
188
 
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: prettyconf
3
+ Version: 2.3.0
4
+ Summary: Separation of settings from code.
5
+ Author-email: Osvaldo Santana Neto <prettyconf@osantana.me>
6
+ License-Expression: MIT
7
+ Project-URL: Source, https://github.com/osantana/prettyconf
8
+ Project-URL: Download, https://github.com/osantana/prettyconf/releases
9
+ Keywords: asyncio,dispatcher,message,microservices,tasks
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Flask
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Programming Language :: Python
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/x-rst
27
+ License-File: LICENSE.txt
28
+ License-File: AUTHORS.md
29
+ Provides-Extra: aws
30
+ Requires-Dist: boto3<2.0.0,>=1.28.0; extra == "aws"
31
+ Dynamic: license-file
32
+
33
+ prettyconf
34
+ ==========
35
+
36
+ |Coverage Status| |Docs| |Codacy|
37
+
38
+ Pretty Conf is a Python library created to make easy the separation of
39
+ configuration and code following the recomendations of `12 Factor`_'s topic
40
+ about configs.
41
+
42
+ It is strongly inspired in `python-decouple`_ and both provides a similar
43
+ API.
44
+
45
+
46
+ Documentation
47
+ -------------
48
+
49
+ You can find ``prettyconf`` documentation at `Read the Docs`_ website.
50
+
51
+
52
+ .. _`12 Factor`: http://12factor.net/
53
+ .. _`Read the Docs`: http://prettyconf.readthedocs.org/
54
+ .. _`python-decouple`: https://github.com/henriquebastos/python-decouple
55
+
56
+ .. |Coverage Status| image:: https://coveralls.io/repos/osantana/prettyconf/badge.svg?branch=main
57
+ :target: https://coveralls.io/r/osantana/prettyconf?branch=main
58
+ .. |Docs| image:: https://readthedocs.org/projects/prettyconf/badge/?version=latest
59
+ :target: https://readthedocs.org/projects/prettyconf/?badge=latest
60
+ .. |Codacy| image:: https://app.codacy.com/project/badge/Grade/e5caa8df7068427b829fb1f9760de3bc
61
+ :target: https://app.codacy.com/gh/osantana/prettyconf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
@@ -1,11 +1,7 @@
1
1
  AUTHORS.md
2
- CHANGES.txt
3
2
  LICENSE.txt
4
- MANIFEST.in
5
3
  README.rst
6
- requirements.txt
7
- setup.cfg
8
- setup.py
4
+ pyproject.toml
9
5
  prettyconf/__init__.py
10
6
  prettyconf/casts.py
11
7
  prettyconf/configuration.py
@@ -16,4 +12,12 @@ prettyconf.egg-info/PKG-INFO
16
12
  prettyconf.egg-info/SOURCES.txt
17
13
  prettyconf.egg-info/dependency_links.txt
18
14
  prettyconf.egg-info/requires.txt
19
- prettyconf.egg-info/top_level.txt
15
+ prettyconf.egg-info/top_level.txt
16
+ tests/test_casts.py
17
+ tests/test_cfgfile.py
18
+ tests/test_commandline.py
19
+ tests/test_config.py
20
+ tests/test_envfile.py
21
+ tests/test_envvar.py
22
+ tests/test_filediscover.py
23
+ tests/test_parameterstore.py
@@ -0,0 +1,3 @@
1
+
2
+ [aws]
3
+ boto3<2.0.0,>=1.28.0