Package DebTorrent :: Package BT1 :: Module fakeopen :: Class FakeOpen
[hide private]
[frames] | no frames]

Class FakeOpen

source code

Fake file objects.

Instance Methods [hide private]
 
__init__(self, initial={})
Initialize the instance.
source code
 
open(self, filename, mode)
Open a new or existing file.
source code
boolean
exists(self, file)
Check if the file exists.
source code
int
getsize(self, file)
Get the current size of the file.
source code
Instance Variables [hide private]
dictionary of {string: list of char} files
the stored file data, keys are file names, values are lists of characters that are the data
Method Details [hide private]

__init__(self, initial={})
(Constructor)

source code 
Initialize the instance.
Parameters:
  • initial (dictionary) - the initial files to create

open(self, filename, mode)

source code 

Open a new or existing file.

Treats everything as read/write, doesn't support append.
Parameters:
  • filename (string) - the file name to open
  • mode (string) - the file mode to open (not used)

exists(self, file)

source code 
Check if the file exists.
Parameters:
  • file (string) - the file name to check
Returns: boolean
whether the file exists

getsize(self, file)

source code 
Get the current size of the file.
Parameters:
  • file (string) - the file name to check
Returns: int
the file size