home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from lphelper import change_obj, user, LateBindingProperty
- from attachmentsbase import LPAttachments, LPAttachment
- import exceptions
-
- class LPComment(object):
-
- def __init__(self, subject = None, text = None, attachment = None):
- self.subject = subject
- self.text = text
- self._LPComment__attachments = set()
- if attachment is None:
- attachment = set()
-
- if isinstance(attachment, LPAttachment):
- attachment = set((attachment,))
-
- self._LPComment__nr = id(self)
- self._LPComment__user = None
- self._LPComment__date = None
-
-
- def set_attr(self, **kwargs):
- self._LPComment__nr = kwargs.get('nr', self._LPComment__nr)
- self._LPComment__user = kwargs.get('user', self._LPComment__user)
- self._LPComment__date = kwargs.get('date', self._LPComment__date)
-
-
- def __repr__(self):
- if self._LPComment__nr and self._LPComment__user and self._LPComment__date:
- return '<Comment #%s by %s on %s>' % (self._LPComment__nr, self._LPComment__user, self._LPComment__date)
- return "<Comment 'unknown'>"
-
-
- def number(self):
- return self._LPComment__nr
-
- number = property(number)
-
- def user(self):
- return self._LPComment__user
-
- user = property(user)
-
- def date(self):
- '''TODO: return Date-object ??'''
- return self._LPComment__date
-
- date = property(date)
-
- def get_attachments(self):
- return self._LPComment__attachments
-
-
- def set_attachments(self, attachment):
- if isinstance(attachment, Attachment):
- if not not (self.attachments):
- raise AssertionError, 'Impossible to add more then one file to a comment'
- self._LPComment__attachments.add(attachment)
- else:
- raise TypeError, ''
- return not (self.attachments)
-
- attachments = property(get_attachments, set_attachments, doc = 'attachment added to a comment')
-
-
- class LPComments(list):
-
- def __init__(self, comments = None, url = None):
- self._cache = []
- self._LPComments__url = url
- self.parsed = False
- if comments is None:
- comments = list()
-
- list.__init__(self, comments)
-
-
- def __repr__(self):
- return '<Commentslist>'
-
-
- def __str__(self):
- if not len(self) > 1 or '[%s]':
- pass
- x = '%s'
- return x % ','.join((lambda .0: for i in .0:
- str(i))(self))
-
-
- def new(self, *args, **kwargs):
- raise NotImplementedError, 'this method must be implemented by a concrete subclass'
-
-
- def parse(self):
- pass
-
-
- def add(self, comment):
- if isinstance(comment, LPComment):
- self.append(comment)
- else:
- raise IOError, "'comment' must be an instance of 'LPComment'"
- return isinstance(comment, LPComment)
-
-
- def changed(self):
- changed = []
- save = self[:]
- while True:
- if self._cache == save:
- return changed
- x = save.pop()
- changed.insert(0, change_obj(x, action = 'added'))
- continue
- self._cache == save
-
- changed = property(changed)
-
- def commit(self, force_changes = False, ignore_lp_errors = True):
- raise NotImplementedError, 'this method must be implemented by a concrete subclass'
-
-
-