DefPixel 0.1.0__3-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.
Files changed (92) hide show
  1. DefPixel/DataAccessObject/Configuration.py +15 -0
  2. DefPixel/DataAccessObject/Connection.py +25 -0
  3. DefPixel/DataAccessObject/Implements/Sqlite/Configuration.py +16 -0
  4. DefPixel/DataAccessObject/Implements/Sqlite/Connection.py +96 -0
  5. DefPixel/DataAccessObject/Implements/Sqlite/Constraint.py +9 -0
  6. DefPixel/DataAccessObject/Implements/Sqlite/Constraints/ForeignKey.py +16 -0
  7. DefPixel/DataAccessObject/Implements/Sqlite/Constraints/PrimaryKey.py +15 -0
  8. DefPixel/DataAccessObject/Implements/Sqlite/Constraints/Unique.py +25 -0
  9. DefPixel/DataAccessObject/Implements/Sqlite/Constraints/__init__.py +11 -0
  10. DefPixel/DataAccessObject/Implements/Sqlite/Context.py +36 -0
  11. DefPixel/DataAccessObject/Implements/Sqlite/Cursor.py +87 -0
  12. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Create.py +115 -0
  13. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Delete.py +35 -0
  14. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Drop.py +34 -0
  15. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Get.py +24 -0
  16. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Insert.py +59 -0
  17. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Select.py +109 -0
  18. DefPixel/DataAccessObject/Implements/Sqlite/Executors/Update.py +34 -0
  19. DefPixel/DataAccessObject/Implements/Sqlite/Executors/__init__.py +19 -0
  20. DefPixel/DataAccessObject/Implements/Sqlite/Expr.py +42 -0
  21. DefPixel/DataAccessObject/Implements/Sqlite/Exprs/Alias.py +20 -0
  22. DefPixel/DataAccessObject/Implements/Sqlite/Exprs/Is.py +29 -0
  23. DefPixel/DataAccessObject/Implements/Sqlite/Exprs/__init__.py +13 -0
  24. DefPixel/DataAccessObject/Implements/Sqlite/Filters/Compare.py +149 -0
  25. DefPixel/DataAccessObject/Implements/Sqlite/Filters/Operator.py +26 -0
  26. DefPixel/DataAccessObject/Implements/Sqlite/Filters/String.py +23 -0
  27. DefPixel/DataAccessObject/Implements/Sqlite/Filters/__init__.py +30 -0
  28. DefPixel/DataAccessObject/Implements/Sqlite/Function.py +15 -0
  29. DefPixel/DataAccessObject/Implements/Sqlite/Functions/Common.py +34 -0
  30. DefPixel/DataAccessObject/Implements/Sqlite/Functions/Condition.py +21 -0
  31. DefPixel/DataAccessObject/Implements/Sqlite/Functions/__init__.py +16 -0
  32. DefPixel/DataAccessObject/Implements/Sqlite/Index.py +23 -0
  33. DefPixel/DataAccessObject/Implements/Sqlite/Joins/FullOuter.py +19 -0
  34. DefPixel/DataAccessObject/Implements/Sqlite/Joins/Inner.py +19 -0
  35. DefPixel/DataAccessObject/Implements/Sqlite/Joins/Join.py +31 -0
  36. DefPixel/DataAccessObject/Implements/Sqlite/Joins/LeftOuter.py +19 -0
  37. DefPixel/DataAccessObject/Implements/Sqlite/Joins/RightOuter.py +19 -0
  38. DefPixel/DataAccessObject/Implements/Sqlite/Joins/__init__.py +13 -0
  39. DefPixel/DataAccessObject/Implements/Sqlite/Mapping.py +303 -0
  40. DefPixel/DataAccessObject/Implements/Sqlite/Orders/Ascend.py +24 -0
  41. DefPixel/DataAccessObject/Implements/Sqlite/Orders/Descend.py +24 -0
  42. DefPixel/DataAccessObject/Implements/Sqlite/Orders/__init__.py +9 -0
  43. DefPixel/DataAccessObject/Implements/Sqlite/Session.py +37 -0
  44. DefPixel/DataAccessObject/Implements/Sqlite/Type.py +75 -0
  45. DefPixel/DataAccessObject/Implements/Sqlite/Types/Binary.py +28 -0
  46. DefPixel/DataAccessObject/Implements/Sqlite/Types/DateTime.py +42 -0
  47. DefPixel/DataAccessObject/Implements/Sqlite/Types/Numeric.py +49 -0
  48. DefPixel/DataAccessObject/Implements/Sqlite/Types/String.py +28 -0
  49. DefPixel/DataAccessObject/Implements/Sqlite/Types/__init__.py +34 -0
  50. DefPixel/DataAccessObject/Implements/Sqlite/__init__.py +39 -0
  51. DefPixel/DataAccessObject/Implements/__init__.py +1 -0
  52. DefPixel/DataAccessObject/Properties/Database/Context.py +33 -0
  53. DefPixel/DataAccessObject/Properties/Database/Cursor.py +27 -0
  54. DefPixel/DataAccessObject/Properties/Database/Database.py +48 -0
  55. DefPixel/DataAccessObject/Properties/Database/Executor.py +38 -0
  56. DefPixel/DataAccessObject/Properties/Database/Executors.py +31 -0
  57. DefPixel/DataAccessObject/Properties/Database/Fetch.py +37 -0
  58. DefPixel/DataAccessObject/Properties/Database/Filter.py +21 -0
  59. DefPixel/DataAccessObject/Properties/Database/Run.py +39 -0
  60. DefPixel/DataAccessObject/Properties/Database/Session.py +36 -0
  61. DefPixel/DataAccessObject/Properties/Database/__init__.py +25 -0
  62. DefPixel/DataAccessObject/Properties/Dataclass.py +25 -0
  63. DefPixel/DataAccessObject/Properties/Document/Document.py +36 -0
  64. DefPixel/DataAccessObject/Properties/Document/__init__.py +7 -0
  65. DefPixel/DataAccessObject/Properties/Index/Index.py +48 -0
  66. DefPixel/DataAccessObject/Properties/Index/__init__.py +7 -0
  67. DefPixel/DataAccessObject/Properties/KeyValue/KeyValue.py +44 -0
  68. DefPixel/DataAccessObject/Properties/KeyValue/__init__.py +7 -0
  69. DefPixel/DataAccessObject/Properties/__init__.py +15 -0
  70. DefPixel/DataAccessObject/__init__.py +9 -0
  71. DefPixel/Validator/Pattern.py +36 -0
  72. DefPixel/Validator/Patterns/Array.py +30 -0
  73. DefPixel/Validator/Patterns/Common.py +92 -0
  74. DefPixel/Validator/Patterns/Compare.py +180 -0
  75. DefPixel/Validator/Patterns/Condition.py +60 -0
  76. DefPixel/Validator/Patterns/DataObject.py +85 -0
  77. DefPixel/Validator/Patterns/DateTime.py +111 -0
  78. DefPixel/Validator/Patterns/Number.py +43 -0
  79. DefPixel/Validator/Patterns/Object.py +150 -0
  80. DefPixel/Validator/Patterns/Size.py +110 -0
  81. DefPixel/Validator/Patterns/String.py +85 -0
  82. DefPixel/Validator/Patterns/Type.py +350 -0
  83. DefPixel/Validator/Patterns/__init__.py +137 -0
  84. DefPixel/Validator/Validate.py +29 -0
  85. DefPixel/Validator/Validator.py +30 -0
  86. DefPixel/Validator/__init__.py +11 -0
  87. DefPixel/__init__.py +0 -0
  88. defpixel-0.1.0.dist-info/METADATA +114 -0
  89. defpixel-0.1.0.dist-info/RECORD +92 -0
  90. defpixel-0.1.0.dist-info/WHEEL +6 -0
  91. defpixel-0.1.0.dist-info/licenses/LICENSE +674 -0
  92. defpixel-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Configuration import Configuration
