maci 0.6.2__tar.gz → 1.1.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.
- maci-1.1.0/PKG-INFO +489 -0
- maci-1.1.0/README.md +456 -0
- {maci-0.6.2 → maci-1.1.0}/maci/__init__.py +6 -4
- {maci-0.6.2 → maci-1.1.0}/maci/__init__.pyi +4 -3
- {maci-0.6.2 → maci-1.1.0}/maci/data.py +13 -6
- maci-1.1.0/maci.egg-info/PKG-INFO +489 -0
- {maci-0.6.2 → maci-1.1.0}/setup.cfg +5 -3
- maci-0.6.2/PKG-INFO +0 -71
- maci-0.6.2/README.md +0 -45
- maci-0.6.2/maci.egg-info/PKG-INFO +0 -71
- {maci-0.6.2 → maci-1.1.0}/MANIFEST.in +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_hash/comparefilehash.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_hash/createfilehash.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_hash/createhash.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_ini/inibuildauto.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_ini/inibuildmanual.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_ini/inidump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_ini/iniload.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_json/jsondump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_json/jsondumpstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_json/jsonload.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_json/jsonloadstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/build.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/cleanformat.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/dump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/dumpraw.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/dumpstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/load.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/loadattrs.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/loaddict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/loadraw.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/loadstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_native/loadstrdict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_pickle/pickledumpbytes.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_pickle/pickleloadbytes.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_toml/tomldump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_toml/tomldumpstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_toml/tomlload.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_toml/tomlloadstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmlbuildmanual.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmldump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmldumpdict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmldumpstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmldumpstrdict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmlload.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmlloaddict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmlloadstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_xml/xmlloadstrdict.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamldump.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamldumpall.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamldumpstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamlload.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamlloadall.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/_yaml/yamlloadstr.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/data.pyi +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/error.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/ext/defusedxml/LICENSE.txt +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/hint.py +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/hint.pyi +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci/py.typed +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci.egg-info/SOURCES.txt +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci.egg-info/dependency_links.txt +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci.egg-info/requires.txt +0 -0
- {maci-0.6.2 → maci-1.1.0}/maci.egg-info/top_level.txt +0 -0
- {maci-0.6.2 → maci-1.1.0}/setup.py +0 -0
maci-1.1.0/PKG-INFO
ADDED
@@ -0,0 +1,489 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: maci
|
3
|
+
Version: 1.1.0
|
4
|
+
Summary: The easy to use library for your data, configuration, and save files
|
5
|
+
Author: aaronater10
|
6
|
+
Author-email: dev_admin@dunnts.com
|
7
|
+
License: MIT
|
8
|
+
Project-URL: Docs, https://docs.macilib.org
|
9
|
+
Project-URL: Code, https://github.com/aaronater10/maci
|
10
|
+
Project-URL: Bugs, https://github.com/aaronater10/maci/issues
|
11
|
+
Project-URL: CI, https://github.com/aaronater10/maci/actions
|
12
|
+
Keywords: maci,aaronater10,python,py,config,file,export,parse,text file,cfg,conf,save file,config file,db,database,simple,configuration,alternative,safe,ini,json,xml,yml,data,import
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
14
|
+
Classifier: Intended Audience :: Developers
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
16
|
+
Classifier: Intended Audience :: Information Technology
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
23
|
+
Classifier: Operating System :: POSIX :: Linux
|
24
|
+
Classifier: Operating System :: Microsoft :: Windows
|
25
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
26
|
+
Requires-Python: >=3.8
|
27
|
+
Description-Content-Type: text/markdown
|
28
|
+
Requires-Dist: pyyaml>=5.4
|
29
|
+
Requires-Dist: tomli>=2.0.1
|
30
|
+
Requires-Dist: tomli-w>=1.0.0
|
31
|
+
Requires-Dist: defusedxml>=0.7.1
|
32
|
+
Requires-Dist: xmltodict>=0.13.0
|
33
|
+
|
34
|
+
[](https://docs.macilib.org/)
|
35
|
+
|
36
|
+
# maci
|
37
|
+
A Python-Styled Serialization Language & Thin Wrapper Library
|
38
|
+
|
39
|
+

|
40
|
+

|
41
|
+
[](https://github.com/aaronater10/maci/actions/workflows/maci_qa.yml)
|
42
|
+

|
43
|
+

|
44
|
+
|
45
|
+
#
|
46
|
+
|
47
|
+
maci is an easy to use library for data serialization. It can parse native python data types from any plain file, which is safer than using an executable .py file for your stored or configuration data. There are useful language features built-in like creating realistic constants for your name/value pairs by locking them, mapping a name to another to follow its value similar to a pointer, and much more.
|
48
|
+
|
49
|
+
Its focus is to reduce boilerplate by removing repetitive code implementation, like code written for common file handling, or common libraries used like JSON, YAML, TOML, etc. maci on its own is a pure Python-based library, and I've used variations of this library on projects for many companies and decided I wanted to make a robust and stable public version. It has made common needs less painful, and has solved simplicity in many ways. Hope it helps you
|
50
|
+
|
51
|
+
# 🎓 tutorials & docs:
|
52
|
+
**quick start: [tutorial video](https://docs.macilib.org/watch/quick-start)**
|
53
|
+
|
54
|
+
**full tutorials: [all videos](https://docs.macilib.org/watch/full-training-series)**
|
55
|
+
|
56
|
+
**docs: [maci docs](https://docs.macilib.org/)**
|
57
|
+
|
58
|
+
**changelog: [update history](https://docs.macilib.org/updates/changelog)**
|
59
|
+
|
60
|
+
**readme**
|
61
|
+
\
|
62
|
+
[installing](#-install-flavors)\
|
63
|
+
[basic usage: maci](#-basic-usage)\
|
64
|
+
[basic usage: thin libs](#-basic-usage-thin-libs)\
|
65
|
+
[exceptions, hints, and built-in tools](#-helpful-extras)\
|
66
|
+
[performance](#%EF%B8%8F-performance)\
|
67
|
+
[testing & release](#-testing--release)\
|
68
|
+
[previous support](#-previous-project-support)
|
69
|
+
|
70
|
+
|
71
|
+
# 🍨 install flavors
|
72
|
+
|
73
|
+
**full --> maci, standard library, and 3rd-party packages**
|
74
|
+
```bash
|
75
|
+
pip install maci
|
76
|
+
```
|
77
|
+
**standard lib --> maci and standard library based packages only**
|
78
|
+
```bash
|
79
|
+
pip install maci-std
|
80
|
+
```
|
81
|
+
**just maci --> maci package only**
|
82
|
+
```bash
|
83
|
+
pip install maci-only
|
84
|
+
```
|
85
|
+
|
86
|
+
[back to top](#maci)
|
87
|
+
|
88
|
+
# 📖 basic usage
|
89
|
+
### maci
|
90
|
+
|
91
|
+
Example file "my.file" with maci (Python-styled) data
|
92
|
+
```python
|
93
|
+
# Example maci data "my.file"
|
94
|
+
data1 = 'my data'
|
95
|
+
data2 = 1
|
96
|
+
data3 = [1,2,3]
|
97
|
+
data4 = {'k1': 1}
|
98
|
+
data5 = True
|
99
|
+
data6 = (1,2,3)
|
100
|
+
data7 = {1,2,3}
|
101
|
+
data8 = 1.0
|
102
|
+
data9 = None
|
103
|
+
data10 = b'\ndata\n'
|
104
|
+
```
|
105
|
+
#### Load
|
106
|
+
load maci data from file
|
107
|
+
```python
|
108
|
+
maci_data = maci.load('my.file')
|
109
|
+
maci_data.data1 # access data with attr name
|
110
|
+
```
|
111
|
+
load raw data from file
|
112
|
+
```python
|
113
|
+
raw_data = maci.loadraw('my.file') # returns string (default)
|
114
|
+
```
|
115
|
+
load attributes names and their values back into your object from file
|
116
|
+
```python
|
117
|
+
maci.loadattrs('my.file', my_obj) # loads in-place
|
118
|
+
my_obj.data4 # access data in your object with attr name
|
119
|
+
```
|
120
|
+
load as dict data from file
|
121
|
+
```python
|
122
|
+
dict_data = maci.loaddict('my.file')
|
123
|
+
dict_data['data3'] # access data as dict key name
|
124
|
+
```
|
125
|
+
load maci data from string
|
126
|
+
```python
|
127
|
+
maci_data = maci.loadstr('data1 = "data"')
|
128
|
+
maci_data.data1 # access data with attr name
|
129
|
+
```
|
130
|
+
load as dict data from string
|
131
|
+
```python
|
132
|
+
dict_data = maci.loadstrdict('data3 = "data"')
|
133
|
+
dict_data['data3'] # access data as dict key name
|
134
|
+
```
|
135
|
+
|
136
|
+
#### Dump
|
137
|
+
dump data to file from maci object, dict, or your own object with attrs
|
138
|
+
```python
|
139
|
+
maci.dump('my.file', maci_data or dict_data or my_obj)
|
140
|
+
# creates new file with data formatted as maci syntax
|
141
|
+
```
|
142
|
+
dump raw data to file
|
143
|
+
```python
|
144
|
+
maci.dumpraw('my.file', 'my data')
|
145
|
+
# creates new file with data raw as-is to file
|
146
|
+
```
|
147
|
+
dump data to string from maci object, dict, or your own object with attrs
|
148
|
+
```python
|
149
|
+
str_data = maci.dumpstr(maci_data or dict_data or my_obj)
|
150
|
+
# returns string with data formatted as maci syntax
|
151
|
+
```
|
152
|
+
|
153
|
+
#### Build
|
154
|
+
build maci data in code
|
155
|
+
```python
|
156
|
+
maci_data = maci.build()
|
157
|
+
maci_data.data1 = 'my data'
|
158
|
+
maci_data.data2 = [1,2,3]
|
159
|
+
maci_data.data3 = 1
|
160
|
+
maci_data.data4 = True
|
161
|
+
```
|
162
|
+
#### In-File Language Features
|
163
|
+
maci supports varying in-file features. Here are some examples using a file named "my.file":
|
164
|
+
|
165
|
+
Lock an attr from re-assignment using a lock glyph
|
166
|
+
```python
|
167
|
+
# Example maci data in "my.file"
|
168
|
+
data1 +l= 'my data'
|
169
|
+
```
|
170
|
+
Hard Lock an attr from re-assignment, deletion, and unlocking using a hard lock glyph
|
171
|
+
```python
|
172
|
+
# Example maci data in "my.file"
|
173
|
+
data1 +h= 'my data'
|
174
|
+
```
|
175
|
+
Reference and follow another attr's value with an attr (like a pointer) using a map glyph
|
176
|
+
```python
|
177
|
+
# Example maci data in "my.file"
|
178
|
+
data1 = 'my data'
|
179
|
+
data2 +m= data1
|
180
|
+
```
|
181
|
+
Date and time parsing
|
182
|
+
```python
|
183
|
+
# Example maci data in "my.file"
|
184
|
+
# Multiple options -> returns datetime, date, or time object
|
185
|
+
date_time1 = 2023-03-13 22:06:00
|
186
|
+
date_time2 = 2023-03-13 22:06:00.50
|
187
|
+
time_date1 = 22:06:00 2023-03-13
|
188
|
+
time_date2 = 22:06:00.50 2023-03-13
|
189
|
+
time1 = 22:06:00
|
190
|
+
time2 = 22:06:00.50
|
191
|
+
date = 2023-03-13
|
192
|
+
date_time_iso8601 = 2023-03-13T22:06:00
|
193
|
+
```
|
194
|
+
|
195
|
+
#### In-Code Language Features
|
196
|
+
The in-file language features can also be handled in code with a maci object
|
197
|
+
```python
|
198
|
+
maci_data.lock_attr('data1')
|
199
|
+
maci_data.hard_lock_attr('data2')
|
200
|
+
maci_data.map_attr('data3', 'data4')
|
201
|
+
```
|
202
|
+
You may unlock attrs, unmap attrs, and much more with a maci object
|
203
|
+
|
204
|
+
Note: if you dump your maci object back to a file, all language features will be retained and represented appropriately in the file
|
205
|
+
|
206
|
+
[back to top](#maci)
|
207
|
+
|
208
|
+
# 📖 basic usage: thin libs
|
209
|
+
|
210
|
+
### json -> based on [json standard library](https://docs.macilib.org/docs/json)
|
211
|
+
load json data from file
|
212
|
+
```python
|
213
|
+
data = maci.jsonload('file.json')
|
214
|
+
```
|
215
|
+
load json data from string
|
216
|
+
```python
|
217
|
+
data = maci.jsonloadstr('{"k1": "data"}')
|
218
|
+
```
|
219
|
+
dump python data to file as json data
|
220
|
+
```python
|
221
|
+
maci.jsondump('file.json', data)
|
222
|
+
```
|
223
|
+
dump data to string as json data
|
224
|
+
```python
|
225
|
+
json_data = maci.jsondumpstr(data)
|
226
|
+
```
|
227
|
+
### yaml -> based on [pyyaml framework](https://docs.macilib.org/docs/yaml)
|
228
|
+
load yaml data from file
|
229
|
+
```python
|
230
|
+
data = maci.yamlload('file.yaml')
|
231
|
+
```
|
232
|
+
load yaml data from string
|
233
|
+
```python
|
234
|
+
data = maci.yamlloadstr('k1: data')
|
235
|
+
```
|
236
|
+
dump python data to file as yaml data
|
237
|
+
```python
|
238
|
+
maci.yamldump('file.yaml', data)
|
239
|
+
```
|
240
|
+
dump data to string as yaml data
|
241
|
+
```python
|
242
|
+
yaml_data = maci.yamldumpstr(data)
|
243
|
+
```
|
244
|
+
There are also "loadall" and "dumpall" for multiple yaml docs in a file
|
245
|
+
|
246
|
+
### toml -> based on [tomli libraries](https://docs.macilib.org/docs/toml)
|
247
|
+
load toml data from file
|
248
|
+
```python
|
249
|
+
data = maci.tomlload('file.toml')
|
250
|
+
```
|
251
|
+
load toml data from string
|
252
|
+
```python
|
253
|
+
data = maci.tomlloadstr('data1 = "data1"')
|
254
|
+
```
|
255
|
+
dump python data to file as toml data
|
256
|
+
```python
|
257
|
+
maci.tomldump('file.toml', data)
|
258
|
+
```
|
259
|
+
dump data to string as toml data
|
260
|
+
```python
|
261
|
+
toml_data = maci.tomldumpstr(data)
|
262
|
+
```
|
263
|
+
### ini -> based on [configparser standard library](https://docs.macilib.org/docs/ini)
|
264
|
+
load ini data from file
|
265
|
+
```python
|
266
|
+
configparser_data = maci.iniload('file.ini')
|
267
|
+
```
|
268
|
+
dump configparser data to file as ini data
|
269
|
+
```python
|
270
|
+
maci.inidump('file.ini', configparser_data)
|
271
|
+
```
|
272
|
+
build ini data to configparser data automatically - learn more about [configparser objects](https://docs.python.org/3/library/configparser.html)
|
273
|
+
```python
|
274
|
+
configparser_data = maci.inibuildauto({'section1': {'k1': 'value1'}})
|
275
|
+
```
|
276
|
+
build configparser data manually - learn more about [configparser objects](https://docs.python.org/3/library/configparser.html)
|
277
|
+
```python
|
278
|
+
configparser_data = maci.inibuildmanual()
|
279
|
+
```
|
280
|
+
|
281
|
+
### xml -> based on [xmltodict module & xml etree from standard library](https://docs.macilib.org/docs/xml)
|
282
|
+
#### Dict (easiest)
|
283
|
+
|
284
|
+
load xml data from file as dict
|
285
|
+
```python
|
286
|
+
dict_data = maci.xmlloaddict('file.xml')
|
287
|
+
```
|
288
|
+
load xml data from string as dict
|
289
|
+
```python
|
290
|
+
dict_data = maci.xmlloadstrdict('<tag>data</tag>')
|
291
|
+
```
|
292
|
+
dump dict data to file as xml data
|
293
|
+
```python
|
294
|
+
maci.xmldumpdict('file.xml', dict_data)
|
295
|
+
```
|
296
|
+
dump dict data to string as xml data
|
297
|
+
```python
|
298
|
+
xml_data = maci.xmldumpstrdict(dict_data)
|
299
|
+
```
|
300
|
+
#### ElementTree - learn more about [element tree objects](https://docs.python.org/3/library/xml.etree.elementtree.html)
|
301
|
+
load xml data from file as element tree object
|
302
|
+
```python
|
303
|
+
et_data = maci.xmlload('file.xml')
|
304
|
+
```
|
305
|
+
load xml data from string as element tree object
|
306
|
+
```python
|
307
|
+
et_data = maci.xmlloadstr('<tag>data</tag>')
|
308
|
+
```
|
309
|
+
dump element tree data to file as xml data
|
310
|
+
```python
|
311
|
+
maci.xmldump('file.xml', et_data)
|
312
|
+
```
|
313
|
+
dump element tree data to string as xml data
|
314
|
+
```python
|
315
|
+
xml_data = maci.xmldumpstr(et_data)
|
316
|
+
```
|
317
|
+
build element tree data manually
|
318
|
+
```python
|
319
|
+
et_data = maci.xmlbuildmanual()
|
320
|
+
```
|
321
|
+
|
322
|
+
[back to top](#maci)
|
323
|
+
|
324
|
+
# 🪄 helpful extras
|
325
|
+
### exceptions
|
326
|
+
All exceptions/errors thrown by maci and its thin wrapper libraries are conveniently accessible here:
|
327
|
+
```python
|
328
|
+
maci.error
|
329
|
+
```
|
330
|
+
Examples of different load exceptions
|
331
|
+
```python
|
332
|
+
maci.error.Load
|
333
|
+
maci.error.JsonLoad
|
334
|
+
maci.error.YamlLoad
|
335
|
+
maci.error.TomlLoad
|
336
|
+
```
|
337
|
+
To catch/suppress all maci exceptions, use its base exception
|
338
|
+
```python
|
339
|
+
maci.error.MaciError
|
340
|
+
```
|
341
|
+
### hinting
|
342
|
+
For type hinting/annotation needs, you can conveniently access the respective object types here:
|
343
|
+
```python
|
344
|
+
maci.hint
|
345
|
+
```
|
346
|
+
Examples of different hint objects
|
347
|
+
```python
|
348
|
+
maci.hint.MaciDataObj
|
349
|
+
maci.hint.ConfigParser
|
350
|
+
maci.hint.ElementTree
|
351
|
+
maci.hint.Element
|
352
|
+
```
|
353
|
+
### useful tools
|
354
|
+
#### cleanformat
|
355
|
+
format nested data cleanly
|
356
|
+
```python
|
357
|
+
str_data = maci.cleanformat([1,{'k1': 1, 'k2': 2},2])
|
358
|
+
|
359
|
+
print(str_data)
|
360
|
+
|
361
|
+
Output -->
|
362
|
+
[
|
363
|
+
1,
|
364
|
+
{
|
365
|
+
'k1': 1,
|
366
|
+
'k2': 2,
|
367
|
+
},
|
368
|
+
2,
|
369
|
+
]
|
370
|
+
```
|
371
|
+
#### pickling
|
372
|
+
pickle your objects using a non-executable file concept with maci
|
373
|
+
```python
|
374
|
+
# Dump to file
|
375
|
+
maci_data.pickle_data = maci.pickledumpbytes(my_obj)
|
376
|
+
maci.dump('my.data', maci_data)
|
377
|
+
|
378
|
+
# Load back from file
|
379
|
+
maci_data = maci.load('my.data')
|
380
|
+
my_obj = maci.pickleloadbytes(maci_data.pickle_data)
|
381
|
+
```
|
382
|
+
This is better than having your whole file having the ability to be unpickled, especially if you cannot trust the file's integrity. More on this from [python pickle docs](https://docs.python.org/3/library/pickle.html). Though this may help improve pickling needs, still use methods to verify integrity of your pickled data if required
|
383
|
+
|
384
|
+
#### hashing
|
385
|
+
Easily generate hash of a file and store hash - default hash is sha256
|
386
|
+
```python
|
387
|
+
maci.createfilehash('my.data', 'my.data.hashed')
|
388
|
+
# always returns string of file hash
|
389
|
+
```
|
390
|
+
Now simply compare the hash of the source file to check integrity when needed
|
391
|
+
```python
|
392
|
+
maci.comparefilehash('my.data', 'my.data.hashed')
|
393
|
+
# returns bool if hash is a valid match
|
394
|
+
```
|
395
|
+
Create hash of data - default hash is sha256
|
396
|
+
```python
|
397
|
+
maci.createhash('data') # returns string of hash
|
398
|
+
```
|
399
|
+
|
400
|
+
[back to top](#maci)
|
401
|
+
|
402
|
+
# ⏳️ performance
|
403
|
+
|
404
|
+
Performance tests each library loading **100,000 lines of data** each in their natural usage
|
405
|
+
|
406
|
+
Tests are done by loading a file with 100 lines of data 1000 times with the proper file syntax for each library. You may also consider this test about loading 1000 files within the time taken as well
|
407
|
+
|
408
|
+
Results vary based on system spec, but you may simulate or prove the same difference in test results for your needs from the "perf" dir in this repo. Results below is running the test 3 times consecutively
|
409
|
+
|
410
|
+
**libs tested:** json, pyyaml, tomli, xmltodict, maci
|
411
|
+
|
412
|
+
---
|
413
|
+
|
414
|
+
**Notes**
|
415
|
+
|
416
|
+
*XML ElementTree type and INI Configparser tests were left out for now*
|
417
|
+
|
418
|
+
*pyyaml loads much faster using its c-based safe loader, but using the native out of the box methods/functions provided as tests for fairness and potential compatibility issues for needing LibYAML bindings*
|
419
|
+
|
420
|
+
|
421
|
+
---
|
422
|
+
[//]: <> (chose yml for nice color syntax)
|
423
|
+
```yml
|
424
|
+
# Test 1
|
425
|
+
$ python3 perf_load.py
|
426
|
+
Performance tests: "load" - loading file 1000 times with 100 lines of data
|
427
|
+
|
428
|
+
xml: 0.225348
|
429
|
+
json: 0.016725
|
430
|
+
yaml: 3.625997
|
431
|
+
toml: 0.23937
|
432
|
+
maci: 0.807448
|
433
|
+
|
434
|
+
# Test 2
|
435
|
+
$ python3 perf_load.py
|
436
|
+
Performance tests: "load" - loading file 1000 times with 100 lines of data
|
437
|
+
|
438
|
+
xml: 0.22595
|
439
|
+
json: 0.016566
|
440
|
+
yaml: 3.652053
|
441
|
+
toml: 0.242974
|
442
|
+
maci: 0.806545
|
443
|
+
|
444
|
+
# Test 3
|
445
|
+
$ python3 perf_load.py
|
446
|
+
Performance tests: "load" - loading file 1000 times with 100 lines of data
|
447
|
+
|
448
|
+
xml: 0.225579
|
449
|
+
json: 0.01695
|
450
|
+
yaml: 3.611955
|
451
|
+
toml: 0.239593
|
452
|
+
maci: 0.802843
|
453
|
+
```
|
454
|
+
|
455
|
+
| place | lib |
|
456
|
+
| ----- | --- |
|
457
|
+
| 🥇 1st | json - avg 0.016s |
|
458
|
+
| 🥈 2nd | xmltodict - avg 0.225s |
|
459
|
+
| 🥉 3rd | tomli - avg 0.240s |
|
460
|
+
| 4th | maci - avg 0.805s |
|
461
|
+
| 5th | pyyaml - avg 3.630s (4th if using CLoader) |
|
462
|
+
|
463
|
+
*Current differences in load time results for 100k lines of data from maci compared to popular or modern libraries*
|
464
|
+
|
465
|
+
Looking to continually improve maci's performance and update the results, but so far, not bad for pure python.
|
466
|
+
|
467
|
+
[back to top](#maci)
|
468
|
+
|
469
|
+
# 🚀 testing & release
|
470
|
+
### 300+ tests and counting ⚡️
|
471
|
+
|
472
|
+
A maci release is only deployed/released if all qa tests pass, and if the revision number is incremented.
|
473
|
+
|
474
|
+
All coverage testing must be at 100% or test pipeline will fail (badge is not auto-updated, and just indicates confidence in testing at 100%).
|
475
|
+
|
476
|
+
[back to top](#maci)
|
477
|
+
|
478
|
+
# ⏪ previous project support
|
479
|
+
Project maci is derived from an older project called [sfcparse](https://github.com/aaronater10/sfcparse) that is no longer supported, and still provides forward ported support for most of the older API names as a courtesy. sfcparse uses the MIT license, and therefore, maci does not really need to associate itself with that older project, but out of notice for the reason of having the forward ported support is it being mentioned if desiring to migrate.
|
480
|
+
|
481
|
+
Reason for sfcparse's deprecation was merely for desire of re-branding and scrapping the old to make usage simpler and anew, thus, maci.
|
482
|
+
|
483
|
+
Though maci does support the older API names as a courtesy, some names being attempted to use may throw exceptions. Also, functionality in a lot of the forward connected API names may require different parameter positional args or kwargs. See these files for API matched names and where they point to
|
484
|
+
|
485
|
+
function names: [\_\_init\_\_.py](https://github.com/aaronater10/maci/blob/main/src/maci/__init__.py) under \_\_getattr\_\_
|
486
|
+
|
487
|
+
exception names: [error.py](https://github.com/aaronater10/maci/blob/main/src/maci/error.py) under \_\_getattr\_\_
|
488
|
+
|
489
|
+
[back to top](#maci)
|