Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
bc55ae9d
Commit
bc55ae9d
authored
Nov 07, 2014
by
Dmitrijs Milajevs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:nltk/nltk into bleu_fix
parents
f83dfc58
c5b21333
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
nltk/internals.py
+11
-2
No files found.
nltk/internals.py
View file @
bc55ae9d
...
@@ -16,6 +16,7 @@ import textwrap
...
@@ -16,6 +16,7 @@ import textwrap
import
types
import
types
import
sys
import
sys
import
stat
import
stat
import
locale
# Use the c version of ElementTree, which is faster, if possible:
# Use the c version of ElementTree, which is faster, if possible:
try
:
try
:
...
@@ -156,7 +157,7 @@ def java(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
...
@@ -156,7 +157,7 @@ def java(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
# Check the return code.
# Check the return code.
if
p
.
returncode
!=
0
:
if
p
.
returncode
!=
0
:
print
(
stderr
.
decode
(
sys
.
stdout
.
encoding
))
print
(
_decode_stdoutdata
(
stderr
))
raise
OSError
(
'Java command failed!'
)
raise
OSError
(
'Java command failed!'
)
return
(
stdout
,
stderr
)
return
(
stdout
,
stderr
)
...
@@ -492,7 +493,7 @@ def find_file_iter(filename, env_vars=(), searchpath=(),
...
@@ -492,7 +493,7 @@ def find_file_iter(filename, env_vars=(), searchpath=(),
try
:
try
:
p
=
subprocess
.
Popen
([
'which'
,
alternative
],
stdout
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
([
'which'
,
alternative
],
stdout
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
stdout
,
stderr
=
p
.
communicate
()
path
=
stdout
.
decode
(
sys
.
stdout
.
encoding
)
.
strip
()
path
=
_decode_stdoutdata
(
stdout
)
.
strip
()
if
path
.
endswith
(
alternative
)
and
os
.
path
.
exists
(
path
):
if
path
.
endswith
(
alternative
)
and
os
.
path
.
exists
(
path
):
if
verbose
:
if
verbose
:
print
(
'[Found
%
s:
%
s]'
%
(
filename
,
path
))
print
(
'[Found
%
s:
%
s]'
%
(
filename
,
path
))
...
@@ -643,6 +644,14 @@ def find_jar(name_pattern, path_to_jar=None, env_vars=(),
...
@@ -643,6 +644,14 @@ def find_jar(name_pattern, path_to_jar=None, env_vars=(),
return
next
(
find_jar_iter
(
name_pattern
,
path_to_jar
,
env_vars
,
return
next
(
find_jar_iter
(
name_pattern
,
path_to_jar
,
env_vars
,
searchpath
,
url
,
verbose
,
is_regex
))
searchpath
,
url
,
verbose
,
is_regex
))
def
_decode_stdoutdata
(
stdoutdata
):
""" Convert data read from stdout/stderr to unicode """
if
not
isinstance
(
stdoutdata
,
bytes
):
return
stdoutdata
encoding
=
getattr
(
sys
.
stdout
,
"encoding"
,
locale
.
getpreferredencoding
())
return
stdoutdata
.
decode
(
encoding
)
##########################################################################
##########################################################################
# Import Stdlib Module
# Import Stdlib Module
##########################################################################
##########################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment