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/chapter_images_manager.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/tirante/chapter_images_manager.py (limited to 'src/tirante/chapter_images_manager.py') diff --git a/src/tirante/chapter_images_manager.py b/src/tirante/chapter_images_manager.py new file mode 100644 index 0000000..1b8afbc --- /dev/null +++ b/src/tirante/chapter_images_manager.py @@ -0,0 +1,33 @@ +from tirante.get_chapter_image_list import get_chapter_image_list + + +def chapter_images_list_to_csv(chapter_data): + """ + Creates csv file for a chapter, given the list. + chapter_data: A list containing a url and a title. + """ + + ch_name = ''.join([chapter_data[1], '.csv']) + + chapter_image_list = get_chapter_image_list(chapter_data) + + with open(ch_name, 'w') as outcsv: + for image in chapter_image_list: + outcsv.write(''.join([image[0], ',', image[1], '\n'])) + + +def chapter_images_csv_to_list(chapter_image_csv): + """ + Returns a list given the csv file. + chapter_image_csv: csv containing data for the chapter. + """ + + out_chapter_image_list = [] + + with open(chapter_image_csv, 'r') as incsv: + lines = incsv.readlines() + for line in lines: + # print(line.strip().split(',')) + out_chapter_image_list.append(line.strip().split(',')) + + return out_chapter_image_list -- cgit v1.2.3-54-g00ecf