Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit af38238

Browse files
author
John Andersen
committed
source: memory: Decorate with entry_point
* Added entry_point decorator to MemorySource * Fixed MemorySource args() and config(). They now use config_get and config_set. Fixes: #78 Signed-off-by: John Andersen <[email protected]>
1 parent d5c4f8a commit af38238

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Fixed
1212
- MemoryOperationImplementationNetwork instantiates OperationImplementations
1313
using their `withconfig()` method.
14+
- MemorySource now decorated with `entry_point`
15+
- MemorySource takes arguments correctly via `config_set` and `config_get`
1416

1517
## [0.2.0] - 2019-05-23
1618
### Added

dffml/source/memory.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from ..repo import Repo
1111
from .source import BaseSourceContext, \
1212
BaseSource
13+
from ..util.cli.arg import Arg
14+
from ..util.entrypoint import entry_point
1315

1416
class MemorySourceContext(BaseSourceContext):
1517

@@ -26,6 +28,7 @@ async def repo(self, src_url: str) -> Repo:
2628
class MemorySourceConfig(BaseConfig, NamedTuple):
2729
repos: List[Repo]
2830

31+
@entry_point('memory')
2932
class MemorySource(BaseSource):
3033
'''
3134
Stores repos in a dict in memory
@@ -40,10 +43,14 @@ def __init__(self, config: BaseConfig) -> None:
4043
self.mem = {repo.src_url: repo for repo in self.config.repos}
4144

4245
@classmethod
43-
def args(self) -> Dict[str, Any]:
44-
return {}
46+
def args(cls, args, *above) -> Dict[str, Arg]:
47+
cls.config_set(args, above, 'keys',
48+
Arg(type=str,
49+
nargs='+',
50+
default=[]))
51+
return args
4552

4653
@classmethod
47-
def config(cls, cmd) -> Dict[str, Any]:
48-
keys = getattr(cmd, 'keys', [])
49-
return MemorySourceConfig(repos=list(map(Repo, keys)))
54+
def config(cls, config, *above):
55+
return MemorySourceConfig(repos=list(map(Repo,
56+
cls.config_get(config, above, 'keys'))))

0 commit comments

Comments
 (0)