From d1d9fc3ede71309585f0324ca24fc413c5d0cf6d Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Wed, 19 Dec 2018 08:51:38 +0100 Subject: [PATCH] Injector to properly reflect doc string etc --- graphenecommon/blockchainobject.py | 7 +++---- graphenecommon/instance.py | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/graphenecommon/blockchainobject.py b/graphenecommon/blockchainobject.py index 06c1ce5f..457cf14d 100644 --- a/graphenecommon/blockchainobject.py +++ b/graphenecommon/blockchainobject.py @@ -58,7 +58,6 @@ class BlockchainObject(dict): type_ids = [] _cache = ObjectCache() - __originalname__ = "" @staticmethod def clear_cache(): @@ -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): @@ -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): diff --git a/graphenecommon/instance.py b/graphenecommon/instance.py index 558275bd..d88cc374 100644 --- a/graphenecommon/instance.py +++ b/graphenecommon/instance.py @@ -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 """ @@ -14,8 +18,6 @@ class AbstractBlockchainInstanceProvider: contains an instance of the main chain instance """ - __originalname__ = "" - def __init__(self, *args, **kwargs): pass @@ -23,12 +25,14 @@ def __init__(self, *args, **kwargs): 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):