Persist Task

This module deals with persisting the “resources” (text files and the stack) to the git repo in the JOY_HOME directory.

class joy.vui.persist_task.PersistTask(home)[source]

This class deals with saving changes to the git repo.

commit(message='auto-commit')[source]

Commit.

handle(message)[source]

Handle messages, dispatch to handle_FOO() methods.

handle_modify(message)[source]

Foo.

handle_open(message)[source]

Foo.

handle_persist(message)[source]

Foo.

handle_persist_new(message)[source]

Foo.

open(name)[source]

Look up the named file in home and return its content_id and data.

persist(content_id)[source]

Persist a resource.

scan()[source]

Return a sorted list of all the files in the home dir.

task_run()[source]

Stage any outstanding changes.

class joy.vui.persist_task.PickledResource(filename, repo_relative_filename, thing=None)[source]

A Resource subclass that uses pickle on its file/thing.

class joy.vui.persist_task.Resource(filename, repo_relative_filename, thing=None)[source]

Handle the content of a text files as a list of lines, deal with saving it and staging the changes to a repo.

persist(repo)[source]

Save the lines to the file and stage the file in the repo.

joy.vui.persist_task.check_filename(name)[source]

Sanity checks for filename.

joy.vui.persist_task.init_repo(repo_dir)[source]

Initialize a git repository in the directory. Stage and commit all files (toplevel, not those in subdirectories if any) in the dir.

joy.vui.persist_task.make_repo_relative_path_maker(repo)[source]

Helper function to return a function that returns a path given a path, that’s relative to the repository.

joy.vui.persist_task.open_repo(repo_dir=None, initialize=False)[source]

Open, or create, and return a Dulwich git repo object for the given directory. If the dir path doesn’t exist it will be created. If it does exist but isn’t a repo the result depends on the initialize argument. If it is False (the default) a NotGitRepository exception is raised, otherwise git init is effected in the dir.