Download modules/artists.py from arbinger5217/arbinger: direct link, hf CLI and curl.
- Browser
- Download file 678 Bytes
-
https://huggingface.co/arbinger5217/arbinger/resolve/main/modules/artists.py
- Command line
-
hf download hf://arbinger5217/arbinger/modules/artists.py
-
curl -L -o artists.py https://huggingface.co/arbinger5217/arbinger/resolve/main/modules/artists.py
678 Bytes
| import os.path | |
| import csv | |
| from collections import namedtuple | |
| Artist = namedtuple("Artist", ['name', 'weight', 'category']) | |
| class ArtistsDatabase: | |
| def __init__(self, filename): | |
| self.cats = set() | |
| self.artists = [] | |
| if not os.path.exists(filename): | |
| return | |
| with open(filename, "r", newline='', encoding="utf8") as file: | |
| reader = csv.DictReader(file) | |
| for row in reader: | |
| artist = Artist(row["artist"], float(row["score"]), row["category"]) | |
| self.artists.append(artist) | |
| self.cats.add(artist.category) | |
| def categories(self): | |
| return sorted(self.cats) | |