PK!carthorse/__init__.pyPK!:&Xcarthorse/actions.pyimport os from subprocess import check_call def run(command): print('$ '+command) check_call(command, shell=True) def create_tag(remote='origin'): tag = os.environ['TAG'] run('git tag '+tag) run('git push {} tag {}'.format(remote, tag)) PK!carthorse/cli.pyimport os from argparse import ArgumentParser from .config import load_config from . import version_from, when, actions def parse_args(): parser = ArgumentParser() parser.add_argument('--config', default='pyproject.toml') return parser.parse_args() def main(): args = parse_args() config = load_config(args.config) version = config.run(version_from, config['version-from']) tag_format = config.get('tag-format', 'v{version}') os.environ['TAG'] = tag_format.format(version=version) ok = True for check in config['when']: ok = config.run(when, check) if not ok: break if ok: for action in config['actions']: config.run(actions, action) PK!k@  carthorse/config.pyfrom functools import reduce from operator import __getitem__ from os.path import splitext from yaml import safe_load as parse_yaml from toml import load as parse_toml class Config(object): def __init__(self, path): with open(path) as source: data = self.parse(source) self.data = reduce(__getitem__, self.root_key, data) self.data['version-from'] = self.expand(self.data['version-from']) for name in 'when', 'actions': self.data[name] = [self.expand(item) for item in self.data[name]] def expand(self, item): if isinstance(item, str): return dict(name=item, args=(), kw={}) else: name = item.pop('name', None) if name is None: (name, arg), = item.items() else: arg = item if isinstance(arg, dict): kw = arg args = () else: kw = {} args = (arg,) return dict(name=name, args=args, kw=kw) def __getitem__(self, item): return self.data[item] def get(self, item, default): return self.data.get(item, default) def run(self, module, config): func = getattr(module, config['name'].replace('-', '_')) kw = config['kw'].copy() return func(*config['args'], **kw) class TomlConfig(Config): root_key = ['tool', 'carthorse'] def parse(self, source): return parse_toml(source) class YamlConfig(Config): root_key = ['carthorse'] def parse(self, source): return parse_yaml(source) parsers = { '.toml': TomlConfig, '.yml': YamlConfig, '.yaml': YamlConfig, } def load_config(path): class_ = parsers[splitext(path)[-1]] return class_(path) PK!~!KVcarthorse/version_from.pyimport toml def poetry(): with open('pyproject.toml') as source: data = toml.load(source) return data['tool']['poetry']['version'] PK!{(carthorse/when.pyimport os from subprocess import CalledProcessError, check_output def version_not_tagged(): version = os.environ['TAG'] command = 'git rev-parse --verify -q '+version print('$ '+command) try: tag = check_output(command, shell=True).decode('ascii').strip() except CalledProcessError as e: if e.returncode == 1: print('No tag found.') return True raise else: print(tag) return False def never(): pass PK!H^*0*carthorse-0.1.0.dist-info/entry_points.txtN+I/N.,()JN,*/*Ns2r3PK!HqfWXcarthorse-0.1.0.dist-info/WHEEL A н#f."jm)!fb҅~ܴA,mTD}E n0H饹*|D[¬c i=0(q3PK!Hc"carthorse-0.1.0.dist-info/METADATARMO0 WLՏj@(lFjLS{<7rR)q6ŏb5JiSсrd]ɲS5`p%GFAqG*>{gb#s.ldcvPB<{# `zZ82'= l8늬>RݮXC9q>"ǫJR8- Wbӽ¿QgPK!H}- carthorse-0.1.0.dist-info/RECORD}Ϲ@@ѼZMvƤ"K,RO'w^c 8hpRXAQݾM ?ܻ6mg*GJu-^Izf^&,>F:I?۽ct5If[3,橕ΫXac*C:;I:'!0+J̞]۸rx펦뼕_az:2m%kk3kVӰvG؝\R@S'[@$(Y*oWН8vfwf|ɩkӶRu*kW1c,|e V%kjU Y* PҲN&KrӾ:\J T7RI WN}X"P̀xNSWf%5Y")SeS/PK!carthorse/__init__.pyPK!:&X3carthorse/actions.pyPK!jcarthorse/cli.pyPK!k@  vcarthorse/config.pyPK!~!KV carthorse/version_from.pyPK!{( carthorse/when.pyPK!H^*0*carthorse-0.1.0.dist-info/entry_points.txtPK!HqfWXcarthorse-0.1.0.dist-info/WHEELPK!Hc"carthorse-0.1.0.dist-info/METADATAPK!H}- carthorse-0.1.0.dist-info/RECORDPK