def __init__(self, dir, show_hidden=False): # Use glib filename reading to make display name out of filenames # this function returns a `unicode` object name = gobject.filename_display_basename(dir) super(DirectorySource, self).__init__(name) self.directory = dir self.show_hidden = show_hidden
def __init__(self, dirlist, depth=0): """ @dirlist: Directories as byte strings """ name = gobject.filename_display_basename(dirlist[0]) if len(dirlist) > 1: name = _("%s et. al.") % name super(FileSource, self).__init__(name) self.dirlist = dirlist self.depth = depth
def __init__(self, obj, name=None): """Construct a FileLeaf The display name of the file is normally derived from the full path, and @name should normally be left unspecified. @obj: byte string (file system encoding) @name: unicode name or None for using basename """ if obj is None: raise InvalidDataError("File path for %s may not be None" % name) # Use glib filename reading to make display name out of filenames # this function returns a `unicode` object if not name: name = gobject.filename_display_basename(obj) super(FileLeaf, self).__init__(obj, name)
def __init__(self, obj, name=None, alias=None): """Construct a FileLeaf The display name of the file is normally derived from the full path, and @name should normally be left unspecified. @obj: byte string (file system encoding) @name: unicode name or None for using basename """ if obj is None: raise InvalidDataError("File path for %s may not be None" % name) # Use glib filename reading to make display name out of filenames # this function returns a `unicode` object if not name: name = gobject.filename_display_basename(obj) super(FileLeaf, self).__init__(obj, name) if alias: self.kupfer_add_alias(alias)
def _createrow(self, fn=None, box=None): rv = [None]*4 if fn is not None: rv[0] = fn rv[2] = gobject.filename_display_basename(fn) # Getting the display name doesn't work if the file doesn't exist. else: rv[0] = rv[2] = '' rv[1] = Box() if box is not None: rv[1].rect = box.rect rv[1].color = box.color rv[3] = rv[1].connect('notify', self._box_changed) ref = id(rv[1]) self.__data[ref] = rv # VERY, VERY IMPORTANT self.__order.append(ref) # FIXME: Trigger events when this sorts # self.__order.sort(key=lambda k: self.__data[k][1]) # print '_createrow:','self.__data:', self.__data return ref
def _get_package_name(self): return gobject.filename_display_basename(self.get_id())
def __init__(self, filepath): """@filepath is a filesystem byte string `str`""" basename = gobject.filename_display_basename(filepath) FileLeaf.__init__(self, filepath, _('Selected File "%s"') % basename)