Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, mdbx, async_loader, root="/", parent=None):
AbstractTreeItem.__init__(self, parent=parent)
self.icon = get_native_folder_icon()
self._root = root
self._mdbx = mdbx
self._async_loader = async_loader
self._checkStateChanged = False
# get info from our own excluded list
excluded_folders = self._mdbx.get_conf("main", "excluded_folders")
if root.lower() in excluded_folders:
# item is excluded
self._originalCheckState = 0
elif any(is_child(root.lower(), f) for f in excluded_folders):
# item's parent is excluded
self._originalCheckState = 0
elif any(is_child(f, root.lower()) for f in excluded_folders):
# some of item's children are excluded
self._originalCheckState = 1
else:
# item is fully included
self._originalCheckState = 2
# overwrite original state if the parent was modified
if self._parent and self._parent._checkStateChanged and not \
self._parent.checkState == 1:
# inherit from parent
self._checkState = self._parent.checkState
self._checkStateChanged = self._parent._checkStateChanged
else:
def is_excluded_by_user(self, dbx_path):
"""
Check if file has been excluded from sync by the user.
:param str dbx_path: Path of folder on Dropbox.
:return: ``True`` or `False`.
:rtype: bool
"""
dbx_path = dbx_path.lower()
# in excluded files?
test0 = dbx_path in self.excluded_files
# in excluded folders?
test1 = any(dbx_path == f or is_child(dbx_path, f) for f in self.excluded_folders)
return any((test0, test1))
def _is_deleted_child(x, parent):
"""Check for children of deleted folders"""
is_deleted_event = (x.event_type is EVENT_TYPE_DELETED)
return is_deleted_event and is_child(x.src_path, parent.src_path)
def clean_excluded_folder_list(folder_list):
"""Removes all duplicates from the excluded folder list."""
# remove duplicate entries by creating set, strip trailing "/"
folder_list = set(f.lower().rstrip(osp.sep) for f in folder_list)
# remove all children of excluded folders
clean_folders_list = list(folder_list)
for folder in folder_list:
clean_folders_list = [f for f in clean_folders_list if not is_child(f, folder)]
return clean_folders_list
def _is_moved_child(x, parent):
"""Check for children of moved folders"""
is_moved_event = (x.event_type is EVENT_TYPE_MOVED)
return (is_moved_event and
is_child(x.src_path, parent.src_path) and
is_child(x.dest_path, parent.dest_path))
self.icon = get_native_folder_icon()
self._root = root
self._mdbx = mdbx
self._async_loader = async_loader
self._checkStateChanged = False
# get info from our own excluded list
excluded_folders = self._mdbx.get_conf("main", "excluded_folders")
if root.lower() in excluded_folders:
# item is excluded
self._originalCheckState = 0
elif any(is_child(root.lower(), f) for f in excluded_folders):
# item's parent is excluded
self._originalCheckState = 0
elif any(is_child(f, root.lower()) for f in excluded_folders):
# some of item's children are excluded
self._originalCheckState = 1
else:
# item is fully included
self._originalCheckState = 2
# overwrite original state if the parent was modified
if self._parent and self._parent._checkStateChanged and not \
self._parent.checkState == 1:
# inherit from parent
self._checkState = self._parent.checkState
self._checkStateChanged = self._parent._checkStateChanged
else:
self._checkStateChanged = False
self._checkState = int(self._originalCheckState)