-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plumbum.color #206
Plumbum.color #206
Conversation
…thods, full property name support, properties now dynamic, some support for setting .use_color
… object and works like one.
… use ColorfulApplication.
Conflicts: docs/_news.rst docs/local_commands.rst
…them. Color API docstrings.
…uff) is now color[stuff]. Docs update next.
…on, camelcase names
…hout metaclasses.
Conflicts: .travis.yml CHANGELOG.rst plumbum/machines/base.py tests/test_local.py
If it was a stand-alone package, it couldn't a.) be integrated with plumbum.cli, and b.) it would run in to the same problem as colorama and all other color packages: they have to be installed to be used, and they are generally "non-essential", and would require a dependency that you would have to check for. If a script depends on plumbum, now it has guaranteed easy access to color. The bracket syntax works just fine, try it. :)
Instead of having an experimental directory, how about making an experimental branch, and then PRing parts into the main branch when ready? That way testing it would be easy, just checkout a branch. Putting things in a separate directory breaks all test scripts, docs, code, etc. I'll set it up if you want me to. I think we really should have two branches at least, a master that mostly takes bug fixes, and a experimental/dev that takes new features and matures them. (PS: It's also easy to checkout my fork branch into a local branch with a different name, that's how I am working now) |
PS: With the exception of the CLI integration, tests, and docs, everything new is contained in The COLOR object is much more powerful than a module could be, for example:
And, of course, you can set up new ones with one line, look at HTMLCOLOR, for example. Also, several color packages seemed to use uppercase names, and colors are "constants" (or, at least, in the first iteration of the package they were str subclasses, so they were), so that's why they are uppercase. That's easy to change. |
The 16 default colors, attributes, and Suggested name change:
Then you could do from Since I'll have to change all docs, tests, etc., would like feedback before making that change. :) |
I've renamed all colors and attributes to lowercase, and I've even made the module syntax work. So from Note that you still have to do |
… original factories.
…ibrary, None or '' means no color.
Conflicts: CHANGELOG.rst
I've added access to colors to the command line, too, using $ python -m plumbum.colors This was always available as an emergency terminal recovery (no arguments is still full reset), but selecting all available styles and using colors instead of colorlib is new. tom Have you had time to look at it yet? If you need prebuilt access to the docs, they are at http://henryiiiplumbum.readthedocs.org/en/latest/. |
Closing in favor of new PR from color branch. |
This is the
plumbum.colors
module I've been working on, designed to make adding colors easy and safe. I've prepared a post about it here, this post has been updated, and there is extensive documentation in the addition. As a quick example:You can access the ANSI 16 basic colors, 256 colors (with names), and full 24 bit color - and can convert between them (This is the only library I know of that can do that). You can easily subclass Style to create more representations (HTMLStyle is included to make documentation easier to write). Styles are smart and know how to combine to create the most effective ANSI sequence. Styles correctly handle being turned off, and don't turn on for non-posix tty systems (can be forced, though). Basic colors can be used on Windows with a tool (like colorama) to convert ANSI codes. (See examples).
Docs (with list of color names), API docs, tests, examples included.
Closes #128