datatypes 0.12.0__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.
- datatypes/__init__.py +153 -0
- datatypes/collections/__init__.py +22 -0
- datatypes/collections/container.py +150 -0
- datatypes/collections/mapping.py +614 -0
- datatypes/collections/sequence.py +469 -0
- datatypes/command.py +572 -0
- datatypes/compat.py +205 -0
- datatypes/config/__init__.py +9 -0
- datatypes/config/environ.py +302 -0
- datatypes/config/parser.py +255 -0
- datatypes/copy.py +151 -0
- datatypes/csv.py +322 -0
- datatypes/datetime.py +888 -0
- datatypes/decorators/__init__.py +23 -0
- datatypes/decorators/base.py +343 -0
- datatypes/decorators/descriptor.py +389 -0
- datatypes/decorators/misc.py +118 -0
- datatypes/email.py +351 -0
- datatypes/enum.py +191 -0
- datatypes/event.py +207 -0
- datatypes/filetypes/__init__.py +12 -0
- datatypes/filetypes/html.py +556 -0
- datatypes/filetypes/toml.py +260 -0
- datatypes/http.py +723 -0
- datatypes/logging.py +384 -0
- datatypes/number.py +187 -0
- datatypes/parse.py +246 -0
- datatypes/path.py +3637 -0
- datatypes/profile.py +232 -0
- datatypes/reflection.py +1498 -0
- datatypes/server.py +408 -0
- datatypes/service.py +212 -0
- datatypes/string.py +1328 -0
- datatypes/token/__init__.py +16 -0
- datatypes/token/abnf.py +1704 -0
- datatypes/token/base.py +475 -0
- datatypes/token/word.py +259 -0
- datatypes/url.py +841 -0
- datatypes/utils.py +142 -0
- datatypes-0.12.0.dist-info/LICENSE.txt +21 -0
- datatypes-0.12.0.dist-info/METADATA +52 -0
- datatypes-0.12.0.dist-info/RECORD +44 -0
- datatypes-0.12.0.dist-info/WHEEL +5 -0
- datatypes-0.12.0.dist-info/top_level.txt +1 -0
datatypes/__init__.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .collections import (
|
|
4
|
+
Pool,
|
|
5
|
+
PriorityQueue,
|
|
6
|
+
Dict,
|
|
7
|
+
NormalizeDict,
|
|
8
|
+
idict, IDict, Idict, iDict,
|
|
9
|
+
AppendList,
|
|
10
|
+
OrderedList,
|
|
11
|
+
ListIterator,
|
|
12
|
+
Trie,
|
|
13
|
+
Namespace,
|
|
14
|
+
ContextNamespace,
|
|
15
|
+
HotSet,
|
|
16
|
+
Stack,
|
|
17
|
+
)
|
|
18
|
+
from .command import (
|
|
19
|
+
SimpleCommand,
|
|
20
|
+
Command,
|
|
21
|
+
Command as AsyncCommand, # DEPRECATED, use Command instead
|
|
22
|
+
ModuleCommand,
|
|
23
|
+
FileCommand,
|
|
24
|
+
)
|
|
25
|
+
from .config import (
|
|
26
|
+
Environ,
|
|
27
|
+
Config,
|
|
28
|
+
)
|
|
29
|
+
from .copy import (
|
|
30
|
+
Deepcopy,
|
|
31
|
+
)
|
|
32
|
+
from .csv import (
|
|
33
|
+
CSV,
|
|
34
|
+
TempCSV,
|
|
35
|
+
)
|
|
36
|
+
from .datetime import (
|
|
37
|
+
Datetime,
|
|
38
|
+
)
|
|
39
|
+
from .decorators import (
|
|
40
|
+
Decorator,
|
|
41
|
+
InstanceDecorator,
|
|
42
|
+
ClassDecorator,
|
|
43
|
+
FuncDecorator,
|
|
44
|
+
property,
|
|
45
|
+
classproperty,
|
|
46
|
+
method,
|
|
47
|
+
instancemethod,
|
|
48
|
+
classmethod,
|
|
49
|
+
staticmethod,
|
|
50
|
+
once,
|
|
51
|
+
deprecated,
|
|
52
|
+
)
|
|
53
|
+
from .email import (
|
|
54
|
+
Email,
|
|
55
|
+
)
|
|
56
|
+
from .enum import (
|
|
57
|
+
Enum,
|
|
58
|
+
)
|
|
59
|
+
from .event import (
|
|
60
|
+
Event,
|
|
61
|
+
)
|
|
62
|
+
from .filetypes import (
|
|
63
|
+
HTMLCleaner,
|
|
64
|
+
HTMLParser,
|
|
65
|
+
HTML,
|
|
66
|
+
HTMLTokenizer,
|
|
67
|
+
TOML,
|
|
68
|
+
)
|
|
69
|
+
from .http import (
|
|
70
|
+
HTTPHeaders,
|
|
71
|
+
HTTPEnviron,
|
|
72
|
+
HTTPClient,
|
|
73
|
+
)
|
|
74
|
+
from .logging import (
|
|
75
|
+
LogMixin,
|
|
76
|
+
)
|
|
77
|
+
from .number import (
|
|
78
|
+
Shorten,
|
|
79
|
+
Integer,
|
|
80
|
+
Hex,
|
|
81
|
+
Binary,
|
|
82
|
+
Exponential,
|
|
83
|
+
)
|
|
84
|
+
from .parse import (
|
|
85
|
+
ArgvParser,
|
|
86
|
+
ArgParser,
|
|
87
|
+
Version,
|
|
88
|
+
)
|
|
89
|
+
from .path import (
|
|
90
|
+
Path,
|
|
91
|
+
Filepath,
|
|
92
|
+
Dirpath,
|
|
93
|
+
Imagepath,
|
|
94
|
+
TempFilepath, Filetemp,
|
|
95
|
+
TempDirpath, Dirtemp,
|
|
96
|
+
Cachepath,
|
|
97
|
+
Sentinel,
|
|
98
|
+
UrlFilepath,
|
|
99
|
+
SitePackagesDirpath,
|
|
100
|
+
)
|
|
101
|
+
from .profile import (
|
|
102
|
+
Profiler,
|
|
103
|
+
AggregateProfiler,
|
|
104
|
+
AggregateProfiler as AProfiler
|
|
105
|
+
)
|
|
106
|
+
from .reflection import (
|
|
107
|
+
OrderedSubclasses,
|
|
108
|
+
Extend,
|
|
109
|
+
ReflectName,
|
|
110
|
+
ReflectModule,
|
|
111
|
+
ReflectClass,
|
|
112
|
+
ReflectMethod,
|
|
113
|
+
ReflectPath,
|
|
114
|
+
)
|
|
115
|
+
from .server import (
|
|
116
|
+
PathServer,
|
|
117
|
+
CallbackServer,
|
|
118
|
+
WSGIServer,
|
|
119
|
+
ThreadingWSGIServer,
|
|
120
|
+
)
|
|
121
|
+
from .string import (
|
|
122
|
+
String,
|
|
123
|
+
ByteString,
|
|
124
|
+
Base64,
|
|
125
|
+
NamingConvention,
|
|
126
|
+
EnglishWord,
|
|
127
|
+
)
|
|
128
|
+
from .token import (
|
|
129
|
+
# we don't import Token because it's too generic for toplevel, if you need it
|
|
130
|
+
# then import it directly from the submodule
|
|
131
|
+
Tokenizer,
|
|
132
|
+
Scanner,
|
|
133
|
+
WordTokenizer,
|
|
134
|
+
StopWordTokenizer,
|
|
135
|
+
ABNFParser,
|
|
136
|
+
ABNFGrammar,
|
|
137
|
+
)
|
|
138
|
+
from .url import (
|
|
139
|
+
Url,
|
|
140
|
+
Host,
|
|
141
|
+
Slug,
|
|
142
|
+
)
|
|
143
|
+
from .utils import (
|
|
144
|
+
cball,
|
|
145
|
+
cbany,
|
|
146
|
+
make_dict,
|
|
147
|
+
make_list,
|
|
148
|
+
Singleton,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
__version__ = "0.12.0"
|
|
153
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .mapping import (
|
|
4
|
+
Pool,
|
|
5
|
+
Dict,
|
|
6
|
+
NormalizeDict,
|
|
7
|
+
idict, IDict, Idict, iDict,
|
|
8
|
+
Namespace,
|
|
9
|
+
ContextNamespace,
|
|
10
|
+
)
|
|
11
|
+
from .sequence import (
|
|
12
|
+
PriorityQueue,
|
|
13
|
+
AppendList,
|
|
14
|
+
OrderedList,
|
|
15
|
+
Stack,
|
|
16
|
+
ListIterator,
|
|
17
|
+
)
|
|
18
|
+
from .container import (
|
|
19
|
+
Trie,
|
|
20
|
+
HotSet,
|
|
21
|
+
)
|
|
22
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Container and membership like objects (eg, sets)
|
|
4
|
+
|
|
5
|
+
https://docs.python.org/3/library/collections.abc.html#collections.abc.Container
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ..compat import *
|
|
9
|
+
|
|
10
|
+
from .sequence import PriorityQueue
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MembershipSet(set):
|
|
14
|
+
"""A set with all the AND, OR, and UNION operations disabled, making it
|
|
15
|
+
really only handy for testing membership
|
|
16
|
+
|
|
17
|
+
This is really more of a skeleton for the few times I've had to do this in a
|
|
18
|
+
project, usually we are implementing custom functionality that acts like a
|
|
19
|
+
set and so it will be nice to just be able to extend this and not have to
|
|
20
|
+
worry about disabling the unsupported methods
|
|
21
|
+
|
|
22
|
+
If you need a readonly set, use frozenset:
|
|
23
|
+
https://docs.python.org/3/library/stdtypes.html#frozenset
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, iterable=None):
|
|
26
|
+
if not iterable:
|
|
27
|
+
iterable = []
|
|
28
|
+
|
|
29
|
+
super(MembershipSet, self).__init__(iterable)
|
|
30
|
+
|
|
31
|
+
def add(self, elem):
|
|
32
|
+
super(MembershipSet, self).add(perm)
|
|
33
|
+
|
|
34
|
+
def remove(self, elem):
|
|
35
|
+
super(MembershipSet, self).remove(perm)
|
|
36
|
+
|
|
37
|
+
def discard(self, elem):
|
|
38
|
+
try:
|
|
39
|
+
self.remove(elem)
|
|
40
|
+
except KeyError:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def clear(self):
|
|
44
|
+
super(MembershipSet, self).clear()
|
|
45
|
+
|
|
46
|
+
def update(self, *others):
|
|
47
|
+
for iterable in others:
|
|
48
|
+
super(MembershipSet, self).update(iterable)
|
|
49
|
+
|
|
50
|
+
def noimp(self, *args, **kwargs):
|
|
51
|
+
raise NotImplementedError()
|
|
52
|
+
|
|
53
|
+
pop = noimp
|
|
54
|
+
__sub__ = noimp
|
|
55
|
+
__and__ = noimp
|
|
56
|
+
__or__ = noimp
|
|
57
|
+
__xor__ = noimp
|
|
58
|
+
__isub__ = noimp
|
|
59
|
+
__iand__ = noimp
|
|
60
|
+
__ior__ = noimp
|
|
61
|
+
__ixor__ = noimp
|
|
62
|
+
intersection_update = noimp
|
|
63
|
+
difference_update = noimp
|
|
64
|
+
symmetric_difference_update = noimp
|
|
65
|
+
symmetric_difference = noimp
|
|
66
|
+
difference = noimp
|
|
67
|
+
intersection = noimp
|
|
68
|
+
union = noimp = noimp
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class HotSet(MembershipSet):
|
|
72
|
+
"""Similar to Pool, this holds maxsize elems and keeps it at that size"""
|
|
73
|
+
def __init__(self, maxsize=0):
|
|
74
|
+
super().__init__()
|
|
75
|
+
self.pq = PriorityQueue(maxsize, key=lambda value: value)
|
|
76
|
+
|
|
77
|
+
def add(self, elem):
|
|
78
|
+
super().add(elem)
|
|
79
|
+
try:
|
|
80
|
+
self.pq.put(elem)
|
|
81
|
+
|
|
82
|
+
except OverflowError:
|
|
83
|
+
self.pop()
|
|
84
|
+
self.pq.put(elem)
|
|
85
|
+
|
|
86
|
+
def remove(self, elem):
|
|
87
|
+
if elem in self:
|
|
88
|
+
self.pq.remove(elem)
|
|
89
|
+
super().remove(elem)
|
|
90
|
+
|
|
91
|
+
def clear(self):
|
|
92
|
+
self.pq.clear()
|
|
93
|
+
super().clear()
|
|
94
|
+
|
|
95
|
+
def update(self, *others):
|
|
96
|
+
for iterable in others:
|
|
97
|
+
for elem in iterable:
|
|
98
|
+
self.add(elem)
|
|
99
|
+
|
|
100
|
+
def pop(self):
|
|
101
|
+
elem = self.pq.get()
|
|
102
|
+
self.discard(elem)
|
|
103
|
+
return elem
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Trie(object):
|
|
107
|
+
"""https://en.wikipedia.org/wiki/Trie"""
|
|
108
|
+
def __init__(self, *values):
|
|
109
|
+
self.values = {}
|
|
110
|
+
|
|
111
|
+
for value in values:
|
|
112
|
+
self.add(value)
|
|
113
|
+
|
|
114
|
+
def add(self, value):
|
|
115
|
+
if value:
|
|
116
|
+
ch = value[0]
|
|
117
|
+
remainder = value[1:]
|
|
118
|
+
if ch not in self.values:
|
|
119
|
+
self.values[ch] = None
|
|
120
|
+
|
|
121
|
+
if remainder:
|
|
122
|
+
if self.values[ch] is None:
|
|
123
|
+
self.values[ch] = type(self)(remainder)
|
|
124
|
+
|
|
125
|
+
else:
|
|
126
|
+
self.values[ch].add(self.normalize_value(remainder))
|
|
127
|
+
|
|
128
|
+
def has(self, value):
|
|
129
|
+
ret = True
|
|
130
|
+
ch = self.normalize_value(value[0])
|
|
131
|
+
remainder = value[1:]
|
|
132
|
+
if ch in self.values:
|
|
133
|
+
if remainder:
|
|
134
|
+
if self.values[ch] is None:
|
|
135
|
+
ret = False
|
|
136
|
+
else:
|
|
137
|
+
ret = self.values[ch].has(remainder)
|
|
138
|
+
|
|
139
|
+
else:
|
|
140
|
+
ret = False
|
|
141
|
+
|
|
142
|
+
#pout.v(ch, ret, self.values.keys())
|
|
143
|
+
return ret
|
|
144
|
+
|
|
145
|
+
def __contains__(self, value):
|
|
146
|
+
return self.has(value)
|
|
147
|
+
|
|
148
|
+
def normalize_value(self, value):
|
|
149
|
+
return value.lower()
|
|
150
|
+
|