Commit 4d28ad16 authored by Philip ABBET's avatar Philip ABBET

Force 4-spaces indentation

parent 37e667d7
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -29,112 +29,112 @@
'''Utilities for drawing toolchains and experiments'''
def text_color(c):
'''Calculates if text must be black/white for a given color background
'''Calculates if text must be black/white for a given color background
The technique deployed in this function calculates the perceptive luminance
for a given color and then choses a black or white color depending on that
value.
The technique deployed in this function calculates the perceptive luminance
for a given color and then choses a black or white color depending on that
value.
Parameters:
Parameters:
c (str): A color definition in the format ``#rrggbb``, in which each color
channel is represented by 2-digit hexadecimal number ranging from 0x0 to
0xff.
c (str): A color definition in the format ``#rrggbb``, in which each color
channel is represented by 2-digit hexadecimal number ranging from 0x0 to
0xff.
Returns:
Returns:
str: Either ``#000000`` (black) or ``#ffffff`` (white) depending on which
better text color would go with the given color.
str: Either ``#000000`` (black) or ``#ffffff`` (white) depending on which
better text color would go with the given color.
'''
'''
c = int(c[1:3], 16), int(c[3:5], 16), int(c[5:], 16)
a = 1 - (0.299 * c[0] + 0.587 * c[1] + 0.114 * c[2])/255;
if a < 0.5: return '#000000'
else: return '#ffffff'
c = int(c[1:3], 16), int(c[3:5], 16), int(c[5:], 16)
a = 1 - (0.299 * c[0] + 0.587 * c[1] + 0.114 * c[2])/255;
if a < 0.5: return '#000000'
else: return '#ffffff'
def lighten_color(n):
'''Lightens the given color
'''Lightens the given color
Parameters:
Parameters:
c (str): A color definition in the format ``#rrggbb``, in which each color
channel is represented by 2-digit hexadecimal number ranging from 0x0 to
0xff.
c (str): A color definition in the format ``#rrggbb``, in which each color
channel is represented by 2-digit hexadecimal number ranging from 0x0 to
0xff.
Returns:
Returns:
str: The hexadecimal representation of the lightened color.
str: The hexadecimal representation of the lightened color.
'''
'''
c = int(n[1:3], 16), int(n[3:5], 16), int(n[5:], 16)
c = [k+120 for k in c]
c = map(lambda k: k if k <= 0xff else 0xff, c)
return '#%02x%02x%02x' % tuple(c)
c = int(n[1:3], 16), int(n[3:5], 16), int(n[5:], 16)
c = [k+120 for k in c]
c = map(lambda k: k if k <= 0xff else 0xff, c)
return '#%02x%02x%02x' % tuple(c)
def create_port_table(type, names, color):
'''Creates an HTML table with the defined port names
'''Creates an HTML table with the defined port names
Parameters:
Parameters:
type (str): The type of port - maybe set to 'input', 'output' or 'result'
type (str): The type of port - maybe set to 'input', 'output' or 'result'
names (str): A set of strings that define the contents of each port
names (str): A set of strings that define the contents of each port
color (str): A color definition in the format ``#rrggbb``, in which each
color channel is represented by 2-digit hexadecimal number ranging from
0x0 to 0xff.
color (str): A color definition in the format ``#rrggbb``, in which each
color channel is represented by 2-digit hexadecimal number ranging from
0x0 to 0xff.
Returns
Returns
str: A string containing the HTML representation for the table, compatible
with GraphViz.
str: A string containing the HTML representation for the table, compatible
with GraphViz.
'''
'''
retval = '<td><table border="0" cellspacing="5" bgcolor="%s">' % \
lighten_color(color)
for n in names:
port = 'port="%s_%s" ' % (type, n) if n.find('<') < 0 else '' #results
retval += '<tr><td %sbgcolor="%s" border="1"><font color="%s">%s</font></td></tr>' % (port, color, text_color(color), n)
retval += '</table></td>'
return retval
retval = '<td><table border="0" cellspacing="5" bgcolor="%s">' % \
lighten_color(color)
for n in names:
port = 'port="%s_%s" ' % (type, n) if n.find('<') < 0 else '' #results
retval += '<tr><td %sbgcolor="%s" border="1"><font color="%s">%s</font></td></tr>' % (port, color, text_color(color), n)
retval += '</table></td>'
return retval
def make_label(inputs, name, outputs, color):
'''Creates an HTML Table representing the label for a given block
'''Creates an HTML Table representing the label for a given block
Parameters:
Parameters:
inputs (list): A list of input names which represent all inputs for this
block
inputs (list): A list of input names which represent all inputs for this
block
name (str): The name of the block
name (str): The name of the block
outputs (list): A list of output names which represent all outputs for this
block
outputs (list): A list of output names which represent all outputs for this
block
color (str): A color definition in the format ``#rrggbb``, in which each
color channel is represented by 2-digit hexadecimal number ranging from
0x0 to 0xff.
color (str): A color definition in the format ``#rrggbb``, in which each
color channel is represented by 2-digit hexadecimal number ranging from
0x0 to 0xff.
Returns
Returns
str: A string containing the HTML representation for the table, compatible
with GraphViz.
str: A string containing the HTML representation for the table, compatible
with GraphViz.
'''
'''
light_color = lighten_color(color)
retval = '<<table border="0" cellspacing="0" bgcolor="%s"><tr>' % light_color
if inputs: retval += create_port_table('input', inputs, color)
retval += '<td><font color="%s">%s</font></td>' % \
(text_color(light_color), name)
if outputs: retval += create_port_table('output', outputs, color)
retval += '</tr></table>>'
return retval
light_color = lighten_color(color)
retval = '<<table border="0" cellspacing="0" bgcolor="%s"><tr>' % light_color
if inputs: retval += create_port_table('input', inputs, color)
retval += '<td><font color="%s">%s</font></td>' % \
(text_color(light_color), name)
if outputs: retval += create_port_table('output', outputs, color)
retval += '</tr></table>>'
return retval
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -45,8 +45,8 @@ else:
def teardown_package():
if os.path.exists(tmp_prefix):
shutil.rmtree(tmp_prefix)
if os.path.exists(tmp_prefix):
shutil.rmtree(tmp_prefix)
if os.path.exists(os.path.join(prefix, '.beat')):
shutil.rmtree(os.path.join(prefix, '.beat'))
if os.path.exists(os.path.join(prefix, '.beat')):
shutil.rmtree(os.path.join(prefix, '.beat'))
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -30,10 +30,10 @@ import nose.tools
from ..stats import Statistics
def test_prototype():
obj = Statistics() #creates from prototype
obj = Statistics() #creates from prototype
assert 'cpu' in obj._data
assert 'memory' in obj._data
assert 'data' in obj._data
assert 'files' in obj.data
nose.tools.eq_(len(obj.data['files']), 0)
assert 'cpu' in obj._data
assert 'memory' in obj._data
assert 'data' in obj._data
assert 'files' in obj.data
nose.tools.eq_(len(obj.data['files']), 0)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment