Beispiel #1
0
 def save_table(self, table_name):
     logger.info("saving table {0}".format(table_name))
     utils.make_path(table_name[:table_name.rfind('/')])
     table_key = table_name.strip('.json').strip(
         self.dbpath).strip(os.path.sep).replace(os.path.sep, '.')
     logger.debug("table_key: {0}: {1}".format(table_key,
         json.dumps(self.tables.get(table_key), sort_keys=True, indent=2)))
     with open(table_name, 'w+') as f:
         f.write(json.dumps(self.tables.get(table_key),
             sort_keys=True, indent=2))
Beispiel #2
0
 def test_makepath(self):
     path = os.path.sep.join(("hello", "world", "hello"))
     self.assertFalse(os.path.exists(path))
     utils.make_path(path)
     self.assertTrue(os.path.exists(path))
     shutil.rmtree(path[:path.find(os.path.sep)])