summaryrefslogtreecommitdiff
path: root/migrate/versioning/util/keyedinstance.py
diff options
context:
space:
mode:
authorJim Rollenhagen <jim@jimrollenhagen.com>2019-09-26 09:56:42 -0400
committerJim Rollenhagen <jim@jimrollenhagen.com>2019-09-26 09:56:42 -0400
commit52672a64cc0cab4ea14a4a756fce850eb03315e3 (patch)
treea86024e4e6141aa8983c750f751c58d924f5b11a /migrate/versioning/util/keyedinstance.py
parent8acab2cd75a5b23ac162e49c8e4fb1e3f958352a (diff)
downloadsqlalchemy-migrate-master.tar.gz
Retire github mirror, repo moved to opendevHEADmaster
Diffstat (limited to 'migrate/versioning/util/keyedinstance.py')
-rw-r--r--migrate/versioning/util/keyedinstance.py36
1 files changed, 0 insertions, 36 deletions
diff --git a/migrate/versioning/util/keyedinstance.py b/migrate/versioning/util/keyedinstance.py
deleted file mode 100644
index a692e08..0000000
--- a/migrate/versioning/util/keyedinstance.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-class KeyedInstance(object):
- """A class whose instances have a unique identifier of some sort
- No two instances with the same unique ID should exist - if we try to create
- a second instance, the first should be returned.
- """
-
- _instances = dict()
-
- def __new__(cls, *p, **k):
- instances = cls._instances
- clskey = str(cls)
- if clskey not in instances:
- instances[clskey] = dict()
- instances = instances[clskey]
-
- key = cls._key(*p, **k)
- if key not in instances:
- instances[key] = super(KeyedInstance, cls).__new__(cls)
- return instances[key]
-
- @classmethod
- def _key(cls, *p, **k):
- """Given a unique identifier, return a dictionary key
- This should be overridden by child classes, to specify which parameters
- should determine an object's uniqueness
- """
- raise NotImplementedError()
-
- @classmethod
- def clear(cls):
- # Allow cls.clear() as well as uniqueInstance.clear(cls)
- if str(cls) in cls._instances:
- del cls._instances[str(cls)]