Permalink
Browse files

added option to process piped input line-by-line

  • Loading branch information...
1 parent 2d2fffb commit 3419b0e9288a42d0f65b798b230f3fae01bd9fca @saffsd committed Jan 10, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 langid/langid.py
View
7 langid/langid.py 100755 → 100644
@@ -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:
@@ -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

0 comments on commit 3419b0e

Please sign in to comment.