All Samples(102020) | Call(102020) | Derive(0) | Import(0)
hasattr(object, name) -> bool Return whether the object has an attribute with the given name. (This is done by calling getattr(object, name) and catching exceptions.)
src/p/o/pony-build-HEAD/examples/push-cgi-notifier/feedparser.py pony-build(Download)
def has_key(self, key):
try:
return hasattr(self, key) or UserDict.has_key(self, key)
except AttributeError:
return False
def name2cp(k):
import htmlentitydefs
if hasattr(htmlentitydefs, 'name2codepoint'): # requires Python 2.3
return htmlentitydefs.name2codepoint[k]
k = htmlentitydefs.entitydefs[k]
else:
infourl = urllib.addinfourl(fp, headers, req.get_full_url())
if not hasattr(infourl, 'status'):
infourl.status = code
return infourl
else:
infourl = urllib.addinfourl(fp, headers, req.get_full_url())
if not hasattr(infourl, 'status'):
infourl.status = code
return infourl
"""
if hasattr(url_file_stream_or_string, 'read'):
return url_file_stream_or_string
src/p/y/PyAMF-HEAD/doc/tutorials/examples/actionscript/simple/python/client.py PyAMF(Download)
# the User class attributes are not present at this point
logging.debug("not hasattr(lenards, 'username'): %s" %
(not hasattr(lenards, 'username')))
logging.debug("not hasattr(lenards, 'email'): %s" %
(not hasattr(lenards, 'email')))
logging.debug("not hasattr(lenards, 'password'): %s" %
(not hasattr(lenards, 'password')))
src/p/y/PyAMF-0.6.1/doc/tutorials/examples/actionscript/simple/python/client.py PyAMF(Download)
# the User class attributes are not present at this point
logging.debug("not hasattr(lenards, 'username'): %s" %
(not hasattr(lenards, 'username')))
logging.debug("not hasattr(lenards, 'email'): %s" %
(not hasattr(lenards, 'email')))
logging.debug("not hasattr(lenards, 'password'): %s" %
(not hasattr(lenards, 'password')))
src/d/j/django_slumber-0.7.0/slumber_examples/tests/client.py django_slumber(Download)
def test_applications_local(self):
client = Client('http://localhost:8000/slumber')
self.assertTrue(hasattr(client, 'slumber_examples'))
def test_applications_remote(self):
def test_applications_with_dots_in_name(self):
client = Client()
self.assertTrue(hasattr(client, 'django'), client.__dict__.keys())
self.assertTrue(hasattr(client.django, 'contrib'), client.django.__dict__.keys())
self.assertTrue(hasattr(client.django.contrib, 'sites'),
def test_has_attributes(self):
user = client.django.contrib.auth.User.get(pk=self.user.pk)
for attr in ['is_active', 'is_staff', 'date_joined', 'is_superuser',
'first_name', 'last_name', 'email', 'username']:
self.assertTrue(hasattr(user, attr), user.__dict__.keys())
src/g/d/gdata-2.0.17/samples/apps/marketplace_sample/atom/service.py gdata(Download)
if not server:
if hasattr(service, 'server'):
server = service.server
else:
server = service
if not url.protocol and hasattr(service, 'ssl'):
ssl = service.ssl
if hasattr(service, 'port'):
return
# Check to see if data is a file-like object that has a read method.
elif hasattr(data, 'read'):
# Read the file and send it a chunk at a time.
while 1:
elif ElementTree.iselement(data):
return len(ElementTree.tostring(data))
elif hasattr(data, 'read'):
# If this is a file-like object, don't try to guess the length.
return None
src/p/y/python-enunciate-samples-HEAD/identity.py python-enunciate-samples(Download)
def parse(input):
"""Parse specified file or string and return an Identity object created from it."""
if hasattr(input, "read"):
data = json.load(input)
else:
def to_json_dict(self):
d = {}
if hasattr(self, "statusCode"):
d["statusCode"] = self.statusCode
if hasattr(self, "statusMessage"):
d["statusMessage"] = self.statusMessage
if hasattr(self, "version"):
d["version"] = self.version
if hasattr(self, "properties"):
src/p/y/python-enunciate-samples-HEAD/familytree.py python-enunciate-samples(Download)
def parse(input):
"""Parse specified file or string and return a FamilyTree object created from it."""
if hasattr(input, "read"):
data = json.load(input)
else:
def to_json_dict(self):
d = {}
if hasattr(self, "statusCode"):
d["statusCode"] = self.statusCode
if hasattr(self, "statusMessage"):
d["statusMessage"] = self.statusMessage
if hasattr(self, "version"):
d["version"] = self.version
if hasattr(self, "pedigrees"):
src/d/u/dutils-0.0.10/dutils/sample/path.py dutils(Download)
# Universal newline support
_textmode = 'r'
if hasattr(file, 'newlines'):
_textmode = 'U'
return self.splitext()[0]
if hasattr(os.path, 'splitunc'):
def splitunc(self):
unc, rest = os.path.splitunc(self)
ismount = os.path.ismount
if hasattr(os.path, 'samefile'):
samefile = os.path.samefile
""" Last-modified time of the file. """)
if hasattr(os.path, 'getctime'):
getctime = os.path.getctime
ctime = property(
""" Size of the file, in bytes. """)
if hasattr(os, 'access'):
def access(self, mode):
""" Return true if current user has access to this path.
src/g/d/gdata-2.0.17/samples/apps/marketplace_sample/gdata/test_config.py gdata(Download)
test.assert_(data_class.__doc__ is not None,
'The class %s should have a docstring' % data_class)
if hasattr(data_class, '_qname'):
qname_versions = None
if isinstance(data_class._qname, tuple):
def check_clients_with_auth(test, classes):
for client_class in classes:
test.assert_(hasattr(client_class, 'api_version'))
test.assert_(isinstance(client_class.auth_service, (str, unicode, int)))
test.assert_(hasattr(client_class, 'auth_service'))
test.assert_(isinstance(client_class.auth_service, (str, unicode)))
test.assert_(hasattr(client_class, 'auth_scopes'))
src/b/r/braintree_python_examples-HEAD/tr_checkout_app_engine/web/utils.py braintree_python_examples(Download)
def getvalue(x):
if hasattr(x, 'file') and hasattr(x, 'value'):
return x.value
elif hasattr(x, 'value'):
return unicodify(x.value)
for (key, value) in defaults.iteritems():
result = value
if hasattr(stor, key):
result = stor[key]
if value == () and not isinstance(result, tuple):
iters = [list, tuple]
import __builtin__
if hasattr(__builtin__, 'set'):
iters.append(set)
if hasattr(__builtin__, 'frozenset'):
Previous 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next