Пример #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
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
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))