-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script bfabric_save_resource_description.py
- Loading branch information
1 parent
37256ea
commit 5a27cad
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
from rich.pretty import pprint | ||
|
||
from bfabric import Bfabric | ||
from bfabric.cli_formatting import setup_script_logging | ||
|
||
|
||
def save_resource_description(client: Bfabric, id: int, description_file: Path) -> None: | ||
description = description_file.read_text() | ||
obj = {"id": id, "description": description} | ||
response = client.save(endpoint="resource", obj=obj) | ||
pprint(response[0], indent_guides=False) | ||
|
||
|
||
def main() -> None: | ||
setup_script_logging() | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("id", type=int) | ||
parser.add_argument("description_file", type=Path) | ||
client = Bfabric.from_config() | ||
args = parser.parse_args() | ||
save_resource_description(client=client, **vars(args)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |