Skip to content
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

Color #213

Merged
merged 90 commits into from
Aug 27, 2015
Merged

Color #213

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
96a288c
Adding new color module
Jul 13, 2015
e40671c
Merge branch 'master' of https://github.com/henryiii/plumbum
henryiii Jul 14, 2015
a687cf1
Adding docs and cleanup for COLOR (and Style) classes
henryiii Jul 14, 2015
e9d9722
Moved color to it's own submodule, moved ansi colors to Style classme…
Jul 14, 2015
983e899
Minor fixes for COLOR, shares code with _COLOR_NAMES now. More tests.
Jul 14, 2015
f88c4bf
Styles now can be summed. COLOR.BOLD + COLOR.RED is now a valid Style…
Jul 14, 2015
dc7dc86
Added color support to Application, use ColorfulApplication for brigh…
Jul 14, 2015
6873a76
Removed the CYAN color for program name, as now you can control it or…
Jul 14, 2015
b933068
Renamed _COLOR_NAMES to ColorCollection (Since it is a class, not an …
henryiii Jul 15, 2015
b8498e1
Update .travis.yml to force classic build method (sudo needed)
henryiii Jul 15, 2015
a91d95a
Moved .__contains__ to BaseMachine, added .get, and getattr will work…
Jul 15, 2015
5a39493
Merge remote-tracking branch 'upstream/master'
Jul 15, 2015
f3797e9
Moved colors to separate file, added the function I used to generate …
Jul 15, 2015
2d75bc0
Adding new colors backend (not finished yet)
Jul 16, 2015
ff444db
Python 2.6 fix, several fixes to base and color
Jul 16, 2015
49f0781
Merging master branch
henryiii Jul 17, 2015
1c1ec91
Merge branch 'upmaster'
henryiii Jul 17, 2015
ba70ee9
Merge branch 'upmaster'
henryiii Jul 17, 2015
7e624ea
Moved completely to new color system. Only visible effect is color(st…
henryiii Jul 17, 2015
f6df722
Updating hex code, repr. Added way to iterate over simple colors.
Jul 17, 2015
9a013c2
Adding ini file for xdist to enable live test monitoring
Jul 17, 2015
11c121d
Working html color, more docs, .RESET for Styles, removed NON_ notati…
henryiii Jul 18, 2015
597de95
Fix typo in BG for HTMLStyle
henryiii Jul 18, 2015
74e916c
Updated sys.stdout override to class level function and propery
henryiii Jul 18, 2015
ee7f5ed
Adding classmethods for stdout
henryiii Jul 18, 2015
f85d69b
Dropping the classmethods for stdout for now. Hard to do properly wit…
henryiii Jul 18, 2015
815b5a7
Added more ways to wrap strings, html output example improved.
henryiii Jul 18, 2015
ed1ef1c
Added documentation, use_color shortcut.
henryiii Jul 18, 2015
0b4f25e
Merge .get work
henryiii Jul 18, 2015
8b58b31
Fixed colortable for different size screens.
henryiii Jul 19, 2015
a39823f
Adding missing simicolons.
henryiii Jul 19, 2015
c8c4254
Added better docs, more shifts, hex shortcut, print, endline support,…
henryiii Jul 20, 2015
02ef52f
Type fix
henryiii Jul 20, 2015
4f5d24a
Fixed .print error.
henryiii Jul 20, 2015
15e2906
Added test, example of color on Windows. The test/example tries to im…
henryiii Jul 20, 2015
570d88b
Making examples executable directly.
Jul 20, 2015
216ad33
Merge branch 'master'
Jul 20, 2015
5b8f86e
Better tests, updated docs to match current status of library
Jul 20, 2015
b9378f8
Added IPython extension
Jul 20, 2015
16c5ba7
Added more accurate, 16 color inclusive color for simple color, exten…
Jul 20, 2015
b112530
Adding color slicing
Jul 20, 2015
21ca902
Fixing a test.
Jul 20, 2015
17661fe
Fixes for tests failing, moving to slicing for tests
Jul 20, 2015
6dfc106
Now __call__ always prints
Jul 20, 2015
43dc097
Updated docs for 16 colors and 24 bit colors
Jul 20, 2015
1aeb258
Dropped the (unneeded) colorful list, as slicing works now. Added ful…
Jul 20, 2015
0b0e056
Spelling typo.
Jul 20, 2015
1e20f95
Updated API docs to be slightly better.
henryiii Jul 21, 2015
7f864ab
Fix for failing test due to removed Color attributes.
henryiii Jul 21, 2015
7a403bf
Adding __getattr__ (from iPhone)
henryiii Jul 21, 2015
ce77e0e
Adding attribute tests.
henryiii Jul 21, 2015
3ecd8f9
Fix typo
henryiii Jul 21, 2015
ec4232f
Simplify and fix name loading, tests pass now.
henryiii Jul 21, 2015
8624790
Reworked html portion of color names, cleaner, auto-generated.
henryiii Jul 21, 2015
c5aa031
Fixed division issue on Python 2
Jul 21, 2015
629178d
Better docs, improvement for [] access
Jul 21, 2015
150dfe8
Made all color names unique.
Jul 21, 2015
0bf4793
Moving tests to better names, prepping for some mild speedups for loo…
Jul 21, 2015
8fb57ac
Removed stub file for test, won't be needed.
henryiii Jul 22, 2015
49b18c8
Move to new color find system, ~8x faster
henryiii Jul 22, 2015
45b6a2a
Removing a few redundant functions.
henryiii Jul 22, 2015
8aa3e40
Small bugfix
Jul 22, 2015
e4ee148
Changed "simple" to "representation", preparing to add conversion fea…
Jul 22, 2015
cf68efc
Added representations, standardized call -> simple will be tried first.
Jul 22, 2015
dece5a2
Adding a few html styles for blogpost.
Jul 22, 2015
0ddde06
Updated colortable, fix for loading by number being simplified to a d…
Jul 22, 2015
c5240a0
Fix test for changed behavior from name loading.
Jul 22, 2015
ce0d033
Converting color needs to have color number reset.
Jul 22, 2015
6698dc7
Correction to not-equal test.
Jul 22, 2015
9a64f76
Merge branch 'master'
henryiii Jul 23, 2015
2be9eb7
Adding & support
henryiii Jul 23, 2015
0dca53b
Added default colors to plumbum.color.
henryiii Jul 23, 2015
858371c
Change COLOR -> colors, now an imitation module, all lowercase names
henryiii Jul 29, 2015
db6d879
Adding rename to setup.py
henryiii Jul 29, 2015
70b0dfb
Some docs updates for the colors renaming
henryiii Jul 29, 2015
9569eb0
Improvements to the __doc__ strings of repeated functions.
henryiii Jul 29, 2015
d50e978
Minor fixes, including tests for importing
henryiii Jul 29, 2015
3b76d5b
Fix for IPython color extension
henryiii Jul 29, 2015
d88bcef
Dropped unneeded complexity for the colors module; it can just be the…
henryiii Jul 29, 2015
e3169a8
Added __slots__, minor cleanup, factory call from Style or ansi now p…
henryiii Aug 3, 2015
b603a36
Added ansi support for empty Styles, added empty style generator to f…
henryiii Aug 3, 2015
e90c808
cli.Application has cleaner color integration, works with any color l…
henryiii Aug 3, 2015
b4be2a2
Minor bugfix with emergency reset, and now can be used as python -m p…
Aug 19, 2015
a6a542e
Dropping unsupported python -m plumbum.colors, this doesn't work.
Aug 19, 2015
bfe8e68
Adding color changes from the command line, like -m plumbum.colorlib …
Aug 19, 2015
431c451
Now implemented a working `-m plumbum.colors`!
Aug 19, 2015
eb130d3
Merge remote-tracking branch 'upstream/master'
Aug 19, 2015
a12f84d
Merge remote-tracking branch 'upstream/master'
henryiii Aug 21, 2015
830db9d
Adding highlighting patch to color part of readme
henryiii Aug 21, 2015
40e685d
Merge branch 'master' into 'color'
Aug 27, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
1.5.1
-----
In development
--------------
* Color: Added colors module, support for colors added to cli


1.5.1 (In development)
----------------------
* Machines: Added ``.get()`` method for checking several commands. (`#205 <https://github.com/tomerfiliba/plumbum/pull/205>`_)
* Machines: ``local.cwd`` now is the current directory even if you change the directory with non-Plumbum methods. (`#207 <https://github.com/tomerfiliba/plumbum/pull/207>`_)

Expand Down
28 changes: 20 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Command nesting
>>> print sudo[ifconfig["-a"]]
/usr/bin/sudo /sbin/ifconfig -a
>>> (sudo[ifconfig["-a"]] | grep["-i", "loop"]) & FG
lo Link encap:Local Loopback
lo Link encap:Local Loopback
UP LOOPBACK RUNNING MTU:16436 Metric:1

Remote commands (over SSH)
Expand All @@ -120,7 +120,7 @@ and `Paramiko <https://github.com/paramiko/paramiko/>`_ (a pure-Python implement
>>> r_ls = remote["ls"]
>>> with remote.cwd("/lib"):
... (r_ls | grep["0.so.0"])()
...
...
u'libusb-1.0.so.0\nlibusb-1.0.so.0.0.0\n'

CLI applications
Expand All @@ -130,22 +130,21 @@ CLI applications

import logging
from plumbum import cli

class MyCompiler(cli.Application):
verbose = cli.Flag(["-v", "--verbose"], help = "Enable verbose mode")
include_dirs = cli.SwitchAttr("-I", list = True, help = "Specify include directories")

@cli.switch("--loglevel", int)
def set_log_level(self, level):
"""Sets the log-level of the logger"""
logging.root.setLevel(level)

def main(self, *srcfiles):
print "Verbose:", self.verbose
print "Include dirs:", self.include_dirs
print "Include dirs:", self.include_dirs
print "Compiling:", srcfiles



if __name__ == "__main__":
MyCompiler.run()

Expand All @@ -159,6 +158,19 @@ Sample output
Include dirs: ['foo/bar', 'spam/eggs']
Compiling: ('x.cpp', 'y.cpp', 'z.cpp')

Color controls
--------------

.. code-block:: python

from plumbum import colors
with colors.red:
print("This library provides safe, flexible color access.")
print("Color", "(and styles in general)" << colors.bold, "are easy!")
print("The simple 16 colors or", '256 named colors,' << colors.orchid + colors.underline,
"or full hex colors" << colors["#129240"], 'can be used.')
print("Unsafe " + colors.bg.dark_khaki + "color access" - colors.bg + " is available too.")



.. image:: https://d2weczhvl823v0.cloudfront.net/tomerfiliba/plumbum/trend.png
Expand Down
28 changes: 28 additions & 0 deletions docs/_cheatsheet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,31 @@ Sample output
Compiling: ('x.cpp', 'y.cpp', 'z.cpp')

See :ref:`guide-cli`.

Color controls
--------------

.. code-block:: python

from plumbum import colors
with colors.red:
print("This library provides safe, flexible color access.")
print("Color", "(and styles in general)" << colors.bold, "are easy!")
print("The simple 16 colors or", '256 named colors,' << colors.orchid + color.underline,
"or full hex colors" << colors["#129240"], 'can be used.')
print("Unsafe " + colors.bg.dark_khaki + "color access" - colors.bg + " is available too.")

Sample output
+++++++++++++

.. raw:: html

<div class="highlight">
<code>
<pre><font color="#800000">This library provides safe color access.
Color <b>(and styles in general)</b> are easy!
</font>The simple 16 colors, <font color="#D75FD7"><span style="text-decoration: underline;">256 named colors,</span></font> <font color="#129240">or full hex colors</font> can be used.
Unsafe <span style="background-color: #AFAF5F">color access</span> is available too.</pre>
</code>
</div>

301 changes: 301 additions & 0 deletions docs/_color_list.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/api/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Package plumbum.cli

.. automodule:: plumbum.cli.terminal
:members:

34 changes: 34 additions & 0 deletions docs/api/colors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Package plumbum.colors
======================

.. automodule:: plumbum.colors
:members:
:special-members:

plumbum.colorlib
----------------

.. automodule:: plumbum.colorlib
:members:
:special-members:

plumbum.colorlib.styles
-----------------------

.. automodule:: plumbum.colorlib.styles
:members:
:special-members:

plumbum.colorlib.factories
--------------------------

.. automodule:: plumbum.colorlib.factories
:members:
:special-members:

plumbum.colorlib.names
----------------------

.. automodule:: plumbum.colorlib.names
:members:
:special-members:
16 changes: 16 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ class-level attributes, such as ``PROGNAME``, ``VERSION`` and ``DESCRIPTION``. F
class MyApp(cli.Application):
PROGNAME = "Foobar"
VERSION = "7.3"

Colors are supported through the class level attributes
``COLOR_PROGNAME``,
``COLOR_DISCRIPTION``,
``COLOR_VERSION``,
``COLOR_HEADING``,
``COLOR_USAGE``,
``COLOR_SUBCOMMANDS``,
``COLOR_GROUPS[]``, and
``COLOR_GROUPS_BODY[]``,
which should contain Style objects. The dictionaries support custom colors
for named groups. The default is ``colors.do_nothing``, but if you just want more
colorful defaults, subclass ``cli.ColorfulApplication``.

.. versionadded:: 1.5

Switch Functions
----------------
Expand Down Expand Up @@ -444,6 +459,7 @@ Here's an example of running this application::
committing...



See Also
--------
* `filecopy.py <https://github.com/tomerfiliba/plumbum/blob/master/examples/filecopy.py>`_ example
Expand Down
Loading