memoryframes 0.2.0__tar.gz → 0.3.0__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.
- {memoryframes-0.2.0 → memoryframes-0.3.0}/PKG-INFO +1 -1
- {memoryframes-0.2.0 → memoryframes-0.3.0}/pyproject.toml +1 -1
- memoryframes-0.3.0/src/MemoryFrames/PluginInfra/Plugin.py +97 -0
- memoryframes-0.3.0/src/MemoryFrames/PluginInfra/README.md +1 -0
- memoryframes-0.3.0/src/MemoryFrames/PluginInfra/UserExperienceInfo.py +22 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/README.md +0 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/src/MemoryFrames/PluginInfra/Note.py +0 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/src/MemoryFrames/PluginInfra/NoteSource.py +0 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/src/MemoryFrames/PluginInfra/__init__.py +0 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/src/MemoryFrames/__init__.py +0 -0
- {memoryframes-0.2.0 → memoryframes-0.3.0}/src/MemoryFrames/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "MemoryFrames"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
# ^^^^^
|
|
5
5
|
# Wheel names will be generated according to this value. Do not manually modify this value; instead
|
|
6
6
|
# update it according to committed changes by running this command from the root of the repository:
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from functools import cached_property
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
import pluggy
|
|
7
|
+
|
|
8
|
+
from MemoryFrames import APP_NAME
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
from threading import Event
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from MemoryFrames.PluginInfra.NoteSource import NoteSource, NoteSourceObserver
|
|
16
|
+
from MemoryFrames.PluginInfra.UserExperienceInfo import UserExperienceInfo
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# ----------------------------------------------------------------------
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class ThreadInfo:
|
|
22
|
+
"""Information about a thread that is defined by a Plugin but created and managed by the application."""
|
|
23
|
+
|
|
24
|
+
description: str
|
|
25
|
+
thread_func: Callable[
|
|
26
|
+
[
|
|
27
|
+
Event # Event set when the application is quitting
|
|
28
|
+
],
|
|
29
|
+
None,
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# ----------------------------------------------------------------------
|
|
34
|
+
class Plugin(ABC):
|
|
35
|
+
"""Base class for all MemoryFrames plugins."""
|
|
36
|
+
|
|
37
|
+
# ----------------------------------------------------------------------
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
root_data_dir: Path,
|
|
41
|
+
) -> None:
|
|
42
|
+
scrubbed_unique_name = self.unique_name
|
|
43
|
+
|
|
44
|
+
for invalid_char in ["<", ">", ":", '"', "/", "\\", "|", "?", "*", "."]:
|
|
45
|
+
scrubbed_unique_name = scrubbed_unique_name.replace(invalid_char, "_")
|
|
46
|
+
|
|
47
|
+
self.working_dir = root_data_dir / scrubbed_unique_name
|
|
48
|
+
|
|
49
|
+
# ----------------------------------------------------------------------
|
|
50
|
+
@property
|
|
51
|
+
@abstractmethod
|
|
52
|
+
def name(self) -> str:
|
|
53
|
+
"""The name of the plugin."""
|
|
54
|
+
raise NotImplementedError() # pragma: no cover
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def author(self) -> str:
|
|
59
|
+
"""The author of the plugin. This value will be used in the plugin's unique name."""
|
|
60
|
+
raise NotImplementedError() # pragma: no cover
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
@abstractmethod
|
|
64
|
+
def description(self) -> str:
|
|
65
|
+
"""The description of the plugin."""
|
|
66
|
+
raise NotImplementedError() # pragma: no cover
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def plugin_priority(self) -> int:
|
|
71
|
+
"""The priority of the plugin. Higher values indicate higher priority, which will cause the plugin to appear before other lower priority plugins."""
|
|
72
|
+
raise NotImplementedError() # pragma: no cover
|
|
73
|
+
|
|
74
|
+
@cached_property
|
|
75
|
+
def unique_name(self) -> str:
|
|
76
|
+
"""The unique name of the plugin."""
|
|
77
|
+
return f"{self.author}_{self.name}"
|
|
78
|
+
|
|
79
|
+
# ----------------------------------------------------------------------
|
|
80
|
+
def GetNoteSource(
|
|
81
|
+
self,
|
|
82
|
+
observer: NoteSourceObserver, # noqa: ARG002
|
|
83
|
+
enqueue_thread_info_func: Callable[[ThreadInfo], None], # noqa: ARG002
|
|
84
|
+
) -> NoteSource | None:
|
|
85
|
+
"""Return a NoteSource implemented by this plugin."""
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ----------------------------------------------------------------------
|
|
90
|
+
@pluggy.HookspecMarker(APP_NAME)
|
|
91
|
+
def GetPlugin(
|
|
92
|
+
root_data_dir: Path,
|
|
93
|
+
all_plugins_settings: dict[str, object],
|
|
94
|
+
user_experience_info: UserExperienceInfo,
|
|
95
|
+
) -> Plugin:
|
|
96
|
+
"""Return a Plugin instance."""
|
|
97
|
+
raise NotImplementedError() # pragma: no cover
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This directory contains all information, base classes, helper classes, etc. used when creating Plugins that customize MemoryFrames behavior.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# ----------------------------------------------------------------------
|
|
5
|
+
class UserExperienceInfo:
|
|
6
|
+
"""Abstract base class for information associated with user experiences.
|
|
7
|
+
|
|
8
|
+
This information is passed to a Plugin on creation, where it uses the info to adjust its behavior
|
|
9
|
+
based on the information's derived type and associated data.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# ----------------------------------------------------------------------
|
|
13
|
+
def __init__(self) -> None:
|
|
14
|
+
# Ensure that only known classes inherit from this base class, as it is not a small thing
|
|
15
|
+
# to introduce a new user experience type (as all plugins, across the world, must be
|
|
16
|
+
# updated to support it.
|
|
17
|
+
if not sys.flags.optimize:
|
|
18
|
+
pass
|
|
19
|
+
# TODO: # Avoid circular import issues by importing here
|
|
20
|
+
# TODO: from MemoryFrames.PluginInfra.TextualUserExperienceInfo import TextualUserExperienceInfo
|
|
21
|
+
|
|
22
|
+
# TODO: assert isinstance(self, (TextualUserExperienceInfo,)), self
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|