Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Sep 12, 2023
1 parent 73a692b commit a5fa17c
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions bugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def _not_found(self, item_id: int, url: str, tag: str) -> Item:
created=now,
updated=now,
url=url,
extra={},
tag=tag,
extra={},
)

def get_item(self, item_id: int = -1, **kwargs) -> Item | None:
Expand Down Expand Up @@ -219,8 +219,8 @@ def _to_item(self, info: Any) -> Item:
created=info.creation_time,
updated=info.last_change_time,
url=f"{self.url}/show_bug.cgi?id={info.id}",
extra=info.__dict__,
tag=f"{self.tag}#{info.id}",
extra=info.__dict__,
)


Expand Down Expand Up @@ -263,8 +263,8 @@ def _to_item(self, info: Any, repo: str) -> Item:
created=info.created_at,
updated=info.updated_at,
url=f"{self.url}/{repo}/issues/{info.number}",
extra=info.__dict__["_rawData"],
tag=f"{self.tag}#{repo}#{info.number}",
extra=info.__dict__["_rawData"],
)


Expand Down Expand Up @@ -314,8 +314,8 @@ def _to_item(self, info: Any, repo: str) -> Item:
created=info.created_at,
updated=info.updated_at,
url=f"{self.url}/{repo}/-/issues/{info.iid}",
extra=info.asdict(),
tag=f"{self.tag}#{repo}#{info.iid}",
extra=info.asdict(),
)


Expand Down Expand Up @@ -351,8 +351,8 @@ def _to_item(self, info: Any) -> Item:
created=info.created_on,
updated=info.updated_on,
url=f"{self.url}/issues/{info.id}",
extra=info.raw(),
tag=f"{self.tag}#{info.id}",
extra=info.raw(),
)


Expand Down Expand Up @@ -448,17 +448,16 @@ def main() -> None: # pylint: disable=too-many-branches
item.created = dateit(item.created, args.time)
item.updated = dateit(item.updated, args.time)
item.status = item.status.upper()
if args.output == "text":
if args.format:
print(Template(args.format).render(item.__dict__))
else:
print(
" ".join(
[f"{item[key]:{align}}" for key, align in keys.items()]
)
)
elif args.output == "json":
if args.output == "json":
all_items.append(item.__dict__)
elif args.format:
print(Template(args.format).render(item.__dict__))
else:
print(
" ".join(
[f"{item[key]:{align}}" for key, align in keys.items()]
)
)

if args.output == "json":
print(json.dumps(all_items, default=str, sort_keys=True))
Expand Down

0 comments on commit a5fa17c

Please sign in to comment.