Adding description handling in profiles.

This commit is contained in:
Anton Hvornum 2020-08-04 14:50:36 +02:00
parent 0b8a3d9540
commit b2a8fd9857
1 changed files with 7 additions and 1 deletions

View File

@ -20,7 +20,13 @@ def list_profiles(base='./profiles/'):
for root, folders, files in os.walk(base):
for file in files:
if os.path.splitext(file)[1] == '.py':
cache[file] = os.path.join(root, file)
description = ''
with open(os.path.join(root, file), 'r') as fh:
first_line = fh.readline()
if first_line[0] == '#':
description = first_line.strip()
cache[file] = {'path' : os.path.join(root, file), 'description' : ''}
break
return cache