"""Extension that generates configuration for Cirrus CI."""fromargparseimportArgumentParserfromtypingimportListfrom..importstructurefrom..actionsimportAction,ActionParams,ScaffoldOpts,Structurefrom..operationsimportno_overwritefrom..templatesimportget_templatefrom.importExtension,includefrom.pre_commitimportPreCommitTEMPLATE_FILE="cirrus"
[docs]classCirrus(Extension):"""Add configuration file for Cirrus CI (includes `--pre-commit`)"""
[docs]defaugment_cli(self,parser:ArgumentParser):"""Augments the command-line interface parser. See :obj:`~pyscaffold.extension.Extension.augment_cli`. """parser.add_argument(self.flag,help=self.help_text,nargs=0,action=include(PreCommit(),self))returnself
[docs]defactivate(self,actions:List[Action])->List[Action]:"""Activate extension, see :obj:`~pyscaffold.extension.Extension.activate`."""returnself.register(actions,add_files,after="define_structure")
[docs]defadd_files(struct:Structure,opts:ScaffoldOpts)->ActionParams:"""Add .cirrus.yml to the file structure Args: struct: project representation as (possibly) nested :obj:`dict`. opts: given options, see :obj:`create_project` for an extensive list. Returns: struct, opts: updated project representation and options """files:Structure={".cirrus.yml":(cirrus_descriptor,no_overwrite())}returnstructure.merge(struct,files),opts
[docs]defcirrus_descriptor(_opts:ScaffoldOpts)->str:"""Returns the rendered template"""returnget_template(TEMPLATE_FILE).template# no substitutions required