Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better practice to use os.path.pathsep, thank you Alexis

  • Loading branch information...
commit fb54a992f98942f36da78a633518878a6c36c4f1 1 parent 917e04d
Morten M. Neergaard authored
Showing with 5 additions and 8 deletions.
  1. +3 −3 nltk/classify/mallet.py
  2. +2 −5 nltk/internals.py
6 nltk/classify/mallet.py
View
@@ -23,7 +23,7 @@
import os
import os.path
-from nltk.internals import find_binary, java, CLASSPATH_SEP
+from nltk.internals import find_binary, java
######################################################################
#{ Configuration
@@ -57,7 +57,7 @@ def config_mallet(mallet_home=None):
if not os.path.isdir(lib_dir):
raise ValueError('While configuring mallet: directory %r '
'not found.' % lib_dir)
- _mallet_classpath = CLASSPATH_SEP.join([os.path.join(lib_dir, filename)
+ _mallet_classpath = os.path.pathsep.join([os.path.join(lib_dir, filename)
for filename in sorted(os.listdir(lib_dir))
if filename.endswith('.jar')])
@@ -78,6 +78,6 @@ def call_mallet(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
if classpath is None:
classpath = _mallet_classpath
else:
- classpath += CLASSPATH_SEP + _mallet_classpath
+ classpath += os.path.pathsep + _mallet_classpath
# Delegate to java()
return java(cmd, classpath, stdin, stdout, stderr, blocking)
7 nltk/internals.py
View
@@ -68,9 +68,6 @@ def subfunc(m):
_java_bin = None
_java_options = []
-CLASSPATH_SEP = ':'
-if os.name == 'nt':
- CLASSPATH_SEP = ';'
# [xx] add classpath option to config_java?
def config_java(bin=None, options=None, verbose=True):
"""
@@ -152,7 +149,7 @@ def java(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
if classpath is None:
classpath = NLTK_JAR
else:
- classpath += CLASSPATH_SEP + NLTK_JAR
+ classpath += os.path.pathsep + NLTK_JAR
# Construct the full command string.
cmd = list(cmd)
@@ -569,7 +566,7 @@ def find_jar(name, path_to_jar=None, env_vars=(),
if env_var in os.environ:
if env_var == 'CLASSPATH':
classpath = os.environ['CLASSPATH']
- for cp in classpath.split(CLASSPATH_SEP):
+ for cp in classpath.split(os.path.pathsep):
if os.path.isfile(cp) and os.path.basename(cp) == name:
if verbose: print '[Found %s: %s]' % (name, cp)
return cp
Please sign in to comment.
Something went wrong with that request. Please try again.