本文整理汇总了Python中location.Location.get方法的典型用法代码示例。如果您正苦于以下问题:Python Location.get方法的具体用法?Python Location.get怎么用?Python Location.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类location.Location
的用法示例。
在下文中一共展示了Location.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LocationTest
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
class LocationTest(unittest.TestCase):
def setUp(self):
self.loc = Location(0, 0, 3)
def test_get(self):
l = self.loc.get()
self.assertTrue(l)
def test_get_yx(self):
x = y = self.loc.size - 1
a = self.loc.get(y=y, x=x)
self.assertIsNotNone(a)
def test_search_free_position(self):
x, y = self.loc.search_free_position()
p = self.loc.get(x=x, y=y)
assert p == 0
def test_registred_players(self):
self.loc.register_player("nobus")
self.loc.register_player("bobus")
p = self.loc.get_current_players()
assert len(p) == 2
self.loc.unregister_player("popus")
p = self.loc.get_current_players()
assert len(p) == 2
self.loc.unregister_player("bobus")
p = self.loc.get_current_players()
assert len(p) == 1
示例2: save_product_for_sale
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
def save_product_for_sale(cls, data, user_id):
p = Product()
p.us_id = user_id
p.name = data.get('title', '-')
p.cat_id = data.get('category')
p.subcat_id = data.get('subcategory')
p.subcat2_id = data.get('subcategory2') or None
p.kind = data.get('bargain_type')
p.loc_id = data.get('city')
p.bargain_type = data.get('bargain_type')
p.price = data.get('price')
p.availability = data.get('availability_type')
p.shipping_method = data.get('shipping_type')
p.description = data.get('description')
p.quantity = int(data.get('quantity'))
p.set_end_date(data.get('end_date'))
p.specifics = [int(x) for x in data.get('specifics', [])]
p.quantity_measure = data.get('quantity_measure', 'P')
if p.loc_id:
city = Location.get(p.loc_id)
if city:
p.localisation = "%s, %s, Polska" % (
city.name, city.wojewodztwo.name.lower())
DBSession.add(p)
DBSession.flush()
return p
示例3: save_edited_product_for_sale
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
def save_edited_product_for_sale(self, data):
self.name = data.get('title', '-')
if self.is_product():
self.cat_id = data.get('category')
self.subcat_id = data.get('subcategory')
self.subcat2_id = data.get('subcategory2')
self.loc_id = data.get('city')
self.bargain_type = data.get('bargain_type')
self.price = data.get('price')
self.availability = data.get('availability_type')
self.shipping_method = data.get('shipping_type')
self.quantity = int(data.get('quantity'))
if data.get('end_date'):
self.set_end_date(data.get('end_date'))
if self.loc_id:
city = Location.get(self.loc_id)
if city:
self.localisation = "%s, %s, Polska" % (
city.name, city.wojewodztwo.name.lower())
self.description = data.get('description')
DBSession.flush()
示例4: create
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
def create(cls, us_id, title, description, date_from, date_to,
loc_id, street, start_hour, start_minute, facebook_url):
e = Event()
e.us_id = us_id
e.title = title
e.description = description
e.event_starts = datetime.datetime.strptime(date_from, '%d-%m-%Y')
e.event_ends = date_to and datetime.datetime.strptime(date_to, '%d-%m-%Y') or None
e.loc_id = loc_id
e.facebook_url = facebook_url
e.street = street
e.event_time = '%s:%s' % (start_hour, start_minute)
if e.loc_id:
city = Location.get(e.loc_id)
if city:
e.localisation = "%s, %s, Polska" % (city.name, city.wojewodztwo.name.lower())
DBSession.add(e)
DBSession.flush()
return e
示例5: Port
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
class Port(object):
def __init__(self,ip='',port='',timesearch='',state='',name='',product='',version='',script='',detail='',head='',city='',hackinfo='',disclosure='',keywords=None,webtitle='',webkeywords=''):
'''
Constructor
'''
self.ip=ip
self.port=port
self.version=version
self.state=state
self.name=name
if timesearch!='':
self.timesearch=timesearch
else:
self.timesearch=webtool.getlocaltime()
self.product=product
self.script=script
self.detail=detail
self.head=head
self.city=city
self.hackinfo=hackinfo
self.disclosure=disclosure
self.keywords=keywords
self.webkeywords = webkeywords
self.webtitle = webtitle
if self.keywords is None:
self.keywords=Location(ip=str(self.ip)).getData()
else:
try:
data=eval(keywords)
self.keywords=data
if self.keywords.get('geoip',None) is None:
self.keywords = Location(ip=str(self.ip)).getData()
except Exception,e:
self.keywords = Location(ip=str(self.ip)).getData()
示例6: Ip
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import get [as 别名]
class Ip(object):
def __init__(self,ip='',vendor='',osfamily='',osgen='',accurate='',state='',hostname='unknow',updatetime='',city='',isp='',county='',country='',region='',location=None):
'''
Constructor
'''
self.ip=ip
self.vendor=vendor
self.osgen=osgen
self.osfamily=osfamily
self.accurate=accurate
if updatetime!='':
self.updatetime=updatetime
else:
self.updatetime=webtool.getlocaltime()
self.state=state
self.hostname=hostname
self.city=city
self.isp=isp
self.county=county
self.country=country
self.region=region
self.location = location
if self.location is None:
self.location = Location(ip=str(self.ip)).getData()
else:
try:
data = eval(location)
self.location = data
if self.location.get('geoip', None) is None:
self.location = Location(ip=str(self.ip)).getData()
except Exception, e:
self.location = Location(ip=str(self.ip)).getData()