Skip to content

Commit

Permalink
Injector to properly reflect doc string etc
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Dec 19, 2018
1 parent bd11945 commit d1d9fc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 3 additions & 4 deletions graphenecommon/blockchainobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class BlockchainObject(dict):
type_ids = []

_cache = ObjectCache()
__originalname__ = ""

@staticmethod
def clear_cache():
Expand Down Expand Up @@ -135,10 +134,10 @@ def testid(self, id):
self.type_ids = [self.type_id]

assert int(parts[0]) == self.space_id, "Valid id's for {} are {}.{}.x".format(
self.__originalname__, self.space_id, self.type_id
self.__name__, self.space_id, self.type_id
)
assert int(parts[1]) in self.type_ids, "Valid id's for {} are {}.{}.x".format(
self.__originalname__, self.space_id, self.type_ids
self.__name__, self.space_id, self.type_ids
)

def cache(self, key=None):
Expand Down Expand Up @@ -170,7 +169,7 @@ def __contains__(self, key):
return dict.__contains__(self, key)

def __repr__(self):
return "<%s %s>" % (self.__originalname__, str(self.identifier))
return "<%s %s>" % (self.__name__, str(self.identifier))


class Object(BlockchainObject, AbstractBlockchainInstanceProvider):
Expand Down
10 changes: 7 additions & 3 deletions graphenecommon/instance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
from functools import update_wrapper
import types


class SharedInstance:
""" This class merely offers a singelton for the Blockchain Instance
"""
Expand All @@ -14,21 +18,21 @@ class AbstractBlockchainInstanceProvider:
contains an instance of the main chain instance
"""

__originalname__ = ""

def __init__(self, *args, **kwargs):
pass

@classmethod
def inject(slf, cls):
class NewClass(slf, cls):
blockchain_instance_class = slf
__originalname__ = cls.__name__

def __init__(self, *args, **kwargs):
slf.__init__(self, *args, **kwargs)
cls.__init__(self, *args, **kwargs)

NewClass.__name__ = cls.__name__
NewClass.__doc__ = cls.__doc__
NewClass.__module__ = cls.__module__
return NewClass

def get_instance_class(self):
Expand Down

0 comments on commit d1d9fc3

Please sign in to comment.