4
+ from .Connection import Connection
5
+ from .Cursor import Cursor
6
+ from .Session import Session
7
+ from .Context import Context
8
+
9
+ from .Mapping import (
10
+ column,
11
+ table,
12
+ view,
13
+ )
14
+
15
+ from .Constraint import Constraint
16
+ from .Index import Index
17
+ from .Expr import Expr
18
+ from .Function import Function
19
+
20
+ from sqlite3 import register_adapter
21
+ from datetime import datetime
22
+
23
+ __all__ = (
24
+ 'Configuration',
25
+ 'Connection',
26
+ 'Cursor',
27
+ 'Session',
28
+ 'Context',
29
+ 'column',
30
+ 'table',
31
+ 'view',
32
+ 'Constraint',
33
+ 'Index',
34
+ 'Expr',
35
+ 'Function',
36
+ )
37
+
38
+
39
+ register_adapter(datetime, datetime.isoformat)
@@ -0,0 +1 @@
1
+ # -*- coding: utf-8 -*-
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Protocol,
6
+ runtime_checkable,
7
+ )
8
+
9
+ __all__ = (
10
+ 'Context'
11
+ )
12
+
13
+
14
+ @runtime_checkable
15
+ class Context(Protocol):
16
+ """Protocol for database execution results."""
17
+
18
+ @abstractmethod
19
+ def rows(self):
20
+ raise NotImplementedError('{} must be implemented rows'.format(self.__class__.__name__))
21
+
22
+ @abstractmethod
23
+ def row(self):
24
+ raise NotImplementedError('{} must be implemented row'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def count(self):
28
+ raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
29
+
30
+ @property
31
+ @abstractmethod
32
+ def query(self):
33
+ raise NotImplementedError('{} must be implemented query'.format(self.__class__.__name__))
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Context import Context
4
+
5
+ from abc import abstractmethod
6
+ from typing import (
7
+ Protocol,
8
+ runtime_checkable,
9
+ )
10
+
11
+ __all__ = (
12
+ 'Cursor'
13
+ )
14
+
15
+
16
+ @runtime_checkable
17
+ class Cursor(Protocol):
18
+ """Protocol for database cursors."""
19
+
20
+ @abstractmethod
21
+ def execute(self, sql, *args, **kwargs) -> Context:
22
+ raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
23
+
24
+ @abstractmethod
25
+ def executes(self, sql, *args, **kwargs) -> Context:
26
+ raise NotImplementedError('{} must be implemented executes'.format(self.__class__.__name__))
27
+
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Context import Context
4
+ from .Cursor import Cursor
5
+ from .Session import Session
6
+
7
+ from abc import abstractmethod
8
+ from typing import (
9
+ Protocol,
10
+ runtime_checkable,
11
+ )
12
+
13
+ __all__ = (
14
+ 'Database'
15
+ )
16
+
17
+
18
+ @runtime_checkable
19
+ class Database(Protocol):
20
+ """Protocol for SQL execution and transaction control."""
21
+
22
+ @abstractmethod
23
+ def begin(self):
24
+ raise NotImplementedError('{} must be implemented begin'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def execute(self, sql, *args, **kwargs) -> Context:
28
+ raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
29
+
30
+ @abstractmethod
31
+ def executes(self, sql, *args, **kwargs) -> Context:
32
+ raise NotImplementedError('{} must be implemented executes'.format(self.__class__.__name__))
33
+
34
+ @abstractmethod
35
+ def cursor(self) -> Cursor:
36
+ raise NotImplementedError('{} must be implemented Cursor'.format(self.__class__.__name__))
37
+
38
+ @abstractmethod
39
+ def session(self) -> Session:
40
+ raise NotImplementedError('{} must be implemented session'.format(self.__class__.__name__))
41
+
42
+ @abstractmethod
43
+ def commit(self):
44
+ raise NotImplementedError('{} must be implemented commit'.format(self.__class__.__name__))
45
+
46
+ @abstractmethod
47
+ def rollback(self):
48
+ raise NotImplementedError('{} must be implemented rollback'.format(self.__class__.__name__))
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ..Dataclass import Dataclass
4
+
5
+ from abc import abstractmethod
6
+ from typing import (
7
+ Union,
8
+ Sequence,
9
+ Mapping,
10
+ Type,
11
+ Protocol,
12
+ runtime_checkable,
13
+ )
14
+
15
+
16
+ __all__ = (
17
+ 'Executor'
18
+ )
19
+
20
+
21
+ @runtime_checkable
22
+ class Executor(Protocol):
23
+ """Protocol exposing a query and its execution arguments."""
24
+
25
+ @abstractmethod
26
+ def __init__(self, o: Type[Dataclass]):
27
+ pass
28
+
29
+ @property
30
+ @abstractmethod
31
+ def query(self) -> str:
32
+ pass
33
+
34
+ @property
35
+ @abstractmethod
36
+ def args(self) -> Union[Sequence, Mapping]:
37
+ pass
38
+
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ..Dataclass import Dataclass
4
+
5
+ from .Executor import Executor
6
+
7
+ from abc import abstractmethod
8
+
9
+ from typing import (
10
+ Type,
11
+ Iterator,
12
+ Protocol,
13
+ runtime_checkable,
14
+ )
15
+
16
+ __all__ = (
17
+ 'Executors'
18
+ )
19
+
20
+
21
+ @runtime_checkable
22
+ class Executors(Protocol):
23
+ """Protocol for iterating over multiple Executors."""
24
+
25
+ @abstractmethod
26
+ def __init__(self, o: Type[Dataclass]):
27
+ pass
28
+
29
+ @abstractmethod
30
+ def __iter__(self) -> Iterator[Executor]:
31
+ pass
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ..Dataclass import Dataclass
4
+
5
+ from abc import abstractmethod
6
+
7
+ from .Filter import Filter
8
+
9
+ from typing import (
10
+ Union,
11
+ Dict,
12
+ List,
13
+ Type,
14
+ TypeVar,
15
+ Optional,
16
+ Protocol,
17
+ runtime_checkable,
18
+ )
19
+
20
+ __all__ = (
21
+ 'Fetch'
22
+ )
23
+
24
+ T = TypeVar('T', bound=Dataclass)
25
+
26
+
27
+ @runtime_checkable
28
+ class Fetch(Protocol):
29
+ """Protocol for converting query results into models or dictionaries."""
30
+ @abstractmethod
31
+ def fetch(
32
+ self,
33
+ cursor,
34
+ filter: Optional[Filter] = None,
35
+ fetch: Optional[Type[T]] = None,
36
+ ) -> Optional[Union[Dict, T, List[Dict], List[T]]]:
37
+ raise NotImplementedError('{} must be implemented fetch'.format(self.__class__.__name__))
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+
5
+ from typing import (
6
+ Dict,
7
+ Protocol,
8
+ runtime_checkable,
9
+ )
10
+
11
+ __all__ = (
12
+ 'Filter',
13
+ )
14
+
15
+
16
+ @runtime_checkable
17
+ class Filter(Protocol):
18
+ """Callable protocol for transforming result rows."""
19
+ @abstractmethod
20
+ def __call__(self, row: Dict) -> Dict:
21
+ raise NotImplementedError('{} must be implemented __call__'.format(self.__class__.__name__))
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ..Dataclass import Dataclass
4
+
5
+ from abc import abstractmethod
6
+
7
+ from .Executors import Executors
8
+ from .Executor import Executor
9
+ from .Filter import Filter
10
+
11
+ from typing import (
12
+ Optional,
13
+ Type,
14
+ TypeVar,
15
+ Union,
16
+ List,
17
+ Dict,
18
+ Protocol,
19
+ runtime_checkable,
20
+ )
21
+
22
+ T = TypeVar('T', bound=Dataclass)
23
+
24
+ __all__ = (
25
+ 'Run'
26
+ )
27
+
28
+
29
+ @runtime_checkable
30
+ class Run(Protocol):
31
+ """Protocol for executing Executors."""
32
+ @abstractmethod
33
+ def run(
34
+ self,
35
+ executor: Union[Executor, Executors],
36
+ filter: Optional[Filter] = None,
37
+ fetch: Optional[Type[T]] = None,
38
+ ) -> Optional[Union[T, List[T], Dict, List[Dict]]]:
39
+ raise NotImplementedError('{} must be implemented run'.format(self.__class__.__name__))
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Protocol,
6
+ runtime_checkable,
7
+ )
8
+
9
+ __all__ = (
10
+ 'Session'
11
+ )
12
+
13
+
14
+ @runtime_checkable
15
+ class Session(Protocol):
16
+ """Protocol for database sessions."""
17
+
18
+ @abstractmethod
19
+ def execute(self, sql, *args, **kwargs):
20
+ raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
21
+
22
+ @abstractmethod
23
+ def executes(self, sql, *args, **kwargs):
24
+ raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def rows(self):
28
+ raise NotImplementedError('{} must be implemented rows'.format(self.__class__.__name__))
29
+
30
+ @abstractmethod
31
+ def row(self):
32
+ raise NotImplementedError('{} must be implemented row'.format(self.__class__.__name__))
33
+
34
+ @abstractmethod
35
+ def count(self):
36
+ raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Database import Database
4
+ from .Context import Context
5
+ from .Cursor import Cursor
6
+ from .Session import Session
7
+
8
+ from .Executor import Executor
9
+ from .Executors import Executors
10
+
11
+ from .Run import Run
12
+ from .Fetch import Fetch
13
+ from .Filter import Filter
14
+
15
+ __all__ = (
16
+ 'Database',
17
+ 'Context',
18
+ 'Cursor',
19
+ 'Session',
20
+ 'Run',
21
+ 'Filter',
22
+ 'Executor',
23
+ 'Executors',
24
+ 'Fetch',
25
+ )
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from dataclasses import Field
4
+ from typing import (
5
+ Any,
6
+ ClassVar,
7
+ Dict,
8
+ Protocol,
9
+ runtime_checkable,
10
+ )
11
+
12
+ __all__ = (
13
+ 'Dataclass',
14
+ )
15
+
16
+
17
+ @runtime_checkable
18
+ class Dataclass(Protocol):
19
+ """Structural type contract exposing standard dataclass field information.
20
+
21
+ Inheritance is not required, and this contract does not guarantee dataclass identity at runtime.
22
+ DAO implementations must validate inputs using is_dataclass().
23
+ """
24
+
25
+ __dataclass_fields__: ClassVar[Dict[str, Field[Any]]]
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Protocol,
6
+ runtime_checkable,
7
+ )
8
+
9
+ __all__ = (
10
+ 'Document'
11
+ )
12
+
13
+
14
+ @runtime_checkable
15
+ class Document(Protocol):
16
+ """Protocol for document storage and retrieval."""
17
+
18
+ @abstractmethod
19
+ def create(self, doc, **kwargs):
20
+ raise NotImplementedError('{} must be implemented create'.format(self.__class__.__name__))
21
+
22
+ @abstractmethod
23
+ def set(self, doc, **kwargs):
24
+ raise NotImplementedError('{} must be implemented set'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def get(self, doc, **kwargs):
28
+ raise NotImplementedError('{} must be implemented get'.format(self.__class__.__name__))
29
+
30
+ @abstractmethod
31
+ def query(self, doc, **kwargs):
32
+ raise NotImplementedError('{} must be implemented find'.format(self.__class__.__name__))
33
+
34
+ @abstractmethod
35
+ def remove(self, doc, **kwargs):
36
+ raise NotImplementedError('{} must be implemented remove'.format(self.__class__.__name__))
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Document import Document
4
+
5
+ __all__ = (
6
+ 'Document',
7
+ )
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Protocol,
6
+ runtime_checkable,
7
+ )
8
+
9
+ __all__ = (
10
+ 'Index'
11
+ )
12
+
13
+
14
+ @runtime_checkable
15
+ class Index(Protocol):
16
+ """Protocol for index-based storage and search."""
17
+
18
+ @abstractmethod
19
+ def create(self, index, *args, **kwargs):
20
+ raise NotImplementedError('{} must be implemented create'.format(self.__class__.__name__))
21
+
22
+ @abstractmethod
23
+ def delete(self, index):
24
+ raise NotImplementedError('{} must be implemented delete'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def total(self, index):
28
+ raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
29
+
30
+ @abstractmethod
31
+ def set(self, index, *args, **kwargs):
32
+ raise NotImplementedError('{} must be implemented set'.format(self.__class__.__name__))
33
+
34
+ @abstractmethod
35
+ def get(self, index, id):
36
+ raise NotImplementedError('{} must be implemented get'.format(self.__class__.__name__))
37
+
38
+ @abstractmethod
39
+ def exists(self, index, id):
40
+ raise NotImplementedError('{} must be implemented exists'.format(self.__class__.__name__))
41
+
42
+ @abstractmethod
43
+ def count(self, index, *args, **kwargs):
44
+ raise NotImplementedError('{} must be implemented search'.format(self.__class__.__name__))
45
+
46
+ @abstractmethod
47
+ def query(self, index, *args, **kwargs):
48
+ raise NotImplementedError('{} must be implemented search'.format(self.__class__.__name__))
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Index import Index
4
+
5
+ __all__ = (
6
+ 'Index',
7
+ )
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import abstractmethod
4
+ from typing import (
5
+ Protocol,
6
+ runtime_checkable,
7
+ )
8
+
9
+ __all__ = (
10
+ 'KeyValue'
11
+ )
12
+
13
+
14
+ @runtime_checkable
15
+ class KeyValue(Protocol):
16
+ """Protocol for key-value storage and expiration management."""
17
+
18
+ @abstractmethod
19
+ def keys(self, key):
20
+ raise NotImplementedError('{} must be implemented keys'.format(self.__class__.__name__))
21
+
22
+ @abstractmethod
23
+ def exists(self, key):
24
+ raise NotImplementedError('{} must be implemented exist'.format(self.__class__.__name__))
25
+
26
+ @abstractmethod
27
+ def get(self, key):
28
+ raise NotImplementedError('{} must be implemented get'.format(self.__class__.__name__))
29
+
30
+ @abstractmethod
31
+ def set(self, key, value, expires=None):
32
+ raise NotImplementedError('{} must be implemented set'.format(self.__class__.__name__))
33
+
34
+ @abstractmethod
35
+ def expire(self, key, seconds):
36
+ raise NotImplementedError('{} must be implemented expire'.format(self.__class__.__name__))
37
+
38
+ @abstractmethod
39
+ def persist(self, key):
40
+ raise NotImplementedError('{} must be implemented persist'.format(self.__class__.__name__))
41
+
42
+ @abstractmethod
43
+ def delete(self, key):
44
+ raise NotImplementedError('{} must be implemented delete'.format(self.__class__.__name__))
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .KeyValue import KeyValue
4
+
5
+ __all__ = (
6
+ 'KeyValue',
7
+ )
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Database import Database
4
+ from .Document import Document
5
+ from .Index import Index
6
+ from .KeyValue import KeyValue
7
+ from .Dataclass import Dataclass
8
+
9
+ __all__ = (
10
+ 'Database',
11
+ 'Document',
12
+ 'Index',
13
+ 'KeyValue',
14
+ 'Dataclass',
15
+ )
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Connection import Connection
4
+ from .Configuration import Configuration
5
+
6
+ __all__ = (
7
+ 'Connection',
8
+ 'Configuration',
9
+ )
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from abc import (
4
+ ABC,
5
+ abstractmethod,
6
+ )
7
+
8
+ __all__ = (
9
+ 'Pattern',
10
+ )
11
+
12
+
13
+ class Pattern(ABC):
14
+ """
15
+ Pattern Interface Class for Validator
16
+
17
+ Sample:
18
+ from operator import eq
19
+
20
+ class SamplePattern(Pattern):
21
+ def __init__(self, compare):
22
+ super(SamplePattern, self).__init__(error)
23
+ self.compare = compare
24
+ return
25
+
26
+ def __call__(self, parameter):
27
+ if not eq(parameter, self.compare):
28
+ raise ValueError('{} is not equal to {}'.format(parameter, self.condition))
29
+ return parameter # if true, return parameter
30
+ """
31
+ @abstractmethod
32
+ def __call__(self, parameter):
33
+ pass
34
+
35
+ def __repr__(self):
36
+ return '{}()'.format(self.__class__.__name__)
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ..Pattern import Pattern
4
+
5
+ from typing import Any
6
+
7
+ __all__ = (
8
+ 'IsElementOf',
9
+ )
10
+
11
+
12
+ class IsElementOf(Pattern):
13
+ def __init__(self, *args):
14
+ self.patterns = args
15
+ return
16
+
17
+ def __call__(self, parameter: Any) -> Any:
18
+ _ = list(parameter)
19
+ for pattern in self.patterns:
20
+ for i, e in enumerate(_):
21
+ _[i] = pattern(e)
22
+ return type(parameter)(_)
23
+
24
+ def __repr__(self):
25
+ return '{}({})'.format(
26
+ self.__class__.__name__,
27
+ ', '.join(
28
+ [repr(p) for p in self.patterns]
29
+ )
30
+ )