Skip to content

Commit 9882896

Browse files
committed
Release 1.2.0
1 parent e9cb8bd commit 9882896

19 files changed

Lines changed: 872 additions & 377 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ dmypy.json
128128
# Pyre type checker
129129
.pyre/
130130

131-
# WingIDE project files
131+
# WingIDE
132132
*.wpr
133133
*.wpu
134+
135+
# Sphinx build
136+
docs/_build

docs/changelog.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,42 @@
22
Changelog
33
#########
44

5+
Version 1.2.0
6+
=============
7+
8+
* Build scheme changed to `PEP 517`.
9+
* Various changes to documentation and type hint adjustments.
10+
* `~firebird.base.config` module:
11+
12+
- **BREAKING CHANGE**: `.ApplicationDirectoryScheme` was replaced by
13+
`~firebird.base.config.DirectoryScheme` class, and
14+
`~firebird.base.config.get_directory_scheme()` has changed signature.
15+
- Directory scheme was reworked and now also supports concept of HOME directory.
16+
- New MacOS directory scheme support. As I don't have access to MacOS, this support
17+
should be considered EXPERIMENTAL. Any feedback about it's correctness is welcome.
18+
- Added: New `.Config` constructor keyword-only `bool` argument `optional` and
19+
associated `~Config.optional` read-only property.
20+
- Added: `.Config.has_value()` function.
21+
- New class: `.PathOption` for Configuration options with `pathlib.Path` value.
22+
* `~firebird.base.protobuf` module:
23+
24+
- Added: function `.get_message_factory`.
25+
* `~firebird.base.signal` module:
26+
27+
- Fix: Bug in `eventsocket` signature handling.
28+
* `~firebird.base.trace` module:
29+
30+
- Added: `apply_to_descendants` boolean configuration option to apply configuration also
31+
to all registered descendant classes. The default value is `True`.
32+
533
Version 1.1.0
634
=============
735

836
* New module: `signal` - Callback system based on Signals and Slots, and "Delphi events"
37+
* `~firebird.base.types` module:
38+
39+
- `~firebird.base.types.load` function now supports `object_name[.object_name...]`
40+
specifications instead single `object_name`.
941
* `~firebird.base.config` module:
1042

1143
- New class `.ApplicationDirectoryScheme`

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
# -- Project information -----------------------------------------------------
2020

2121
project = 'Firebird-base'
22-
copyright = '2020, The Firebird Project'
22+
copyright = '2020-2021, The Firebird Project'
2323
author = 'Pavel Císař'
2424

2525
# The short X.Y version
26-
version = '1.1.0'
26+
version = '1.2.0'
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = '1.1.0'
29+
release = '1.2.0'
3030

3131

3232
# -- General configuration ---------------------------------------------------
@@ -37,7 +37,7 @@
3737
extensions = [
3838
'sphinx.ext.autodoc',
3939
'sphinx.ext.intersphinx',
40-
'sphinxcontrib.napoleon',
40+
'sphinx.ext.napoleon',
4141
'sphinx_autodoc_typehints',
4242
'sphinx.ext.todo',
4343
'sphinx.ext.coverage',

docs/config.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,15 @@ Application Directory Scheme
319319

320320
.. versionadded:: 1.1.0
321321

322-
.. autoclass:: ApplicationDirectoryScheme
322+
.. versionchanged:: 1.2.0
323+
324+
.. autoclass:: DirectoryScheme
325+
326+
.. autoclass:: WindowsDirectoryScheme
327+
328+
.. autoclass:: LinuxDirectoryScheme
329+
330+
.. autoclass:: MacOSDirectoryScheme
323331

324332
.. autofunction:: get_directory_scheme
325333

@@ -365,6 +373,10 @@ EnumOption
365373
----------
366374
.. autoclass:: EnumOption
367375

376+
FlagOption
377+
----------
378+
.. autoclass:: FlagOption
379+
368380
UUIDOption
369381
----------
370382
.. autoclass:: UUIDOption
@@ -381,6 +393,10 @@ DataclassOption
381393
---------------
382394
.. autoclass:: DataclassOption
383395

396+
PathOption
397+
----------
398+
.. autoclass:: PathOption
399+
384400
PyExprOption
385401
------------
386402
.. autoclass:: PyExprOption

docs/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Topic covered by `firebird-base` package:
1818
- Context-based logging.
1919
- Trace/audit for class instances.
2020
- General "hook" mechanism.
21-
- Callback system based on Signals and Slots, and "Delphi events"
21+
- Callback system based on Signals and Slots, and "Delphi events".
2222

2323

2424
.. note:: Requires Python 3.8+

firebird/base/buffer.py

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545
@runtime_checkable
4646
class BufferFactory(Protocol): # pragma: no cover
47-
"BufferFactory Protocol definition"
47+
"""BufferFactory Protocol definition.
48+
"""
4849
def create(self, init_or_size: Union[int, bytes], size: int=None) -> Any:
4950
"""This function must create and return a mutable character buffer.
5051
@@ -91,7 +92,8 @@ def create(self, init_or_size: Union[int, bytes], size: int=None) -> bytearray:
9192
buffer[:limit] = init_or_size[:limit]
9293
return buffer
9394
def clear(self, buffer: bytearray) -> None:
94-
"Fills the buffer with zero."
95+
"""Fills the buffer with zero.
96+
"""
9597
buffer[:] = b'\x00' * len(buffer)
9698

9799
class CTypesBufferFactory:
@@ -125,7 +127,8 @@ def create(self, init_or_size: Union[int, bytes], size: int=None) -> bytearray:
125127
buffer[:limit] = init_or_size[:limit]
126128
return buffer
127129
def clear(self, buffer: bytearray, init: int=0) -> None:
128-
"Fills the buffer with specified value (default)."
130+
"""Fills the buffer with specified value (default).
131+
"""
129132
memset(buffer, init, len(buffer))
130133

131134
def safe_ord(byte: Union[bytes, int]) -> int:
@@ -169,108 +172,133 @@ def _check_space(self, size: int):
169172
if len(self.raw) < self.pos + size:
170173
raise IOError("Insufficient buffer size")
171174
def clear(self) -> None:
172-
"Fills the buffer with zeros and resets the position in buffer to zero."
175+
"""Fills the buffer with zeros and resets the position in buffer to zero.
176+
"""
173177
self.factory.clear(self.raw)
174178
self.pos = 0
175179
def resize(self, size: int) -> None:
176-
"Resize buffer to specified length."
180+
"""Resize buffer to specified length.
181+
"""
177182
if self.max_size is not UNLIMITED and self.max_size < size:
178183
raise IOError(f"Cannot resize buffer past max. size {self.max_size} bytes")
179184
self.raw = self.factory.create(self.raw, size)
180185
def is_eof(self) -> bool:
181-
"Return True when positioned past the end of buffer or on `.eof_marker` (if defined)."
186+
"""Return True when positioned past the end of buffer or on `.eof_marker`
187+
(if defined).
188+
"""
182189
if self.pos >= len(self.raw):
183190
return True
184191
if self.eof_marker is not None and safe_ord(self.raw[self.pos]) == self.eof_marker:
185192
return True
186193
return False
187194
def write(self, data: bytes) -> None:
188-
"Write bytes."
195+
"""Write bytes.
196+
"""
189197
size = len(data)
190198
self._ensure_space(size)
191199
self.raw[self.pos:self.pos + size] = data
192200
self.pos += size
193201
def write_byte(self, byte: int) -> None:
194-
"Write one byte."
202+
"""Write one byte.
203+
"""
195204
self._ensure_space(1)
196205
self.raw[self.pos] = byte
197206
self.pos += 1
198207
def write_number(self, value: int, size: int, *, signed: bool=False) -> None:
199-
"Write number with specified size (in bytes)."
208+
"""Write number with specified size (in bytes).
209+
"""
200210
self.write(value.to_bytes(size, self.byteorder.value, signed=signed))
201211
def write_short(self, value: int) -> None:
202-
"Write 2 byte number (c_ushort)."
212+
"""Write 2 byte number (c_ushort).
213+
"""
203214
self.write_number(value, 2)
204215
def write_int(self, value: int) -> None:
205-
"Write 4 byte number (c_uint)."
216+
"""Write 4 byte number (c_uint).
217+
"""
206218
self.write_number(value, 4)
207219
def write_bigint(self, value: int) -> None:
208-
"Write tagged 8 byte number (c_ulonglong)."
220+
"""Write tagged 8 byte number (c_ulonglong).
221+
"""
209222
self.write_number(value, 8)
210223
def write_string(self, value: str, *, encoding='ascii') -> None:
211-
"Write zero-terminated string."
224+
"""Write zero-terminated string.
225+
"""
212226
self.write(value.encode(encoding))
213227
self.write_byte(0)
214228
def write_pascal_string(self, value: str, *, encoding='ascii') -> None:
215-
"Write tagged Pascal string (2 byte length followed by data)."
229+
"""Write tagged Pascal string (2 byte length followed by data).
230+
"""
216231
value = value.encode(encoding)
217232
size = len(value)
218233
self.write_byte(size)
219234
self.write(value)
220235
def read(self, size: int=-1) -> bytes:
221-
"Reads specified number of bytes, or all remaining data."
236+
"""Reads specified number of bytes, or all remaining data.
237+
"""
222238
if size < 0:
223239
size = self.buffer_size - self.pos
224240
self._check_space(size)
225241
result = self.raw[self.pos: self.pos + size]
226242
self.pos += size
227243
return result
228244
def read_number(self, size: int, *, signed=False) -> int:
229-
"Read number with specified size in bytes."
245+
"""Read number with specified size in bytes.
246+
"""
230247
self._check_space(size)
231248
result = (0).from_bytes(self.raw[self.pos: self.pos + size], self.byteorder.value, signed=signed)
232249
self.pos += size
233250
return result
234251
def read_byte(self, *, signed=False) -> int:
235-
"Read 1 byte number (c_ubyte)."
252+
"""Read 1 byte number (c_ubyte).
253+
"""
236254
return self.read_number(1, signed=signed)
237255
def read_short(self, *, signed=False) -> int:
238-
"Read 2 byte number (c_ushort)."
256+
"""Read 2 byte number (c_ushort).
257+
"""
239258
return self.read_number(2, signed=signed)
240259
def read_int(self, *, signed=False) -> int:
241-
"Read 4 byte number (c_uint)."
260+
"""Read 4 byte number (c_uint).
261+
"""
242262
return self.read_number(4, signed=signed)
243263
def read_bigint(self, *, signed=False) -> int:
244-
"Read 8 byte number (c_ulonglong)."
264+
"""Read 8 byte number (c_ulonglong).
265+
"""
245266
return self.read_number(8, signed=signed)
246267
def read_sized_int(self, *, signed=False) -> int:
247-
"Read number cluster (2 byte length followed by data)."
268+
"""Read number cluster (2 byte length followed by data).
269+
"""
248270
return self.read_number(self.read_short(), signed=signed)
249271
def read_string(self, *, encoding='ascii') -> str:
250-
"Read null-terminated string."
272+
"""Read null-terminated string.
273+
"""
251274
i = self.pos
252275
while i < self.buffer_size and safe_ord(self.raw[i]) != 0:
253276
i += 1
254277
result = self.read(i - self.pos).decode(encoding)
255278
self.pos += 1
256279
return result
257280
def read_pascal_string(self, *, encoding='ascii') -> str:
258-
"Read Pascal string (1 byte length followed by string data)."
281+
"""Read Pascal string (1 byte length followed by string data).
282+
"""
259283
return self.read(self.read_byte()).decode(encoding)
260284
def read_sized_string(self, *, encoding='ascii') -> str:
261-
"Read string (2 byte length followed by data)."
285+
"""Read string (2 byte length followed by data).
286+
"""
262287
return self.read(self.read_short()).decode(encoding)
263288
def read_bytes(self) -> bytes:
264-
"Read content of binary cluster (2 bytes data length followed by data)."
289+
"""Read content of binary cluster (2 bytes data length followed by data).
290+
"""
265291
return self.read(self.read_short())
266292
# Properties
267293
@property
268294
def buffer_size(self) -> int:
269-
"Current buffer size in bytes."
295+
"""Current buffer size in bytes.
296+
"""
270297
return len(self.raw)
271298
@property
272299
def last_data(self) -> int:
273-
"Index of first non-zero byte when searched from the end of buffer."
300+
"""Index of first non-zero byte when searched from the end of buffer.
301+
"""
274302
i = len(self.raw) - 1
275303
while i >= 0:
276304
if safe_ord(self.raw[i]) != 0:

firebird/base/collections.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,13 @@ def get(self, key: Any, default: Any=None) -> Item:
457457
return default
458458
@property
459459
def frozen(self) -> bool:
460-
"True if list items couldn't be changed."
460+
"""True if list items couldn't be changed.
461+
"""
461462
return self.__frozen
462463
@property
463464
def key_expr(self) -> Item:
464-
"Key expression."
465+
"""Key expression.
466+
"""
465467
return self.__key_expr
466468
@property
467469
def type_spec(self) -> Union[TypeSpec, Sentinel]:

0 commit comments

Comments
 (0)