PK!carthorse/__init__.pyPK! carthorse/actions.pyimport os from subprocess import check_call def run(command): print('$ '+command) check_call(command, shell=True) def git_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!HڽTUcarthorse-0.1.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Hn5"carthorse-0.1.0.dist-info/METADATAAK1sT]W(*J=ֵXl: l:I,Mӄ޼#|ÀŖkg\J4hHAzǞķYJbAlpO-m;`=y8datmGzl4R;CtyhvX閬%L`ٳөZA=$'O:3G 2/^55јJ1Ji-Aa pq7ܔH[rHʱOPK!H1 carthorse-0.1.0.dist-info/RECORD}Ϲ@ѼlB EeQ ()Dg|G]A ."Yj.lSDCW/38c^rAfƣ_?*{\Wd&Ec+9S#j1s4.Zq̊ Y0w*g]{7+Der7$oG1rn #aL|,w=z0p(}]%wń+9p |fA88tLSz]zߗ@Cr,&=FUMqՓE?žӒGALh) SjhF;t( |[Mۿ!vDZΝZhYI՘S§٦JJo3څ:{˝] ?bzn'Q䣦GPK!carthorse/__init__.pyPK! 3carthorse/actions.pyPK!gcarthorse/cli.pyPK!k@  scarthorse/config.pyPK!~!KV carthorse/version_from.pyPK!{( carthorse/when.pyPK!H^*0*carthorse-0.1.0.dist-info/entry_points.txtPK!HڽTUcarthorse-0.1.0.dist-info/WHEELPK!Hn5"carthorse-0.1.0.dist-info/METADATAPK!H1 carthorse-0.1.0.dist-info/RECORDPK