# Uso: python3 -I credits.py # Lista, a partir dos arquivos .txt que acompanham cada recurso em game_art/, a imagem, a musica e o som que o jogo realmente serve. import os, re, sys tree, dist = sys.argv[1], sys.argv[2] def side(kind, name): base = os.path.splitext(name)[0] for cand in (base + '.txt', name + '.txt'): p = os.path.join(tree, 'game_art', kind, cand) if os.path.exists(p): return open(p, encoding='utf-8', errors='replace').read() return None def field(t, k): m = re.search(r'^' + re.escape(k) + r':[ \t]*(.*)$', t, re.M) return m.group(1).strip() if m else '' out = [] for folder, kind in (('img', 'img'), ('snd', None)): names = sorted(os.listdir(os.path.join(dist, folder))) out.append('--- ' + ('Images (img/)' if folder == 'img' else 'Music and sounds (snd/)')) for n in names: if n in ('char.wav', 'grl.wav'): out.append('%s: short beep generated by beeps.py (published with the game, CC0); the original sound of the author is not in the repository' % n) continue t = None if kind: t = side(kind, n) else: t = side('music', n) or side('sound', n) if t is None: # a musica foi gravada sob outro nome? procura o sidecar pelo nome sem extensao t = side('music', os.path.splitext(n)[0] + '.ogg') or side('sound', os.path.splitext(n)[0] + '.wav') if t is None: out.append('%s: no information file in the repository (covered by the licence of the repository)' % n) continue title, artist, lic, url = field(t, 'title'), field(t, 'artist'), field(t, 'license'), field(t, 'url') coll = field(t, 'collection') line = '%s: ' % n if title: line += '"%s" ' % title if coll: line += '(%s) ' % coll line += 'by %s; licence %s' % (artist or 'unknown', lic or 'not stated') if url: line += '; %s' % url out.append(line) out.append('') print('\n'.join(out))