remove broken stdin
This commit is contained in:
parent
768b5d81b4
commit
c836bdee49
31
main.py
31
main.py
@ -6,19 +6,20 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# parse arguments
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="parse netlist and pack all references to current working directory")
|
# parse arguments
|
||||||
parser.add_argument("files", nargs="*", type=argparse.FileType("r"), default=sys.stdin)
|
parser = argparse.ArgumentParser(description="parse netlist and pack all references to current working directory")
|
||||||
parser.add_argument("-d", action="store_const", const=True, default=False, help="Dryrun")
|
parser.add_argument("files", nargs="*", type=argparse.FileType("r"))
|
||||||
|
parser.add_argument("-d", action="store_const", const=True, default=False, help="Dryrun")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
fileregex = re.compile(r"(?<!\w)file=\"(.*?)\"")
|
fileregex = re.compile(r"(?<!\w)file=\"(.*?)\"")
|
||||||
files = {}
|
files = {}
|
||||||
|
|
||||||
|
|
||||||
# process all netlists
|
# process all netlists
|
||||||
for file in args.files:
|
for file in args.files:
|
||||||
location = Path(file.name)
|
location = Path(file.name)
|
||||||
print(f"parsing {file.name}")
|
print(f"parsing {file.name}")
|
||||||
|
|
||||||
@ -58,16 +59,16 @@ for file in args.files:
|
|||||||
|
|
||||||
outfile.write(content[last:])
|
outfile.write(content[last:])
|
||||||
|
|
||||||
# do dryrun if it is wanted
|
# do dryrun if it is wanted
|
||||||
if args.d:
|
if args.d:
|
||||||
for file in files:
|
for file in files:
|
||||||
print(f"copy {file} -> {files[file]}")
|
print(f"copy {file} -> {files[file]}")
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
# copy all files found in netlist earlier
|
# copy all files found in netlist earlier
|
||||||
for file in files:
|
for file in files:
|
||||||
src = Path(file)
|
src = Path(file)
|
||||||
dst = Path(files[file])
|
dst = Path(files[file])
|
||||||
|
|
||||||
@ -80,5 +81,5 @@ for file in files:
|
|||||||
shutil.copyfile(src, dst)
|
shutil.copyfile(src, dst)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user