Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit f72611d

Browse files
feat: more property in release
* doc(readme): update extra command Co-authored-by: JamzumSum <zzzzss990315@gmail.com>
1 parent 1933454 commit f72611d

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Update assets from network. This repo is a component of [QzEmoji][qzemoji].
1313
pip install AssetsUpdater@https://github.com/JamzumSum/AssetsUpdater.git
1414
~~~
1515

16-
For supporting async-download:
16+
For a simple terminal ui:
1717

1818
~~~ shell
19-
pip install AssetsUpdater[async]@https://github.com/JamzumSum/AssetsUpdater.git
19+
pip install AssetsUpdater[tui]@https://github.com/JamzumSum/AssetsUpdater.git
2020
~~~
2121

2222
## Example and Demo

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "AssetsUpdater"
3-
version = "1.5.0"
3+
version = "1.5.1"
44
description = "Update assets from network."
55
authors = ["JamzumSum <zzzzss990315@gmail.com>"]
66
license = "MIT"

src/updater/github.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
from typing import Optional, Union
23

34
from httpx import URL, AsyncClient
@@ -28,7 +29,19 @@ def title(self) -> str:
2829

2930
@property
3031
def tag(self) -> str:
31-
return self.raw.get("tag_name", None)
32+
return self.raw.get("tag_name", "")
33+
34+
@property
35+
def body(self) -> str:
36+
return self.raw.get("body", "")
37+
38+
@property
39+
def draft(self) -> bool:
40+
return self.raw["draft"]
41+
42+
@property
43+
def id(self) -> int:
44+
return self.raw["id"]
3245

3346

3447
class GhUpdater(Updater):

src/updater/type.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from abc import ABC, abstractmethod, abstractproperty
1+
from abc import ABC, abstractmethod
22
from dataclasses import dataclass
33
from typing import AsyncGenerator, Callable, List, Optional
44

@@ -20,22 +20,35 @@ def from_tag(self) -> str:
2020

2121

2222
class Release(ABC):
23-
@abstractproperty
23+
@property
24+
@abstractmethod
2425
def tag(self) -> str:
2526
return ""
2627

27-
@abstractproperty
28+
@property
29+
@abstractmethod
2830
def title(self) -> str:
2931
return ""
3032

3133
@abstractmethod
3234
def assets(self) -> List[Asset]:
3335
return []
3436

35-
@abstractproperty
37+
@property
38+
@abstractmethod
3639
def pre(self) -> bool:
3740
return False
3841

42+
@property
43+
@abstractmethod
44+
def draft(self) -> bool:
45+
return False
46+
47+
@property
48+
@abstractmethod
49+
def body(self) -> str:
50+
return ""
51+
3952
def has_asset(self, name: str):
4053
for i in self.assets():
4154
if i.name == name:

test/test_github.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
async def test_latest(up: GhUpdater):
1010
r = await up.latest()
1111
assert r
12-
assert r.tag
13-
assert r.title
12+
assert isinstance(r.tag, str)
13+
assert isinstance(r.title, str)
14+
assert isinstance(r.body, str)
15+
assert isinstance(r.pre, bool)
16+
assert r.draft is False
1417

1518

1619
async def test_asset(up: GhUpdater):
@@ -21,7 +24,8 @@ async def test_asset(up: GhUpdater):
2124
f = list(filter(lambda i: i.name == "emoji.db", a))
2225
if len(f) == 1:
2326
a = f[0]
24-
assert a.download_url
27+
assert isinstance(a.download_url, str)
28+
assert a.from_release is r
2529

2630

2731
async def test_all(up: GhUpdater):

0 commit comments

Comments
 (0)