# encoding=utf-8 # # Copyright © 2014 Simon McVittie <*****@*****.**> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You can find the GPL license text on a Debian system under # /usr/share/common-licenses/GPL-2. import os import yaml from game_data_packager import load_games from game_data_packager.util import ascii_safe if __name__ == '__main__': for name, game in load_games().items(): game.load_file_data() ascii_safe(game.longname, force=True).encode('ascii') ascii_safe(game.help_text, force=True).encode('ascii') if 'DEBUG' in os.environ or 'GDP_DEBUG' in os.environ: print('# %s -----------------------------------------' % name) print(yaml.safe_dump(game.to_data()))
from game_data_packager.build import (choose_mirror) from game_data_packager.command_line import (TerminalProgress) from game_data_packager.data import (HashedFile) from game_data_packager.util import (AGENT) archives = [] os.environ.pop('GDP_MIRROR', None) parser = argparse.ArgumentParser() parser.add_argument('--destination', default='/var/www/html') args = parser.parse_args() print('loading game definitions...') for gamename, game in load_games().items(): game.load_file_data() for filename, file in game.files.items(): if file.unsuitable: # quake2-rogue-2.00.tar.xz could have been tagged this way archive = os.path.join(args.destination, filename) if os.path.isfile(archive): print('Obsolete archive: %s (%s)' % (archive, file.unsuitable)) elif filename == 'tnt31fix.zip?repack': continue elif file.download: url = choose_mirror(file)[0] if '?' not in url: destname = os.path.basename(url) elif '?' not in filename: destname = filename
# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You can find the GPL license text on a Debian system under # /usr/share/common-licenses/GPL-2. import json import urllib.request from game_data_packager import load_games from game_data_packager.util import AGENT url = 'https://github.com/SteamDatabase/SteamLinux/raw/master/GAMES.json' response = urllib.request.urlopen(urllib.request.Request(url, headers={'User-Agent': AGENT})) native = json.loads(response.read().decode('utf8')) native = set(int(id) for id in native.keys()) for shortname, game in load_games().items(): for package in game.packages.values(): steam = package.steam or game.steam if not steam: continue if steam.get('native') and steam.get('id') in native: print('correctly tagged as native: %s' % package.name) elif steam.get('native'): print('extraneously tagged as native: %s' % package.name) elif steam.get('id') in native: print('should be tagged as native: %s' % package.name)
except IndexError: todo = '*' urls = dict() with open(CSV, 'r', encoding='utf8') as f: for line in f.readlines(): line = line.strip() if not line: continue shortname, url = line.split(';', 1) urls[shortname] = url def is_wikipedia(href): return href and "wikipedia" in href for shortname, game in load_games(game=todo).items(): if not game.wiki: continue if shortname in urls: continue print('processing %s ...' % shortname) url = game.wikibase + game.wiki html = urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent': AGENT})) soup = BeautifulSoup(html, 'lxml') for tag in soup.find_all(href=is_wikipedia): print(' ' + tag['href']) urls[shortname] = tag['href'] #break time.sleep(1)
if __name__ == '__main__': games = '*' if len(sys.argv) > 1: assert len(sys.argv) == 2 games = sys.argv[1] if os.path.exists('ref.zip'): t = time.process_time() # usage: # make # cp out/vfs.zip ref.zip # make # make check from_ref = load_games(games, use_vfs='ref.zip') dt = time.process_time() - t print('# loaded game data from ref.zip in %.3f seconds' % dt) else: from_ref = None t = time.process_time() from_vfs = load_games(games, use_vfs=True) dt = time.process_time() - t print('# loaded game data from vfs.zip in %.3f seconds' % dt) t = time.process_time() from_json = load_games(games, use_vfs=False) dt = time.process_time() - t print('# loaded game data from JSON in %.3f seconds' % dt)
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You can find the GPL license text on a Debian system under # /usr/share/common-licenses/GPL-2. import json import urllib.request from game_data_packager import load_games from game_data_packager.util import AGENT url = 'https://github.com/SteamDatabase/SteamLinux/raw/master/GAMES.json' response = urllib.request.urlopen( urllib.request.Request(url, headers={'User-Agent': AGENT})) native = json.loads(response.read().decode('utf8')) native = set(int(id) for id in native.keys()) for shortname, game in load_games().items(): for package in game.packages.values(): steam = package.steam or game.steam if not steam: continue if steam.get('native') and steam.get('id') in native: print('correctly tagged as native: %s' % package.name) elif steam.get('native'): print('extraneously tagged as native: %s' % package.name) elif steam.get('id') in native: print('should be tagged as native: %s' % package.name)