-
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.
Ditch sed for Python. Default AP_BASE_URL is empty string now.
- Loading branch information
Showing
6 changed files
with
66 additions
and
41 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 was deleted.
Oops, something went wrong.
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,44 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import docopt | ||
|
||
|
||
def main() -> int: | ||
command = Path(sys.argv[0]).name | ||
usage = f"""\ | ||
Patch web app's index.html | ||
Usage: | ||
{command} <pathname> | ||
Arguments: | ||
pathname Pathname of index.html file to patch | ||
Options: | ||
-h --help Show this screen and exit | ||
""" | ||
status = 1 | ||
|
||
try: | ||
arguments = sys.argv[1:] | ||
arguments = docopt.docopt(usage, arguments) | ||
html_pathname = arguments["<pathname>"] # type: ignore | ||
|
||
search_for = '<script src="python.js"></script>' | ||
replace_with = f'{search_for}\n <script src="js/pathways.js"></script>' | ||
|
||
path = Path(html_pathname) | ||
content = path.read_text(encoding="utf-8") | ||
content = content.replace(search_for, replace_with) | ||
path.write_text(content, encoding="utf-8") | ||
|
||
status = 0 | ||
except Exception as exception: | ||
sys.stderr.write(f"{exception}\n") | ||
|
||
return status | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file was deleted.
Oops, something went wrong.