/
constants.py
72 lines (70 loc) · 2.67 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings
import pandas as pd
import pkg_resources
from os.path import join
import ArtSciColor.paths as pth
import ArtSciColor.auxiliary as aux
SWATCH_DIMS = {'width': 750, 'height': 50}
NOT_ART = set(('Splatoon', 'Ghibli'))
CATEGORIES = {
'Art': set((
"Matisse", "Nolde", "Warhol", "Monet", "Kirchner",
"Miro", "Picasso", "Kandinsky", "EdnaAndrade", "Signac",
"VanGogh", "DarbyBannard", "UmbertoBoccioni"
)),
'Movies': set(('Ghibli', 'Disney')),
'Gaming': set(('Splatoon', )),
'Other': set(('chipdelmal', 'coolors', 'lospec', 'Public'))
}
ARTISTS_SET = set.union(*list(CATEGORIES.values()))
DF_SORTING = (
'artist', 'title', 'palette', 'hash',
'clusters', 'clustering', 'url', 'filename'
)
###############################################################################
# Load Serialized data
# https://stackoverflow.com/questions/779495/access-data-in-package-subdirectory
# https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
###############################################################################
DATA_PATH = pkg_resources.resource_filename('ArtSciColor', 'data/')
(PT_SW, PT_DF) = (join(DATA_PATH, 'SWATCHES.bz'), join(DATA_PATH, 'DB.csv'))
try:
SWATCHES = aux.loadDatabase(PT_SW, df=False)
SWATCHES_DF = pd.read_csv(PT_DF)
except:
warnings.warn("Missing colors database!")
###############################################################################
# HTML/MD Text
###############################################################################
# hdr = ('ID', 'Palette', 'Hex Palette')
hdr = ('Title', 'ID', 'Palette', 'Hex Palette')
# ('Artist', 'Title', 'Palette', 'ID') # , 'Hex Palette')
RDM_HEADER = [
f'<th style="text-align: center; vertical-align: middle;">{e}</th>'
for e in hdr
]
RDM_TEXT = '''
<!DOCTYPE html>
<html><body>
<h1>{}</h1>
<p>Click on the color palette to see the original artwork or source!</p>
<table style="width:100%">
<tr>{}</tr>{}
</table>
</body></html>
'''
def generateHTMLEntry(artist, url, title, relPth, hname, strPal):
entry = [
f'<td style="text-align: center; vertical-align: middle;">{e}</td>'
for e in (
# f'<p style="font-size:14px">{artist}</p>', # Artist
f'<a href={url} style="font-size:14px">{title}</a>', # Title
f'<p style="font-size:14px">{hname}</p>', # Hash Name
f'<a href={url} style="font-size:14px"><img style="border-radius: 14px;" src="{relPth}" height="25"></a>', # Relative Path
f'<p style="font-size:14px">{strPal}</p>' # String Palette
)
]
mdRow = '\r<tr>'+' '.join(entry)+'</tr>'
return mdRow