ubernostrum / webcolors Goto Github PK
View Code? Open in Web Editor NEWA library for working with HTML/CSS color formats in Python.
Home Page: https://webcolors.readthedocs.io/
License: BSD 3-Clause "New" or "Revised" License
A library for working with HTML/CSS color formats in Python.
Home Page: https://webcolors.readthedocs.io/
License: BSD 3-Clause "New" or "Revised" License
This seems to have been introduced when upgrading from 1.7.0 to 1.8.0.
Installing via pip is giving the following error:
AssertionError: webcolors .dist-info direction not found
I've locked the version on my end to 1.7.0, so it works.
Here's details about my environment if that helps:
pip: 9.0.1
python: 3.5.1
While the project seems to use type annotations internally, type checkers will ignore them because the py.typed
marker file is missing. Note that adding the file will not be enough, since you will also need to explicitly add py.typed
to the package_data
so the py.typed
marker is still there after installation.
I read through the documentation but couldn't find any function which simply allows throwing in any css color attribute and getting back RGB information.
styles = {'color': 'hotpink', 'background-color': '#C0FFEE'}
webcolors.parse(styles['color'])
webcolors.parse(styles['background-color'])
Hi,
I've recently used this module to get the name of an RGB color, but was only interested in getting generic names (like the group names from here). I needed to write a dictionary for converting from color name to color group.
What about extending the functionality of get_colour_name
by adding a group
flag? If needed, I could totally help with that.
Best,
Cosmina
rebeccapurple
(#663399
) is a named color added in CSS Color Module Level 4 to honor web pioneer Eric Meyer. Although Level 4 is not a formal W3C Recommendation & rebeccapurple is not in the SVG 1.1 spec, it is a Candidate Recommendation Draft and all browsers have supported this value since 2015. Therefore, this color should probably be added, and tests/definitions.py
should migrate to Level 4.
I have a Raspberry Pi with Raspbian and Python 3.2.3. When I attempt to install Webcolors with pip, or manually download the tar.gz and run the install script, I get the following error:
running install
running build
running build_py
running install_lib
creating /usr/local/lib/python3.2
creating /usr/local/lib/python3.2/dist-packages
copying build/lib/webcolors.py -> /usr/local/lib/python3.2/dist-packages
byte-compiling /usr/local/lib/python3.2/dist-packages/webcolors.py to webcolors.cpython-32.pyc
File "/usr/local/lib/python3.2/dist-packages/webcolors.py", line 41
SUPPORTED_SPECIFICATIONS = (u'html4', u'css2', u'css21', u'css3')
^
SyntaxError: invalid syntax
running install_egg_info
Writing /usr/local/lib/python3.2/dist-packages/webcolors-1.5.egg-info
Any ideas?
Hi there! And thanks for this useful library!
I'm using this with pycollada, which wants RGB values as arrays of three floats from 0.0 to 1.0.
Would you be interested in a pull request to a function for exposing color values as rgb floats?
As we all know, today more than ever before, it is crucial to be able to trust our computing environments. One of the main difficulties that package maintainers of GNU/Linux distributions face, is the difficulty to verify the authenticity and the integrity of the source code. With GPG signatures it is possible for packagers to verify source code releases quickly and easily.
GPGit is meant to bring GPG to the masses. It is not only a Python script that automates the process of creating new signed Git releases with GPG, but also a quick-start-guide for learning how to use GPG. GPGit integrates perfectly with the Github Release API for uploading.
The security status of GNU/Linux projects will be tracked in the Linux Security Database. If you have any further questions, do not hesitate to contact me personally. Thanks for your help in making GNU/Linux projects more secure by using GPG signatures.
Thanks in advance.
Would be excellent if the library included a function that accepted any of the color representations allowed in a CSS file, and normalized that to e.g. RGBA.
While webcolors
has typing annotations in the code (which is amazing!), unfortunately those annotation can't be used by mypy
to actually check the code against those annotations.
$ cat test.py
import webcolors
$ mypy test.py
test.py:1: error: Skipping analyzing 'webcolors': found module but no type hints or library stubs
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.812
$ python --version
Python 3.9.2
The reason for that is webcolors
get installed as site-packages/webcolors.py
, but for mypy
to be able to use the typing annotations in the code, it should be installed as site-packages/webcolors/__init__.py
, with empty site-packages/webcolors/py.typed
file present.
See https://mypy.readthedocs.io/en/stable/installed_packages.html for details.
Love the library and use it regularly for my projects!
It would be cool if there was the conversion to and from RGBA.
A in RGBA stands for Alpha and basically represents the opacity for each pixel (in %).
Perhaps it's possible to use the existing methods to convert the last 2 characters in 8 character HEX string into Alpha %.
I would like to know how many colors does webcolors provide?
Thanks in advance
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.