cleaned
This commit is contained in:
parent
7b678af1b4
commit
97e6c397d9
|
@ -131,6 +131,10 @@ def show_progress(iterable,N_iter=None,prefix='',bar_length=50):
|
|||
Character length of bar. Defaults to 50.
|
||||
|
||||
"""
|
||||
if N_iter == 1 or len(iterable) == 1:
|
||||
for item in iterable:
|
||||
yield item
|
||||
else:
|
||||
status = _ProgressBar(N_iter if N_iter is not None else len(iterable),prefix,bar_length)
|
||||
|
||||
for i,item in enumerate(iterable):
|
||||
|
@ -431,19 +435,11 @@ def dict_compress(d):
|
|||
|
||||
"""
|
||||
if isinstance(d,dict) and len(d) == 1:
|
||||
key = list(d.keys())[0]
|
||||
entry = d[key]
|
||||
if isinstance(entry,dict):
|
||||
new = dict_compress(entry.copy())
|
||||
entry = d[list(d.keys())[0]]
|
||||
new = dict_compress(entry.copy()) if isinstance(entry,dict) else entry
|
||||
else:
|
||||
new = entry
|
||||
else:
|
||||
new = {}
|
||||
for k,v in d.items():
|
||||
if isinstance(v, dict):
|
||||
v = dict_compress(v)
|
||||
if not isinstance(v,dict) or v == {}:
|
||||
new[k] = v
|
||||
new = {k: (dict_compress(v) if isinstance(v, dict) else v) for k,v in d.items()}
|
||||
|
||||
return new
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue