about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/core/asmbloc.py4
-rw-r--r--miasm2/core/graph.py25
-rw-r--r--miasm2/ir/ir.py15
3 files changed, 24 insertions, 20 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index dea0577b..38d3d17a 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -708,14 +708,14 @@ class AsmCFG(DiGraph):
     def node2lines(self, node):
         yield self.DotCellDescription(text=str(node.label.name),
                                       attr={'align': 'center',
-                                      'colspan': 2,
+                                            'colspan': 2,
                                             'bgcolor': 'grey'})
 
         if isinstance(node, asm_block_bad):
             yield [self.DotCellDescription(
                 text=node.ERROR_TYPES.get(node._errno,
                                           node._errno),
-                attr={})
+                                           attr={})]
             raise StopIteration
         for line in node.lines:
             if self._dot_offset:
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index f1681078..f544757d 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -3,6 +3,7 @@ import re
 
 
 class DiGraph(object):
+
     """Implementation of directed graph"""
 
     # Stand for a cell in a dot node rendering
@@ -91,7 +92,7 @@ class DiGraph(object):
     def add_uniq_edge(self, src, dst):
         """Add an edge from @src to @dst if it doesn't already exist"""
         if (src not in self._nodes_succ or
-            dst not in self._nodes_succ[src]):
+                dst not in self._nodes_succ[src]):
             self.add_edge(src, dst)
 
     def del_edge(self, src, dst):
@@ -611,6 +612,7 @@ class DiGraph(object):
 
 
 class DiGraphSimplifier(object):
+
     """Wrapper on graph simplification passes.
 
     Instance handle passes lists.
@@ -645,6 +647,7 @@ class DiGraphSimplifier(object):
 
 
 class MatchGraphJoker(object):
+
     """MatchGraphJoker are joker nodes of MatchGraph, that is to say nodes which
     stand for any node. Restrictions can be added to jokers.
 
@@ -719,6 +722,7 @@ class MatchGraphJoker(object):
 
 
 class MatchGraph(DiGraph):
+
     """MatchGraph intends to be the counterpart of MatchExpr, but for DiGraph
 
     This class provides API to match a given DiGraph pattern, with addidionnal
@@ -783,8 +787,8 @@ class MatchGraph(DiGraph):
             return False
 
         # Check arity
-        ## If filter_in/out, then arity must be the same
-        ## Otherwise, arity of the candidate must be at least equal
+        # If filter_in/out, then arity must be the same
+        # Otherwise, arity of the candidate must be at least equal
         if ((expected.restrict_in == True and
              len(self.predecessors(expected)) != len(graph.predecessors(candidate))) or
             (expected.restrict_in == False and
@@ -801,12 +805,12 @@ class MatchGraph(DiGraph):
             return True
         for pred in self.predecessors(expected):
             if (pred in partial_sol and
-                partial_sol[pred] not in graph.predecessors(candidate)):
+                    partial_sol[pred] not in graph.predecessors(candidate)):
                 return False
 
         for succ in self.successors(expected):
             if (succ in partial_sol and
-                partial_sol[succ] not in graph.successors(candidate)):
+                    partial_sol[succ] not in graph.successors(candidate)):
                 return False
 
         # All checks OK
@@ -820,11 +824,11 @@ class MatchGraph(DiGraph):
         """
         real_node = partial_sol[node]
         for candidate in propagator(self, node):
-            ## Edge already in the partial solution, skip it
+            # Edge already in the partial solution, skip it
             if candidate in partial_sol:
                 continue
 
-            ## Check candidate
+            # Check candidate
             for candidate_real in propagator(graph, real_node):
                 if self._check_node(candidate_real, candidate, graph,
                                     partial_sol):
