aboutsummaryrefslogtreecommitdiffstats
path: root/string_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'string_utils.py')
-rw-r--r--string_utils.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/string_utils.py b/string_utils.py
index c4439da..12d22b8 100644
--- a/string_utils.py
+++ b/string_utils.py
@@ -172,9 +172,14 @@ def alignment_to_sexp(alignment, sexp, l2):
if index == -1:
break
else:
- re.sub("(?P<begin>\d+ \d+ \d+ \d+\s) \w+(?P<end>\)+$)",
- "\g<begin>{0}\g<end>".format(
- " ".join([l2[i] for i in list(index)])),
- line)
- line.encode('string-escape')
+ if type(index) == tuple:
+ word = " ".join([l2[i] for i in list(index)])
+ else:
+ try:
+ word = l2[index]
+ except IndexError:
+ print index
+ word = word.encode("utf-8").encode("string-escape")
+ re.sub("(?P<begin>\d+ \d+ \d+ \d+\s) \w+(?P<end>\)+$)",
+ "\g<begin>{0}\g<end>".format(word), line)
print line