mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Write to file with FileType('r+')
This commit is contained in:
parent
5fc6c59ea5
commit
e156683b30
1 changed files with 4 additions and 6 deletions
|
@ -76,9 +76,7 @@ class BlueprintApp:
|
||||||
nargs="+",
|
nargs="+",
|
||||||
metavar="filenames",
|
metavar="filenames",
|
||||||
default=sys.stdin,
|
default=sys.stdin,
|
||||||
type=argparse.FileType(
|
type=argparse.FileType("r+"),
|
||||||
"r"
|
|
||||||
), # idk, but opening with "rw" somehow throws an error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
port = self.add_subcommand("port", "Interactive porting tool", self.cmd_port)
|
port = self.add_subcommand("port", "Interactive porting tool", self.cmd_port)
|
||||||
|
@ -179,9 +177,9 @@ class BlueprintApp:
|
||||||
|
|
||||||
if data != formatted:
|
if data != formatted:
|
||||||
if not opts.check:
|
if not opts.check:
|
||||||
open(file.name, "w").write(
|
file.seek(0)
|
||||||
formatted
|
file.truncate()
|
||||||
) # This is very unelegant, should actually be `file.write(formatted)`
|
file.write(formatted)
|
||||||
|
|
||||||
formatted_files += 1
|
formatted_files += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue