Beispiel #1
0
    def load_all_configs(cls):
        '''
        读取当前硬盘上所有DB_CONFIG 对应的json
        :return: None
        '''
        config_path = DayuPath(
            os.environ.get(
                DAYU_CONFIG_STATIC_PATH,
                DayuPath(__file__).parent.child('static', cls.prefix +
                                                '_config_presets')))

        assert config_path.exists() is True

        for json_preset in config_path.walk():
            if json_preset.ext == '.json':
                with open(json_preset, 'r') as jf:
                    preset_value = json.load(jf, encoding='utf-8')

                    preset_key = json_preset.replace(config_path,
                                                     '').replace('\\', '/')
                    preset_key = preset_key.replace('.json',
                                                    '').replace('default',
                                                                '').strip('/')
                    preset_key = cls.prefix + '.' + '.'.join(
                        preset_key.split('/'))

                    cls.all_configs.update({preset_key: preset_value})

        return cls()
Beispiel #2
0
 def test_os_functions(self):
     path = DayuPath(self.mock_path).child(
         'cam_test', 'A001C001_180212_RG8C.9876521.exr')
     self.assertIsNotNone(path.state())
     self.assertIsNotNone(path.lstate())
     self.assertIsNotNone(path.exists())
     self.assertIsNotNone(path.lexists())
     self.assertIsNotNone(path.isfile())
     self.assertIsNotNone(path.isdir())
     self.assertIsNotNone(path.islink())
     self.assertIsNotNone(path.ismount())
     self.assertIsNotNone(path.atime())
     self.assertIsNotNone(path.ctime())
     self.assertIsNotNone(path.mtime())
     self.assertIsNotNone(path.size())