本文整理汇总了Python中models.district.District.query方法的典型用法代码示例。如果您正苦于以下问题:Python District.query方法的具体用法?Python District.query怎么用?Python District.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.district.District
的用法示例。
在下文中一共展示了District.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getShortName
# 需要导入模块: from models.district import District [as 别名]
# 或者: from models.district.District import query [as 别名]
def getShortName(self, name_str, district_code=None):
"""
Extracts a short name like "Silicon Valley" from an event name like
"Silicon Valley Regional sponsored by Google.org".
See https://github.com/the-blue-alliance/the-blue-alliance-android/blob/master/android/src/test/java/com/thebluealliance/androidclient/test/helpers/EventHelperTest.java
"""
district_keys = memcache.get('EventHelper.getShortName():district_keys')
if not district_keys:
codes = set([d.id()[4:].upper() for d in District.query().fetch(keys_only=True)])
if district_code:
codes.add(district_code.upper())
if 'MAR' in codes: # MAR renamed to FMA in 2019
codes.add('FMA')
if 'TX' in codes: # TX and FIT used interchangeably
codes.add('FIT')
district_keys = '|'.join(codes)
memcache.set('EventHelper.getShortName():district_keys', district_keys, 60*60)
# 2015+ districts
# Numbered events with no name
re_string = '({}) District Event (#\d+)'.format(district_keys)
match = re.match(re_string, name_str)
if match:
return '{} {}'.format(match.group(1).strip(), match.group(2).strip())
# The rest
re_string = '(?:{}) District -?(.+)'.format(district_keys)
match = re.match(re_string, name_str)
if match:
partial = match.group(1).strip()
match2 = re.sub(r'(?<=[\w\s])Event\s*(?:[\w\s]*$)?', '', partial)
return match2.strip()
# 2014- districts
# district championships, other districts, and regionals
name_str = re.sub(r'\s?Event','', name_str)
match = re.match(r'\s*(?:MAR |PNW |)(?:FIRST Robotics|FRC|)(.+)(?:District|Regional|Region|Provincial|State|Tournament|FRC|Field)(?:\b)(?:[\w\s]+?(#\d*)*)?', name_str)
if match:
short = ''.join(match.groups(''))
match = re.match(r'(.+)(?:FIRST Robotics|FRC)', short)
if match:
result = match.group(1).strip()
else:
result = short.strip()
if result.startswith('FIRST'):
result = result[5:]
return result.strip()
return name_str.strip()
示例2: get_districts_async
# 需要导入模块: from models.district import District [as 别名]
# 或者: from models.district.District import query [as 别名]
def get_districts_async():
district_keys = yield District.query().order(-District.year).fetch_async(keys_only=True)
districts = yield ndb.get_multi_async(district_keys)
raise ndb.Return(districts)
示例3: _query_async
# 需要导入模块: from models.district import District [as 别名]
# 或者: from models.district.District import query [as 别名]
def _query_async(self):
abbreviation = self._query_args[0]
district_keys = yield District.query(District.abbreviation.IN(get_equivalent_codes(abbreviation))).fetch_async(keys_only=True)
districts = yield ndb.get_multi_async(district_keys)
raise ndb.Return(districts)