Created
September 29, 2014 14:11
-
-
Save gunthercox/efd5656f27637652c32e to your computer and use it in GitHub Desktop.
Converts a file name to a color code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filecolor(filename): | |
colors = ("#f15501", "#f15501", "#f3ca0a", "#199c4b", | |
"#0298c3", "#ca2afe", "#6e4a7e", "#701516", | |
"#6594b9", "#0d3c6e", "#3ebc27", "#a9188d", | |
"#f15501", "#543978", "#37775b", "#0579aa",) | |
# if the filename has an extension, use it for the hash | |
if "." in filename: | |
filename = filename.split(".")[1] | |
selection = hash(filename) % 16 | |
return colors[selection] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment