diff --git a/analyze_cube_keywords.py b/analyze_cube_keywords.py index 2a3a926..45e87eb 100644 --- a/analyze_cube_keywords.py +++ b/analyze_cube_keywords.py @@ -6,10 +6,8 @@ import cubecobra_csv import keyword_stats if __name__ == '__main__': - cube_id = 'jeskaicube' - csv_path = cubecobra_csv.request_cube_csv(cube_id, cube_id) - cube_list = cubecobra_csv.load_cube_names(f'cube_csvs/{cube_id}.csv') - cube_json_filename = cube_json.create_cube_json(cube_list, f'cubes/{cube_id}.json') + cube_list = cubecobra_csv.load_cube_names('cube_csvs/TheElegantCube_2020-11-17_5.0.4.csv', {'core'}) + cube_json_filename = cube_json.create_cube_json(cube_list, 'cubes/TheElegantCube_2020-11-17_5.0.4.json') keyword_dict = keyword_stats.keyword_count(cube_json_filename) # keyword_stats.keyword_report(keyword_dict) diff --git a/cubecobra_csv.py b/cubecobra_csv.py index 320c80a..3f8ddeb 100644 --- a/cubecobra_csv.py +++ b/cubecobra_csv.py @@ -7,7 +7,7 @@ from typing import List, Set import requests EXPECTED_HEADER = [ - 'name', + 'Name', 'CMC', 'Type', 'Color', @@ -15,12 +15,12 @@ EXPECTED_HEADER = [ 'Collector Number', 'Rarity', 'Color Category', - 'status', + 'Status', 'Finish', - 'maybeboard', - 'image URL', - 'image Back URL', - 'tags', + 'Maybeboard', + 'Image URL', + 'Image Back URL', + 'Tags', 'Notes', 'MTGO ID' ] @@ -95,8 +95,7 @@ def load_cube(filename) -> List[CubeCard]: tags = _get_tags(line) color_category = _get_color_category(line) colors = _get_colors(line) - if not _get_maybeboard(line): - cards.append(CubeCard(card_name, color_category, colors, tags)) + cards.append(CubeCard(card_name, color_category, colors, tags)) return cards @@ -105,11 +104,11 @@ def _assert_header(header_line): def _get_name(line: List) -> str: - return line[COLUMNS['name']] + return line[COLUMNS['Name']] def _get_tags(line: List) -> Set[str]: - return set(t.strip() for t in line[COLUMNS['tags']].split(';')) + return set(t.strip() for t in line[COLUMNS['Tags']].split(';')) def _get_color_category(line: List) -> str: @@ -122,9 +121,3 @@ def _get_colors(line: List) -> str: colors = line[COLUMNS['Color']] #assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown' return sorted(colors.lower()) - -def _get_maybeboard(line: List) -> str: - maybeboard = line[COLUMNS['maybeboard']] - if 't' in maybeboard.lower(): - return True - return False \ No newline at end of file diff --git a/word_count.py b/word_count.py index fa8df18..47c6a93 100644 --- a/word_count.py +++ b/word_count.py @@ -173,9 +173,8 @@ if __name__ == '__main__': # cube_list = cubecobra_csv.load_cube_names(csv_path) # 2. If you have your cube in Cube Cobra and want to consider only cards with a certain tag - cube_id = 'jeskaicube' - csv_path = cubecobra_csv.request_cube_csv(cube_id, cube_id) - cube_list = cubecobra_csv.load_cube_names(csv_path, tag_filter=None) + csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant') + cube_list = cubecobra_csv.load_cube_names(csv_path, tag_filter={'core'}) # 3. If you have a .txt of your cube # cube_list = cube_json.load_cube_from_txt('YourCubeHere.txt')