source: SHX/trunk/src/SeismicHandler/basics/tools.py @ 258

Revision 258, 561 bytes checked in by marcus, 12 years ago (diff)

Working on miniseed access and configuration file.

  • Property svn:eol-style set to native
Line 
1# -*- coding: utf-8 -*-
2
3"""
4Collection of globally used helper functions.
5"""
6__all__ = ["Property", "Singleton"]
7
8# property wrapper
9def Property(func):
10    return property(**func())
11
12class Singleton(type):
13    """
14    Meta-class for singletons.
15    """
16
17    def __init__(cls, name, bases, dic):
18        super(Singleton, cls).__init__(name, bases, dic)
19        cls.instance = None
20
21    def __call__(cls, *args, **kwargs):
22        if cls.instance is None:
23            cls.instance = super(Singleton, cls).__call__(*args, **kwargs)
24
25        return cls.instance
Note: See TracBrowser for help on using the repository browser.