[game-data-packager] 02/05: read XML game list with a generator
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Thu Jun 30 06:49:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
detiste-guest pushed a commit to branch steam
in repository game-data-packager.
commit 60a83900999251f3f2315c5c5e10a603e539ca06
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Fri Apr 3 15:00:40 2015 +0200
read XML game list with a generator
---
game_data_packager/steam.py | 14 ++++++++++++++
game_data_packager/steam_wip.py | 15 ++-------------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/game_data_packager/steam.py b/game_data_packager/steam.py
index 19ffe43..665be53 100644
--- a/game_data_packager/steam.py
+++ b/game_data_packager/steam.py
@@ -16,6 +16,8 @@
# /usr/share/common-licenses/GPL-2.
import glob
+import xml.etree.ElementTree
+import urllib.request
def parse_acf(path):
for manifest in glob.glob(path + '/*.acf'):
@@ -39,3 +41,15 @@ def parse_acf(path):
if 'name' not in acf_struct:
acf_struct['name'] = acf_struct['installdir']
yield acf_struct
+
+def owned_steam_games(id):
+ url = "http://steamcommunity.com/id/" + id + "/games?xml=1"
+ html = urllib.request.urlopen(url)
+ tree = xml.etree.ElementTree.ElementTree()
+ tree.parse(html)
+ games_xml = tree.getiterator('game')
+ for game in games_xml:
+ appid = int(game.find('appID').text)
+ name = game.find('name').text
+ #print(appid, name)
+ yield {appid, name}
diff --git a/game_data_packager/steam_wip.py b/game_data_packager/steam_wip.py
index 509647d..c1e9f9d 100644
--- a/game_data_packager/steam_wip.py
+++ b/game_data_packager/steam_wip.py
@@ -16,15 +16,11 @@
# /usr/share/common-licenses/GPL-2.
import os
-import glob
import argparse
import logging
-import urllib.request
-import xml.etree.ElementTree
from . import GameData,load_games,rm_rf
-from .paths import DATADIR
-from .steam import parse_acf
+from .steam import parse_acf,owned_steam_games
from .util import is_installed
logging.basicConfig()
@@ -165,15 +161,8 @@ def parse(games,args):
print(record)
def owned(games,args):
- url = "http://steamcommunity.com/id/" + os.environ.get('STEAM_ID', 'sir_dregan') + "/games?xml=1"
- html = urllib.request.urlopen(url)
- tree = xml.etree.ElementTree.ElementTree()
- tree.parse(html)
- games_xml = tree.getiterator('game')
owned = {}
- for game in games_xml:
- appid = int(game.find('appID').text)
- name = game.find('name').text
+ for appid, name in owned_steam_games(os.environ.get('STEAM_ID', 'sir_dregan')):
for supported in games:
if supported['steam_id'] == appid:
owned[appid] = name
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list