Пример #1
0
    def parse(cls, api, json):
        idea = cls(api)
        setattr(idea, '_json', json)

        for k, v in json.items():
            if k == 'authorInfo':
                author_model = getattr(api.parser.model_factory,
                                       'author') if api else Author
                author = author_model.parse(api, v)
                setattr(idea, k, author)
            elif k == 'creationDateTime':
                setattr(idea, k, parse_datetime(v))
            elif k == 'editedAt':
                setattr(idea, k, parse_datetime(v))
            elif k == 'statusChangeDate':
                setattr(idea, k, parse_datetime(v))
            elif k == 'tags':
                tags = []
                for tag in v:
                    tags.append(tag)
                setattr(idea, k, tags)
            else:
                setattr(idea, k, v)

        return idea
Пример #2
0
    def parse(cls, api, json):
        vote = cls(api)
        setattr(vote, '_json', json)

        for k, v in json.items():
            if k == 'creationDateTime' or k == 'creationDate':
                setattr(vote, k, parse_datetime(v))
            else:
                setattr(vote, k, v)

        return vote
Пример #3
0
    def parse(cls, api, json):
        vote = cls(api)
        setattr(vote, '_json', json)

        for k, v in json.items():
            if k == 'creationDate':
                setattr(vote, k, parse_datetime(v))
            else:
                setattr(vote, k, v)

        return vote
Пример #4
0
    def parse(cls, api, json):
        idea = cls(api)
        setattr(idea, '_json', json)

        for k, v in json.items():
            if k == 'authorInfo':
                author_model = getattr(api.parser.model_factory, 'author') if api else Author
                author = author_model.parse(api, v)
                setattr(idea, k, author)
            elif k == 'creationDateTime':
                setattr(idea, k, parse_datetime(v))
            elif k == 'editedAt':
                setattr(idea, k, parse_datetime(v))
            elif k == 'statusChangeDate':
                setattr(idea, k, parse_datetime(v))
            elif k == 'tags':
                tags = []
                for tag in v:
                    tags.append(tag)
                setattr(idea, k, tags)
            else:
                setattr(idea, k, v)

        return idea