forked from opengaming/osgameclones
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_ext.py
30 lines (23 loc) · 826 Bytes
/
_ext.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
import os.path as op
from datetime import date, timedelta
import yaml
from cyrax import events
def names(item):
return item.get('names') or [item['name']]
def mark_new(item):
if 'added' in item:
item['new'] = (date.today() - item['added']) < timedelta(days=30)
return item
def parse_data(site):
data = yaml.load(file(op.join(op.dirname(__file__), 'games.yaml')))
site.clones = []
site.reimplementations = []
for item in data:
if 'clones' in item:
site.clones.append(
(names(item), map(mark_new, item['clones'])))
if 'reimplementations' in item:
site.reimplementations.append(
(names(item), map(mark_new, item['reimplementations'])))
def callback(site):
events.events.connect('traverse-started', parse_data)