Skip to content

Commit ea40fc1

Browse files
authored
Merge pull request #59 from den4uk/dev
dependency fixes
2 parents 50c4785 + 95353b6 commit ea40fc1

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
===
33

4+
### 3.6.2 (2022-04-29)
5+
6+
- Dependency pins for Jinja2 and MarkupSafe
7+
- Tar extraction to local (from temp path, which can be limited in size)
8+
9+
410
### 3.6.1 (2021-10-31)
511

612
- Bugfix for the package gui modules not being included when building.

andriller/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '3.6.1'
1+
__version__ = '3.6.2'
22
__app_name__ = 'Andriller CE'
33
__package_name__ = 'andriller'
44
__website__ = "https://github.com/den4uk/andriller"

andriller/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,14 @@ def get_koi(payload, keys: list) -> dict:
8383
Flattens the object and gets values for keys
8484
"""
8585
# Cleanup the object
86-
if payload and type(payload) == str:
87-
try:
86+
if payload and isinstance(payload, str):
87+
with contextlib.suppress(Exception):
8888
payload = re.sub('\n', '', payload)
8989
return get_koi(json.loads(payload), keys)
90-
except Exception:
91-
return {}
90+
return {}
9291

9392
targets = [str, int, float, bool]
94-
result = {k: None for k in keys}
93+
result = dict.fromkeys(keys)
9594

9695
def process(payload):
9796
if isinstance(payload, dict):
@@ -105,7 +104,7 @@ def process(payload):
105104
for i in payload:
106105
process(i)
107106

108-
if payload and type(payload) in [list, dict]:
107+
if payload and isinstance(payload, (list, dict)):
109108
process(payload)
110109
return result if set(result.values()) else {}
111110

@@ -142,12 +141,11 @@ def ab_file_verify(cls, file_obj):
142141
pass
143142

144143
@classmethod
145-
def ab_to_tar(cls, input_file, to_tmp=True):
144+
def ab_to_tar(cls, input_file: str, to_tmp: bool = False, buffer: int = (2 ** 20)):
146145
"""
147146
Takes AB file, and converts it to a tarball, return file path to tar
148147
If to_tmp is set to False, converts into same directory
149148
"""
150-
BUFFER = 2 ** 20
151149
with open(input_file, 'rb') as backup_file:
152150
cls.ab_file_verify(backup_file)
153151
# TODO: make it responsive to encrypted backups
@@ -156,7 +154,7 @@ def ab_to_tar(cls, input_file, to_tmp=True):
156154
to_tmp else open(f'{input_file}.tar', 'wb')
157155
zlib_obj = zlib.decompressobj()
158156
while True:
159-
d = backup_file.read(BUFFER)
157+
d = backup_file.read(buffer)
160158
if not d:
161159
break
162160
c = zlib_obj.decompress(d)
@@ -166,10 +164,12 @@ def ab_to_tar(cls, input_file, to_tmp=True):
166164
return temptar.name
167165

168166
@staticmethod
169-
def extract_form_tar(src_file, dst_dir, targets=[], full=False):
167+
def extract_form_tar(src_file, dst_dir, targets: list = None, full=False):
170168
"""
171169
Yields tar file names, uses a list of targets or a full extraction
172170
"""
171+
if targets is None:
172+
targets = []
173173
with tarfile.open(src_file) as tar:
174174
for tar_name in tar.getnames():
175175
try:

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
flake8
44
pytest-cov
55
pytest-mock
6+
wheel

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
wheel
21
dateutils
32
javaobj-py3>=0.4.3
43
pycryptodomex
54
python-dateutil
65
XlsxWriter
7-
Jinja2
6+
Jinja2>=2.11.3,<3
7+
MarkupSafe==2.0.1
88
wrapt-timeout-decorator==1.3.1
9-
appdirs>=1.4.4
9+
appdirs>=1.4.4,<2
1010
requests
1111
dataclasses>=0.8;python_version=="3.6"

0 commit comments

Comments
 (0)