-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
223 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Contributing to strava-offline | ||
|
||
## Development | ||
|
||
Obtain the source code: | ||
|
||
$ git clone https://github.com/liskin/strava-offline | ||
|
||
Setup Python virtual env and install missing dependencies: | ||
|
||
$ make | ||
|
||
Make changes using your preferred editor. | ||
|
||
Then invoke lints, tests, …: | ||
|
||
$ make check | ||
|
||
These checks are also invoked in [CI (GitHub Actions)][ci] (against multiple | ||
Python versions and also using different Linux distributions Python packages) | ||
whenever a branch is pushed or a pull request is opened. You may need to | ||
enable Actions in your fork's settings. | ||
|
||
Other common tasks are available in the [Makefile](Makefile): | ||
|
||
<!-- include tests/readme/make-help.md --> | ||
<!-- | ||
$ cd "$TESTDIR"/../.. | ||
$ function make { | ||
> command make --no-print-directory COLUMNS=120 "$@" 2>/dev/null | ||
> } | ||
--> | ||
|
||
$ make help | ||
venv-system-site-packages: Setup ./.venv/ (--system-site-packages) | ||
venv: Setup ./.venv/ | ||
pipx: Install locally using pipx | ||
pipx-site-packages: Install locally using pipx (--system-site-packages) | ||
check: Invoke all checks (lints, tests, readme) | ||
lint: Invoke lints | ||
lint-flake8: | ||
lint-mypy: | ||
lint-isort: | ||
test: Invoke tests | ||
test-pytest: | ||
test-prysk: | ||
readme: Update usage/examples in *.md and fail if it differs from version control | ||
dist: Build distribution artifacts (tar, wheel) | ||
twine-upload: Release to PyPI | ||
ipython: Invoke IPython in venv (not installed by default) | ||
clean: Clean all gitignored files/directories | ||
template-update: Re-render cookiecutter template into the template branch | ||
template-merge: Re-render cookiecutter template and merge into the current branch | ||
check-wheel: Check that the wheel we build works in a completely empty venv (i.e. check for unspecified dependencies) | ||
help: Display this help | ||
<!-- end include tests/readme/make-help.md --> | ||
|
||
[ci]: https://github.com/liskin/strava-offline/actions | ||
|
||
## Style Guidelines | ||
|
||
* Try to follow the existing style (where it's not already enforced by a | ||
linter). This applies to both code and git commits. | ||
|
||
* Familiarise yourself with [the seven rules of a great Git commit | ||
message](https://cbea.ms/git-commit/#seven-rules). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# orig src: https://github.com/liskin/dotfiles/blob/home/_help.mk | ||
|
||
.PHONY: help | ||
## Display this help | ||
help: COLUMNS=$(shell tput cols) | ||
help: | ||
@$(MAKE) --silent help-src \ | ||
| perl -Mfeature=say -MText::Wrap -0777 -ne 'while(/((?:^##(?:| .*)$$(?#)\n)+)(^.*:)/gm) { my ($$t, $$h) = ($$2, $$1); $$h =~ s/^## ?//gm; $$h =~ s/\s+/ /g; $$h =~ s/^\s+|\s+$$//g; say "$$t $$h"; }' | fmt $(if $(COLUMNS),-$(COLUMNS)) -t | ||
|
||
.PHONY: help-src | ||
help-src: help-src-makefiles | ||
|
||
.PHONY: help-src-makefiles | ||
help-src-makefiles: | ||
@cat $(MAKEFILE_LIST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# orig src: https://github.com/liskin/dotfiles/blob/home/bin/liskin-include-preproc.py | ||
|
||
from __future__ import annotations # python 3.8 compat | ||
|
||
from dataclasses import dataclass | ||
from pathlib import Path | ||
import re | ||
|
||
import click | ||
|
||
|
||
@dataclass | ||
class Subst: | ||
comment_start: str | ||
comment_end: str | ||
|
||
def include(self, m: re.Match[str]) -> str: | ||
filename = m[1] | ||
|
||
content = self.includes(Path(filename).expanduser().read_text()) | ||
nl = "\n" if not content.endswith("\n") else "" | ||
|
||
cs = self.comment_start | ||
ce = self.comment_end | ||
return f"{cs}include {filename}{ce}\n{content}{nl}{cs}end include {filename}{ce}" | ||
|
||
def includes(self, s: str) -> str: | ||
cs = re.escape(self.comment_start) | ||
ce = re.escape(self.comment_end) | ||
regex = f"^{cs}include (\\S+){ce}$.*?^{cs}end include \\1{ce}$" | ||
return re.sub(regex, self.include, s, flags=re.DOTALL | re.MULTILINE) | ||
|
||
|
||
@click.command(context_settings={"show_default": True}) | ||
@click.option("--comment-start", type=str, default="## ") | ||
@click.option("--comment-end", type=str, default="") | ||
@click.argument("filename", type=click.Path(exists=True, allow_dash=True)) | ||
def main(comment_start, comment_end, filename): | ||
""" | ||
Simple preprocessor for including files in one another. | ||
Substitution is done in-place: the input file is modified and directives are retained so it can | ||
serve as an input again. | ||
""" | ||
with click.open_file(filename, "r") as f: | ||
input = f.read() | ||
output = Subst(comment_start=comment_start, comment_end=comment_end).includes(input) | ||
with click.open_file(filename, "w", atomic=True) as f: | ||
f.write(output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.