forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnull.py
More file actions
55 lines (37 loc) · 1.03 KB
/
null.py
File metadata and controls
55 lines (37 loc) · 1.03 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
# -*- coding: utf-8 -*-
from requests.compat import is_py3
class NullObject(object):
def __init__(self, initializer=None):
self.__dict__['initializer'] = initializer
def __int__(self):
return 0
def __bool__(self):
return False
__nonzero__ = __bool__
def __str__(self):
return ''
def __unicode__(self):
return '' if is_py3 else ''.decode()
def __repr__(self):
return '<NullObject({0})>'.format(
repr(self.__getattribute__('initializer'))
)
def __getitem__(self, index):
return self
def __setitem__(self, index, value):
pass
def __getattr__(self, attr):
return self
def __setattr__(self, attr, value):
pass
def __call__(self, *args, **kwargs):
return self
def __contains__(self, other):
return False
def __iter__(self):
return iter([])
def __next__(self):
raise StopIteration
next = __next__
def is_null(self):
return True