Package portage :: Module output
[hide private]

Module output

source code

Classes [hide private]
  create_color_func
  ConsoleStyleFile
A file-like object that behaves something like the colorize() function.
  StyleWriter
This is just a DumbWriter with a hook in the new_styles() method that passes a styles tuple as a single argument to a callable style_listener attribute.
  EOutput
Performs fancy terminal formatting for status and informational messages.
  ProgressBar
The interface is copied from the ProgressBar class from the EasyDialogs module (which is Mac only).
  TermProgressBar
A tty progress bar similar to wget's.
  _LazyInitColorMap
Functions [hide private]
 
color(fg, bg='default', attr=['normal']) source code
dict
_parse_color_map(config_root='/', onerror=None)
Parse /etc/portage/color.map and return a dict of error codes.
source code
 
nc_len(mystr) source code
 
xtermTitle(mystr, raw=False) source code
 
xtermTitleReset() source code
 
notitles()
turn off title setting
source code
 
nocolor()
turn off colorization
source code
 
resetColor() source code
String
style_to_ansi_code(style)
Returns: A string containing one or more ansi escape codes that are used to render the given style.
source code
 
colormap() source code
 
colorize(color_key, text) source code
 
get_term_size(fd=None)
Get the number of lines and columns of the tty that is connected to fd.
source code
 
set_term_size(lines, columns, fd)
Set the number of lines and columns for the tty that is connected to fd.
source code
 
_init(config_root='/')
Load color.map from the given config_root.
source code
Variables [hide private]
  havecolor = 1
  dotitles = 1
  esc_seq = '\x1b['
  ansi_codes = ['30m', '30;01m', '31m', '31;01m', '32m', '32;01m...
  rgb_ansi_colors = ['0x000000', '0x555555', '0xAA0000', '0xFF55...
  _legal_terms_re = re.compile(r'^(xterm|xterm-color|Eterm|aterm...
  _disable_xtermTitle = None
hash(x)
  _max_xtermTitle_len = 253
  default_xterm_title = None
hash(x)
  compat_functions_colors = ['bold', 'white', 'teal', 'turquoise...
  _color_map_loaded = True
  codes = {'0x000000': u'', '0x0000AA': u'', '0x00AA00...
Maps attribute name to ansi code.
  _styles = {'BAD': ('red'), 'BRACKET': ('blue'), 'GOOD': ('gree...
Maps style class to tuple of attribute names.
  __package__ = 'portage'
  blue = <portage.output.create_color_func object at 0x8b048cc>
  bold = <portage.output.create_color_func object at 0x8b0483c>
  brown = <portage.output.create_color_func object at 0x8b04944>
  c = 'darkred'
  darkblue = <portage.output.create_color_func object at 0x8b048e4>
  darkgreen = <portage.output.create_color_func object at 0x8b04...
  darkred = <portage.output.create_color_func object at 0x8b049a4>
  darkteal = <portage.output.create_color_func object at 0x8b047f4>
  darkyellow = <portage.output.create_color_func object at 0x8b0...
  fuchsia = <portage.output.create_color_func object at 0x8b0489c>
  green = <portage.output.create_color_func object at 0x8b048fc>
  purple = <portage.output.create_color_func object at 0x8b048b4>
  red = <portage.output.create_color_func object at 0x8b04974>
  teal = <portage.output.create_color_func object at 0x8b04854>
  turquoise = <portage.output.create_color_func object at 0x8b04...
  white = <portage.output.create_color_func object at 0x8b04764>
  yellow = <portage.output.create_color_func object at 0x8b0492c>

Imports: errno, io, formatter, re, subprocess, sys, portage, os, _encodings, _unicode_encode, _unicode_decode, COLOR_MAP_FILE, CommandNotFound, FileNotFound, ParseError, PermissionDenied, PortageException, _, writemsg


Function Details [hide private]

_parse_color_map(config_root='/', onerror=None)

source code 

Parse /etc/portage/color.map and return a dict of error codes.

Parameters:
  • onerror (callable) - an optional callback to handle any ParseError that would otherwise be raised
Returns: dict
a dictionary mapping color classes to color codes

style_to_ansi_code(style)

source code 
Parameters:
  • style (String) - A style name
Returns: String
A string containing one or more ansi escape codes that are used to render the given style.

get_term_size(fd=None)

source code 

Get the number of lines and columns of the tty that is connected to fd. Returns a tuple of (lines, columns) or (0, 0) if an error occurs. The curses module is used if available, otherwise the output of `stty size` is parsed. The lines and columns values are guaranteed to be greater than or equal to zero, since a negative COLUMNS variable is known to prevent some commands from working (see bug #394091).

set_term_size(lines, columns, fd)

source code 

Set the number of lines and columns for the tty that is connected to fd. For portability, this simply calls `stty rows $lines columns $columns`.

_init(config_root='/')

source code 

Load color.map from the given config_root. This is called automatically on first access of the codes or _styles attributes (unless it has already been called for some other reason).


Variables Details [hide private]

ansi_codes

Value:
['30m',
 '30;01m',
 '31m',
 '31;01m',
 '32m',
 '32;01m',
 '33m',
 '33;01m',
...

rgb_ansi_colors

Value:
['0x000000',
 '0x555555',
 '0xAA0000',
 '0xFF5555',
 '0x00AA00',
 '0x55FF55',
 '0xAA5500',
 '0xFFFF55',
...

_legal_terms_re

Value:
re.compile(r'^(xterm|xterm-color|Eterm|aterm|rxvt|screen|kterm|rxvt-un\
icode|gnome|interix)')

compat_functions_colors

Value:
['bold',
 'white',
 'teal',
 'turquoise',
 'darkteal',
 'fuchsia',
 'purple',
 'blue',
...

codes

Maps attribute name to ansi code.

Value:
{'0x000000': u'',
 '0x0000AA': u'',
 '0x00AA00': u'',
 '0x00AAAA': u'',
 '0x555555': u'',
 '0x5555FF': u'',
 '0x55FF55': u'',
 '0x55FFFF': u'',
...

_styles

Maps style class to tuple of attribute names.

Value:
{'BAD': ('red'),
 'BRACKET': ('blue'),
 'GOOD': ('green'),
 'HILITE': ('teal'),
 'INFORM': ('darkgreen'),
 'MERGE_LIST_PROGRESS': ('yellow'),
 'NORMAL': ('normal'),
 'PKG_BINARY_MERGE': ('purple'),
...

darkgreen

Value:
<portage.output.create_color_func object at 0x8b0405c>

darkyellow

Value:
<portage.output.create_color_func object at 0x8b0495c>

turquoise

Value:
<portage.output.create_color_func object at 0x8b0486c>