Example #1
0
def replyTemplate(user, message):
    #Given an user and message, returns it as a reply.
    template = Template(sessions.current_session.config['templates']['reply'])
    mapping = {}
    mapping['message'] = message
    mapping['user'] = user
    return template.Substitute(mapping)
Example #2
0
 def __init__(self,
              buffer,
              filename,
              item_template=None,
              first=None,
              last=None,
              range_type=RANGE_ALL,
              **kwargs):
     self.buffer = buffer
     self.first = first
     self.last = last
     self.filename = filename
     if item_template is not None:
         self.item_template = Template(item_template)
     else:
         self.item_template = None
     self.range_type = range_type
     if self.range_type not in (RANGE_ALL, RANGE_ALL_REVERSED,
                                RANGE_CUSTOM):
         raise ValueError(
             "'range_type' is not a valid range type identifier.")
     if self.range_type == RANGE_CUSTOM and (self.first is None
                                             or self.last is None):
         raise ValueError(
             "'first' and 'last' are required for a custom range.")
Example #3
0
 def format_user_info(self, index=None):
     user_ptr = self.get_user_info(index)
     if not user_ptr:
         return
     template = Template(self.session.config['templates']['user_info'])
     mapping = {}
     mapping['name'] = user_ptr['name']
     mapping['screen_name'] = user_ptr['screen_name']
     mapping['location'] = user_ptr['location']
     mapping['url'] = user_ptr['url']
     mapping['bio'] = user_ptr['description']
     mapping['followers_count'] = user_ptr['followers_count']
     mapping['friends_count'] = user_ptr['friends_count']
     mapping['tweets_count'] = user_ptr['statuses_count']
     mapping['when'] = self.relative_time(
         self.standardize_timestamp(user_ptr['created_at']))
     mapping['time'] = self.actual_time(
         self.standardize_timestamp(user_ptr['created_at']))
     mapping['date'] = self.actual_date(
         self.standardize_timestamp(user_ptr['created_at']))
     if user_ptr['utc_offset'] or user_ptr['utc_offset'] == 0:
         mapping['local_time'] = self.user_local_time(
             user_ptr['utc_offset'])
         mapping['local_date'] = self.user_local_date(
             user_ptr['utc_offset'])
     else:
         mapping['local_time'] = "not available"
         mapping['local_date'] = "not available"
     return template.Substitute(mapping)
Example #4
0
 def format_item(self, index=None, item=None, template="spoken"):
     template = Template(self.get_template(template))
     mapping = self.get_item_data(index=index, item=item)
     return template.Substitute(mapping)