Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ptype = "file"
fname = os.path.split(p)[1]
id_ = self.tree.insert(node, "end", text=fname, values=[p, ptype])
if ptype == 'directory':
if fname not in ('.', '..'):
self.images.append(get_bitmap("folder"))
self.tree.insert(id_, 0, text="dummy")
self.tree.item(id_, text=fname,
image=self.images[-1],
tags=("base",))
elif ptype == 'file':
mimetype = mimetypes.guess_type(fname)[0].split("/")[0]
if mimetype == "image":
img = get_bitmap("imagefile")
elif mimetype == "video":
img = get_bitmap("moviefile")
elif mimetype == "audio":
img = get_bitmap("musicfile")
else:
img = get_bitmap("textfile")
self.images.append(img)
self.tree.item(id_, image=self.images[-1])
if fname not in ('.', '..'):
self.images.append(get_bitmap("folder"))
self.tree.insert(id_, 0, text="dummy")
self.tree.item(id_, text=fname,
image=self.images[-1],
tags=("base",))
elif ptype == 'file':
mimetype = mimetypes.guess_type(fname)[0].split("/")[0]
if mimetype == "image":
img = get_bitmap("imagefile")
elif mimetype == "video":
img = get_bitmap("moviefile")
elif mimetype == "audio":
img = get_bitmap("musicfile")
else:
img = get_bitmap("textfile")
self.images.append(img)
self.tree.item(id_, image=self.images[-1])
special_dirs = []
for p in special_dirs + os.listdir(path):
ptype = None
p = os.path.join(path, p).replace('\\', '/')
if os.path.isdir(p):
ptype = "directory"
elif os.path.isfile(p):
ptype = "file"
fname = os.path.split(p)[1]
id_ = self.tree.insert(node, "end", text=fname, values=[p, ptype])
if ptype == 'directory':
if fname not in ('.', '..'):
self.images.append(get_bitmap("folder"))
self.tree.insert(id_, 0, text="dummy")
self.tree.item(id_, text=fname,
image=self.images[-1],
tags=("base",))
elif ptype == 'file':
mimetype = mimetypes.guess_type(fname)[0].split("/")[0]
if mimetype == "image":
img = get_bitmap("imagefile")
elif mimetype == "video":
img = get_bitmap("moviefile")
elif mimetype == "audio":
img = get_bitmap("musicfile")
else:
img = get_bitmap("textfile")
self.images.append(img)
self.tree.item(id_, image=self.images[-1])
if ptype == 'directory':
if fname not in ('.', '..'):
self.images.append(get_bitmap("folder"))
self.tree.insert(id_, 0, text="dummy")
self.tree.item(id_, text=fname,
image=self.images[-1],
tags=("base",))
elif ptype == 'file':
mimetype = mimetypes.guess_type(fname)[0].split("/")[0]
if mimetype == "image":
img = get_bitmap("imagefile")
elif mimetype == "video":
img = get_bitmap("moviefile")
elif mimetype == "audio":
img = get_bitmap("musicfile")
else:
img = get_bitmap("textfile")
self.images.append(img)
self.tree.item(id_, image=self.images[-1])