Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
size = int(float(size) * 10**3)
elif unit == 'MB':
size = int(float(size) * 10**6)
elif unit == 'GB':
size = int(float(size) * 10**9)
elif unit == 'TB':
size = int(float(size) * 10**12)
if change_type == 'added' or change_type == 'removed':
full_path = line[line.find(line_split[3]):]
elif change_type == "modified":
full_path = line[line.find(line_split[4]):]
dir, name = os.path.split(full_path)
# add to nested dict of folders to find nested dirs.
d = get_dict_from_list(nested_file_list, dir.split('/'))
if name not in d:
d[name] = {}
else:
size = 0
full_path = line[line.find(line_split[2]):]
dir, name = os.path.split(full_path)
# add to nested dict of folders to find nested dirs.
d = get_dict_from_list(nested_file_list, full_path.split('/'))
return size, change_type, name, dir
def parse_line(line):
size, modified, full_path = line.split('\t')
size = int(size)
dir, name = os.path.split(full_path)
# add to nested dict of folders to find nested dirs.
d = get_dict_from_list(nested_file_list, dir.split('/'))
if name not in d:
d[name] = {}
return size, modified, name, dir
self.itemData = [name, modified]
self.childItems = []
# Pre-filter children
self._filtered_children = []
search_path = os.path.join(self.path, name)
if parent is None: # Find path for root folder
for root_folder in nested_file_list.keys():
self._filtered_children.append((0, '', root_folder, '', ))
else:
# This adds direct children.
self._filtered_children = [f for f in files_with_attributes if search_path == f[3]]
# Add nested folders.
for immediate_child in get_dict_from_list(nested_file_list, search_path.split('/')).keys():
if not [True for child in self._filtered_children if child[2] == immediate_child]:
self._filtered_children.append((0, '', immediate_child, search_path))
self.is_loaded = False
unit = line_split[2]
else:
change_type = "modified"
size = line_split[0]
unit = line_split[1]
# If present remove '+' or '-' sign at the front
if size[0] in ('+', '-'):
size = size[1:]
if line_split[0].startswith("["):
size = 0
change_type = line[:line.find(line_split[3])]
full_path = line[line.find(line_split[3]):]
dir, name = os.path.split(full_path)
# add to nested dict of folders to find nested dirs.
d = get_dict_from_list(nested_file_list, full_path.split('/'))
elif line_split[1] not in ['directory', 'link']:
if unit == 'B':
size = int(size)
elif unit == 'kB':
size = int(float(size) * 10**3)
elif unit == 'MB':
size = int(float(size) * 10**6)
elif unit == 'GB':
size = int(float(size) * 10**9)
elif unit == 'TB':
size = int(float(size) * 10**12)
if change_type == 'added' or change_type == 'removed':
full_path = line[line.find(line_split[3]):]
elif change_type == "modified":
full_path = line[line.find(line_split[4]):]
self.checkedState = False
# Pre-filter children
self._filtered_children = []
search_path = os.path.join(self.path, name)
if parent is None: # Find path for root folder
for root_folder in nested_file_list.keys():
self._filtered_children.append((0, '', root_folder, '', ))
else:
self.checkedState = parent.checkedState # If there is a parent, use its checked-status.
# This adds direct children.
self._filtered_children = [f for f in files_with_attributes if search_path == f[3]]
# Add nested folders.
for immediate_child in get_dict_from_list(nested_file_list, search_path.split('/')).keys():
if not [True for child in self._filtered_children if child[2] == immediate_child]:
self._filtered_children.append((0, '', immediate_child, search_path))
self.is_loaded = False