Skip to content

Commit 72fc3b6

Browse files
committed
Merge branch 'release/1.2.0' into main
# Conflicts: # README.md # pyttman/version.py
2 parents 8274478 + 4ffcf9d commit 72fc3b6

File tree

24 files changed

+533
-629
lines changed

24 files changed

+533
-629
lines changed

CHANGELOG.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,37 @@
22

33

44

5+
# v 1.1.12
6+
**2022-04-10**
7+
8+
This mini-release contains small changes and bug fixes.
9+
10+
### :star2: News
11+
* **Improved behavior control when using the EntityParser Api**
12+
13+
Added the option for developers to state explicitly whether they want to ignore or keep any strings in 'lead' and/or 'trail' from the Intent, as possible strings
14+
in the EntityParser.
15+
### 👀 Changes
16+
17+
* **Internal cleaning and refactoring of our Parser code.**
18+
19+
Removed redundant class `AbstractParserBase`, making the `Parser` class
20+
the base parser class in Pyttman.
21+
22+
23+
* **BoolEntityField now defaults to `False`**
24+
25+
The `BoolEntityField` class defaults to `False` if it can't find the
26+
sought value in a message, in comparison to the previous default `None`
27+
as default value.
28+
29+
### **🐛 Splatted bugs and corrected issues**
30+
* **Fixes [#63](https://github.com/dotchetter/Pyttman/issues/63)**
31+
32+
533

634
# v 1.1.11
7-
**2022-**
35+
**2022-04-7**
836

937
This release improves the **EntityParser** API, packs the new `create
1038
ability` command for the `pyttman` cli tool, and introduces a
@@ -106,8 +134,8 @@ few new other features and bugfixes.
106134
*
107135

108136
### **🐛 Splatted bugs and corrected issues**
109-
* **Fixes [#58]((https://github.com/dotchetter/Pyttman/issues/58)**
110-
* **Fixes [#62]((https://github.com/dotchetter/Pyttman/issues/58)**
137+
* **Fixes [#58](https://github.com/dotchetter/Pyttman/issues/58)**
138+
* **Fixes [#62](https://github.com/dotchetter/Pyttman/issues/62)**
111139

112140

113141

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ pyttman shell my_first_app
153153
pyttman runclient my_first_app
154154
```
155155

156-
## Find content in messages
157-
156+
## Discord support built in - No extra code to get your chatbot online
158157

159158
**Pyttman aims to offer developers a platform-independent experience.**
160159
We're constantly developing support for more platforms. As of today, Pyttman offers built-in support for Discord through the [discord.py](https://github.com/Rapptz/discord.py) library, and we have more on the way.

devtools/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
This module contains tools for developers contributing to Pyttman.
3+
4+
It helps with building the framework for testing and simplifies
5+
deployment, and makes it easier to verify functionality of tools such
6+
as Pyttman CLI and testing the framework using a local-only test-app
7+
with the most recent build of the framework.
8+
"""
9+

devtools/build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import shutil
3+
import subprocess
4+
import sys
5+
from pathlib import Path
6+
7+
# Set the current working dir to parent directory
8+
sys.path.append(Path.cwd().parent.as_posix())
9+
os.chdir("..")
10+
CATALOGS = ("build", "dist")
11+
12+
BUILD_CMD = "python -m setup sdist bdist_wheel".split()
13+
14+
if __name__ == "__main__":
15+
[shutil.rmtree(i) for i in CATALOGS]
16+
subprocess.run(BUILD_CMD)

devtools/create_environment.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Set the current working dir to parent directory
2+
import os
3+
import shutil
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
from time import sleep
8+
9+
sys.path.append(Path.cwd().parent.as_posix())
10+
os.chdir("..")
11+
12+
LAB_ENV_PATH = Path.cwd() / Path("dev_env")
13+
BUILD_OUTPUT_PATH = Path.cwd() / "dist"
14+
15+
if __name__ == "__main__":
16+
if (LAB_ENV_PATH / "venv").exists():
17+
shutil.rmtree((LAB_ENV_PATH / "venv").as_posix())
18+
19+
if not Path("dist").exists():
20+
print("\nCannot create local testing environment as there is no "
21+
"build generated for the current local version of Pyttman.",
22+
"Run 'build.py' to create one.")
23+
exit(-1)
24+
25+
LAB_ENV_PATH.mkdir(exist_ok=True)
26+
os.chdir(LAB_ENV_PATH.as_posix())
27+
subprocess.run("python -m virtualenv venv".split())
28+
29+
while not Path("venv").exists():
30+
sleep(0.01)
31+
32+
package_file = [
33+
i for i in os.listdir(BUILD_OUTPUT_PATH.as_posix()) if i.endswith("tar.gz")
34+
].pop()
35+
36+
print(f"Installing package: '{package_file}' from your local build...")
37+
package_file = (BUILD_OUTPUT_PATH / package_file).as_posix()
38+
venv_python = (LAB_ENV_PATH / "venv/scripts/python.exe").as_posix()
39+
subprocess.run(f"{venv_python} -m pip install multidict".split())
40+
subprocess.run(f"{venv_python} -m pip install {package_file}".split())
41+
42+
print("\nFinished! You can now create an app and start testing in "
43+
f"{LAB_ENV_PATH.as_posix()}.")

pyttman/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__version__ = version.__version__
66
__author__ = "Simon Olofsson"
7-
__copyright__ = "(c) Pyttman development Team 2020-2021"
7+
__copyright__ = "(c) Pyttman development Team 2020-2022"
88
__licence__ = "MIT"
99

1010

pyttman/clients/builtin/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def run_client(self):
3131
elif isinstance(reply, Reply):
3232
print(f"{pyttman.settings.APP_NAME}:", reply.as_str())
3333
print()
34-
except KeyboardInterrupt:
34+
except (KeyboardInterrupt, EOFError):
3535
sys.exit(0)
3636

3737
@staticmethod

pyttman/core/ability.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ def __validate_intents(self):
6868
"Ability class.\nHint: Change '(FooIntent(), "
6969
"BarIntent())' to '(FooIntent, BarIntent).")
7070

71-
# Validate the EntityParser by calling constructor
72-
if intent_class.EntityParser is not None:
73-
try:
74-
intent_class().EntityParser()
75-
except Exception as e:
76-
raise AttributeError(
77-
"An error occurred with the EntityParser "
78-
f"in Intent class '{intent_class}': {e}")
79-
8071
def before_create(self):
8172
"""
8273
Lifecycle hook. This hook method is executed before the

pyttman/core/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MessageMixin(PrettyReprMixin):
1919
inheritance when a Message-like class is developed
2020
for supporting a 3rd party library / API.
2121
"""
22-
__repr_fields__ = ("created", "content")
22+
__repr_fields__ = ("author", "created")
2323

2424
def __init__(self, content=None, **kwargs):
2525
self.author = "anonymous"

pyttman/core/entity_parsing/fields.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ class EntityFieldBase(EntityFieldValueParser, ABC):
2121
datatype if a match is True.
2222
2323
"""
24+
default = None
2425
type_cls = None
2526
identifier_cls = None
2627

2728
def __init__(self,
2829
identifier: Type[Identifier] | None = None,
2930
as_list: bool = False,
31+
default: Any = None,
3032
**kwargs):
3133
"""
3234
:param as_list: If set to True combined with providing 'valid_strings',
@@ -52,12 +54,11 @@ def __init__(self,
5254
f"a valid value for "
5355
f"'type_cls'.")
5456

55-
identifier_cls = self.identifier_cls
5657
self.as_list = as_list
57-
if identifier is not None:
58-
identifier_cls = identifier
58+
_default_arg = default if default is not None else self.default
5959

60-
super().__init__(identifier=identifier_cls, **kwargs)
60+
super().__init__(identifier=identifier or self.identifier_cls,
61+
default=_default_arg, **kwargs)
6162

6263
def convert_value(self, value: Any) -> Any:
6364
"""
@@ -150,6 +151,7 @@ class BoolEntityField(EntityFieldBase):
150151
The value output from this EntityField is <int>.
151152
"""
152153
type_cls = bool
154+
default = False
153155
truncates_message_in_parsing = False
154156

155157
def __init__(self, *args,

0 commit comments

Comments
 (0)