This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
afe.py
75 lines (61 loc) · 2.32 KB
/
afe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#import window
import config
from config import _
import machine_config as mconf
import os
import xml.etree.ElementTree as ElementTree
import pyglet
print('''
*************************************************
Arrancando Argentron Front End v{app_version}
Creado por Martin Sebastian Wain
Maquina {machine[name]}
Codigo {machine[code]}
Ubicacion {machine[location]}
*************************************************
'''.format(app_version=config.app_version, machine=mconf.machine))
try: os.makedirs(mconf.games_folder)
except: pass
def load_game_info(game_name):
info = {}
#find screenshot
dir = os.path.join(mconf.games_folder, game_name)
for f in os.listdir(dir):
abs_path = os.path.join(dir, f)
if os.path.isfile(abs_path):
splat = os.path.splitext(f)
if splat[0] == config.thumb['filename'] and splat[1] in config.thumb['supported_ext']:
info['thumb'] = os.path.normpath(abs_path)
if not 'thumb' in info:
info['thumb'] = config.thumb['default_path']
# 'name' is the codename/directory name
info['name'] = game_name
# defaults just in case...
info['fullname'] = game_name
for key, value in config.info_defaults.items():
info[key] = value
info_path = os.path.normpath(os.path.join(dir, config.info_filename))
if os.path.exists(info_path) and os.path.isfile(info_path):
try:
xroot = ElementTree.parse(info_path).getroot()
for key in ('fullname', *config.info_defaults.keys()):
tag = xroot.find(key)
if tag is not None:
info[key] = tag.text
for sub in tag:
if sub.tag in config.allowed_html_tags:
info[key] += str(ElementTree.tostring(sub))
else:
info[key] += '' or sub.tail
except:
print(_('Error cargando "{path}"').format(path=info_path))
return info
game_infos = []
dirs = [item for item in os.listdir(mconf.games_folder) if os.path.isdir(os.path.join(mconf.games_folder, item))]
for game_name in sorted(dirs):
print("Game found:"+game_name)
game_infos.append(load_game_info(game_name))
import gui
gui.game_infos = game_infos
gui.refresh()
pyglet.app.run()