Exemple #1
0
    def refresh(self):
        '''Refetch instance data from the API.
      '''
        response = requests.get('%s/categories/%s' % (API_BASE_URL, self.name))
        attributes = response.json()

        self.ancestors = [Category(name) for name in attributes['ancestors']]
        self.contents = WikiText(attributes['contents_raw'],
                                 attributes['contents_rendered'])
        self.description = attributes['description']
        self.guides = []
        for guide in attributes['guides']:
            self.guides.append(Guide(guide['guideid']))
        # Unlike guides, categories return flags as a dict, keyed by flagid.
        # *Except* when it's empty, in which case we get an empty list due to
        # PHP's json_encode() not knowing the difference between an empty array
        # and an empty dict.
        flags = dict(attributes['flags']).values()
        self.flags = [Flag.from_id(flag['flagid']) for flag in flags]
        self.image = Image(
            attributes['image']['id']) if attributes['image'] else None
        self.locale = attributes['locale']
        #self.parts = attributes['parts']
        #self.solutions = attributes['solutions']
        self.title = attributes['display_title']
Exemple #2
0
    def refresh(self):
        '''Refetch instance data from the API.
      '''
        response = requests.get('%s/guides/%s' % (API_BASE_URL, self.id))
        attributes = response.json()

        self.category = Category(attributes['category'])
        self.url = attributes['url']

        self.title = attributes['title']
        if attributes['image']:
            self.image = Image(attributes['image']['id'])
        else:
            self.image = None
        self.locale = attributes['locale']
        self.introduction = WikiText(attributes['introduction_raw'],
                                     attributes['introduction_rendered'])
        self.conclusion = WikiText(attributes['conclusion_raw'],
                                   attributes['conclusion_rendered'])
        if (attributes['tools']):
            self.tools = attributes['tools']
        else:
            self.tools = None
        self.parts = attributes['parts']
        self.subject = attributes['subject']
        self.modifiedDate = datetime.utcfromtimestamp(
            attributes['modified_date'])
        self.createdDate = datetime.utcfromtimestamp(
            attributes['created_date'])
        self.publishedDate = datetime.utcfromtimestamp(
            attributes['published_date'])
        #self.documents = attributes['documents']
        author = attributes['author']
        #self.author = User(author['userid'], name=author['text'])
        if (attributes['time_required_min']):
            self.time_required_min = attributes['time_required_min']
        else:
            self.time_required_min = -1
        if (attributes['time_required_max']):
            self.time_required_max = attributes['time_required_max']
        else:
            self.time_required_max = -1
        self.steps = [
            Step(step['guideid'], step['stepid'], data=step)
            for step in attributes['steps']
        ]
        self.type = attributes['type']
        self.public = attributes['public']
        self.revision = attributes['revisionid']
        self.difficulty = attributes['difficulty']
        self.prerequisites = [
            Guide(guide['guideid']) for guide in attributes['prerequisites']
        ]
        #                     attributes['prereq_modified_date']
        #self.summary = attributes['summary']
        self.flags = [
            Flag.from_id(flag['flagid']) for flag in attributes['flags']
        ]
Exemple #3
0
 def refresh(self):
    '''Refetch instance data from the API.
    '''
    response = requests.get('%s/guides/%s' % (API_BASE_URL, self.id))
    attributes = response.json()
    
    self.category = Category(attributes['category'])
    self.url = attributes['url']
    
    self.title = attributes['title']
    if attributes['image']:
       self.image = Image(attributes['image']['id'])
    else:
       self.image = None
    self.locale = attributes['locale']
    self.introduction = WikiText(attributes['introduction_raw'],
                                 attributes['introduction_rendered'])
    self.conclusion = WikiText(attributes['conclusion_raw'],
                               attributes['conclusion_rendered'])
    #self.tools = attributes['tools']
    #self.parts = attributes['parts']
    self.subject = attributes['subject']
    self.modifiedDate = datetime.utcfromtimestamp(attributes['modified_date'])
    self.createdDate = datetime.utcfromtimestamp(attributes['created_date'])
    self.publishedDate = datetime.utcfromtimestamp(attributes['published_date'])
    #self.documents = attributes['documents']
    author = attributes['author']
    #self.author = User(author['userid'], name=author['text'])
    #self.timeRequired = attributes['timeRequired']
    self.steps = [Step(step['guideid'], step['stepid'], data=step) for step in attributes['steps']]
    self.type = attributes['type']
    self.public = attributes['public']
    self.revision = attributes['revisionid']
    self.difficulty = attributes['difficulty']
    self.prerequisites = [Guide(guide['guideid']) for guide in attributes['prerequisites']]
    #                     attributes['prereq_modified_date']
    #self.summary = attributes['summary']
    self.flags = [Flag.from_id(flag['flagid']) for flag in attributes['flags']]
Exemple #4
0
 def refresh(self):
    '''Refetch instance data from the API.
    '''
    response = requests.get('%s/categories/%s' % (API_BASE_URL, self.name))
    attributes = response.json()
    
    self.ancestors = [Category(name) for name in attributes['ancestors']]
    self.contents = WikiText(attributes['contents_raw'],
                             attributes['contents_rendered'])
    self.description = attributes['description']
    self.guides = []
    for guide in attributes['guides']:
       self.guides.append(Guide(guide['guideid']))
    # Unlike guides, categories return flags as a dict, keyed by flagid.
    # *Except* when it's empty, in which case we get an empty list due to
    # PHP's json_encode() not knowing the difference between an empty array
    # and an empty dict.
    flags = dict(attributes['flags']).values()
    self.flags = [Flag.from_id(flag['flagid']) for flag in flags]
    self.image = Image(attributes['image']['id']) if attributes['image'] else None
    self.locale = attributes['locale']
    #self.parts = attributes['parts']
    #self.solutions = attributes['solutions']
    self.title = attributes['display_title']