storage :: File :: File :: Class File
[hide private]
[frames] | no frames]

Class File

object --+
         |
        File

Class for representing a file or folder on a storage device. Do not subclass this class.

Instance Methods [hide private]
 
__init__(self, device)
Creates a new File object belonging to the given storage device.
 
__cmp__(self, other)
 
__repr__(self)
Returns a readable representation of this File for debugging purposes.
 
__get_full_path(self)
 
full_path(self)
read-only: full virtual path of the file
 
__get_source_icon(self)
 
source_icon(self)
read-only: pixbuf icon representing the source device
 
__get_md5(self)
 
md5(self)
read-only: MD5 sum for uniquely identifying the file internally
 
__set_thumbnail_md5(self, v)
 
__get_thumbnail_md5(self)
 
__get_medium(self)
 
medium(self)
read-only: path of the medium where the file is on (local files only)
 
new_file(self)
Creates a new file in this folder.
 
delete(self)
Deletes this file.
 
get_children(self)
Returns a list of children of this folder.
 
get_children_async(self, cb, *args)
Lists the children of this folder asynchronously by invoking the given callback handler on every file.
 
load(self, maxlen, cb, *args)
Retrieves the given amount of bytes of the file asynchronously.
 
get_resource(self)
 
keep(self)
Instructs the storage device to keep this file.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Variables [hide private]
  FILE = "application/x-other"
MIME type for unknown file types
  DIRECTORY = "application/x-folder"
MIME type for folders
  thumbnail_md5 = property(__get_thumbnail_md5, __set_thumbnail_...
read-write: MD5 sum for uniquely identifying the file's thumbnail preview
Instance Variables [hide private]
  can_skip
whether the user may skip files (previous/next) in this folder
  can_add_to_library
whether the user may add this folder to the library
  can_add
whether the user may add items to this folder
  can_delete
whether the user may delete this file
  can_keep
whether the user may keep this non-local file
  can_download
whether the user may download this file
  is_local
whether this file is local
  path
virtual path of the file on the device
  name
name of the file presented to the user
  info
some info text
  description
text for further description
  index
index number that can be used for sorting
  parent
name of parent folder, if any (can be used for grouping items)
  thumbnail
may contain the URI of a thumbnail image
  mimetype
MIME type of the file
  resource
URI for accessing the file
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, device)
(Constructor)

 

Creates a new File object belonging to the given storage device.

Parameters:
  • device - the storage device of the file
Overrides: object.__init__

__repr__(self)
(Representation operator)

 

Returns a readable representation of this File for debugging purposes.

Returns:
readable representation
Overrides: object.__repr__

new_file(self)

 

Creates a new file in this folder. This only works if the storage device implements the new_file method.

Returns:
the new File object

delete(self)

 

Deletes this file. This only works if the storage device implements the delete method.

get_children(self)

 

Returns a list of children of this folder.

Returns:
list of File objects

Deprecated: get_children_async should be used instead

get_children_async(self, cb, *args)

 

Lists the children of this folder asynchronously by invoking the given callback handler on every file. Terminates with a None object.

Parameters:
  • cb - callback handler
  • args - variable list of arguments to the callback handler

load(self, maxlen, cb, *args)

 

Retrieves the given amount of bytes of the file asynchronously.

May raise an IOError if retrieving is not supported.

Parameters:
  • maxlen - number of bytes to retrieve or -1 for retrieving the whole file
  • cb - callback handler for accepting the data chunks
  • args - variable list of arguments to the callback handler

keep(self)

 

Instructs the storage device to keep this file. This method can be used for keeping a local copy of a remote file. This only works if the storage device implements the keep method.


Class Variable Details [hide private]

thumbnail_md5

read-write: MD5 sum for uniquely identifying the file's thumbnail preview

Value:
property(__get_thumbnail_md5, __set_thumbnail_md5)