Push from_config up one level into character

pull/447/head
Kieran Prasch 2018-09-24 13:58:50 -07:00
parent 293f9c158c
commit c3923e2537
5 changed files with 9 additions and 17 deletions

View File

@ -465,6 +465,10 @@ class Character(Learner):
self._set_checksum_address()
return self._checksum_address
@classmethod
def from_config(cls, config, **overrides) -> 'Character':
return config.produce(**overrides)
@classmethod
def from_public_keys(cls, powers_and_material: Dict, federated_only=True, *args, **kwargs) -> 'Character':
# TODO: Need to be federated only until we figure out the best way to get the checksum_address in here.

View File

@ -149,14 +149,6 @@ class Bob(Character):
from nucypher.policy.models import WorkOrderHistory # Need a bigger strategy to avoid circulars.
self._saved_work_orders = WorkOrderHistory()
@classmethod
def from_config(cls, filepath, overrides: dict = None) -> 'Bob':
payload = parse_character_config(filepath=filepath)
if overrides is not None:
payload.update(overrides)
instance = cls(**payload)
return instance
def peek_at_treasure_map(self, treasure_map=None, map_id=None):
"""
Take a quick gander at the TreasureMap matching map_id to see which
@ -576,11 +568,6 @@ class Ursula(Character, VerifiableNode, Miner):
# Alternate Constructors
#
@classmethod
def from_config(cls, ursula_configuration, **overrides) -> 'Ursula':
ursula = ursula_configuration.produce(**overrides)
return ursula
@classmethod
def from_rest_url(cls,
network_middleware: RestMiddleware,

View File

@ -5,7 +5,7 @@ from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
from cryptography.x509 import Certificate
from nucypher.blockchain.eth.agents import EthereumContractAgent, PolicyAgent
from nucypher.blockchain.eth.agents import EthereumContractAgent
from nucypher.config.constants import DEFAULT_CONFIG_FILE_LOCATION
from nucypher.config.node import NodeConfiguration
from nucypher.crypto.powers import CryptoPower
@ -120,7 +120,7 @@ class UrsulaConfiguration(NodeConfiguration):
# if self.save_metadata: # TODO: Does this belong here..?
ursula.write_node_metadata(node=ursula)
ursula.save_certificate_to_disk(directory=ursula.known_certificates_dir) # TODO: Move this
ursula.save_certificate_to_disk(directory=ursula.known_certificates_dir) # TODO: Move this..?
if self.temp:
class MockDatastoreThreadPool(object): # TODO: Does this belong here..?
@ -152,4 +152,5 @@ class AliceConfiguration(NodeConfiguration):
class BobConfiguration(NodeConfiguration):
from nucypher.characters.lawful import Bob
_Character = Bob

View File

@ -18,7 +18,7 @@ class NodeConfiguration:
_parser = NotImplemented
DEFAULT_OPERATING_MODE = 'decentralized'
__TEMP_CONFIGURATION_DIR_PREFIX = "nucypher-tmp-cli-"
__TEMP_CONFIGURATION_DIR_PREFIX = "nucypher-tmp-"
__REGISTRY_NAME = 'contract_registry.json'
__DEFAULT_NETWORK_MIDDLEWARE_CLASS = RestMiddleware

View File

@ -27,7 +27,7 @@ class NoBlockchainPower(PowerUpError):
class CryptoPower(object):
def __init__(self, power_ups: dict = None) -> None:
def __init__(self, power_ups: list = None) -> None:
self._power_ups = {} # type: dict
# TODO: The keys here will actually be IDs for looking up in a KeyStore.
self.public_keys = {} # type: dict