Skip to content

Commit

Permalink
added option to process piped input line-by-line
Browse files Browse the repository at this point in the history
  • Loading branch information
saffsd committed Jan 10, 2013
1 parent 2d2fffb commit 3419b0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion langid/langid.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def application(environ, start_response):
parser.add_option('--demo',action="store_true", default=False, help='launch an in-browser demo application')
parser.add_option('-d', '--dist', action='store_true', default=False, help='show full distribution over languages')
parser.add_option('-u', '--url', help='langid of URL')
parser.add_option('--line', action="store_true", default=False, help='process pipes line-by-line rather than as a document')
options, args = parser.parse_args()

if options.verbosity:
Expand Down Expand Up @@ -504,7 +505,11 @@ def generate_paths():
print _process(text)
else:
# Redirected
print _process(sys.stdin.read())
if options.line:
for line in sys.stdin.readlines():
print _process(line)
else:
print _process(sys.stdin.read())

else:
# Running as an imported module; unpack the internal model
Expand Down

0 comments on commit 3419b0e

Please sign in to comment.