-
-
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.
Implement basic inclusion of images, JavaScript, and CSS
This is kind of a MVP? It really needs a lot more functionality to make it more usable, but I'm not mad at it for an afternoon's work.
- Loading branch information
Showing
5 changed files
with
181 additions
and
7 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,36 @@ | ||
import sys | ||
import os | ||
|
||
import argparse | ||
|
||
from . import freeze_to_string | ||
|
||
# Based on what pip does, but try to be brief and not hardcode our name | ||
def get_prog() -> str: | ||
package = __loader__.name.split(".")[0] | ||
try: | ||
prog = os.path.basename(sys.argv[0]) | ||
if prog in ("__main__.py", "-c"): | ||
# go back to orig_argv[0] to get what the user used | ||
return f"{sys.orig_argv[0]} -m {package}" | ||
else: | ||
return prog | ||
except (AttributeError, TypeError, IndexError): | ||
pass | ||
return package | ||
|
||
def main() -> int: | ||
parser = argparse.ArgumentParser( | ||
prog = get_prog(), | ||
description = 'Create a single-file version of an HTML file', | ||
) | ||
parser.add_argument('url') | ||
|
||
args = parser.parse_args() | ||
|
||
print(freeze_to_string(args.url)) | ||
|
||
return 0 | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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