Skip to content

Commit

Permalink
Merge pull request #59 from den4uk/dev
Browse files Browse the repository at this point in the history
dependency fixes
  • Loading branch information
den4uk authored Apr 29, 2022
2 parents 50c4785 + 95353b6 commit ea40fc1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
===

### 3.6.2 (2022-04-29)

- Dependency pins for Jinja2 and MarkupSafe
- Tar extraction to local (from temp path, which can be limited in size)


### 3.6.1 (2021-10-31)

- Bugfix for the package gui modules not being included when building.
Expand Down
2 changes: 1 addition & 1 deletion andriller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.6.1'
__version__ = '3.6.2'
__app_name__ = 'Andriller CE'
__package_name__ = 'andriller'
__website__ = "https://github.com/den4uk/andriller"
Expand Down
20 changes: 10 additions & 10 deletions andriller/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ def get_koi(payload, keys: list) -> dict:
Flattens the object and gets values for keys
"""
# Cleanup the object
if payload and type(payload) == str:
try:
if payload and isinstance(payload, str):
with contextlib.suppress(Exception):
payload = re.sub('\n', '', payload)
return get_koi(json.loads(payload), keys)
except Exception:
return {}
return {}

targets = [str, int, float, bool]
result = {k: None for k in keys}
result = dict.fromkeys(keys)

def process(payload):
if isinstance(payload, dict):
Expand All @@ -105,7 +104,7 @@ def process(payload):
for i in payload:
process(i)

if payload and type(payload) in [list, dict]:
if payload and isinstance(payload, (list, dict)):
process(payload)
return result if set(result.values()) else {}

Expand Down Expand Up @@ -142,12 +141,11 @@ def ab_file_verify(cls, file_obj):
pass

@classmethod
def ab_to_tar(cls, input_file, to_tmp=True):
def ab_to_tar(cls, input_file: str, to_tmp: bool = False, buffer: int = (2 ** 20)):
"""
Takes AB file, and converts it to a tarball, return file path to tar
If to_tmp is set to False, converts into same directory
"""
BUFFER = 2 ** 20
with open(input_file, 'rb') as backup_file:
cls.ab_file_verify(backup_file)
# TODO: make it responsive to encrypted backups
Expand All @@ -156,7 +154,7 @@ def ab_to_tar(cls, input_file, to_tmp=True):
to_tmp else open(f'{input_file}.tar', 'wb')
zlib_obj = zlib.decompressobj()
while True:
d = backup_file.read(BUFFER)
d = backup_file.read(buffer)
if not d:
break
c = zlib_obj.decompress(d)
Expand All @@ -166,10 +164,12 @@ def ab_to_tar(cls, input_file, to_tmp=True):
return temptar.name

@staticmethod
def extract_form_tar(src_file, dst_dir, targets=[], full=False):
def extract_form_tar(src_file, dst_dir, targets: list = None, full=False):
"""
Yields tar file names, uses a list of targets or a full extraction
"""
if targets is None:
targets = []
with tarfile.open(src_file) as tar:
for tar_name in tar.getnames():
try:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
flake8
pytest-cov
pytest-mock
wheel
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
wheel
dateutils
javaobj-py3>=0.4.3
pycryptodomex
python-dateutil
XlsxWriter
Jinja2
Jinja2>=2.11.3,<3
MarkupSafe==2.0.1
wrapt-timeout-decorator==1.3.1
appdirs>=1.4.4
appdirs>=1.4.4,<2
requests
dataclasses>=0.8;python_version=="3.6"

0 comments on commit ea40fc1

Please sign in to comment.