mirror of
https://codeberg.org/privacy1st/paper-secret
synced 2024-12-22 23:56:05 +01:00
34 lines
873 B
Python
Executable File
34 lines
873 B
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
"""
|
|
Creates two single-file python executables `enpaper` and `depaper`.
|
|
|
|
One can use this method as an alternative to an installation from PyPi.
|
|
"""
|
|
package = Path() / 'src' / 'paper_secret'
|
|
util = package / 'util.py'
|
|
|
|
enpaper_files = [util, package / 'enpaper.py']
|
|
depaper_files = [util, package / 'depaper.py']
|
|
|
|
create_script(enpaper_files, Path('enpaper'))
|
|
create_script(depaper_files, Path('depaper'))
|
|
|
|
|
|
def create_script(files: list[Path], dst: Path):
|
|
text = '\n'.join([file.read_text() for file in files])
|
|
|
|
text = text.replace('import paper_secret.util as util', '')
|
|
text = text.replace('util.execute_stdin_capture', 'execute_stdin_capture')
|
|
|
|
dst.write_text(text)
|
|
dst.chmod(0o755)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|