MambuPy 2.1.1__py3-none-any.whl → 2.3.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.
- MambuPy/__init__.py +2 -4
- MambuPy/mambuconfig.py +3 -13
- MambuPy/mambuutil.py +15 -61
- MambuPy/orm/schema_groups.py +3 -4
- MambuPy/orm/schema_orm.py +0 -2
- MambuPy/rest/__init__.py +27 -45
- MambuPy/rest/mambuactivity.py +689 -32
- MambuPy/utils/update_user_roles.py +432 -0
- mambupy/__init__.py +2 -4
- mambupy/mambuconfig.py +3 -13
- mambupy/mambuutil.py +15 -61
- mambupy/orm/schema_groups.py +3 -4
- mambupy/orm/schema_orm.py +0 -2
- mambupy/rest/__init__.py +27 -45
- mambupy/rest/mambuactivity.py +689 -32
- mambupy/utils/update_user_roles.py +432 -0
- {mambupy-2.1.1.dist-info → mambupy-2.3.0.dist-info}/METADATA +1 -1
- {mambupy-2.1.1.dist-info → mambupy-2.3.0.dist-info}/RECORD +21 -53
- {mambupy-2.1.1.dist-info → mambupy-2.3.0.dist-info}/WHEEL +1 -1
- MambuPy/rest/mambubranch.py +0 -122
- MambuPy/rest/mambucentre.py +0 -104
- MambuPy/rest/mambuclient.py +0 -317
- MambuPy/rest/mambugroup.py +0 -372
- MambuPy/rest/mambuloan.py +0 -687
- MambuPy/rest/mambuproduct.py +0 -180
- MambuPy/rest/mamburepayment.py +0 -99
- MambuPy/rest/mamburestutils.py +0 -116
- MambuPy/rest/mamburoles.py +0 -98
- MambuPy/rest/mambusaving.py +0 -114
- MambuPy/rest/mambusavingfundingrepayment.py +0 -94
- MambuPy/rest/mambusavingtransaction.py +0 -163
- MambuPy/rest/mambustruct.py +0 -1066
- MambuPy/rest/mambutask.py +0 -163
- MambuPy/rest/mambutransaction.py +0 -103
- MambuPy/rest/mambutransactionchannel.py +0 -101
- MambuPy/rest/mambuuser.py +0 -229
- mambupy/rest/mambubranch.py +0 -122
- mambupy/rest/mambucentre.py +0 -104
- mambupy/rest/mambuclient.py +0 -317
- mambupy/rest/mambugroup.py +0 -372
- mambupy/rest/mambuloan.py +0 -687
- mambupy/rest/mambuproduct.py +0 -180
- mambupy/rest/mamburepayment.py +0 -99
- mambupy/rest/mamburestutils.py +0 -116
- mambupy/rest/mamburoles.py +0 -98
- mambupy/rest/mambusaving.py +0 -114
- mambupy/rest/mambusavingfundingrepayment.py +0 -94
- mambupy/rest/mambusavingtransaction.py +0 -163
- mambupy/rest/mambustruct.py +0 -1066
- mambupy/rest/mambutask.py +0 -163
- mambupy/rest/mambutransaction.py +0 -103
- mambupy/rest/mambutransactionchannel.py +0 -101
- mambupy/rest/mambuuser.py +0 -229
- {mambupy-2.1.1.dist-info → mambupy-2.3.0.dist-info}/licenses/LICENSE +0 -0
- {mambupy-2.1.1.dist-info → mambupy-2.3.0.dist-info}/top_level.txt +0 -0
MambuPy/__init__.py
CHANGED
|
@@ -8,15 +8,13 @@
|
|
|
8
8
|
MambuPy.api
|
|
9
9
|
MambuPy.api.connector
|
|
10
10
|
MambuPy.orm
|
|
11
|
-
MambuPy.rest
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
Currently, there are two different ways to access Mambu objects:
|
|
15
14
|
|
|
16
15
|
1) Objects using `Mambu REST API
|
|
17
16
|
<https://developer.mambu.com/customer/en/portal/articles/1162276-rest-apis-overview/>`_
|
|
18
|
-
, they live at the :any:`MambuPy.api` package
|
|
19
|
-
V1-compatible code lives at :any:`MambuPy.rest`
|
|
17
|
+
, they live at the :any:`MambuPy.api` package
|
|
20
18
|
|
|
21
19
|
2) An ORM using a `DB backup retrieved from Mambu
|
|
22
20
|
<https://support.mambu.com/docs/mambu-data-dictionary>`_
|
|
@@ -39,7 +37,7 @@ import sys
|
|
|
39
37
|
from importlib.abc import MetaPathFinder
|
|
40
38
|
from importlib.util import spec_from_file_location
|
|
41
39
|
|
|
42
|
-
__version__ = "2.
|
|
40
|
+
__version__ = "2.3.0"
|
|
43
41
|
"""The version of this module."""
|
|
44
42
|
|
|
45
43
|
|
MambuPy/mambuconfig.py
CHANGED
|
@@ -105,20 +105,10 @@ You may edit this to your own liking. But beware of pricking eyes!
|
|
|
105
105
|
"""
|
|
106
106
|
|
|
107
107
|
import os
|
|
108
|
+
import configparser
|
|
109
|
+
from configparser import NoSectionError
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
import sys
|
|
111
|
-
|
|
112
|
-
if sys.version_info.major < 3:
|
|
113
|
-
import ConfigParser
|
|
114
|
-
from ConfigParser import NoSectionError
|
|
115
|
-
|
|
116
|
-
config = ConfigParser.ConfigParser(defaults=default_configs)
|
|
117
|
-
else:
|
|
118
|
-
import configparser
|
|
119
|
-
from configparser import NoSectionError
|
|
120
|
-
|
|
121
|
-
config = configparser.ConfigParser(defaults=default_configs)
|
|
111
|
+
config = configparser.ConfigParser(defaults=default_configs)
|
|
122
112
|
|
|
123
113
|
# argparse for command line arguments overriding
|
|
124
114
|
import argparse
|
MambuPy/mambuutil.py
CHANGED
|
@@ -31,13 +31,6 @@ import yaml
|
|
|
31
31
|
from .mambuconfig import apipagination, apipwd, apiurl, apiuser, loggingconf, activate_request_session_objects
|
|
32
32
|
from .mambugeturl import getmambuurl
|
|
33
33
|
|
|
34
|
-
try:
|
|
35
|
-
# python2
|
|
36
|
-
unicode
|
|
37
|
-
except NameError:
|
|
38
|
-
# python3
|
|
39
|
-
unicode = str
|
|
40
|
-
|
|
41
34
|
import json
|
|
42
35
|
import sys
|
|
43
36
|
from datetime import datetime, timezone
|
|
@@ -186,21 +179,23 @@ def date_format(field, formato=None, as_utc=False):
|
|
|
186
179
|
|
|
187
180
|
if not formato:
|
|
188
181
|
formato = "%Y-%m-%dT%H:%M:%S"
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
182
|
+
|
|
183
|
+
field_with_tz = datetime.fromisoformat(field)
|
|
184
|
+
|
|
185
|
+
if as_utc and field_with_tz.tzinfo is not None:
|
|
186
|
+
# Convertir a UTC mientras aún tiene tzinfo
|
|
187
|
+
field_as_dt = field_with_tz.astimezone(timezone.utc)
|
|
188
|
+
field_as_dt = datetime.strptime(
|
|
189
|
+
field_as_dt.strftime(formato),
|
|
192
190
|
formato,
|
|
193
191
|
)
|
|
194
192
|
else:
|
|
195
193
|
field_as_dt = datetime.strptime(
|
|
196
|
-
|
|
194
|
+
field_with_tz.strftime(formato),
|
|
197
195
|
formato,
|
|
198
196
|
)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
timezone.utc
|
|
202
|
-
).replace(tzinfo=None)
|
|
203
|
-
return field_as_dt
|
|
197
|
+
|
|
198
|
+
return field_as_dt
|
|
204
199
|
|
|
205
200
|
|
|
206
201
|
def strip_tags(html):
|
|
@@ -221,10 +216,7 @@ def strip_tags(html):
|
|
|
221
216
|
"""
|
|
222
217
|
|
|
223
218
|
def __init__(self):
|
|
224
|
-
|
|
225
|
-
super().__init__() # required for python3
|
|
226
|
-
except TypeError: # pragma: no cover
|
|
227
|
-
pass # with python2 raises TypeError
|
|
219
|
+
super().__init__()
|
|
228
220
|
self.reset()
|
|
229
221
|
self.fed = []
|
|
230
222
|
|
|
@@ -256,12 +248,7 @@ def strip_consecutive_repeated_char(s, ch):
|
|
|
256
248
|
return sdest
|
|
257
249
|
|
|
258
250
|
|
|
259
|
-
|
|
260
|
-
# python3
|
|
261
|
-
from urllib import parse as urlparse
|
|
262
|
-
else: # pragma: no cover
|
|
263
|
-
# python2
|
|
264
|
-
import urlparse
|
|
251
|
+
from urllib import parse as urlparse
|
|
265
252
|
|
|
266
253
|
|
|
267
254
|
def iri_to_uri(iri):
|
|
@@ -277,35 +264,9 @@ def iri_to_uri(iri):
|
|
|
277
264
|
unicode chars there. Using this I solved the problem.
|
|
278
265
|
"""
|
|
279
266
|
|
|
280
|
-
def url_encode_non_ascii(b):
|
|
281
|
-
"""Encode Non ASCII chars to URL-friendly chars.
|
|
282
|
-
|
|
283
|
-
Sometimes unicode gets in the way. A shame, I know. And perhaps the
|
|
284
|
-
biggest shame is not me correctly handling it.
|
|
285
|
-
"""
|
|
286
|
-
import re
|
|
287
|
-
|
|
288
|
-
return re.sub("[\x80-\xFF]", lambda c: "%%%02x" % ord(c.group(0)), b)
|
|
289
|
-
|
|
290
267
|
parts = urlparse.urlparse(iri)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
partes = []
|
|
294
|
-
for parti, part in enumerate(parts):
|
|
295
|
-
try:
|
|
296
|
-
if parti != 1:
|
|
297
|
-
partes.append(url_encode_non_ascii(part.encode("utf-8")))
|
|
298
|
-
else:
|
|
299
|
-
partes.append(part.encode("idna"))
|
|
300
|
-
except UnicodeDecodeError:
|
|
301
|
-
partes.append(url_encode_non_ascii(part.decode("latin")))
|
|
302
|
-
except Exception:
|
|
303
|
-
raise Exception
|
|
304
|
-
return urlparse.urlunparse(partes)
|
|
305
|
-
else:
|
|
306
|
-
# python3
|
|
307
|
-
uri = [part.decode("utf8") for parti, part in enumerate(parts.encode("utf8"))]
|
|
308
|
-
return urlparse.urlunparse(uri)
|
|
268
|
+
uri = [part.decode("utf8") for parti, part in enumerate(parts.encode("utf8"))]
|
|
269
|
+
return urlparse.urlunparse(uri)
|
|
309
270
|
|
|
310
271
|
|
|
311
272
|
def encoded_dict(in_dict):
|
|
@@ -315,13 +276,6 @@ def encoded_dict(in_dict):
|
|
|
315
276
|
"""
|
|
316
277
|
out_dict = {}
|
|
317
278
|
for k, v in in_dict.items():
|
|
318
|
-
if isinstance(v, unicode):
|
|
319
|
-
if sys.version_info < (3, 0): # pragma: no cover
|
|
320
|
-
v = v.encode("utf8")
|
|
321
|
-
elif isinstance(v, str):
|
|
322
|
-
# Must be encoded in UTF-8
|
|
323
|
-
if sys.version_info < (3, 0): # pragma: no cover
|
|
324
|
-
v.decode("utf8")
|
|
325
279
|
out_dict[k] = v
|
|
326
280
|
return out_dict
|
|
327
281
|
|
MambuPy/orm/schema_groups.py
CHANGED
|
@@ -15,10 +15,9 @@ from .schema_users import User
|
|
|
15
15
|
|
|
16
16
|
# technical debt, cannot import name schema_clients
|
|
17
17
|
try:
|
|
18
|
-
from . import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import schema_clients # python 2
|
|
18
|
+
from . import schema_clients
|
|
19
|
+
except Exception:
|
|
20
|
+
import schema_clients
|
|
22
21
|
|
|
23
22
|
from sqlalchemy import (Column, DateTime, ForeignKey, Integer, Numeric, String,
|
|
24
23
|
Text)
|
MambuPy/orm/schema_orm.py
CHANGED
|
@@ -23,8 +23,6 @@ every schema_*.py you need.
|
|
|
23
23
|
This last requirement also applies for the Base, or for the engine and
|
|
24
24
|
the sessionmaker for that matter.
|
|
25
25
|
"""
|
|
26
|
-
from __future__ import absolute_import
|
|
27
|
-
|
|
28
26
|
from sqlalchemy.ext.declarative import declarative_base
|
|
29
27
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
|
30
28
|
|
MambuPy/rest/__init__.py
CHANGED
|
@@ -1,49 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
"""MambuPy REST module - DEPRECATED.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
<https://developer.mambu.com/customer/en/portal/articles/1162276-rest-apis-overview/>`_
|
|
4
|
+
.. warning::
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
DEPRECATED: This module uses Mambu API v1 which is no longer supported.
|
|
7
|
+
This code is maintained only for backwards compatibility with legacy systems.
|
|
8
|
+
It will be removed in a future version of MambuPy.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
MambuPy.rest.mambuclient
|
|
11
|
-
MambuPy.rest.mambugroup
|
|
12
|
-
MambuPy.rest.mambuloan
|
|
13
|
-
MambuPy.rest.mamburepayment
|
|
14
|
-
MambuPy.rest.mambutransaction
|
|
15
|
-
MambuPy.rest.mambuproduct
|
|
16
|
-
MambuPy.rest.mambubranch
|
|
17
|
-
MambuPy.rest.mambucentre
|
|
18
|
-
MambuPy.rest.mambuactivity
|
|
19
|
-
MambuPy.rest.mambutask
|
|
20
|
-
MambuPy.rest.mambusaving
|
|
21
|
-
MambuPy.rest.mambusavingtransaction
|
|
22
|
-
MambuPy.rest.mambutransactionchannel
|
|
23
|
-
MambuPy.rest.mambuuser
|
|
24
|
-
MambuPy.rest.mamburoles
|
|
25
|
-
|
|
26
|
-
.. warning:: This package is soon to be deprecated. Use the :any:`MambuPy.api` package instead.
|
|
27
|
-
|
|
28
|
-
The REST API way is the currently most developed code on *MambuPy*.
|
|
29
|
-
|
|
30
|
-
Lives under the :any:`MambuPy.rest` package
|
|
31
|
-
|
|
32
|
-
It has a lot of objects which model some Mambu entity.
|
|
33
|
-
|
|
34
|
-
Every object inherits from the parent :any:`mambustruct.MambuStruct`
|
|
35
|
-
class. Start at the documentation there for more info on how it works.
|
|
36
|
-
|
|
37
|
-
.. todo:: Implement objects to make POST requests. The suggestion may be to use
|
|
38
|
-
MambuStruct, to default the __init__ to make a POST request (via the data
|
|
39
|
-
argument) and the attrs attribute to store the elements of the response that
|
|
40
|
-
Mambu gives when a successful POST is achieved.
|
|
41
|
-
.. todo:: Implement a lot of other Mambu entities available through GET requests on
|
|
42
|
-
Mambu.
|
|
43
|
-
.. todo:: Implement a lot of lacking GET filters on the currently available Mambu
|
|
44
|
-
objects, inside the urlfuncs on the mambuutil module.
|
|
45
|
-
.. todo:: A lot of TODO comments are inserted inside the pydocs of the code
|
|
46
|
-
itself. Please read them for suggestions on work need to be done.
|
|
10
|
+
Only mambuactivity is available in this legacy module.
|
|
47
11
|
"""
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
import warnings
|
|
13
|
+
|
|
14
|
+
warnings.warn(
|
|
15
|
+
"MambuPy.rest module is deprecated and will be removed in a future version. "
|
|
16
|
+
"Mambu API v1 is no longer supported by Mambu.",
|
|
17
|
+
DeprecationWarning,
|
|
18
|
+
stacklevel=2,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from .mambuactivity import (
|
|
22
|
+
MambuActivity,
|
|
23
|
+
MambuActivities,
|
|
24
|
+
getactivitiesurl,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"MambuActivity",
|
|
29
|
+
"MambuActivities",
|
|
30
|
+
"getactivitiesurl",
|
|
31
|
+
]
|