Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit fb54a992f98942f36da78a633518878a6c36c4f1 1 parent 917e04d
Morten M. Neergaard authored

Showing 2 changed files with 5 additions and 8 deletions. Show diff stats Hide diff stats

  1. +3 3 nltk/classify/mallet.py
  2. +2 5 nltk/internals.py
6 nltk/classify/mallet.py
@@ -23,7 +23,7 @@
23 23 import os
24 24 import os.path
25 25
26   -from nltk.internals import find_binary, java, CLASSPATH_SEP
  26 +from nltk.internals import find_binary, java
27 27
28 28 ######################################################################
29 29 #{ Configuration
@@ -57,7 +57,7 @@ def config_mallet(mallet_home=None):
57 57 if not os.path.isdir(lib_dir):
58 58 raise ValueError('While configuring mallet: directory %r '
59 59 'not found.' % lib_dir)
60   - _mallet_classpath = CLASSPATH_SEP.join([os.path.join(lib_dir, filename)
  60 + _mallet_classpath = os.path.pathsep.join([os.path.join(lib_dir, filename)
61 61 for filename in sorted(os.listdir(lib_dir))
62 62 if filename.endswith('.jar')])
63 63
@@ -78,6 +78,6 @@ def call_mallet(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
78 78 if classpath is None:
79 79 classpath = _mallet_classpath
80 80 else:
81   - classpath += CLASSPATH_SEP + _mallet_classpath
  81 + classpath += os.path.pathsep + _mallet_classpath
82 82 # Delegate to java()
83 83 return java(cmd, classpath, stdin, stdout, stderr, blocking)
7 nltk/internals.py
@@ -68,9 +68,6 @@ def subfunc(m):
68 68
69 69 _java_bin = None
70 70 _java_options = []
71   -CLASSPATH_SEP = ':'
72   -if os.name == 'nt':
73   - CLASSPATH_SEP = ';'
74 71 # [xx] add classpath option to config_java?
75 72 def config_java(bin=None, options=None, verbose=True):
76 73 """
@@ -152,7 +149,7 @@ def java(cmd, classpath=None, stdin=None, stdout=None, stderr=None,
152 149 if classpath is None:
153 150 classpath = NLTK_JAR
154 151 else:
155   - classpath += CLASSPATH_SEP + NLTK_JAR
  152 + classpath += os.path.pathsep + NLTK_JAR
156 153
157 154 # Construct the full command string.
158 155 cmd = list(cmd)
@@ -569,7 +566,7 @@ def find_jar(name, path_to_jar=None, env_vars=(),
569 566 if env_var in os.environ:
570 567 if env_var == 'CLASSPATH':
571 568 classpath = os.environ['CLASSPATH']
572   - for cp in classpath.split(CLASSPATH_SEP):
  569 + for cp in classpath.split(os.path.pathsep):
573 570 if os.path.isfile(cp) and os.path.basename(cp) == name:
574 571 if verbose: print '[Found %s: %s]' % (name, cp)
575 572 return cp

0 comments on commit fb54a99

Please sign in to comment.
Something went wrong with that request. Please try again.