forked from bear/python-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory.py
More file actions
59 lines (45 loc) · 1.42 KB
/
Copy pathcategory.py
File metadata and controls
59 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
class Category(object):
"""A class representing the suggested user category structure used by the twitter API.
The UserStatus structure exposes the following properties:
category.name
category.slug
category.size
"""
def __init__(self, **kwargs):
"""An object to hold a Twitter suggested user category .
This class is normally instantiated by the twitter.Api class and
returned in a sequence.
Args:
name:
name of the category
slug:
size:
"""
param_defaults = {
'name': None,
'slug': None,
'size': None,
}
for (param, default) in param_defaults.iteritems():
setattr(self, param, kwargs.get(param, default))
@property
def Name(self):
return self.name or False
@property
def Slug(self):
return self.slug or False
@property
def Size(self):
return self.size or False
@staticmethod
def NewFromJsonDict(data):
"""Create a new instance based on a JSON dict.
Args:
data: A JSON dict, as converted from the JSON in the twitter API
Returns:
A twitter.Category instance
"""
return Category(name=data.get('name', None),
slug=data.get('slug', None),
size=data.get('size', None))