-
Notifications
You must be signed in to change notification settings - Fork 8
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
52 changed files
with
2,588 additions
and
1,083 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
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,6 @@ | ||
|
||
``pymap.imap`` | ||
============== | ||
|
||
.. automodule:: pymap.imap | ||
:members: |
This file was deleted.
Oops, something went wrong.
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 +1,13 @@ | ||
"""Root package for the pymap project.""" | ||
"""Contains the package version string. | ||
See Also: | ||
`PEP 396 <https://www.python.org/dev/peps/pep-0396/>`_ | ||
""" | ||
|
||
import pkg_resources | ||
|
||
__all__ = ['__version__'] | ||
|
||
#: The package version string. | ||
__version__: str = pkg_resources.require(__package__)[0].version |
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
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
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
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
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,54 @@ | ||
|
||
from typing import Optional, Tuple, Sequence, Dict | ||
|
||
from pymap.filter import EntryPointFilterSet | ||
|
||
__all__ = ['FilterSet'] | ||
|
||
|
||
class FilterSet(EntryPointFilterSet[bytes]): | ||
|
||
def __init__(self) -> None: | ||
super().__init__('sieve') | ||
self._filters: Dict[str, bytes] = {} | ||
self._active: Optional[str] = None | ||
|
||
async def put(self, name: str, value: bytes) -> None: | ||
self._filters[name] = value | ||
|
||
async def delete(self, name: str) -> None: | ||
if name not in self._filters: | ||
raise KeyError(name) | ||
elif name == self._active: | ||
raise ValueError(name) | ||
del self._filters[name] | ||
|
||
async def rename(self, before_name: str, after_name: str) -> None: | ||
if before_name not in self._filters: | ||
raise KeyError(before_name) | ||
elif after_name in self._filters: | ||
raise KeyError(after_name) | ||
self._filters[after_name] = self._filters[before_name] | ||
del self._filters[before_name] | ||
if self._active == before_name: | ||
self._active = after_name | ||
|
||
async def set_active(self, name: Optional[str]) -> None: | ||
if name is None: | ||
self._active = None | ||
elif name not in self._filters: | ||
raise KeyError(name) | ||
else: | ||
self._active = name | ||
|
||
async def get(self, name: str) -> bytes: | ||
return self._filters[name] | ||
|
||
async def get_active(self) -> Optional[bytes]: | ||
if self._active is None: | ||
return None | ||
else: | ||
return self._filters[self._active] | ||
|
||
async def get_all(self) -> Tuple[Optional[str], Sequence[str]]: | ||
return self._active, list(self._filters.keys()) |
Oops, something went wrong.