inspectormustache / base16-builder-python Goto Github PK
View Code? Open in Web Editor NEWA base16 colorscheme builder for Python
License: MIT License
A base16 colorscheme builder for Python
License: MIT License
When there's not template or scheme file, we get a general error saying not all resources present. Instead, it'd be nice if it reported what is missing. I suggest creating two children of LookupError
and return a corresponding error. What do you think?
I'm ready to implement this.
From windows cmd, I run pybase16 update
, and get Git executable not found in $PATH
. Git is in my path. Typing git
into cmd, I get the help text. If I open python and run
import subprocess
subprocess.Popen('git')
I get the git help text. However, if I run:
import shutil
if not shutil.which('git'):
print('No git!')
I get 'No git!'
I'm not sure why shutil can't find my git executable yet subprocess can. Either way, it's causing the script to fail
Whatever I produce with this builder, can I integrate it into my own GPL3 licensed projects?*
I thought I knew how this works, but I get very confused because this builder combines so many different repositories. Would I essentially have to look up each template/scheme?
* Apparently the MIT license requires me to add itself - but looking through a few repos, they all have different names in their copyright. Huh.
inject -s
expects a real path to a scheme file, while build -s
just takes a scheme name. Ideally the two interfaces should be consistent (and subsequently build -t
would also be consistent).
Hello!
Thank your work on this builder. It's amazing to produce so many themes with your tool 👍
I'm mainting base16-qutebrowser and would like to ask you about a good workflow with base16-builder-python.
pybase16
to update all schemes from https://github.com/chriskempson/base16-schemes-source.pybase build [options]
to generate all themes by reading base16-qutebrowser/templates/config.yaml
and base16-qutebrowsertemplates/default.mustache
and storing them in base16-qutebrowser/themes
.I use the following Makefile:
BUILD=pybase16
TEMPLATE=qutebrowser
THEME_FOLDER=themes
OUTPUT=output
all: update build
update:
$(BUILD) update
build:
$(BUILD) build -t ${TEMPLATE} -o ${OUTPUT}
rm -r ${THEME_FOLDER}
mv ${OUTPUT}/${TEMPLATE}/themes/ ${THEME_FOLDER}/
rm -r ${OUTPUT}
pybase update
downloads all templates to base16-qutebrowser/templates/
, e.g. base16-qutebrowser/templates/qutebrowser/
as well. Beside the fact, that I don't need all templates, it clones my own repo with the (old) default.mustache
as well. This is rather confusing and the old cloned default.mustache
is used to generate all templates.
So I would like to be able to only update the schemes (not the templates) sources and/or specify which default.mustache
it has to use.
Is this already possible? Otherwise it would be a very cool feature!
Thank you very much!
I've just cloned master
in order to give this base16-builder business a try (it looks great) and seem to have run into a bug.
I ran these commands successfully:
$ python3 -mvenv .
$ . ./bin/activate
$ pip install
$ pybase16 update
Then I did the build, which mostly worked. It printed this part-way through its output, before hanging:
$ pybase16 build
Building colorschemes for scheme "Material Vivid"…
Building colorschemes for scheme "Tomorrow"…
Building colorschemes for scheme "Tomorrow Night"…
Building colorschemes for scheme "Mocha"…
Building colorschemes for scheme "Ocean"…
Building colorschemes for scheme "Rebecca"…
Exception in thread Thread-38:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/graham/tmp/base16/base16-builder-python/lib/python3.7/site-packages/pybase16_builder/builder.py", line 161, in build_single_worker
build_single(scheme_file, templates, base_output_dir)
File "/home/graham/tmp/base16/base16-builder-python/lib/python3.7/site-packages/pybase16_builder/builder.py", line 126, in build_single
format_scheme(scheme, scheme_slug)
File "/home/graham/tmp/base16/base16-builder-python/lib/python3.7/site-packages/pybase16_builder/builder.py", line 99, in format_scheme
int(scheme['{}-hex-r'.format(base)], 16))
ValueError: invalid literal for int() with base 16: '#2'
Built colorschemes for scheme "Summerfruit Light".
Built colorschemes for scheme "Heetch Light".
Built colorschemes for scheme "Mexico Light".
Built colorschemes for scheme "Synth Midnight Dark".
Built colorschemes for scheme "One Light".
There's one process and 39 threads, and I suspect they're all blocked because the main thread is waiting for that thread that couldn't parse its input?
Let me know if you need any more info. It doesn't look like it matters, but this is with Python 3.7.3 on Pop!_OS 19.04.
Cheers!
I just cloned the repository (commit 00b02a8), and wanted to update/build the themes, but the python program reportedly could not connect to github.com.
Python version was 3.6, I can also ping successfully myself.
Any tips on how to resolve this issue?
C:\Users\gilj\themes
(py36) λ python base16-builder-python\pybase16.py update
Creating sources.yaml…
Cloning sources…
Start cloning from https://github.com/chriskempson/base16-schemes-source.git…
Start cloning from https://github.com/chriskempson/base16-templates-source.git…
Error cloning from https://github.com/chriskempson/base16-schemes-source.git:
Cloning into 'C:\Users\gilj\themes\sources\schemes'...
fatal: unable to access 'https://github.com/chriskempson/base16-schemes-source.git/': Could not resolve host: github.com
Error cloning from https://github.com/chriskempson/base16-templates-source.git:
Cloning into 'C:\Users\gilj\themes\sources\templates'...
fatal: unable to access 'https://github.com/chriskempson/base16-templates-source.git/': Could not resolve host: github.com
Cloning templates…
Necessary resources for updating not found in current working directory.
C:\Users\gilj\themes
(py36) λ ping github.com
Pinging github.com [192.30.253.112] with 32 bytes of data:
Reply from 192.30.253.112: bytes=32 time=88ms TTL=51
Reply from 192.30.253.112: bytes=32 time=88ms TTL=51
Ping statistics for 192.30.253.112:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 88ms, Maximum = 88ms, Average = 88ms
Control-C
^C
C:\Users\gilj\themes
(py36) λ python --version
Python 3.6.5
Thanks for the tool.
This one does not work for me:
pybase16 inject -s schemes/default/ocean.yaml -f ~/.gtkrc-2.0.mine -f ~/.config/dunst/dunstrc -f ~/.config/i3/config -f ~/.config/termite/config -f ~/.config/zathura/zathurarc
scheme file not found like that.
Should be like in your travis test:
cd <your_base_dir>
pybase16 inject -s ocean -f ~/.gtkrc-2.0.mine -f ~/.config/dunst/dunstrc -f ~/.config/i3/config -f ~/.config/termite/config -f ~/.config/zathura/zathurarc
and to really make it clear maybe a non default one:
pybase16 inject -s black-metal-burzum -f /home/gk/.Xresources
apropos .Xresources - too minor for an issue imho, just a big ugly:
The tool swallows the last newline, at least in .Xresources type of target file, resulting in:
/home/gk/.Xresources:59: warning: End of input with no newline, supplemented newline
when xrdb ~./Xresources
is run after injection. Not a big deal here but I think it should be corrected. Thanks again.
The program at the moment returns 0
even if an error has occurred. It would be useful to return a non-zero code on an error so it is possible to take any action in case of a failure.
For example, I have a script that uses inject
to update configs and then reloads all corresponding programs. I would like to avoid reloading if the injection wasn't successful. At the moment, I'm just checking the output, which clearly isn't a good solution.
It also would be more correct if all error messages were written to stderr
, not stdout
.
$ cat config.yaml
default:
extension:
output: colors
$ python3 pybase16.py build -t radare2
$ cd output/radare2/colors && ls
base16-3024None ...
Hi! Just wanted to let you know that the version of pybase16-builder published to PyPI is out of date and missing some more recent commits. Would you please update it and bump the minor version? Thanks so much for making this!
In my opinion, the prettiness of f-strings doesn't outweigh the ability to run this script on Debian Stable.
Here's a patch that removes f-strings, making this compatible with Python 3.5:
diff --git a/pybase16_builder/builder.py b/pybase16_builder/builder.py
index cee6ad0..9f0bf68 100644
--- a/pybase16_builder/builder.py
+++ b/pybase16_builder/builder.py
@@ -26,7 +26,7 @@ class TemplateGroup(object):
templates = get_yaml_dict(config_path)
for temp, sub in templates.items():
mustache_path = os.path.join(get_parent_dir(config_path),
- f'{temp}.mustache')
+ temp+'.mustache')
sub['parsed'] = get_pystache_parsed(mustache_path)
return templates
@@ -90,18 +90,18 @@ def format_scheme(scheme, slug):
scheme['scheme-slug'] = slug
bases = ['base{:02X}'.format(x) for x in range(0, 16)]
for base in bases:
- scheme[f'{base}-hex'] = scheme.pop(base)
- scheme[f'{base}-hex-r'] = scheme[f'{base}-hex'][0:2]
- scheme[f'{base}-hex-g'] = scheme[f'{base}-hex'][2:4]
- scheme[f'{base}-hex-b'] = scheme[f'{base}-hex'][4:6]
-
- scheme[f'{base}-rgb-r'] = str(int(scheme[f'{base}-hex-r'], 16))
- scheme[f'{base}-rgb-g'] = str(int(scheme[f'{base}-hex-g'], 16))
- scheme[f'{base}-rgb-b'] = str(int(scheme[f'{base}-hex-b'], 16))
-
- scheme[f'{base}-dec-r'] = str(int(scheme[f'{base}-rgb-r']) / 255)
- scheme[f'{base}-dec-g'] = str(int(scheme[f'{base}-rgb-g']) / 255)
- scheme[f'{base}-dec-b'] = str(int(scheme[f'{base}-rgb-b']) / 255)
+ scheme[base+'-hex'] = scheme.pop(base)
+ scheme[base+'-hex-r'] = scheme[base+'-hex'][0:2]
+ scheme[base+'-hex-g'] = scheme[base+'-hex'][2:4]
+ scheme[base+'-hex-b'] = scheme[base+'-hex'][4:6]
+
+ scheme[base+'-rgb-r'] = str(int(scheme[base+'-hex-r'], 16))
+ scheme[base+'-rgb-g'] = str(int(scheme[base+'-hex-g'], 16))
+ scheme[base+'-rgb-b'] = str(int(scheme[base+'-hex-b'], 16))
+
+ scheme[base+'-dec-r'] = str(int(scheme[base+'-rgb-r']) / 255)
+ scheme[base+'-dec-g'] = str(int(scheme[base+'-rgb-g']) / 255)
+ scheme[base+'-dec-b'] = str(int(scheme[base+'-rgb-b']) / 255)
def slugify(scheme_file):
Ignores proxies and other settings, causing failures to fetch in some environments.
Is there a way to specify a single color scheme to clone and/or build? As a way to do color scheme development.
BTW, thank for the easy-to-use tool!
Given: An empty current working directory and a clean pybase16-builder install (using pipx)
When: I run
$ pybase16 update
Then: I would expect no interaction is required. However, I get prompted for Github credentials:
$ pybase16 update
Creating sources.yaml…
Cloning sources…
Cloning templates…
Username for 'https://github.com':
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.