Package conduit :: Package datatypes :: Module File :: Class File
[hide private]

Class File

source code


Instance Methods [hide private]
 
__init__(self, URI, **kwargs)
File constructor.
source code
 
_open_file(self) source code
 
_close_file(self) source code
 
_xfer_check_global_cancel_flag(self) source code
 
_xfer_progress_callback(self, info, cancel_func) source code
 
_get_text_uri(self)
The mixing of text_uri and gnomevfs.URI in the gnomevfs api is very annoying.
source code
 
_get_file_info(self)
Gets the file info.
source code
 
_defer_rename(self, filename)
In the event that the file is on a read-only volume this call defers the file rename till after the transfer proces
source code
 
_is_deferred_rename(self) source code
 
_defer_new_mtime(self, mtime)
In the event that the file is on a read-only volume this call defers the file mtime modification till after the transfer proces
source code
 
_is_deferred_new_mtime(self) source code
 
_is_tempfile(self) source code
 
_is_proxyfile(self) source code
 
_set_file_mtime(self, mtime) source code
 
_set_filename(self, filename) source code
 
set_from_instance(self, f)
Function to give this file all the properties of the supplied instance.
source code
 
to_tempfile(self)
Copies this file to a temporary file in the system tempdir
source code
 
exists(self) source code
 
is_local(self)
Checks if a File is on the local filesystem or not.
source code
 
is_directory(self)
Returns: True if the File is a directory
source code
 
force_new_filename(self, filename)
Renames the file
source code
 
force_new_file_extension(self, ext)
Changes the file extension to ext.
source code
 
force_new_mtime(self, mtime)
Changes the mtime of the file
source code
 
transfer(self, newURIString, overwrite=False, cancel_function=None)
Transfers the file to newURI.
source code
 
delete(self) source code
 
get_mimetype(self) source code
datetime
get_mtime(self)
Returns the modification time for the file
source code
 
set_mtime(self, mtime)
Sets the modification time of the file
source code
 
get_size(self)
Gets the file size
source code
 
get_hash(self) source code
 
get_filename(self)
Returns the filename of the file
source code
 
get_filename_and_extension(self)
Returns: filename,file_extension
source code
 
get_contents_as_text(self) source code
string
get_local_uri(self)
Gets the local URI (full path) for the file.
source code
 
get_relative_uri(self)
Returns: The files URI relative to its basepath
source code
 
compare(self, B, sizeOnly=False)
Compare me with B based upon their modification times, or optionally based on size only
source code
 
__getstate__(self)
Store the object state in a dict for pickling
source code
 
__setstate__(self, data)
Set object state from dict (after unpickling)
source code

Inherited from DataType.DataType: get_UID, get_open_URI, get_rid, get_snippet, get_tags, get_type, set_UID, set_open_URI, set_tags

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

Class Variables [hide private]
string _name_ = "file"
The name of the type
Instance Variables [hide private]

Inherited from DataType.DataType: UID, URI

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, URI, **kwargs)
(Constructor)

source code 
File constructor. Compulsory args
  • URI: The title of the note
Optional kwargs
  • basepath: The files basepath
  • group: A named group to which this file belongs
Overrides: DataType.DataType.__init__

_get_text_uri(self)

source code 
The mixing of text_uri and gnomevfs.URI in the gnomevfs api is very annoying. This function returns the full text uri for the file

_get_file_info(self)

source code 

Gets the file info. Because gnomevfs is dumb this method works a lot more reliably than self.vfsFileHandle.get_file_info().

Only tries to get the info once for performance reasons

set_from_instance(self, f)

source code 
Function to give this file all the properties of the supplied instance. This is important in converters where there might be pending renames etc on the file that you do not want to lose

to_tempfile(self)

source code 
Copies this file to a temporary file in the system tempdir
Returns:
The local file path

is_local(self)

source code 
Checks if a File is on the local filesystem or not. If not, it is expected that the caller will call get_local_uri, which will copy the file to that location, and return the new path

is_directory(self)

source code 
Returns:
True if the File is a directory

force_new_file_extension(self, ext)

source code 
Changes the file extension to ext.
Parameters:
  • ext - The new file extension (including the dot)

transfer(self, newURIString, overwrite=False, cancel_function=None)

source code 
Transfers the file to newURI. Thin wrapper around go_gnomevfs_transfer because it also sets the new info of the file. By wrapping the xfer_uri funtion it gives the ability to cancel transfers

get_mtime(self)

source code 
Returns the modification time for the file
Returns: datetime
A python datetime object containing the modification time of the file or None on error.
Overrides: DataType.DataType.get_mtime

set_mtime(self, mtime)

source code 
Sets the modification time of the file
Overrides: DataType.DataType.set_mtime

get_hash(self)

source code 
Overrides: DataType.DataType.get_hash

get_filename_and_extension(self)

source code 
Returns:
filename,file_extension

get_local_uri(self)

source code 

Gets the local URI (full path) for the file. If the file is already on the local system then its local path is returned (excluding the vfs sheme, i.e. file:///foo/bar becomes /foo/bar)

If it is a remote file then a local temporary file copy is created

This function is useful for non gnomevfs enabled libs
Returns: string
local absolute path the the file or None on error

get_relative_uri(self)

source code 
Returns:
The files URI relative to its basepath

compare(self, B, sizeOnly=False)

source code 
Compare me with B based upon their modification times, or optionally based on size only
Overrides: DataType.DataType.compare

__getstate__(self)

source code 
Store the object state in a dict for pickling
Overrides: DataType.DataType.__getstate__
(inherited documentation)

__setstate__(self, data)

source code 
Set object state from dict (after unpickling)
Overrides: DataType.DataType.__setstate__
(inherited documentation)