repomate_plug
Module Reference¶
API¶
-
class
repomate_plug.
Plugin
[source]¶ Base class for plugin classes. For plugin classes to be picked up by
repomate
, they must inherit from this class.Public methods must be hook methods, i.e. implement the specification of one of the hooks defined in
PeerReviewHook
orCloneHook
. If there are any other public methods, an error is raised on class creation. As long as the method has the correct name, it will be recognized as a hook method.The signature of the method is not checked until the hook is registered by the
repomate_plug.manager
(an instance ofpluggy.manager.PluginManager
). Therefore, when testing a plugin, it is a good idea to include a test where it is registered with the manager to ensure that it has the correct signatures.Private methods (i.e. methods prefixed with
_
) carry no such restrictions.
pluginmeta¶
-
class
repomate_plug.pluginmeta.
Plugin
[source]¶ Base class for plugin classes. For plugin classes to be picked up by
repomate
, they must inherit from this class.Public methods must be hook methods, i.e. implement the specification of one of the hooks defined in
PeerReviewHook
orCloneHook
. If there are any other public methods, an error is raised on class creation. As long as the method has the correct name, it will be recognized as a hook method.The signature of the method is not checked until the hook is registered by the
repomate_plug.manager
(an instance ofpluggy.manager.PluginManager
). Therefore, when testing a plugin, it is a good idea to include a test where it is registered with the manager to ensure that it has the correct signatures.Private methods (i.e. methods prefixed with
_
) carry no such restrictions.
corehooks¶
Hookspecs for repomate core hooks.
Core hooks provide the basic functionality of repomate. These hooks all have default implementations, but are overridden by any other implementation. All hooks in this module should have the firstresult=True option to the hookspec to allow for this dynamic override.
-
class
repomate_plug.corehooks.
PeerReviewHook
[source]¶ Hook functions related to allocating peer reviews.
-
generate_review_allocations
(master_repo_name, students, num_reviews, review_team_name_function)[source]¶ Generate a (peer_review_team -> reviewers) mapping for each student repository (i.e. <student>-<master_repo_name>), where len(reviewers) = num_reviews.
review_team_name_function should be used to generate review team names. It should be called like:
review_team_name_function(master_repo_name, student)
Important
There must be strictly more students than reviewers per repo (num_reviews). Otherwise, allocation is impossible.
Parameters: - master_repo_name (
str
) – Name of a master repository. - students (
Iterable
[str
]) – Students for which to generate peer review allocations. - num_reviews (
int
) – Amount of reviews each student should perform (and consequently amount of reviewers per repo) - review_team_name_function (
Callable
[[str
,str
],str
]) – A function that takes a master repo name as its first argument, and a student username as its second, and returns a review team name.
Return type: Returns: a (peer_review_team -> reviewers) mapping for each student repository.
- master_repo_name (
-
exthooks¶
Hookspecs for repomate extension hooks.
Extension hooks add something to the functionality of repomate, but are not necessary for its operation. Currently, all extension hooks are related to cloning repos.
-
class
repomate_plug.exthooks.
CloneHook
[source]¶ Hook functions related to cloning repos.
-
act_on_cloned_repo
(path, api)[source]¶ Do something with a cloned repo.
Parameters: Return type: Optional
[HookResult
]Returns: optionally returns a HookResult namedtuple for reporting the outcome of the hook. May also return None, in which case no reporting will be performed for the hook.
-
clone_parser_hook
(clone_parser)[source]¶ Do something with the clone repos subparser before it is used used to parse CLI options. The typical task is to add options to it.
Parameters: clone_parser ( ArgumentParser
) – Theclone
subparser.Return type: None
-
config_hook
(config_parser)[source]¶ Hook into the config file parsing.
Parameters: config – the config parser after config has been read. Return type: None
-
parse_args
(args)[source]¶ Get the raw args from the parser. Only called for the clone parser. The typical task is to fetch any values from options added in
clone_parser_hook()
.Parameters: args ( Namespace
) – The full namespace returned byargparse.ArgumentParser.parse_args()
Return type: None
-