some updates (mostly by comparison with opensourcegameclones)

This commit is contained in:
Trilarion
2019-08-19 15:53:57 +02:00
parent 70552f0e0f
commit 3515ffc167
37 changed files with 136 additions and 109 deletions

View File

@ -10,7 +10,7 @@ valid_fields = ('Home', 'Media', 'State', 'Play', 'Download', 'Platform', 'Keywo
'Code license', 'Code dependencies', 'Assets license', 'Build system', 'Build instructions')
valid_platforms = ('Windows', 'Linux', 'macOS', 'Android', 'Browser')
recommended_keywords = ('action', 'arcade', 'adventure', 'visual novel', 'sports', 'platform', 'puzzle', 'role playing', 'simulation', 'strategy', 'card game', 'board game', 'music', 'educational', 'tool', 'game engine', 'framework', 'library')
regex_sanitze_name = re.compile(r"[^A-Za-z -0-9]+")
def entry_iterator(games_path):
"""
@ -32,6 +32,17 @@ def entry_iterator(games_path):
yield entry, entry_path, content
def derive_canonical_file_name(name):
"""
Derives a canonical file name from a game name
"""
name = regex_sanitze_name.sub('', name)
name = name.replace(' ', '_')
name = name.casefold()
name = name + '.md'
return name
def parse_entry(content):
"""
Returns a dictionary of the features of the content
@ -185,6 +196,15 @@ def assemble_infos(games_path):
# add file information
info['file'] = entry
# check canonical file name
canonical_file_name = derive_canonical_file_name(info['name'])
if canonical_file_name != entry:
print('file {} should be {}'.format(entry, canonical_file_name))
source_file = os.path.join(games_path, entry)
target_file = os.path.join(games_path, canonical_file_name)
if not os.path.isfile(target_file):
os.rename(source_file, target_file)
# add to list
infos.append(info)