old_contents: """Singleton behaviour for tracking individual objects (enum-like)"""
  
  from collections import OrderedDict
  from properties.base import PropertyMetaclass
  from properties import HasProperties
  import six
  
  
  class SingletonMetaclass(PropertyMetaclass):
      """Metaclass to produce singleton behaviour"""
  
      def __call__(cls, name, **kwargs):
          """Look up an entry by 'name' from the registry, or make a new one"""
          if name in cls._SINGLETONS:
              return cls._SINGLETONS[name]
          new_singleton = super(SingletonMetaclass, cls).__call__(name, **kwargs)
          cls._SINGLETONS[name] = new_singleton
          return new_singleton
  
  
  class Singleton(
          six.with_metaclass(SingletonMetaclass, HasProperties)):
      """Class that only allows one of each child with a given name"""
  
      _SINGLETONS = OrderedDict()
  
      def __init__(self, name, **kwargs):
          """Initialize with a name"""
          self.name = name
          super(Singleton, self).__init__(**kwargs)
  
      def serialize(self, **kwargs):
          """Serialize to a name representation"""
          return self.name
  
      @classmethod
      def deserialize(cls, value, **kwargs):
          """Deserialize to reconstruct as needed"""
          if isinstance(value, cls):
              return value
          if isinstance(value, str) and value in cls._SINGLETONS:
              return cls._SINGLETONS[value]
          return super(Singleton, cls).deserialize(value, **kwargs)
  
      def __str__(self):
          return self.name
  
new_contents: """Singleton behavior for tracking individual objects (enum-like)"""
  import six
  
  from ..base import HasProperties, PropertyMetaclass
  
  
  class SingletonMetaclass(PropertyMetaclass):
      """Metaclass to produce singleton behaviour"""
  
      def __call__(cls, name, **kwargs):
          """Look up an entry by name in the registry, or make a new one"""
          if name in cls._SINGLETONS:
              oldinst = cls._SINGLETONS[name]
              if oldinst.__class__ is not cls:
                  raise ValueError('Singleton {} is class {}, not {}'.format(
                      name, oldinst.__class__.__name__, cls.__name__,
                  ))
              return oldinst
          newinst = super(SingletonMetaclass, cls).__call__(name, **kwargs)
          cls._SINGLETONS[name] = newinst
          return newinst
  
  
  class Singleton(six.with_metaclass(SingletonMetaclass, HasProperties)):
      """Class that only allows one of each child with a given name"""
  
      _SINGLETONS = dict()
  
      def __init__(self, name, **kwargs):
          """Initialize with a name"""
          self.name = name
          self.__id__ = name
          super(Singleton, self).__init__(**kwargs)
  
      def serialize(self, **kwargs):
          json_dict = super(Singleton, self).serialize(**kwargs)
          json_dict['__id__'] = self.__id__
          return json_dict
  
      @classmethod
      def deserialize(cls, value, **kwargs):
          if not isinstance(value, dict):
              raise ValueError('HasProperties must deserialize from dictionary')
          if '__id__' not in value:
              raise ValueError('Singleton classes must contain identifying name')
          if value['__id__'] in cls._SINGLETONS:
              return cls._SINGLETONS[value['__id__']]
          name = value.get('name', None)
          value.update({'name': value['__id__']})
          newinst = super(Singleton, cls).deserialize(value, **kwargs)
          if name:
              newinst.name = name
          return newinst
  
subject: Update singleton funtionality to be slightly more generic