Beispiel #1
0
    def attempt_fetch_games(self, filename):
        '''
        Fetches all games in the system. The data is pulled
        from the json files that do not end in _test.json in the test_data directory.
        
        @return: The json response object.
        '''

        return FileAccess.read_game_table(
            lambda file: self._parse_games_file(file), filename)
 def perform_game_update(self, steamid, test_mode=False):
     game_filename = 'game_table_test.json' if test_mode else 'game_table.json'
     game_data = FileAccess.read_game_table(
         lambda game_jsonfile: self._read_data(game_jsonfile),
         game_filename)
     request = GameRequestAPI(steamid, self.api)
     result = request.get_info(test_mode)
     if result != None and str(steamid) in game_data:
         game_data[str(steamid)]['initialprice'] = result['initialprice']
         game_data[str(steamid)]['actualprice'] = result['actualprice']
         game_data[str(steamid)]['onsale'] = result['onsale']
     FileAccess.write_game_table(
         lambda game_data, jsonfile: self._write_data(game_data, jsonfile),
         game_filename, game_data)
Beispiel #3
0
    def __init__(self, steam_id, current_price, initial_price, test_mode):
        '''
        Creates a new EmailFormatter
        @precondition none
        @postcondition self.steam_id == steam_id, self.current_price == current_price,
                       self.initial_price == initial_price, self.steam_game_name == name pulled from game_table with the steam_id.
        '''
        self.steam_id = steam_id
        self.steam_game_name = "game not found"

        game_table = FileAccess.read_game_table(
            lambda jsonfile: self._read_data(jsonfile),
            'game_table_test.json' if test_mode else 'game_table.json')
        self.steam_game_name = game_table[str(steam_id)]['title']

        self.current_price = current_price
        self.initial_price = initial_price