\r
log = logging.getLogger(__name__)\r
\r
+def has_required_metadata(metadata):\r
+ """\r
+ Determines if a give set of metadata has enough data to create a game,\r
+ server, and map with.\r
+ """\r
+ flg_has_req_metadata = True\r
+\r
+ if 'T' not in game_meta or\\r
+ 'G' not in game_meta or\\r
+ 'M' not in game_meta or\\r
+ 'S' not in game_meta:\r
+ flg_has_req_metadata = False\r
+\r
+ return flg_has_req_metadata\r
+\r
+ \r
def is_real_player(events):\r
"""\r
Determines if a given set of player events correspond with a player who\r
\r
(game_meta, players) = parse_body(request) \r
\r
- # verify required metadata is present\r
- if 'T' not in game_meta or\\r
- 'G' not in game_meta or\\r
- 'M' not in game_meta or\\r
- 'S' not in game_meta:\r
+ if not has_required_metadata(game_meta):\r
log.debug("Required game meta fields (T, G, M, or S) missing. "\\r
"Can't continue.")\r
raise Exception("Required game meta fields (T, G, M, or S) missing.")\r
server = get_or_create_server(session=session, name=game_meta['S'])\r
gmap = get_or_create_map(session=session, name=game_meta['M'])\r
\r
- if 'W' in game_meta:\r
- winner = game_meta['W']\r
- else:\r
- winner = None\r
-\r
game = create_game(session=session, \r
start_dt=datetime.datetime(\r
*time.gmtime(float(game_meta['T']))[:6]), \r