mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 11:35:40 +00:00
Add output_path argument
This commit is contained in:
parent
ae8864c946
commit
a6e63be6ee
@ -3,7 +3,10 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
from .embed import embed_assets
|
||||
embed_assets(args.path)
|
||||
embed_assets(
|
||||
args.input_path,
|
||||
output_path=args.output_path,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -26,8 +26,13 @@ parser.add_argument(
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'path',
|
||||
help='path to the root HTML file',
|
||||
'input_path',
|
||||
help='input path to the root HTML file',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-o', '--output-path',
|
||||
help='output path to resulting HTML file',
|
||||
)
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def embed_assets(index_file):
|
||||
def embed_assets(index_file, output_path=None):
|
||||
|
||||
init_files = {}
|
||||
for filename in [
|
||||
@ -46,7 +46,8 @@ def embed_assets(index_file):
|
||||
base_dir = os.path.dirname(index_file)
|
||||
base_name = os.path.basename(index_file)
|
||||
new_base_name = 'SELF_CONTAINED_' + base_name
|
||||
result_file = os.path.join(base_dir, new_base_name)
|
||||
if not output_path:
|
||||
output_path = os.path.join(base_dir, new_base_name)
|
||||
|
||||
file_tree = load_filetree(
|
||||
base_dir,
|
||||
@ -85,10 +86,10 @@ def embed_assets(index_file):
|
||||
global_context=global_context,
|
||||
)
|
||||
|
||||
with open(result_file, 'w') as fp:
|
||||
with open(output_path, 'w') as fp:
|
||||
fp.write(result)
|
||||
|
||||
return result_file
|
||||
return output_path
|
||||
|
||||
|
||||
def prepare_file(filename, before, after):
|
||||
|
Loading…
x
Reference in New Issue
Block a user