@@ -852,8 +856,8 @@ class MatchGraph(DiGraph):
         """
         # Partial solution: nodes corrects, edges between these nodes corrects
         # A partial solution is a dictionary MatchGraphJoker -> @graph's node
-        todo = list() # Dictionnaries containing partial solution
-        done = list() # Aleady computed partial solutions
+        todo = list()  # Dictionnaries containing partial solution
+        done = list()  # Aleady computed partial solutions
 
         # Elect first candidates
         to_match = next(iter(self._nodes))
@@ -869,7 +873,8 @@ class MatchGraph(DiGraph):
             # -> using last entry of todo first performs a "depth first"
             # approach on solutions
             # -> the algorithm may converge faster to a solution, a desired
-            # behavior while doing graph simplification (stopping after one sol)
+            # behavior while doing graph simplification (stopping after one
+            # sol)
             partial_sol = todo.pop()
 
             # Avoid infinite loop and recurrent work
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py
index 35054f50..122ce6d0 100644
--- a/miasm2/ir/ir.py
+++ b/miasm2/ir/ir.py
@@ -30,7 +30,7 @@ from miasm2.core.graph import DiGraph
 
 class irbloc(object):
 
-    def __init__(self, label, irs, lines = []):
+    def __init__(self, label, irs, lines=[]):
         assert(isinstance(label, asm_label))
         self.label = label
         self.irs = irs
@@ -39,7 +39,6 @@ class irbloc(object):
         self._dst = None
         self._dst_linenb = None
 
-
     def _get_dst(self):
         """Find the IRDst affectation and update dst, dst_linenb accordingly"""
         if self._dst is not None:
@@ -121,6 +120,7 @@ class irbloc(object):
 
 
 class DiGraphIR(DiGraph):
+
     """DiGraph for IR instances"""
 
     def __init__(self, blocks, *args, **kwargs):
@@ -174,6 +174,7 @@ class DiGraphIR(DiGraph):
         self._dot_offset = offset
         return super(DiGraphIR, self).dot()
 
+
 class ir(object):
 
     def __init__(self, arch, attrib, symbol_pool=None):
@@ -197,7 +198,7 @@ class ir(object):
         @ad: an ExprId/ExprInt/label/int"""
 
         if (isinstance(ad, m2_expr.ExprId) and
-            isinstance(ad.name, asm_label)):
+                isinstance(ad.name, asm_label)):
             ad = ad.name
         if isinstance(ad, m2_expr.ExprInt):
             ad = int(ad.arg)
@@ -214,7 +215,7 @@ class ir(object):
         label = self.get_label(ad)
         return self.blocs.get(label, None)
 
-    def add_instr(self, l, ad=0, gen_pc_updt = False):
+    def add_instr(self, l, ad=0, gen_pc_updt=False):
         b = asm_bloc(self.gen_label())
         b.lines = [l]
         self.add_bloc(b, gen_pc_updt)
@@ -275,7 +276,6 @@ class ir(object):
             # Add the merged one
             affect_list.append(m2_expr.ExprAff(dst, final_dst))
 
-
     def getby_offset(self, offset):
         out = set()
         for irb in self.blocs.values():
@@ -289,7 +289,7 @@ class ir(object):
                                                                     l.offset))])
         c.lines.append(l)
 
-    def add_bloc(self, bloc, gen_pc_updt = False):
+    def add_bloc(self, bloc, gen_pc_updt=False):
         c = None
         ir_blocs_all = []
         for l in bloc.lines:
@@ -305,7 +305,6 @@ class ir(object):
             c.irs.append(ir_bloc_cur)
             c.lines.append(l)
 
-
             if ir_blocs_extra:
                 for b in ir_blocs_extra:
                     b.lines = [l] * len(b.irs)
@@ -385,7 +384,7 @@ class ir(object):
             for i, l in enumerate(irs):
                 irs[i] = l.replace_expr(rep)
 
-    def get_rw(self, regs_ids = []):
+    def get_rw(self, regs_ids=[]):
         """
         Calls get_rw(irb) for each bloc
         @regs_ids : ids of registers used in IR