本文整理汇总了Python中models.Location.status方法的典型用法代码示例。如果您正苦于以下问题:Python Location.status方法的具体用法?Python Location.status怎么用?Python Location.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: geocode
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import status [as 别名]
def geocode(rawLocation):
"""
:rtype : Location
"""
url = "https://maps.googleapis.com/maps/api/geocode/json?address=%s" % rawLocation.replace(" ","+")
response = urllib2.urlopen(url)
geocode = json.load(response)
#debug
pprint.pprint(geocode)
location = Location()
location.status = geocode["status"].encode('utf_8').decode('utf_8')
if location.status == "OK":
location.address = geocode["results"][0]["formatted_address"].encode('utf_8').decode('utf_8')
location.latlng = ndb.GeoPt(geocode["results"][0]["geometry"]["location"]["lat"], geocode["results"][0]["geometry"]["location"]["lng"])
else:
location.address = None
location.latlng = None
# Debugs
print "in geocode"
print (location.status.encode('utf_8') if location.status else None)
print type(location.status)
print (location.address.encode('utf_8') if location.address else None)
print type(location.address)
return location
示例2: add_location
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import status [as 别名]
def add_location(data, location_key=""):
if location_key:
location = Location.get_by_id(location_key)
else:
location_id = slugify(data["name"])
temp_location_id = location_id
while True:
count = 1
if Location.get_by_id(temp_location_id):
temp_location_id = location_id + str(count)
count += 1
else:
location = Location(id=temp_location_id)
break
if data["name"]:
location.name = data["name"]
if data["needs"]:
location.needs = data["needs"]
if data["centers"]:
location.centers = data["centers"]
if data["latlong"]:
location.latlong = data["latlong"]
if data["featured_photo"]:
location.featured_photo = data["featured_photo"]
if data["death_count"]:
location.death_count = int(data["death_count"])
if data["death_count_text"]:
location.death_count_text = data["death_count_text"]
if data["affected_count"]:
location.affected_count = int(data["affected_count"])
if data["affected_count_text"]:
location.affected_count_text = data["affected_count_text"]
if data["status_board"]:
location.status_board = data["status_board"]
if data["needs"]:
location.needs = data["needs"]
if data["status"]:
location.status = data["status"]
if data["images"]:
location.images = data["images"]
if data["hash_tag"]:
location.hash_tag = data["hash_tag"]
location.put()
return location