for files in /readme, get date, id and title

This commit is contained in:
rolux 2012-04-07 16:42:20 +02:00
parent 1e1bd9689b
commit adbecb75a2

View file

@ -161,7 +161,8 @@ def build_oxjs(downloads=False, geo=False):
'%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S',
time.gmtime(os.path.getmtime(root_path + 'readme/html/' + x)) time.gmtime(os.path.getmtime(root_path + 'readme/html/' + x))
), ),
'name': x.split('.')[0] 'id': x.split('.')[0],
'title': get_title(root_path + 'readme/html/' + x)
}, },
filter( filter(
lambda x: not re.search('^[\._]', x), lambda x: not re.search('^[\._]', x),
@ -207,6 +208,10 @@ def filter_source(tarinfo):
return None return None
return tarinfo return tarinfo
def get_title(file):
match = re.search('<h1>(.+)</h1>', read_file(file))
return match.groups()[0] if match else 'Untitled'
def read_file(file): def read_file(file):
print 'reading', file print 'reading', file
f = open(file) f = open(file)