Do not use property decorators as 2.5 does not support .setter et al

This commit is contained in:
Andrew Resch 2009-08-12 21:18:39 +00:00
parent f562e8aff3
commit 74ed19b5f2
1 changed files with 63 additions and 70 deletions

View File

@ -221,8 +221,7 @@ class TorrentMetadata(object):
# Write out the torrent file
open(torrent_path, "wb").write(bencode(torrent))
@property
def data_path(self):
def get_data_path(self):
"""
The path to the files that the torrent will contain. It can be either
a file or a folder. This property needs to be set before the torrent
@ -230,8 +229,7 @@ class TorrentMetadata(object):
"""
return self.__data_path
@data_path.setter
def data_path(self, path):
def set_data_path(self, path):
"""
:param path: the path to the data
:type path: string
@ -244,8 +242,7 @@ class TorrentMetadata(object):
else:
raise InvalidPath("No such file or directory: %s" % path)
@property
def piece_size(self):
def get_piece_size(self):
"""
The size of pieces in bytes. The size must be a multiple of 16KiB.
If you don't set a piece size, one will be automatically selected to
@ -254,8 +251,7 @@ class TorrentMetadata(object):
"""
return self.__piece_size
@piece_size.setter
def piece_size(self, size):
def set_piece_size(self, size):
"""
:param size: the desired piece size in bytes
@ -266,24 +262,21 @@ class TorrentMetadata(object):
raise InvalidPieceSize("Piece size must be a multiple of 16384")
self.__piece_size = size
@property
def comment(self):
def get_comment(self):
"""
Comment is some extra info to be stored in the torrent. This is
typically an informational string.
"""
return self.__comment
@comment.setter
def comment(self, comment):
def set_comment(self, comment):
"""
:param comment: an informational string
:type comment: string
"""
self.__comment = comment
@property
def private(self):
def get_private(self):
"""
Private torrents only announce to the tracker and will not use DHT or
Peer Exchange.
@ -293,16 +286,14 @@ class TorrentMetadata(object):
"""
return self.__private
@private.setter
def private(self, private):
def set_private(self, private):
"""
:param private: True if the torrent is to be private
:type private: bool
"""
self.__private = private
@property
def trackers(self):
def get_trackers(self):
"""
The announce trackers is a list of lists.
@ -311,16 +302,14 @@ class TorrentMetadata(object):
"""
return self.__trackers
@trackers.setter
def trackers(self, trackers):
def set_trackers(self, trackers):
"""
:param trackers: a list of lists of trackers, each list is a tier
:type trackers: list of list of strings
"""
self.__trackers = trackers
@property
def webseeds(self):
def get_webseeds(self):
"""
The web seeds can either be:
Hoffman-style: http://bittorrent.org/beps/bep_0017.html
@ -332,27 +321,31 @@ class TorrentMetadata(object):
"""
return self.__web_seeds
@webseeds.setter
def webseeds(self, webseeds):
def set_webseeds(self, webseeds):
"""
:param webseeds: the webseeds which can be either Hoffman or GetRight style
:type webseeds: list of urls
"""
self.__webseeds = webseeds
@property
def pad_files(self):
def get_pad_files(self):
"""
If this is True, padding files will be added to align files on piece
boundaries.
"""
return self.__pad_files
@pad_files.setter
def pad_files(self, pad):
def set_pad_files(self, pad):
"""
:param pad: set True to align files on piece boundaries
:type pad: bool
"""
self.__pad_files = pad
data_path = property(get_data_path, set_data_path)
piece_size = property(get_piece_size, set_piece_size)
comment = property(get_comment, set_comment)
private = property(get_private, set_private)
trackers = property(get_trackers, set_trackers)
webseeds = property(get_webseeds, set_webseeds)
pad_files = property(get_pad_files, set_pad_files)