text stringlengths 1 93.6k |
|---|
"bright": colorama.Style.BRIGHT,
|
"dim": colorama.Style.DIM,
|
None: "",
|
}
|
pre = colors[color] + styles[style]
|
post = colorama.Style.RESET_ALL
|
return f"{pre}{msg}{post}"
|
def cprint(msg, color=None, style=None):
|
print(colored(msg, color=color, style=style))
|
def wait_for_enter():
|
input(colored("\nPress Enter to continue", style="dim"))
|
print()
|
def get_package_name():
|
with open("./setup.py", "r") as fp:
|
nameline = next(
|
(l.strip() for l in fp if l.startswith("NAME = ")), None
|
)
|
return nameline.split("=")[-1].strip().strip('"')
|
def get_package_version(pkgname):
|
ctx = {}
|
with open(f"{pkgname}/__version__.py", "r") as fp:
|
exec(fp.read(), ctx)
|
return ctx["__version__"]
|
class Step:
|
def pre(self, context):
|
pass
|
def post(self, context):
|
wait_for_enter()
|
def run(self, context):
|
try:
|
self.pre(context)
|
self.action(context)
|
self.post(context)
|
except KeyboardInterrupt:
|
cprint("\nInterrupted.", color="red")
|
raise SystemExit(1)
|
def instruct(self, msg):
|
cprint(msg, color="green")
|
def print_run(self, msg):
|
cprint("Run:", color="cyan", style="bright")
|
self.print_cmd(msg)
|
def print_cmd(self, msg):
|
cprint("\t" + msg, color="cyan", style="bright")
|
def do_cmd(self, cmd):
|
cprint(f"Going to run: {cmd}", color="magenta", style="bright")
|
wait_for_enter()
|
os.system(cmd)
|
class GitToMaster(Step):
|
def action(self, context):
|
self.instruct("Make sure you're on master and changes are merged in")
|
self.print_run("git checkout master")
|
class UpdateChangelog(Step):
|
def action(self, context):
|
self.instruct(f"Update change log for version {context['version']}")
|
self.print_run("vi CHANGELOG.md")
|
class UpdateReadme(Step):
|
def action(self, context):
|
self.instruct("Update readme if necessary (check for version update)")
|
self.print_run("vi README.md")
|
class RunTests(Step):
|
def action(self, context):
|
self.do_cmd("make test")
|
class BumpVersionPackage(Step):
|
def action(self, context):
|
self.instruct("Update __version__.py with new version")
|
self.do_cmd(f"vi {context['pkgname']}/__version__.py")
|
def post(self, context):
|
wait_for_enter()
|
context["version"] = self._get_version(context)
|
def _get_version(self, context):
|
# Get the version from the version file
|
return get_package_version(context["pkgname"])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.