Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
import importlib | ||
import sys | ||
import os | ||
|
||
|
||
if __name__ == '__main__': | ||
import importlib | ||
def get_chatterbot_version(): | ||
chatterbot = importlib.import_module('chatterbot') | ||
return chatterbot.__version__ | ||
|
||
if '--version' in sys.argv: | ||
chatterbot = importlib.import_module('chatterbot') | ||
print(chatterbot.__version__) | ||
|
||
if 'list_nltk_data' in sys.argv: | ||
import os | ||
import nltk.data | ||
def get_nltk_data_directories(): | ||
import nltk.data | ||
|
||
data_directories = [] | ||
|
||
# Find each data directory in the NLTK path that has content | ||
for path in nltk.data.path: | ||
if os.path.exists(path): | ||
if os.listdir(path): | ||
data_directories.append(path) | ||
|
||
data_directories = [] | ||
return os.linesep.join(data_directories) | ||
|
||
# Find each data directory in the NLTK path that has content | ||
for path in nltk.data.path: | ||
if os.path.exists(path): | ||
if os.listdir(path): | ||
data_directories.append(path) | ||
|
||
print(os.linesep.join(data_directories)) | ||
if __name__ == '__main__': | ||
if '--version' in sys.argv: | ||
print(get_chatterbot_version()) | ||
|
||
if 'list_nltk_data' in sys.argv: | ||
print(get_nltk_data_directories()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from unittest import TestCase | ||
from chatterbot import __version__ | ||
from chatterbot import __main__ as main | ||
|
||
|
||
class CommandLineInterfaceTests(TestCase): | ||
""" | ||
Tests for the command line tools that are included with ChatterBot. | ||
""" | ||
|
||
def test_get_chatterbot_version(self): | ||
version = main.get_chatterbot_version() | ||
self.assertEqual(version, __version__) | ||
|
||
def test_get_nltk_data_directories(self): | ||
directories = main.get_nltk_data_directories() | ||
self.assertIn('/', directories) |