Skip to content
Snippets Groups Projects
Commit cc512081 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

added file to schema

parent fe3e9933
No related branches found
No related tags found
No related merge requests found
# v2.15
* _TBA_
* added `file` to the schema
......@@ -15,6 +15,8 @@ you should instantiate a Descriptor. Descriptor reflects how your config is nest
.. autoclass:: satella.configuration.schema.String
.. autoclass:: satella.configuration.schema.File
.. autoclass:: satella.configuration.schema.IPv4
.. autoclass:: satella.configuration.schema.List
......
__version__ = '2.15a1'
__version__ = '2.15'
import os
import re
import typing as tp
......@@ -52,6 +53,21 @@ class String(Descriptor):
BASIC_MAKER = str
@staticmethod
def _make_file(v: str) -> bool:
if not os.path.isfile(v):
raise ConfigurationValidationError('Expected to find a file under %s'
% (v,))
@register_custom_descriptor('file')
class File(Descriptor):
"""This value must be a valid path to a file"""
BASIC_MAKER = _make_file
class Regexp(String):
"""
Base class for declaring regexp-based descriptors. Overload it's attribute REGEXP. Use as
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment