Loglan-Core 0.4.1__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {loglan_core-0.4.1 → loglan_core-0.4.3/Loglan_Core.egg-info}/PKG-INFO +2 -2
  2. {loglan_core-0.4.1/Loglan_Core.egg-info → loglan_core-0.4.3}/PKG-INFO +2 -2
  3. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/__init__.py +11 -2
  4. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/base_selector.py +33 -8
  5. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/definition.py +5 -6
  6. {loglan_core-0.4.1 → loglan_core-0.4.3}/setup.py +1 -1
  7. {loglan_core-0.4.1 → loglan_core-0.4.3}/LICENSE +0 -0
  8. {loglan_core-0.4.1 → loglan_core-0.4.3}/Loglan_Core.egg-info/SOURCES.txt +0 -0
  9. {loglan_core-0.4.1 → loglan_core-0.4.3}/Loglan_Core.egg-info/dependency_links.txt +0 -0
  10. {loglan_core-0.4.1 → loglan_core-0.4.3}/Loglan_Core.egg-info/requires.txt +0 -0
  11. {loglan_core-0.4.1 → loglan_core-0.4.3}/Loglan_Core.egg-info/top_level.txt +0 -0
  12. {loglan_core-0.4.1 → loglan_core-0.4.3}/README.md +0 -0
  13. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/__init__.py +0 -0
  14. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/definition_selector.py +0 -0
  15. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/export_word_converter.py +0 -0
  16. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/exporter.py +0 -0
  17. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/key_selector.py +0 -0
  18. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/utils.py +0 -0
  19. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/word_linker.py +0 -0
  20. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/word_selector.py +0 -0
  21. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/addons/word_sourcer.py +0 -0
  22. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/author.py +0 -0
  23. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/base.py +0 -0
  24. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/connect_tables.py +0 -0
  25. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/event.py +0 -0
  26. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/key.py +0 -0
  27. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/setting.py +0 -0
  28. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/syllable.py +0 -0
  29. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/table_names.py +0 -0
  30. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/type.py +0 -0
  31. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/word.py +0 -0
  32. {loglan_core-0.4.1 → loglan_core-0.4.3}/loglan_core/word_spell.py +0 -0
  33. {loglan_core-0.4.1 → loglan_core-0.4.3}/pyproject.toml +0 -0
  34. {loglan_core-0.4.1 → loglan_core-0.4.3}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Loglan-Core
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Loglan Dictionary Database Model for SQLAlchemy
5
5
  Home-page: https://github.com/torrua/loglan_core
6
- Download-URL: https://github.com/torrua/loglan_core/archive/0.4.1.tar.gz
6
+ Download-URL: https://github.com/torrua/loglan_core/archive/0.4.3.tar.gz
7
7
  Author: torrua
8
8
  Author-email: torrua@gmail.com
9
9
  License: MIT
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Loglan-Core
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Loglan Dictionary Database Model for SQLAlchemy
5
5
  Home-page: https://github.com/torrua/loglan_core
6
- Download-URL: https://github.com/torrua/loglan_core/archive/0.4.1.tar.gz
6
+ Download-URL: https://github.com/torrua/loglan_core/archive/0.4.3.tar.gz
7
7
  Author: torrua
8
8
  Author-email: torrua@gmail.com
9
9
  License: MIT
@@ -8,12 +8,15 @@ __author__ = "torrua"
8
8
  __copyright__ = "Copyright 2024, loglan_core project"
9
9
  __email__ = "torrua@gmail.com"
10
10
 
11
- from loglan_core.author import BaseAuthor as Author
12
11
  from loglan_core.connect_tables import (
13
12
  t_connect_authors,
14
13
  t_connect_words,
15
14
  t_connect_keys,
16
15
  )
16
+
17
+ from loglan_core.base import BaseModel as Base
18
+
19
+ from loglan_core.author import BaseAuthor as Author
17
20
  from loglan_core.definition import BaseDefinition as Definition
18
21
  from loglan_core.event import BaseEvent as Event
19
22
  from loglan_core.key import BaseKey as Key
@@ -23,5 +26,11 @@ from loglan_core.type import BaseType as Type
23
26
  from loglan_core.word import BaseWord as Word
24
27
  from loglan_core.word_spell import BaseWordSpell as WordSpell
25
28
 
26
- from loglan_core.base import BaseModel as Base
29
+ from loglan_core.addons.base_selector import BaseSelector
30
+ from loglan_core.addons.definition_selector import DefinitionSelector
31
+ from loglan_core.addons.key_selector import KeySelector
27
32
  from loglan_core.addons.word_selector import WordSelector
33
+
34
+ from loglan_core.addons.export_word_converter import ExportWordConverter
35
+ from loglan_core.addons.exporter import Exporter
36
+ from loglan_core.addons.word_linker import WordLinker
@@ -6,8 +6,8 @@ from __future__ import annotations
6
6
 
7
7
  from typing import Type, Iterable, Any
8
8
 
9
- from sqlalchemy import true, select, Select
10
- from sqlalchemy.orm import Session, selectinload, InstrumentedAttribute
9
+ from sqlalchemy import select, Select
10
+ from sqlalchemy.orm import Session, InstrumentedAttribute, joinedload
11
11
  from typing_extensions import Self
12
12
 
13
13
  from loglan_core.base import BaseModel
@@ -164,25 +164,50 @@ class BaseSelector: # pylint: disable=too-many-ancestors
164
164
  self._statement = self._statement.order_by(*columns)
165
165
  return self
166
166
 
167
+ def filter(self, *args) -> Self:
168
+ """Filter results based on arbitrary keyword arguments.
169
+
170
+ Args:
171
+ *args: Column-value pairs to filter by.
172
+
173
+ Returns:
174
+ Self: The current instance for method chaining.
175
+ """
176
+
177
+ self._statement = self._statement.filter(*args)
178
+
179
+ return self
180
+
167
181
  def filter_by(self, **kwargs) -> Self:
168
182
  """Filter results based on arbitrary keyword arguments.
169
183
 
170
184
  Args:
171
- **kwargs: Column-value pairs to filter by.
185
+ *kwargs: Column-value pairs to filter by.
172
186
 
173
187
  Returns:
174
188
  Self: The current instance for method chaining.
175
189
  """
176
- for key, value in kwargs.items():
177
- condition = self._generate_column_condition(key, value)
178
- self._statement = self._statement.where(condition)
179
190
 
191
+ self._statement = self._statement.filter_by(**kwargs)
192
+
193
+ return self
194
+
195
+ def where(self, *args) -> Self:
196
+ """Filter results based on arbitrary keyword arguments.
197
+
198
+ Args:
199
+ *args: Column-value pairs to filter by.
200
+
201
+ Returns:
202
+ Self: The current instance for method chaining.
203
+ """
204
+ self._statement = self._statement.where(*args)
180
205
  return self
181
206
 
182
207
  def _generate_column_condition(self, key: str | InstrumentedAttribute, value: Any):
183
208
  column = getattr(self.model, key, None) if isinstance(key, str) else key
184
209
  if column is None:
185
- return true()
210
+ raise AttributeError(f"Model {self.model} has no attribute {key}")
186
211
 
187
212
  value = str(value).replace("*", "%")
188
213
  if self.case_sensitive:
@@ -235,7 +260,7 @@ class BaseSelector: # pylint: disable=too-many-ancestors
235
260
  attr: getattr(self.model, attr) for attr in self.model.relationships()
236
261
  }
237
262
  relationships = {
238
- selectinload(v)
263
+ joinedload(v)
239
264
  for k, v in available_relationships.items()
240
265
  if not selected or k in selected
241
266
  }
@@ -112,12 +112,11 @@ class BaseDefinition(BaseModel):
112
112
  @property
113
113
  def grammar(self) -> str:
114
114
  """
115
- Combine definition's 'slots' and 'grammar_code' attributes
115
+ Combine definition's 'slots' and 'grammar_code' attributes.
116
116
 
117
117
  Returns:
118
- String with grammar data like (3v) or (2n)
118
+ String with grammar data like (3v) or (2n), or an empty string if both are None.
119
119
  """
120
- return (
121
- f"({self.slots if self.slots else ''}"
122
- f"{self.grammar_code if self.grammar_code else ''})"
123
- )
120
+ sl_str = self.slots or ""
121
+ gr_str = self.grammar_code or ""
122
+ return f"({sl_str}{gr_str})" if sl_str or gr_str else ""
@@ -4,7 +4,7 @@ from io import open
4
4
 
5
5
  from setuptools import setup
6
6
 
7
- CURRENT_VERSION = "0.4.1"
7
+ CURRENT_VERSION = "0.4.3"
8
8
 
9
9
 
10
10
  def read(filename): # pylint: disable=C0116
File without changes
File without changes
File without changes
File without changes