String changes to meet PEP8 standards.

Except max line length of 100.

Also use escaping to fix long lines.
This commit is contained in:
Chris PeBenito 2015-02-12 14:01:44 -05:00
parent 2d1c9184ed
commit 15a8b2de2c
7 changed files with 26 additions and 17 deletions

5
sedta
View File

@ -66,8 +66,9 @@ def print_transition(trans, entrypoints, setexec, dyntrans, setcur):
print()
parser = argparse.ArgumentParser(description="SELinux policy domain transition analysis tool.",
epilog="If no analysis algorithm is selected, all transitions out of a domain will be calculated.")
parser = argparse.ArgumentParser(
description="SELinux policy domain transition analysis tool.",
epilog="If no analysis is selected, all forward transitions out of the source will be printed.")
parser.add_argument("--version", action="version", version=setools.__version__)
parser.add_argument(
"-p", "--policy", help="Path to SELinux policy to analyze.", required=True)

View File

@ -22,8 +22,9 @@ import setools
import argparse
import sys
parser = argparse.ArgumentParser(description="SELinux policy information flow analysis tool.",
epilog="If no analysis algorithm is selected, all information flow out of the source domain will be calculated.")
parser = argparse.ArgumentParser(
description="SELinux policy information flow analysis tool.",
epilog="If no analysis is selected, all information flow out of the source will be printed.")
parser.add_argument("--version", action="version", version=setools.__version__)
parser.add_argument("--stats", action="store_true",
help="Display statistics at the end of the analysis.")

View File

@ -78,7 +78,7 @@ class InfoFlowAnalysis(object):
"""
if not isinstance(perm_map, (str, permmap.PermissionMap)):
raise TypeError(
"Permission map must be a permission map object or a path to a permission map file.")
"Permission map must be an object or a path to a file.")
if isinstance(perm_map, str):
self.perm_map = permmap.PermissionMap(perm_map)

View File

@ -77,8 +77,9 @@ class PermissionMap(object):
format(permmapfile, line_num, entry[0]))
if num_classes < 1:
SyntaxError("{0}:{1}:Number of classes must be positive: {2}".format(
permmapfile, line_num, entry[2]))
SyntaxError(
"{0}:{1}:Number of classes must be 1-32: {2}".
format(permmapfile, line_num, entry[2]))
state = 2
@ -93,12 +94,14 @@ class PermissionMap(object):
try:
num_perms = int(entry[2])
except ValueError:
raise SyntaxError("{0}:{1}:Invalid number of permissions: {2}".format(
permmapfile, line_num, entry[2]))
raise SyntaxError(
"{0}:{1}:Invalid number of permissions: {2}".
format(permmapfile, line_num, entry[2]))
if num_perms < 1:
SyntaxError("{0}:{1}:Number of permissions must be positive: {2}".format(
permmapfile, line_num, entry[2]))
SyntaxError(
"{0}:{1}:Number of permissions must be 1-32: {2}".
format(permmapfile, line_num, entry[2]))
class_count += 1
perm_count = 0
@ -116,12 +119,14 @@ class PermissionMap(object):
try:
weight = int(entry[2])
except ValueError:
SyntaxError("{0}:{1}:Invalid information flow weight: {2}".format(
permmapfile, line_num, entry[2]))
SyntaxError(
"{0}:{1}:Invalid permission weight: {2}".
format(permmapfile, line_num, entry[2]))
if not self.min_weight <= weight <= self.max_weight:
SyntaxError(
"{0}:{1}:Information flow weight must be 1-10: {2}".format(permmapfile, line_num, entry[2]))
"{0}:{1}:Permission weight must be 1-10: {2}".
format(permmapfile, line_num, entry[2]))
self.permmap[class_name][perm_name] = (
flow_direction, weight)

View File

@ -84,7 +84,8 @@ class ConditionalExpr(symbol.PolicySymbol):
for expr_node in self.qpol_symbol.expr_node_iter(self.policy):
expr_node_type = expr_node.expr_type(self.policy)
if expr_node_type == qpol.QPOL_COND_EXPR_BOOL and other == boolean_factory(self.policy, expr_node.get_boolean(self.policy)):
if expr_node_type == qpol.QPOL_COND_EXPR_BOOL and other == \
boolean_factory(self.policy, expr_node.get_boolean(self.policy)):
return True
return False

View File

@ -28,7 +28,8 @@ def _is_mls(policy, symbol):
sym_type = expr_node.sym_type(policy)
expr_type = expr_node.expr_type(policy)
if expr_type == qpol.QPOL_CEXPR_TYPE_ATTR and sym_type >= qpol.QPOL_CEXPR_SYM_L1L2:
if expr_type == qpol.QPOL_CEXPR_TYPE_ATTR and \
sym_type >= qpol.QPOL_CEXPR_SYM_L1L2:
return True
return False

View File

@ -162,7 +162,7 @@ class PortconQuery(compquery.ComponentQuery, contextquery.ContextQuery):
if (pending_ports[0] > pending_ports[1]):
raise ValueError(
"The low port of the range must be smaller than the high port: {0[0]}-{0[1]}".format(ports))
"The low port must be smaller than the high port: {0[0]}-{0[1]}".format(ports))
self.ports = pending_ports