# Path: gsdview/utils.py
# def default_workdir():
# def _getresource(resource, package):
# def getresource(resource, package=None):
# def format_platform_info():
# def format_bugreport(exctype=None, excvalue=None, tracebackobj=None,
#                      extra_info=None):
#     def isexecutable(cmd):
#     def isexecutable(cmd):
# def isscript(filename):
# def scriptcmd(scriptname):
#     def get_tree_size(path):
#     def get_tree_size(path):
# def data_uuid(path, prefixlen=23):
# def geonormalize(x, angle_range=360.):


import os
import shutil
import tempfile
import unittest
from gsdview import utils



class TestDirectorySize(unittest.TestCase):
    DATASIZE = 1024  # 1 kbyte

    def setUp(self):
        self.dirname = tempfile.mkdtemp(prefix='gsdview_test_utils_')

    def _popuate_test_dir(self):
        data = b'0' * self.DATASIZE

        with open(os.path.join(self.dirname, 'test.dat'), 'wb') as fd:
            fd.write(data)

        subdir = os.path.join(self.dirname, 'testdir')
        os.makedirs(subdir)

        with open(os.path.join(subdir, 'test.dat'), 'wb') as fd:
            fd.write(data)

    def tearDown(self):
        shutil.rmtree(self.dirname)

    def test_directory_size(self):
        self._popuate_test_dir()
        dirsize = utils.get_tree_size(self.dirname)
        self.assertEqual(dirsize, 2 * self.DATASIZE)

    def test_empty_directory_size(self):

# Path: gsdview/utils.py
# def default_workdir():
# def _getresource(resource, package):
# def getresource(resource, package=None):
# def format_platform_info():
# def format_bugreport(exctype=None, excvalue=None, tracebackobj=None,
#                      extra_info=None):
#     def isexecutable(cmd):
#     def isexecutable(cmd):
# def isscript(filename):
# def scriptcmd(scriptname):
#     def get_tree_size(path):
#     def get_tree_size(path):
# def data_uuid(path, prefixlen=23):
# def geonormalize(x, angle_range=360.):


# Path: tests/test_utils.py
import os
import shutil
import tempfile
import unittest
from gsdview import utils




class TestDirectorySize(unittest.TestCase):
    DATASIZE = 1024  # 1 kbyte

    def setUp(self):
        self.dirname = tempfile.mkdtemp(prefix='gsdview_test_utils_')

    def _popuate_test_dir(self):
        data = b'0' * self.DATASIZE

        with open(os.path.join(self.dirname, 'test.dat'), 'wb') as fd:
            fd.write(data)

        subdir = os.path.join(self.dirname, 'testdir')
        os.makedirs(subdir)

        with open(os.path.join(subdir, 'test.dat'), 'wb') as fd:
            fd.write(data)

    def tearDown(self):
        shutil.rmtree(self.dirname)

    def test_directory_size(self):
        self._popuate_test_dir()
        dirsize = utils.get_tree_size(self.dirname)
        self.assertEqual(dirsize, 2 * self.DATASIZE)

    def test_empty_directory_size(self):

        dirsize = utils.get_tree_size(self.dirname)