reformatted code to pep8 convention

This commit is contained in:
Guillaume Raffy 2018-08-27 14:54:55 +00:00
parent 197e94d320
commit e9f3c5a784
1 changed files with 253 additions and 258 deletions

View File

@ -6,16 +6,12 @@
This application takes its input from a database, currently in the form of an sql dump, but it could easily be adapted to read directly from a mysql database This application takes its input from a database, currently in the form of an sql dump, but it could easily be adapted to read directly from a mysql database
''' '''
import sqlite3
import os
import re import re
import sys
import pygraphviz import pygraphviz
from inventory import Inventory from inventory import Inventory
from SimpaDbUtil import SqlFile, SqlDatabaseReader from SimpaDbUtil import SqlFile, SqlDatabaseReader
def add_capacity_constraints(capacity1, capacity2): def add_capacity_constraints(capacity1, capacity2):
""" """
combines 2 capacity constraints (max amperes) together combines 2 capacity constraints (max amperes) together
@ -32,6 +28,7 @@ def add_capacity_constraints(capacity1, capacity2):
else: else:
return min(capacity1, capacity2) return min(capacity1, capacity2)
class Machine(object): class Machine(object):
""" """
represents a device with input and output power plugs. It could represent a power consumer such as a server (in which case, it has no output plug), or a power distrubtion unit (in which case, it has one input plug and more than one output plugs), or even something else... represents a device with input and output power plugs. It could represent a power consumer such as a server (in which case, it has no output plug), or a power distrubtion unit (in which case, it has one input plug and more than one output plugs), or even something else...
@ -211,7 +208,6 @@ class PowerConfig(object):
if power_consumption is not None: if power_consumption is not None:
machine.power_consumption = power_consumption machine.power_consumption = power_consumption
def get_connection_to(self, to_plug): def get_connection_to(self, to_plug):
for connection in self.connections: for connection in self.connections:
if connection.to_plug == to_plug: if connection.to_plug == to_plug:
@ -254,7 +250,6 @@ def power_config_to_svg( power_config, svg_file_path ):
graph.graph_attr['overlap'] = 'false' graph.graph_attr['overlap'] = 'false'
graph.graph_attr['splines'] = 'true' graph.graph_attr['splines'] = 'true'
graph.edge_attr['colorscheme'] = 'rdylgn9' # 'brbg11' graph.edge_attr['colorscheme'] = 'rdylgn9' # 'brbg11'
graph.node_attr['shape'] = 'box' graph.node_attr['shape'] = 'box'
graph.node_attr['height'] = 0.3 # default 0.5 inches graph.node_attr['height'] = 0.3 # default 0.5 inches
@ -280,7 +275,7 @@ def power_config_to_svg( power_config, svg_file_path ):
amperes = power_consumption / 220.0 amperes = power_consumption / 220.0
color = 'green' color = 'green'
capacity = con.get_max_amperes() capacity = con.get_max_amperes()
if capacity == None: if capacity is None:
label = '?' label = '?'
else: else:
label = str(capacity) + 'A' label = str(capacity) + 'A'