diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 17:42:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 17:42:51 +0000 |
commit | ba429d344132c088177e853cce8ff7181570b221 (patch) | |
tree | 87ebf15269b4301737abd1735baabba71be93622 /plugins/snippets/snippets/singleton.py | |
parent | Initial commit. (diff) | |
download | gedit-upstream.tar.xz gedit-upstream.zip |
Adding upstream version 44.2.upstream/44.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/snippets/snippets/singleton.py')
-rw-r--r-- | plugins/snippets/snippets/singleton.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/snippets/snippets/singleton.py b/plugins/snippets/snippets/singleton.py new file mode 100644 index 0000000..9bc346d --- /dev/null +++ b/plugins/snippets/snippets/singleton.py @@ -0,0 +1,27 @@ +# Gedit snippets plugin +# Copyright (C) 2011 Jesse van den Kieboom <jessevdk@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +class Singleton(type): + def __init__(cls, name, bases, dict): + super(Singleton, cls).__init__(name, bases, dict) + cls.instance = None + + def __call__(cls, *args, **kw): + if cls.instance is None: + cls.instance = super(Singleton, cls).__call__(*args, **kw) + + return cls.instance |