예제 #1
0
    def test_persist(self):
        try:
            Registry.set(1, 2, 3, 4)
            tmp = tempfile.mkdtemp()
            file_path = os.path.join(tmp, "foo.json")
            Registry.persist(file_path)

            Registry.set(1, 2, 3, 5)
            Registry._obj = {}

            Registry.from_file(file_path)

            self.assertEqual({"1": {"2": {"3": 4}}}, Registry())
        finally:
            shutil.rmtree(tmp)
예제 #2
0
파일: cli.py 프로젝트: tefra/pytuber
def cli(ctx: click.Context):
    """Create and upload music playlists to youtube."""
    appdir = click.get_app_dir("pytuber", False)
    if not os.path.exists(appdir):
        print("Application Directory not found! Creating one at", appdir)
        os.makedirs(appdir)
    cfg = os.path.join(appdir, "storage.db")
    init_registry(cfg, version)

    ctx.call_on_close(lambda: Registry.persist(cfg))
예제 #3
0
파일: cli.py 프로젝트: Starz0r/pytuber
def cli(ctx: click.Context):
    """Create and upload music playlists to youtube."""
    cfg = os.path.join(click.get_app_dir("pytuber", False), "storage.db")
    init_registry(cfg, version)

    ctx.call_on_close(lambda: Registry.persist(cfg))