summaryrefslogtreecommitdiff
path: root/monkey/util.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-02 18:39:17 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-02 18:39:17 +0100
commit3af76b914dc48f7c729b34d8605bb2ad51a5156b (patch)
tree119abc3510895f20419c3177309a2ffc043933fa /monkey/util.py
parent1c76b686a5896950b0037e773d5229e401e980b3 (diff)
Improve hints returned by monkey.fix_hints
Diffstat (limited to 'monkey/util.py')
-rw-r--r--monkey/util.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/monkey/util.py b/monkey/util.py
index 655cca9..3940f84 100644
--- a/monkey/util.py
+++ b/monkey/util.py
@@ -63,6 +63,18 @@ def get_line(text, n):
return lines[n]
return None
+# Does sequence [a] begin with sequence [b]?
+def startswith(a, b):
+ if len(a) < len(b):
+ return False
+ return all(x == y for x, y in zip(a, b))
+
+# Does sequence [a] end with sequence [b]?
+def endswith(a, b):
+ if len(a) < len(b):
+ return False
+ return all(x == y for x, y in zip(reversed(a), reversed(b)))
+
# Indent each line in [text] by [indent] spaces.
def indent(text, indent=2):
return '\n'.join([' '*indent+line for line in text.split('\n')])