mirror of
https://github.com/thegeeklab/git-batch.git
synced 2024-11-14 15:20:40 +00:00
28 lines
571 B
Python
28 lines
571 B
Python
#!/usr/bin/env python3
|
|
"""Global utility methods and classes."""
|
|
|
|
import os
|
|
from distutils.util import strtobool
|
|
|
|
|
|
def normalize_path(path):
|
|
if path:
|
|
return os.path.abspath(os.path.expanduser(os.path.expandvars(path)))
|
|
|
|
return None
|
|
|
|
|
|
def to_bool(string):
|
|
return bool(strtobool(str(string)))
|
|
|
|
|
|
class Singleton(type):
|
|
"""Meta singleton class."""
|
|
|
|
_instances = {}
|
|
|
|
def __call__(cls, *args, **kwargs):
|
|
if cls not in cls._instances:
|
|
cls._instances[cls] = super().__call__(*args, **kwargs)
|
|
return cls._instances[cls]
|