From 3e6a3ce2785784c731534b1b5aa1e84c685724bb Mon Sep 17 00:00:00 2001
From: Gusev Anton <gusev_aa@groupbwt.com>
Date: Thu, 13 Jun 2019 18:40:15 +0300
Subject: [PATCH] refactoring move Singleton class to separate file

---
 src/database/Connector.py | 9 +--------
 src/utils/Singleton.py    | 9 +++++++++
 src/utils/__init__.py     | 0
 3 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 src/utils/Singleton.py
 create mode 100644 src/utils/__init__.py

diff --git a/src/database/Connector.py b/src/database/Connector.py
index 808ba27..3641bcd 100644
--- a/src/database/Connector.py
+++ b/src/database/Connector.py
@@ -1,14 +1,7 @@
 from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker
 from scrapy.conf import settings
-
-
-class Singleton(type):
-    _instances = {}
-    def __call__(cls, *args, **kwargs):
-        if cls not in cls._instances:
-            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
-        return cls._instances[cls]
+from utils.Singleton import Singleton
 
 
 class Connector(metaclass=Singleton):
diff --git a/src/utils/Singleton.py b/src/utils/Singleton.py
new file mode 100644
index 0000000..0ef7844
--- /dev/null
+++ b/src/utils/Singleton.py
@@ -0,0 +1,9 @@
+
+
+class Singleton(type):
+    _instances = {}
+
+    def __call__(cls, *args, **kwargs):
+        if cls not in cls._instances:
+            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
+        return cls._instances[cls]
\ No newline at end of file
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
new file mode 100644
index 0000000..e69de29
-- 
GitLab