Skip to content

Commit eb7e4c5

Browse files
committed
Add full CLI support
This commit .. * Improves scripts * Updates dependencies * Supercharges .gitignore * Migrates it into an installable CLI utility .. and fixes #8
1 parent 73e10c2 commit eb7e4c5

14 files changed

+305
-109
lines changed

.gitignore

+135
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,144 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff
69+
.scrapy
70+
71+
# VSCode stuff
72+
.vscode
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
101+
__pypackages__/
102+
103+
# Celery stuff
104+
celerybeat-schedule
105+
celerybeat.pid
106+
107+
# SageMath parsed files
108+
*.sage.py
4109

5110
# Environments
6111
.env
112+
.venv
113+
env/
114+
venv/
115+
ENV/
116+
env.bak/
117+
venv.bak/
118+
119+
# Spyder project settings
120+
.spyderproject
121+
.spyproject
122+
123+
# Rope project settings
124+
.ropeproject
125+
126+
# mkdocs documentation
127+
/site
128+
129+
# mypy
130+
.mypy_cache/
131+
.dmypy.json
132+
dmypy.json
133+
134+
# Pyre type checker
135+
.pyre/
136+
137+
# pytype static type analyzer
138+
.pytype/
139+
140+
# Cython debug symbols
141+
cython_debug/
7142

8143
# Gotta fetch 'em all!
9144
/palettes/*/**/*

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ It's as easy as `pip install -r requirements.txt`, but you might want to make su
3535
Fetching color sets and processing them is really straightforward - for everything else, there's `--help`:
3636

3737
```bash
38-
$ python main.py
39-
Usage: main.py [OPTIONS] COMMAND [ARGS]...
38+
$ colors
39+
Usage: colors [OPTIONS] COMMAND [ARGS]...
4040

4141
Options:
4242
-v, --version Show the version and exit.
@@ -51,10 +51,10 @@ Using its commands `fetch` and `process` is fairly easy, like that:
5151

5252
```bash
5353
# Example 1 - Gotta fetch 'em `--all`:
54-
$ python main.py fetch --all && python main.py process
54+
$ colors fetch --all && colors process
5555

5656
# Example 2 - Fetching specific sets & processing them:
57-
$ python main.py fetch copic dulux && python main.py process copic dulux
57+
$ colors fetch copic dulux && colors process copic dulux
5858
```
5959

6060
### FAQ

examples.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
# For more information, see https://www.python.org/dev/peps/pep-0008/#imports
77
##
88

9-
import os
10-
import glob
9+
from os import system
10+
from os.path import basename, dirname
11+
from glob import glob
1112

1213

13-
for file in glob.glob('./examples/*/index.php'):
14+
for file in glob('./examples/*/index.php'):
1415
html = file.replace('.php', '.html')
15-
os.system('cd ' + os.path.dirname(file) + ' && php ' + os.path.basename(file) + ' > ' + os.path.basename(html))
16+
system('cd ' + dirname(file) + ' && php ' + basename(file) + ' > ' + basename(html))
1617

1718
print('Generating ' + html + ' .. done')

main.py

-93
This file was deleted.

setup.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ~*~ coding=utf-8 ~*~
2+
3+
import io
4+
from os.path import abspath, dirname, join
5+
from setuptools import find_packages, setup
6+
7+
8+
VERSION = '1.0.0'
9+
10+
11+
def long_description():
12+
readme_file = join(dirname(abspath(__file__)), 'README.md')
13+
14+
with io.open(readme_file, encoding='utf8') as file:
15+
return file.read()
16+
17+
18+
setup(
19+
name='we-love-colors',
20+
description='PANTONE®, RAL®, Dulux®, Copic® and Prismacolor® color palettes for Scribus, GIMP & Inkscape, the Python way',
21+
long_description=long_description(),
22+
long_description_content_type='text/markdown',
23+
version=VERSION,
24+
license='MIT',
25+
author='Martin Folkers',
26+
author_email='[email protected]',
27+
maintainer='Fundevogel',
28+
maintainer_email='[email protected]',
29+
url='https://github.com/Fundevogel/we-love-colors',
30+
project_urls={
31+
"Source code": "https://github.com/Fundevogel/we-love-colors",
32+
"Issues": "https://github.com/Fundevogel/we-love-colors/issues",
33+
},
34+
packages=find_packages(),
35+
install_requires=[
36+
'bs4',
37+
'click',
38+
'lxml',
39+
'pillow',
40+
],
41+
entry_points='''
42+
[console_scripts]
43+
colors=we_love_colors.cli:cli
44+
''',
45+
python_requires='>=3.5',
46+
)

setup.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
#!/bin/bash
22

3-
# Setting up virtualenv & installing dependencies from `requirements.txt`
4-
virtualenv -p python3 .env && source .env/bin/activate && pip install -r requirements.txt
3+
# Setting up & activating virtualenv
4+
virtualenv -p python3 .env
5+
# shellcheck disable=SC1091
6+
source .env/bin/activate
7+
8+
# Installing dependencies
9+
pip install --editable .
10+
11+
# Creating directory structure
12+
cd palettes || exit
13+
14+
for dir in copic \
15+
dulux \
16+
pantone \
17+
prismacolor \
18+
ral
19+
do
20+
mkdir -p "$dir"
21+
done

0 commit comments

Comments
 (0)