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!=lkcarthorse/cli.pyimport os from argparse import ArgumentParser from .config import load_config from .plugins import Plugins 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) plugins = Plugins.load() version = config.run(plugins['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(plugins['when'], check) if not ok: break if ok: for action in config['actions']: config.run(plugins['actions'], action) PK!xcarthorse/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, plugins, config): kw = config['kw'].copy() return plugins[config['name']](*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!'carthorse/plugins.pyfrom collections import defaultdict from pkg_resources import iter_entry_points class Plugins(defaultdict): @classmethod def load(cls): """ Load plugins from entrypoints specified in packages and register them """ plugins = Plugins(dict) for type in 'version_from', 'when', 'actions': for entrypoint in iter_entry_points(group='carthorse.'+type): plugin = entrypoint.load() plugins[type][entrypoint.name] = plugin return plugins PK!9 22carthorse/version_from.pyfrom subprocess import check_output import toml def poetry(): with open('pyproject.toml') as source: data = toml.load(source) return data['tool']['poetry']['version'] def setup_py(python='python'): return check_output([python, 'setup.py', '--version']).decode('ascii').strip() PK!-Lcarthorse/when.pyimport os from subprocess import CalledProcessError, check_output def run(command): print('$ '+command) output = check_output(command, shell=True).decode('ascii').strip() if output: print(output) return output def version_not_tagged(remote='origin'): version = os.environ['TAG'] if run('git remote -v'): run("git fetch {} 'refs/tags/*:refs/tags/*'".format(remote)) try: run('git rev-parse --verify -q '+version) except CalledProcessError as e: if e.returncode == 1: print('No tag found.') return True raise else: print('Version is already tagged.') return False def never(): pass PK!HQ*carthorse-1.1.0.dist-info/entry_points.txtuQ D.zNb!t$ dYximWL;!Qy)16zCUV /Iw@*d 'dZ5VBAsjy9<"ϩB؟hbu[o(VcmQiD[<G~ jrAPK!HڽTUcarthorse-1.1.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H+BP"carthorse-1.1.0.dist-info/METADATAWoF?! ĉm$(QBw^:ͮ}wAmRgw~fvByYH/ߕu43NoV3ʥNqN]qյNBU=VI%YU)锣R5ԛR6KETtPseSU%"޷nԾinŝv9<׹j8<AiDRWHm?_D[jR?:mKz,D9?MM*^hC(!5gWY(C]>Fq]ھuEPk+vn;yS^UWgtZ7|[O˭n=OLUӾ}^]:/ħmJ~:"MiLfeKCeq[vj<Η+J}O!V?!U7w4IMJ쐤@ԄdSfv!e_H3# V 3˪Fq$N_xNdʲ!Mr"!5r%EqKjc:o1U.KԴG7Zodal-=[?k?Gkbކ}`Rq]#Cnc}$5{CDjy]IIlQI7^>==~s1޷ cw*n|A=suɆrz`8P!ĒˆMW]l βoc,, \V͆B7L 05s3Z6QB Ɓ͵`lFe~\ ( ]G[h qleZ%?0FB$[[tA;0\%,*\2h4ǔ)z`͑ '!ÒKpPGЃ19!MnĒx~!\/zgM>Z!X8oVcA $-yumkW`Y6Bs\h+ ˽eM5tR 8΁6G=Ta_cFkn0ic5[!B-dWy2Y,C͵O%b3rnU=΍16zmӐNؽ>}SkӶcq0A'?:ŹU;[AM֣ȲA2sWxg?+8ӁuPK!H#p G carthorse-1.1.0.dist-info/RECORD}˖@| 8@" "#OetO6C6NUlU?Ba nXRe(!yx( cah +b:~݊;IzU0}D QFD3@lƗz8J!#.g]Fq]HF{*j,[G[J|PjVxwaE:I O* /ȶΙWQ]X`eue?*YC|Md #b$ǂط0dTZD=q+(rIq4?͵SNڀKUtS7s*{#D >UU<5zp#o!;ncBYܕ{qC;JvEr8>wVrݬ]p593Gg@م@&!1 bTNuq[e4 &۶4XSxՌ"~FZ}0iTRWO՝9p{{Qnrf}C PK!carthorse/__init__.pyPK!:&X3carthorse/actions.pyPK!=lkjcarthorse/cli.pyPK!xcarthorse/config.pyPK!' carthorse/plugins.pyPK!9 22 carthorse/version_from.pyPK!-Lfcarthorse/when.pyPK!HQ*Wcarthorse-1.1.0.dist-info/entry_points.txtPK!HڽTU2carthorse-1.1.0.dist-info/WHEELPK!H+BP"carthorse-1.1.0.dist-info/METADATAPK!H#p G Ecarthorse-1.1.0.dist-info/RECORDPK