Show More
@@ -74,6 +74,11 b' username = platform.username' | |||||
74 |
|
74 | |||
75 | # Python compatibility |
|
75 | # Python compatibility | |
76 |
|
76 | |||
|
77 | _notset = object() | |||
|
78 | ||||
|
79 | def safehasattr(thing, attr): | |||
|
80 | return getattr(thing, attr, _notset) is not _notset | |||
|
81 | ||||
77 | def sha1(s=''): |
|
82 | def sha1(s=''): | |
78 | ''' |
|
83 | ''' | |
79 | Low-overhead wrapper around Python's SHA support |
|
84 | Low-overhead wrapper around Python's SHA support | |
@@ -87,10 +92,6 b" def sha1(s=''):" | |||||
87 |
|
92 | |||
88 | return _fastsha1(s) |
|
93 | return _fastsha1(s) | |
89 |
|
94 | |||
90 | _notset = object() |
|
|||
91 | def safehasattr(thing, attr): |
|
|||
92 | return getattr(thing, attr, _notset) is not _notset |
|
|||
93 |
|
||||
94 | def _fastsha1(s=''): |
|
95 | def _fastsha1(s=''): | |
95 | # This function will import sha1 from hashlib or sha (whichever is |
|
96 | # This function will import sha1 from hashlib or sha (whichever is | |
96 | # available) and overwrite itself with it on the first call. |
|
97 | # available) and overwrite itself with it on the first call. |
General Comments 0
You need to be logged in to leave comments.
Login now