Skip to content

Commit 4e43934

Browse files
committed
fix command-line scrapely.tool usage that was broken by previous commit
1 parent f2d780e commit 4e43934

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scrapely/tool.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def do_t(self, line):
5151

5252
def do_a(self, line):
5353
"""a <template> <data> [-n number] [-f field]- add or test annotation
54-
54+
5555
Add a new annotation (if -f is passed) or test what would be annotated
5656
otherwise
5757
"""
@@ -78,7 +78,7 @@ def do_al(self, template_id):
7878
t = self._load_template(template_id)
7979
tm = TemplateMaker(t)
8080
for n, (a, i) in enumerate(tm.annotations()):
81-
print "[%s-%d] (%s) %r" % (template_id, n, a['annotations']['content'],
81+
print "[%s-%d] (%s) %r" % (template_id, n, a['annotations']['content'],
8282
remove_annotation(tm.selected_data(i)))
8383

8484
def do_s(self, url):
@@ -133,7 +133,9 @@ def _parse_criteria(self, criteria_str):
133133
p.add_option('-f', '--field', help='field to annotate')
134134
p.add_option('-n', '--number', type="int", help='number of result to select')
135135
o, a = p.parse_args(shlex.split(criteria_str))
136-
o.text = ' '.join(a).decode(self.stdin.encoding or 'ascii')
136+
137+
encoding = getattr(self.stdin, 'encoding', None) or sys.stdin.encoding
138+
o.text = ' '.join(a).decode(encoding or 'ascii')
137139
return o
138140

139141

0 commit comments

Comments
 (0)