codebases

Models

This module contains a model that is expected to be used for the codebases used by Transifex. The following definitions are used:

resource:
A file within a codebase
codebase:
A collection of files (VCS repo, tarball, etc.) that contains resources, some or all of which are to be translated
class Unit(*args, **kwargs)

An abstract codebase; a VCS repo, tarball, or some other piece of code.

The following methods should be implemented by children:
prepare teardown get_files get_rev submit
classmethod bootstrap(unit)
Creates a descendent from a Unit and returns it, saving if a new Unit descendant is created
classmethod bootstrap_extra(unit)
Extra initialization after bootstrapping Descendents should override as necessary
get_files(filter)
Returns one or more resources within to the codebase as given by the filter
get_rev(path)
Returns the current revision of either the codebase or of a resource within it
prepare()
Prepares the codebase for use by Transifex by downloading, extracting, etc.
promote()
Returns a descendent model that refers to this codebase
submit(files, message, user)
Replaces one or more of the resources in a codebase with supplied contents
teardown()
Cleans out any downloads used by the codebase

Library

get_browser_class(codebase_type)

Return the appropriate VCS browser class.

Keyword arguments: codebase_type – The type of the codebase, used to decide the class to be returned.

>>> print get_browser_class('hg')
vcs.lib.types.hg.HgBrowser
get_browser_object(codebase_type)

Return the appropriate codebase browser object.

This is a wrapper around get_browser_class which returns a browser object, ready to be initialized.

>>> browser = get_browser_object('hg')
need_browser(fn)
Decorator to initialize the unit.browser when it is needed.