-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Insert example from index.php * Bump version to 24.7
- Loading branch information
1 parent
8398e8b
commit 9bd7d15
Showing
5 changed files
with
61 additions
and
4 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
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,8 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
python "./scripts/insert-example.py" "README.template" > "README.md" | ||
|
||
rm "README.template" |
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,34 @@ | ||
import argparse | ||
import os | ||
import re | ||
import typing | ||
|
||
REPLACE_RE = re.compile(r'^%insert (?P<file_name>[^%]+)%$', re.MULTILINE) | ||
|
||
|
||
def read_text(filename: str) -> str: | ||
with open(filename, "rt") as rf: | ||
text = rf.read() | ||
return text | ||
|
||
|
||
def main(template: typing.TextIO) -> None: | ||
content: str = template.read() | ||
|
||
def sub_match(match): | ||
file_name = match.group('file_name') | ||
return read_text(file_name) | ||
|
||
text = REPLACE_RE.sub(sub_match, content) | ||
print(text) | ||
|
||
|
||
def parse_args() -> typing.Dict[str, typing.Any]: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("template", type=argparse.FileType("rt"), help="README.template") | ||
kwargs = vars(parser.parse_args()) | ||
return kwargs | ||
|
||
|
||
if __name__ == "__main__": | ||
main(**parse_args()) |
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