filebot/util.py

34 lines
774 B
Python
Raw Normal View History

2022-10-06 15:44:35 +02:00
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
2016-04-21 21:55:31 +02:00
import os
def log(data):
with open(curr_directory() + '/logs.log', 'a') as fl:
fl.write(str(data) + '\n')
def curr_directory():
return os.path.dirname(os.path.realpath(__file__))
2016-10-02 19:19:39 +02:00
def folder_size(path):
size = 0
for f in os.listdir(path):
f = unicode(f)
if os.path.isfile(os.path.join(path, f)):
size += os.path.getsize(os.path.join(path, f))
return size
2016-04-21 21:55:31 +02:00
class Singleton(object):
def __new__(cls, *args, **kwargs):
if not hasattr(cls, '_instance'):
2022-10-06 15:44:35 +02:00
cls._instance = super(Singleton, cls).__new__(cls)
2016-04-21 21:55:31 +02:00
return cls._instance
@classmethod
def get_instance(cls):
return cls._instance