Skip to content

Commit 82b5a6f

Browse files
committed
Refactor the interactive mode, add shell.py
1 parent ae9d2d2 commit 82b5a6f

19 files changed

Lines changed: 2181 additions & 2156 deletions

Changes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Revision history for the Python package RiveScript.
22

3+
1.13.0 TBD
4+
- Restructure the code to keep it on par with the JavaScript and Go versions:
5+
- `rivescript.parser` now contains all the parsing code:
6+
`parse()` and `check_syntax()` are moved here.
7+
- Refactor the RiveScript interactive mode (`rivescript.interactive`) to use
8+
argparse instead of getopt and add a pretty ASCII logo.
9+
- Add `shell.py` as a possibly easier-to-access (and certainly
10+
easier-to-discover) shortcut to running RiveScript's interactive mode.
11+
312
1.12.3 Jul 8 2016
413
- Fix the Python object macro handler to use `six.text_type` on the return
514
value, allowing Python 2 objects to return Unicode strings.

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
all: build
2+
3+
build:
4+
python setup.py build
5+
6+
install:
7+
python setup.py install
8+
9+
test:
10+
pip install -r requirements.txt
11+
nosetests
12+
13+
clean:
14+
rm -rf build dist rivescript.egg-info
15+
find . -name '*.pyc' -delete
16+
17+
.PHONY: build install test clean

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ interactive chat session:
4040

4141
python rivescript ./eg/brain
4242

43+
In case running RiveScript as a script is inconvenient (for example, when it's
44+
installed as a system module) you can use the `shell.py` script as an alias:
45+
46+
python shell.py eg/brain
47+
4348
When used as a library, the synopsis is as follows:
4449

4550
```python

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'sphinx.ext.autodoc',
3838
'sphinx.ext.todo',
3939
'sphinx.ext.viewcode',
40+
'sphinx.ext.napoleon',
4041
]
4142

4243
# Add any paths that contain templates here, relative to this directory.

docs/rivescript.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ rivescript.rivescript module
1212
:undoc-members:
1313
:show-inheritance:
1414

15+
rivescript.brain module
16+
-----------------------
17+
18+
.. automodule:: rivescript.brain
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
1523
rivescript.exceptions module
1624
----------------------------
1725

@@ -20,6 +28,29 @@ rivescript.exceptions module
2028
:undoc-members:
2129
:show-inheritance:
2230

31+
rivescript.inheritance module
32+
-----------------------------
33+
34+
.. automodule:: rivescript.inheritance
35+
:members:
36+
:undoc-members:
37+
:show-inheritance:
38+
39+
rivescript.interactive module
40+
-----------------------------
41+
42+
.. automodule:: rivescript.interactive
43+
:members:
44+
:undoc-members:
45+
:show-inheritance:
46+
47+
rivescript.parser module
48+
------------------------
49+
50+
.. automodule:: rivescript.parser
51+
:members:
52+
:undoc-members:
53+
:show-inheritance:
2354

2455
rivescript.python module
2556
------------------------
@@ -28,3 +59,27 @@ rivescript.python module
2859
:members:
2960
:undoc-members:
3061
:show-inheritance:
62+
63+
rivescript.regexp module
64+
------------------------
65+
66+
.. automodule:: rivescript.regexp
67+
:members:
68+
:undoc-members:
69+
:show-inheritance:
70+
71+
rivescript.sorting module
72+
-------------------------
73+
74+
.. automodule:: rivescript.sorting
75+
:members:
76+
:undoc-members:
77+
:show-inheritance:
78+
79+
rivescript.utils module
80+
-----------------------
81+
82+
.. automodule:: rivescript.utils
83+
:members:
84+
:undoc-members:
85+
:show-inheritance:

mkdocs.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

rivescript/__init__.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
#!/usr/bin/env python
2-
3-
# pyRiveScript - A RiveScript interpreter written in Python.
4-
5-
# The MIT License (MIT)
6-
#
7-
# Copyright (c) 2016 Noah Petherbridge
8-
#
9-
# Permission is hereby granted, free of charge, to any person obtaining a copy
10-
# of this software and associated documentation files (the "Software"), to deal
11-
# in the Software without restriction, including without limitation the rights
12-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13-
# copies of the Software, and to permit persons to whom the Software is
14-
# furnished to do so, subject to the following conditions:
1+
# RiveScript-Python
152
#
16-
# The above copyright notice and this permission notice shall be included in all
17-
# copies or substantial portions of the Software.
3+
# This code is released under the MIT License.
4+
# See the "LICENSE" file for more information.
185
#
19-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25-
# SOFTWARE.
6+
# https://www.rivescript.com/
267

278
# Python 3 compat
289
from __future__ import print_function, unicode_literals
@@ -39,7 +20,10 @@
3920
__docformat__ = 'plaintext'
4021

4122
__all__ = ['rivescript']
42-
__version__ = '1.12.3'
23+
__version__ = '1.12.4'
4324

44-
from .rivescript import RiveScript, RiveScriptError, NoMatchError, NoReplyError,\
45-
ObjectError, DeepRecursionError, NoDefaultRandomTopicError, RepliesNotSortedError
25+
from .rivescript import RiveScript
26+
from .exceptions import (
27+
RiveScriptError, NoMatchError, NoReplyError, ObjectError,
28+
DeepRecursionError, NoDefaultRandomTopicError, RepliesNotSortedError
29+
)

rivescript/__main__.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1-
#!/usr/bin/env python
2-
3-
# The MIT License (MIT)
4-
#
5-
# Copyright (c) 2016 Noah Petherbridge
6-
#
7-
# Permission is hereby granted, free of charge, to any person obtaining a copy
8-
# of this software and associated documentation files (the "Software"), to deal
9-
# in the Software without restriction, including without limitation the rights
10-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
# copies of the Software, and to permit persons to whom the Software is
12-
# furnished to do so, subject to the following conditions:
1+
# RiveScript-Python
132
#
14-
# The above copyright notice and this permission notice shall be included in all
15-
# copies or substantial portions of the Software.
3+
# This code is released under the MIT License.
4+
# See the "LICENSE" file for more information.
165
#
17-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
# SOFTWARE.
6+
# https://www.rivescript.com/
247

258
from __future__ import absolute_import, unicode_literals
269

0 commit comments

Comments
 (0)