def convertToLink(self, s, l, t): fname = t[1] if isImage(fname): return '<img src="%s/%s"/>' % (PAGE_ATTACH_DIR, fname) else: return '<a href="%s/%s">%s</a>' % (PAGE_ATTACH_DIR, fname, fname)
def _addIconToDir(self, grouppath, iconpath): ''' Add single icon with full path iconpath into folder groupPath. Not images is skipped. ''' if (not isImage(iconpath) or not os.path.exists(iconpath)): return iconname = os.path.basename(iconpath) newIconName = self._getNewIconName(grouppath, iconname) newIconPath = os.path.join(grouppath, newIconName) try: IconMaker().create(iconpath, newIconPath) except (IOError, ValueError): pass
def _addIconToDir(self, grouppath, iconpath): """ Add single icon with full path iconpath into folder groupPath. Not images is skipped. """ if not isImage(iconpath) or not os.path.exists(iconpath): return iconname = os.path.basename(iconpath) newIconName = self._getNewIconName(grouppath, iconname) newIconPath = os.path.join(grouppath, newIconName) try: IconMaker().create(iconpath, newIconPath) except (IOError, ValueError): pass
def setCover(self, groupname, fname): if groupname is None: groupname = self._rootGroupName grouppath = os.path.join(self._iconsDir, groupname) if not os.path.exists(grouppath): raise KeyError if (not isImage(fname) or not os.path.exists(fname)): return newIconPath = os.path.join(grouppath, self.COVER_FILE_NAME) try: IconMaker().create(fname, newIconPath) except (IOError, ValueError): pass self._scanIconsDir(self._iconsDir)
def setCover(self, groupname, fname): if groupname is None: groupname = self._rootGroupName grouppath = os.path.join(self._iconsDir, groupname) if not os.path.exists(grouppath): raise KeyError if not isImage(fname) or not os.path.exists(fname): return newIconPath = os.path.join(grouppath, self.COVER_FILE_NAME) try: IconMaker().create(fname, newIconPath) except (IOError, ValueError): pass self._scanIconsDir(self._iconsDir)
def filterFile(self, fname): return isImage(fname)