def get_item_value(self, resource, context, item, column): if column == 'checkbox': if self.is_folder(item): return None proxy = super(AddImage_BrowseContent, self) return proxy.get_item_value(resource, context, item, column) elif column == 'icon': if self.is_folder(item): # icon path_to_icon = item.get_resource_icon(48) if path_to_icon.startswith(';'): path_to_icon = Path('%s/' % item.name).resolve(path_to_icon) else: path = item.abspath path_to_icon = ";thumb?width=48&height=48" if path: path_to_resource = Path(str(path) + '/') path_to_icon = path_to_resource.resolve(path_to_icon) return path_to_icon else: proxy = super(AddImage_BrowseContent, self) return proxy.get_item_value(resource, context, item, column)
def resolve(base, path): if type(base) is not Path: base = Path(base) path = base.resolve(path) return str(path)
def test_resolve_wo_slash(self): before = Path('/a/b') after = Path('/a/c') self.assertEqual(before.resolve('c'), after)
def test_resolve_w_slash(self): before = Path('/a/b/') after = Path('/a/b/c') self.assertEqual(before.resolve('c'), after)