From ad4f0144b82a0e881ac7b0a8f1cdb0232775e43a Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Mon, 13 Sep 2021 01:54:59 -0600 Subject: change to using pbr and restructure directories --- src/tirante/chapters_manager.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/tirante/chapters_manager.py (limited to 'src/tirante/chapters_manager.py') diff --git a/src/tirante/chapters_manager.py b/src/tirante/chapters_manager.py new file mode 100644 index 0000000..3d99c3f --- /dev/null +++ b/src/tirante/chapters_manager.py @@ -0,0 +1,31 @@ +def chapters_list_to_csv(chapters_list, + manga_name): + """ + Creates a csv file from the input chapter_list. + chapters_list: List of data of the chapters. + manga_name: Name of the manga, folder naming friendly. + """ + + # Adding '.csv' for csv creation. + m_name_ext = ''.join([manga_name, '.csv']) + # print(m_name) + + with open(m_name_ext, 'w') as outcsv: + for chapter in chapters_list: + outcsv.write(''.join([chapter[0], ',', chapter[1], '\n'])) + + +def chapters_csv_to_list(chapter_csv): + """ + Gives a list of chaptesrs from a csv file. + chapters_list: List of data of the chapters. + """ + + out_chapters_list = [] + + with open(chapter_csv, 'r') as incsv: + lines = incsv.readlines() + for line in lines: + out_chapters_list.append(line.strip().split(',')) + + return out_chapters_list -- cgit v1.2.3-54-g00ecf