Jelajahi Sumber

Forced usage of Leaf stringification in line generator.

This allows for overwriting of the stringification method. To be able to
introduce utf-8 version of the PI-character, for example.
Taddeus Kroes 14 tahun lalu
induk
melakukan
d7b3096197
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      line.py

+ 4 - 4
line.py

@@ -98,7 +98,7 @@ def generate_line(root):
         return '<empty expression>'
 
     if root.is_leaf:
-        return '-' * root.negated + root.title()
+        return str(root)
 
     content = {}
 
@@ -194,7 +194,7 @@ def generate_line(root):
     # the leafs and nodes in depth first order.
     for node in traverse_depth_first(root):
         if node.is_leaf:
-            content[node] = node.title()
+            content[node] = str(node)
         else:
             arity = len(node)
 
@@ -206,8 +206,8 @@ def generate_line(root):
             else:
                 content[node] = construct_function(node)
 
-        # Add negations
-        content[node] = '-' * node.negated + content[node]
+            # Add negations
+            content[node] = '-' * node.negated + content[node]
 
     # Merge binary plus and unary minus signs into binary minus.
     return content[root].replace('+ -', '- ')