-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68704a8
commit fa23686
Showing
4 changed files
with
3,064 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Cache | ||
cache/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import sys | ||
import os | ||
import re | ||
import zipfile | ||
import json | ||
|
||
import urllib.request as request | ||
|
||
|
||
def main(argv): | ||
getFileFromServer() | ||
foo = getFileList() | ||
filepath = "cache/extract/base16-shell-master/scripts" | ||
colorInfo = [] | ||
for fileName in getFileList(): | ||
with open(filepath + "/" + fileName) as f: | ||
content = f.readlines() | ||
dic = dict() | ||
dic["name"] = fileName[:-3] | ||
dic.update(getColorInfo(content)) | ||
colorInfo.append(dic) | ||
jsonString = json.dumps(colorInfo, indent=4, separators=(',', ':')) | ||
schemesFile = open("schemes.json", "w") | ||
schemesFile.write(jsonString) | ||
schemesFile.close() | ||
print("🎉 Compelete!") | ||
|
||
|
||
def getFileFromServer(force=False, url="https://github.com/chriskempson/base16-shell/archive/master.zip"): | ||
if not os.path.exists("cache"): | ||
os.mkdir("cache") | ||
if not os.path.exists("cache/master.zip") or force: | ||
print("🚀 Downloading implementation from remote server...") | ||
request.urlretrieve(url, "cache/master.zip") | ||
print("✅ Download compeleted.") | ||
unZipFile() | ||
|
||
|
||
def unZipFile(): | ||
zipFile = zipfile.ZipFile("cache/master.zip") | ||
if os.path.isdir("cache/extract"): | ||
pass | ||
else: | ||
os.mkdir("cache/extract") | ||
print("🤐 Unzipping implementation...") | ||
for names in zipFile.namelist(): | ||
zipFile.extract(names, "cache/extract") | ||
zipFile.close() | ||
print("✅ Unzip compeleted.") | ||
|
||
|
||
def getFileList(): | ||
return os.listdir("cache/extract/base16-shell-master/scripts") | ||
|
||
|
||
def getColorInfo(l: list): | ||
# Oh my shit code!!! | ||
dirtyColorInfo = list(filter(lambda x: re.match(r"color.*=", x), l)) | ||
dirtyColorInfo = dict(map(lambda x: x.split("="), dirtyColorInfo)) | ||
|
||
colorNamePrefix = "color" | ||
for i in range(16): | ||
if i < 10: | ||
getColorHex(dirtyColorInfo, colorNamePrefix + "0" + str(i)) | ||
else: | ||
getColorHex(dirtyColorInfo, colorNamePrefix + str(i)) | ||
getColorHex(dirtyColorInfo, "color_foreground") | ||
getColorHex(dirtyColorInfo, "color_background") | ||
for i in range(16): | ||
if i < 10: | ||
getColorRef(dirtyColorInfo, colorNamePrefix + "0" + str(i)) | ||
else: | ||
getColorRef(dirtyColorInfo, colorNamePrefix + str(i)) | ||
getColorRef(dirtyColorInfo, "color_foreground") | ||
getColorRef(dirtyColorInfo, "color_background") | ||
|
||
cleanColorInfo = dict() | ||
cleanColorInfo["black"] = dirtyColorInfo["color00"] | ||
cleanColorInfo["red"] = dirtyColorInfo["color01"] | ||
cleanColorInfo["green"] = dirtyColorInfo["color02"] | ||
cleanColorInfo["yellow"] = dirtyColorInfo["color03"] | ||
cleanColorInfo["blue"] = dirtyColorInfo["color04"] | ||
cleanColorInfo["magenta"] = dirtyColorInfo["color05"] | ||
cleanColorInfo["cyan"] = dirtyColorInfo["color06"] | ||
cleanColorInfo["white"] = dirtyColorInfo["color07"] | ||
cleanColorInfo["brightBlack"] = dirtyColorInfo["color08"] | ||
cleanColorInfo["brightRed"] = dirtyColorInfo["color09"] | ||
cleanColorInfo["brightGreen"] = dirtyColorInfo["color10"] | ||
cleanColorInfo["btightYellow"] = dirtyColorInfo["color11"] | ||
cleanColorInfo["brightBlue"] = dirtyColorInfo["color12"] | ||
cleanColorInfo["brightMagenta"] = dirtyColorInfo["color13"] | ||
cleanColorInfo["brightCyan"] = dirtyColorInfo["color14"] | ||
cleanColorInfo["brightWhite"] = dirtyColorInfo["color15"] | ||
cleanColorInfo["background"] = dirtyColorInfo["color_background"] | ||
cleanColorInfo["foreground"] = dirtyColorInfo["color_foreground"] | ||
cleanColorInfo["selectionBackground"] = dirtyColorInfo["color_foreground"] | ||
return cleanColorInfo | ||
|
||
|
||
def getColorHex(dic, name): | ||
if re.match(r"\$.*", dic[name]): | ||
pass | ||
else: | ||
hex = dic[name].split("\"")[1].split("/") | ||
dic[name] = "#" + hex[0] + hex[1] + hex[2] | ||
|
||
|
||
def getColorRef(dic, name): | ||
if re.match(r"\$.*", dic[name]): | ||
dic[name] = dic[dic[name][1:8]] | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.