Compare commits

..

No commits in common. "79bec88cfd08126efa84d6610a5c117f744810db" and "5f68547a6ae6e3bca34a78dd35c1ef64b087157e" have entirely different histories.

2 changed files with 167 additions and 182 deletions

309
build.py
View File

@ -3,11 +3,8 @@
import yaml import yaml
from os.path import dirname from os.path import dirname
# BASE = dirname('/home/hendrik/git/list-of-game/src/build.py')
BASE = dirname(__file__) + '/src' BASE = dirname(__file__) + '/src'
TITLE_LEFT = "List of Shame"
TITLE_RIGHT = "List of Pride"
MAX_WIDTH = 64 MAX_WIDTH = 64
MAX_WIDTH_TITLE = 40 MAX_WIDTH_TITLE = 40
MAX_WIDTH_PLATFORM = 4 MAX_WIDTH_PLATFORM = 4
@ -18,202 +15,190 @@ DELIMITER = "| :|"
# split strings longer than length into a list # split strings longer than length into a list
# strings are split at last index of delim # strings are split at last index of delim
def split_to_list(str, length, delim=' '): def split_to_list(str, length, delim=' '):
l = [] l = []
while len(str) > length: while len(str) > length:
sep = str.rfind(delim, 0, length) sep = str.rfind(delim, 0, length)
l.append(str[0:sep]) l.append(str[0:sep])
str = str[sep+1:] str = str[sep+1:]
l.append(str)
l.append(str) return l
return l
# build_header using section title # build_header using section title
def build_header(l_title, add_index=False, index_string=None): def build_header(l_title):
header = [] header = []
len_title = len(l_title[0]) len_title = len(l_title[0])
pad, pad_left = divmod(MAX_WIDTH - (len_title + (TITLE_PADDING * 2)) - 2, 2) pad, pad_left = divmod(MAX_WIDTH - (len_title + (TITLE_PADDING * 2)) - 2, 2)
len_border = len_title + ((TITLE_PADDING * 2) - 2) len_border = len_title + ((TITLE_PADDING * 2) - 2)
# upper part
header.append(' ' * (pad + pad_left + 2) + '_' * len_border + ' ' * (pad + 2))
header.append('_' * (pad + pad_left) + '//' + ' ' * len_border + '\\\\' + '_' * pad)
# ' ' padded Title
count = 1
for title in l_title:
c_pad = '_' if count == len(l_title) else ' '
pad_right = len_title - len(title)
header.append(c_pad * (pad + pad_left) + '|' + ' ' * TITLE_PADDING + title + ' ' * (TITLE_PADDING + pad_right) + '|' + c_pad * pad)
count += 1
# lower part
header.append(' ' * (pad + pad_left) + '\\\\' + '_' * len_border + '//' + ' ' * pad)
header.append(' ' * MAX_WIDTH)
# upper part return header
header.append(' ' * (pad + pad_left + 2) + '_' * len_border + ' ' * (pad + 2))
header.append('_' * (pad + pad_left) + '//' + ' ' * len_border + '\\\\' + '_' * pad)
# ' ' padded Title
count = 1
for title in l_title:
c_pad = '_' if count == len(l_title) else ' '
pad_right = len_title - len(title)
header.append(c_pad * (pad + pad_left) + '|' + ' ' * TITLE_PADDING + title + ' ' * (TITLE_PADDING + pad_right) + '|' + c_pad * pad)
count += 1
# lower part
# optional navigation tag
if add_index == True and index_string != None:
header.append(' ' * (pad + pad_left) + '\\\\' + '_' * len_border + '//' + ' ' * (pad - 7) + f'[{index_string}] ')
else:
header.append(' ' * (pad + pad_left) + '\\\\' + '_' * len_border + '//' + ' ' * pad)
header.append(' ' * MAX_WIDTH)
return header
def index_string(prefix, index):
return f'{prefix}{index:>03d}'
def build_index(yaml, prefix): def build_index(yaml, prefix):
l_title = [] l_title = []
for item in yaml: for item in yaml:
l_title += [item['title']] l_title += [item['title']]
l_index = [] l_index = []
for i, item in enumerate(l_title): for i, item in enumerate(l_title):
l_index += [' - ' + item.ljust(MAX_WIDTH - 10) + f'[{index_string(prefix, i+1)}] '] l_index += [' - ' + item.ljust(MAX_WIDTH - 10) + f'[{prefix}{i+1}00] ']
l_index += [' ' * MAX_WIDTH] l_index += [' ' * MAX_WIDTH]
return l_index return l_index
def build_game(name, platform): def build_game(name, platform):
s_platform = platform.ljust(MAX_WIDTH_PLATFORM) s_platform = platform.ljust(MAX_WIDTH_PLATFORM)
s_name = name.ljust(MAX_WIDTH_NAME) s_name = name.ljust(MAX_WIDTH_NAME)
return f' {s_platform} | {s_name} ' return f' {s_platform} | {s_name} '
# #
# main # main
# #
def main(): def main():
print('go') print('go')
with open(f'{BASE}/todo.yaml', 'r') as file: with open(f'{BASE}/todo.yaml', 'r') as file:
todo_yaml = yaml.safe_load(file) todo_yaml = yaml.safe_load(file)
with open(f'{BASE}/finished.yaml', 'r') as file: with open(f'{BASE}/finished.yaml', 'r') as file:
finished_yaml = yaml.safe_load(file) finished_yaml = yaml.safe_load(file)
# #
# Section: TO-DO # Section: TO-DO
# #
todo_result = []
todo_result = [] todo_result += build_header(['List of Shame'])
todo_result += build_header([TITLE_LEFT]) todo_result += build_index(todo_yaml, 'S')
todo_result += build_index(todo_yaml, 'S') for section in todo_yaml:
s_title = section['title']
l_title = []
item_count = 0 if len(s_title) > MAX_WIDTH_TITLE:
for section in todo_yaml: l_title = split_to_list(s_title, MAX_WIDTH_TITLE)
s_title = section['title'] else:
l_title = [] l_title = [s_title]
# Create section header
todo_result += build_header(l_title)
# Create table header
todo_result += [' ______ ________________________________________________________',
'|======|========================================================']
if len(s_title) > MAX_WIDTH_TITLE: # Add games one by one
l_title = split_to_list(s_title, MAX_WIDTH_TITLE) # Prefix : |
else: for game in section['games']:
l_title = [s_title] s_name = game['name']
s_platform = game['platform']
# Create section header if len(s_platform) > MAX_WIDTH_PLATFORM:
item_count += 1 raise Exception(f"Platform shortcode for {s_name} is longer than 4 characters. Cannot parse...")
todo_result += build_header(l_title, add_index=True, index_string=index_string('S', item_count))
if len(s_name) > MAX_WIDTH_NAME:
l_name = split_to_list(s_name, MAX_WIDTH_NAME)
for i,i_name in enumerate(l_name):
todo_result += ['|' + build_game(i_name, s_platform if i == 0 else '')]
else:
todo_result += ['|' + build_game(s_name, s_platform)]
# Create table header # Close table header
todo_result += [' ______ ________________________________________________________', todo_result += ['|______|________________________________________________________',
'|======|========================================================'] ' ' * MAX_WIDTH]
#
# Section: Finished
#
# Add games one by one finished_result = []
# Prefix : |
for game in section['games']:
s_name = game['name']
s_platform = game['platform']
if len(s_platform) > MAX_WIDTH_PLATFORM: finished_result += build_header(['List of Pride'])
raise Exception(f"Platform shortcode for {s_name} is longer than 4 characters. Cannot parse...")
if len(s_name) > MAX_WIDTH_NAME: finished_result += build_index(finished_yaml, 'P')
l_name = split_to_list(s_name, MAX_WIDTH_NAME)
for i,i_name in enumerate(l_name):
todo_result += ['|' + build_game(i_name, s_platform if i == 0 else '')]
else:
todo_result += ['|' + build_game(s_name, s_platform)]
# Close table header for section in finished_yaml:
todo_result += ['|______|________________________________________________________', s_title = section['title']
' ' * MAX_WIDTH] l_title = []
# if len(s_title) > MAX_WIDTH_TITLE:
# Section: Finished l_title = split_to_list(s_title, MAX_WIDTH_TITLE)
# else:
l_title = [s_title]
# Create section header
finished_result += build_header(l_title)
# Create table header
finished_result += ['______ ________________________________________________________ ',
'======|========================================================|']
finished_result = [] # Add games one by one
# Suffix : |
for game in section['games']:
s_name = game['name']
s_platform = game['platform']
finished_result += build_header([TITLE_RIGHT]) if len(s_platform) > MAX_WIDTH_PLATFORM:
raise Exception(f"Platform shortcode for {s_name} is longer than 4 characters. Cannot parse...")
if len(s_name) > MAX_WIDTH_NAME:
l_name = split_to_list(s_name, MAX_WIDTH_NAME)
for i,i_name in enumerate(l_name):
finished_result += [build_game(i_name, platform if i == 0 else '') + '|']
else:
finished_result += [build_game(s_name, s_platform) + '|']
finished_result += build_index(finished_yaml, 'P') # Close table header
finished_result += ['______|________________________________________________________|',
' ' * MAX_WIDTH]
item_count = 0 # adjust length of both sides
for section in finished_yaml: len_difference = len(todo_result) - len(finished_result)
s_title = section['title'] # todo > finished
l_title = [] if len_difference > 0:
finished_result += [' ' * MAX_WIDTH] * len_difference
# todo < finished
elif len_difference < 0:
len_difference *= -1
todo_result += [' ' * MAX_WIDTH] * len_difference
if len(s_title) > MAX_WIDTH_TITLE: if len(todo_result) != len(finished_result):
l_title = split_to_list(s_title, MAX_WIDTH_TITLE) raise Exception("Results are not of equal size. Something went wrong...")
else:
l_title = [s_title] result = []
i = 0
while len(todo_result) > i:
result += [todo_result[i] + DELIMITER + finished_result[i]]
i += 1
with open('list-of-game.txt', 'w') as file:
for i in result:
file.write(f"{i}\n")
# Create section header print('done')
item_count += 1
finished_result += build_header(l_title, add_index=True, index_string=index_string('P', item_count)) return
# Create table header
finished_result += ['______ ________________________________________________________ ',
'======|========================================================|']
# Add games one by one
# Suffix : |
for game in section['games']:
s_name = game['name']
s_platform = game['platform']
if len(s_platform) > MAX_WIDTH_PLATFORM:
raise Exception(f"Platform shortcode for {s_name} is longer than 4 characters. Cannot parse...")
if len(s_name) > MAX_WIDTH_NAME:
l_name = split_to_list(s_name, MAX_WIDTH_NAME)
for i,i_name in enumerate(l_name):
finished_result += [build_game(i_name, platform if i == 0 else '') + '|']
else:
finished_result += [build_game(s_name, s_platform) + '|']
# Close table header
finished_result += ['______|________________________________________________________|',
' ' * MAX_WIDTH]
# adjust length of both sides
len_difference = len(todo_result) - len(finished_result)
# todo > finished
if len_difference > 0:
finished_result += [' ' * MAX_WIDTH] * len_difference
# todo < finished
elif len_difference < 0:
len_difference *= -1
todo_result += [' ' * MAX_WIDTH] * len_difference
if len(todo_result) != len(finished_result):
raise Exception("Results are not of equal size. Something went wrong...")
result = []
i = 0
while len(todo_result) > i:
result += [todo_result[i] + DELIMITER + finished_result[i]]
i += 1
with open('list-of-game.txt', 'w') as file:
for i in result:
file.write(f"{i}\n")
print('done')
return
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -3,18 +3,18 @@ __________________// \\_________________| :|__________
__________________| List of Shame |_________________| :|__________________| List of Pride |_________________ __________________| List of Shame |_________________| :|__________________| List of Pride |_________________
\\_________________________// | :| \\_________________________// \\_________________________// | :| \\_________________________//
| :| | :|
- Currently Playing [S001] | :| - Early Days [P001] - Currently Playing [S100] | :| - Early Days [P100]
- Upcoming [S002] | :| - First PC [P002] - Upcoming [S200] | :| - First PC [P200]
- Soon(TM) 2022 [S003] | :| - The Multiplayer Phase [P003] - Soon(TM) 2022 [S300] | :| - The Multiplayer Phase [P300]
- Unknown Future [S004] | :| - 2020 [P004] - Unknown Future [S400] | :| - 2020 [P400]
- Haunts my Dreams [S005] | :| - 2021 [P005] - Haunts my Dreams [S500] | :| - 2021 [P500]
- Not Yet Owned (Wishlist) [S006] | :| - 2022 [P006] - Not Yet Owned (Wishlist) [S600] | :| - 2022 [P600]
| :| - 2023 [P007] | :| - 2023 [P700]
_____________________________ | :| _____________________________ | :|
________________// \\_______________| :| ______________________ ________________// \\_______________| :| ______________________
________________| Currently Playing |_______________| :|___________________// \\___________________ ________________| Currently Playing |_______________| :|___________________// \\___________________
\\_____________________________// [S001] | :|___________________| Early Days |___________________ \\_____________________________// | :|___________________| Early Days |___________________
| :| \\______________________// [P001] | :| \\______________________//
______ ________________________________________________________| :| ______ ________________________________________________________| :|
|======|========================================================| :|______ ________________________________________________________ |======|========================================================| :|______ ________________________________________________________
| PC | Kingdom Two Crowns | :|======|========================================================| | PC | Kingdom Two Crowns | :|======|========================================================|
@ -23,7 +23,7 @@ ________________| Currently Playing |_______________| :|__________
____________________ | :| GBA | Pokemon Sapphire | ____________________ | :| GBA | Pokemon Sapphire |
____________________// \\____________________| :| GBC | Pokemon Trading Card Game | ____________________// \\____________________| :| GBC | Pokemon Trading Card Game |
____________________| Upcoming |____________________| :| GBC | Pokemon Crystal | ____________________| Upcoming |____________________| :| GBC | Pokemon Crystal |
\\____________________// [S002] | :| PC | Colin McRae Rally 2.0 | \\____________________// | :| PC | Colin McRae Rally 2.0 |
| :| PC | Anno 1602 | | :| PC | Anno 1602 |
______ ________________________________________________________| :| GBA | Pokemon Emerald | ______ ________________________________________________________| :| GBA | Pokemon Emerald |
|======|========================================================| :| PC | Need for Speed: Underground | |======|========================================================| :| PC | Need for Speed: Underground |
@ -38,7 +38,7 @@ ____________________| Upcoming |____________________| :| GBC | Po
_________________________ | :| NDS | Final Fantasy III | _________________________ | :| NDS | Final Fantasy III |
__________________// \\_________________| :| GBA | Final Fantasy I & II: Dawn of Souls | __________________// \\_________________| :| GBA | Final Fantasy I & II: Dawn of Souls |
__________________| Soon(TM) 2022 |_________________| :| NDS | Final Fantasy IV | __________________| Soon(TM) 2022 |_________________| :| NDS | Final Fantasy IV |
\\_________________________// [S003] | :| GBA | Final Fantasy V Advance | \\_________________________// | :| GBA | Final Fantasy V Advance |
| :| GBA | Final Fantasy VI Advance | | :| GBA | Final Fantasy VI Advance |
______ ________________________________________________________| :| PSP | Lego Star Wars | ______ ________________________________________________________| :| PSP | Lego Star Wars |
|======|========================================================| :| PSP | Lego Star Wars II | |======|========================================================| :| PSP | Lego Star Wars II |
@ -54,7 +54,7 @@ __________________| Soon(TM) 2022 |_________________| :| NDS | Fi
__________________________ | :| GBA | The Legend of Zelda: Minish Cap | __________________________ | :| GBA | The Legend of Zelda: Minish Cap |
_________________// \\_________________| :| PC | Moorhuhn 3: ...Es Gibt Huhn! | _________________// \\_________________| :| PC | Moorhuhn 3: ...Es Gibt Huhn! |
_________________| Unknown Future |_________________| :| GBA | Pokemon Pinball: Ruby & Sapphire | _________________| Unknown Future |_________________| :| GBA | Pokemon Pinball: Ruby & Sapphire |
\\__________________________// [S004] | :| NDS | Mario Kart DS | \\__________________________// | :| NDS | Mario Kart DS |
| :| GBA | Pokemon Leaf Green | | :| GBA | Pokemon Leaf Green |
______ ________________________________________________________| :| GBA | Pokemon Mystery Dungeon: Red Rescue Team | ______ ________________________________________________________| :| GBA | Pokemon Mystery Dungeon: Red Rescue Team |
|======|========================================================| :| PC | Shrek 2 | |======|========================================================| :| PC | Shrek 2 |
@ -87,7 +87,7 @@ _________________| Unknown Future |_________________| :| GBA | Po
____________________________ | :| NDS | Professor Layton and the Curious Village | ____________________________ | :| NDS | Professor Layton and the Curious Village |
________________// \\________________| :| NDS | Professor Layton and the Diabolical Box | ________________// \\________________| :| NDS | Professor Layton and the Diabolical Box |
________________| Haunts my Dreams |________________| :| PC | Tachyon: The Fringe | ________________| Haunts my Dreams |________________| :| PC | Tachyon: The Fringe |
\\____________________________// [S005] | :| NDS | The Simpsons | \\____________________________// | :| NDS | The Simpsons |
| :| NDS | Spectrobes | | :| NDS | Spectrobes |
______ ________________________________________________________| :| PC | Trackmania Original | ______ ________________________________________________________| :| PC | Trackmania Original |
|======|========================================================| :| GBA | Wario Ware | |======|========================================================| :| GBA | Wario Ware |
@ -99,7 +99,7 @@ ________________| Haunts my Dreams |________________| :| PC | Ta
| PC | The Secret of Monkey Island | :| ____________________ | PC | The Secret of Monkey Island | :| ____________________
| PC | Monkey Island 2 | :|____________________// \\____________________ | PC | Monkey Island 2 | :|____________________// \\____________________
| GBA | Fire Emblem | :|____________________| First PC |____________________ | GBA | Fire Emblem | :|____________________| First PC |____________________
| PC | Deus Ex: Game of the Year | :| \\____________________// [P002] | PC | Deus Ex: Game of the Year | :| \\____________________//
| PS2 | Metal Gear Solid 2: Sons of Liberty | :| | PS2 | Metal Gear Solid 2: Sons of Liberty | :|
| PC | Bravery Network Online | :|______ ________________________________________________________ | PC | Bravery Network Online | :|______ ________________________________________________________
| NES | Ninja Gaiden | :|======|========================================================| | NES | Ninja Gaiden | :|======|========================================================|
@ -126,7 +126,7 @@ ________________| Haunts my Dreams |________________| :| PC | Ta
| PC | Final Fantasy IX | :| _________________________________ | PC | Final Fantasy IX | :| _________________________________
| PC | Final Fantasy X | :|______________// \\_____________ | PC | Final Fantasy X | :|______________// \\_____________
| PC | Final Fantasy XII | :|______________| The Multiplayer Phase |_____________ | PC | Final Fantasy XII | :|______________| The Multiplayer Phase |_____________
| PS3 | Final Fantasy XIII | :| \\_________________________________// [P003] | PS3 | Final Fantasy XIII | :| \\_________________________________//
| PC | Lightning Returns: Final Fantasy XIII | :| | PC | Lightning Returns: Final Fantasy XIII | :|
| PC | Bastion | :|______ ________________________________________________________ | PC | Bastion | :|______ ________________________________________________________
| PC | Crashlands | :|======|========================================================| | PC | Crashlands | :|======|========================================================|
@ -141,7 +141,7 @@ ________________| Haunts my Dreams |________________| :| PC | Ta
____________________________________ | :| PC | The Beginner's Guide | ____________________________________ | :| PC | The Beginner's Guide |
____________// \\____________| :| PC | Stanley's Parable | ____________// \\____________| :| PC | Stanley's Parable |
____________| Not Yet Owned (Wishlist) |____________| :| PC | What Remains of Edith Finch | ____________| Not Yet Owned (Wishlist) |____________| :| PC | What Remains of Edith Finch |
\\____________________________________// [S006] | :| PC | Ori and the Blind Forest | \\____________________________________// | :| PC | Ori and the Blind Forest |
| :| PC | Realm of the Mad God | | :| PC | Realm of the Mad God |
______ ________________________________________________________| :| PC | Raft | ______ ________________________________________________________| :| PC | Raft |
|======|========================================================| :| NX | The Legend of Zelda: Breath of the Wild | |======|========================================================| :| NX | The Legend of Zelda: Breath of the Wild |
@ -153,7 +153,7 @@ ____________| Not Yet Owned (Wishlist) |____________| :| PC | Wh
| PC | Beacon Pines | :| ________________ | PC | Beacon Pines | :| ________________
| PC | Switchcars | :|______________________// \\______________________ | PC | Switchcars | :|______________________// \\______________________
| PC | Into the Breach | :|______________________| 2020 |______________________ | PC | Into the Breach | :|______________________| 2020 |______________________
| PS1 | Parasite Eve | :| \\________________// [P004] | PS1 | Parasite Eve | :| \\________________//
| PC | Sifu | :| | PC | Sifu | :|
| PS4 | Dark Souls 2 | :|______ ________________________________________________________ | PS4 | Dark Souls 2 | :|______ ________________________________________________________
| PS4 | Dark Souls 3 | :|======|========================================================| | PS4 | Dark Souls 3 | :|======|========================================================|
@ -173,7 +173,7 @@ ____________| Not Yet Owned (Wishlist) |____________| :| PC | Wh
| PC | Hellblade: Senua's Sacrifice | :| ________________ | PC | Hellblade: Senua's Sacrifice | :| ________________
| PC | Factorio | :|______________________// \\______________________ | PC | Factorio | :|______________________// \\______________________
| PC | VA-11 Hall-A: Cyberpunk Bartender Action | :|______________________| 2021 |______________________ | PC | VA-11 Hall-A: Cyberpunk Bartender Action | :|______________________| 2021 |______________________
| PC | Katana Zero | :| \\________________// [P005] | PC | Katana Zero | :| \\________________//
| PC | art of rally | :| | PC | art of rally | :|
| PC | Ooblets | :|______ ________________________________________________________ | PC | Ooblets | :|______ ________________________________________________________
| PC | Don't Escape: 4 Days to Survive | :|======|========================================================| | PC | Don't Escape: 4 Days to Survive | :|======|========================================================|
@ -198,7 +198,7 @@ ____________| Not Yet Owned (Wishlist) |____________| :| PC | Wh
| PC | Hyper Light Breaker | :| ________________ | PC | Hyper Light Breaker | :| ________________
| PC | Crypt of the Necrodancer | :|______________________// \\______________________ | PC | Crypt of the Necrodancer | :|______________________// \\______________________
| PC | Just Shapes & Beats | :|______________________| 2022 |______________________ | PC | Just Shapes & Beats | :|______________________| 2022 |______________________
| PC | Minit | :| \\________________// [P006] | PC | Minit | :| \\________________//
| PC | A Short Hike | :| | PC | A Short Hike | :|
| PC | Dysmantle | :|______ ________________________________________________________ | PC | Dysmantle | :|______ ________________________________________________________
| PC | Omori | :|======|========================================================| | PC | Omori | :|======|========================================================|
@ -239,7 +239,7 @@ ____________| Not Yet Owned (Wishlist) |____________| :| PC | Wh
| :| ________________ | :| ________________
| :|______________________// \\______________________ | :|______________________// \\______________________
| :|______________________| 2023 |______________________ | :|______________________| 2023 |______________________
| :| \\________________// [P007] | :| \\________________//
| :| | :|
| :|______ ________________________________________________________ | :|______ ________________________________________________________
| :|======|========================================================| | :|======|========================================================|