Skip to content

Commit

Permalink
Use FlatpakGenerator.build_module_as_[yaml_]str in main.
Browse files Browse the repository at this point in the history
These methods implement formatting, so why duplicate that code. Fixes #45.

* req2flatpak.py (main)
  • Loading branch information
real-yfprojects committed Mar 11, 2023
1 parent 9bb6055 commit 6d9303d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions req2flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,16 @@ def main(): # pylint: disable=too-many-branches
}

# generate flatpak-builder build module
build_module = FlatpakGenerator.build_module(requirements, downloads)

if options.yaml:
yaml.dump(build_module, output_stream, default_flow_style=False)
parser.exit()

# write output
json.dump(build_module, output_stream, indent=4)
# write yaml
output_stream.write(
FlatpakGenerator.build_module_as_yaml_str(requirements, downloads)
)
else:
# write json
output_stream.write(
FlatpakGenerator.build_module_as_str(requirements, downloads)
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_req2flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def validate_build_module(self, build_module: dict) -> None:
@contextmanager
def requirements_file(
self,
) -> Generator[tempfile._TemporaryFileWrapper[str], None, None]:
) -> Generator[tempfile._TemporaryFileWrapper, None, None]:
"""Create a temporary requirements file."""
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8") as req_file:
req_file.write("\n".join(self.requirements))
Expand Down

0 comments on commit 6d9303d

Please sign in to comment.