Skip to content

Commit 18b7c69

Browse files
committed
Rename get_info() to firmware_info()
1 parent 5508bdc commit 18b7c69

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ You should not use it to repack a custom firmware.
176176

177177
```py
178178
import asyncio
179-
from reolinkfw import ReolinkFirmware, get_info
179+
from reolinkfw import ReolinkFirmware, firmware_info
180180

181181
async def main():
182182
url = "https://reolink-storage.s3.amazonaws.com/website/firmware/20200523firmware/RLC-410-5MP_20_20052300.zip"
183-
print(await get_info(url))
183+
print(await firmware_info(url))
184184
pak = "/home/ben/RLC-410-5MP_20_20052300.pak"
185185
with ReolinkFirmware.from_file(pak) as fw:
186186
print(await fw.get_info())
@@ -210,7 +210,7 @@ There are 3 types of file systems used for Reolink firmwares:
210210
- [squashfs](https://www.kernel.org/doc/html/latest/filesystems/squashfs.html) (handled by [PySquashfsImage](https://github.com/matteomattei/PySquashfsImage))
211211
- [UBIFS](https://www.kernel.org/doc/html/latest/filesystems/ubifs.html) (handled by [ubi_reader](https://github.com/jrspruitt/ubi_reader))
212212

213-
Some ZIP files provided by Reolink contain multiple PAKs. This is why `get_info`
213+
Some ZIP files provided by Reolink contain multiple PAKs. This is why `firmware_info`
214214
always returns a list.
215215

216216
Here's a map of vendors to hardware versions:

reolinkfw/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ async def firmwares_from_file(file_or_url: StrPathURL, use_cache: bool = True) -
558558
raise Exception("Not a URL or file")
559559

560560

561-
async def get_info(file_or_url: StrPathURL, use_cache: bool = True) -> list[dict[str, Any]]:
561+
async def firmware_info(file_or_url: StrPathURL, use_cache: bool = True) -> list[dict[str, Any]]:
562562
"""Retrieve firmware info from an on-disk file or a URL.
563563
564564
The file or resource may be a ZIP or a PAK.

reolinkfw/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
from datetime import datetime
88
from pathlib import Path, PurePath
99

10-
from reolinkfw import __version__, firmwares_from_file, get_info
10+
from reolinkfw import __version__, firmware_info, firmwares_from_file
1111

1212
HW_FIELDS = ("board_type", "detail_machine_type", "board_name")
1313

1414

1515
async def info(args: Namespace) -> None:
16-
pak_infos = await get_info(args.file_or_url, not args.no_cache)
16+
pak_infos = await firmware_info(args.file_or_url, not args.no_cache)
1717
if args.json is None:
1818
width = 21
1919
for idx, info in enumerate(pak_infos):
@@ -55,9 +55,9 @@ async def extract(args: Namespace) -> None:
5555
raise Exception("No PAKs found in ZIP file")
5656
dest = Path.cwd() if args.dest is None else args.dest
5757
for pakname, fw in fws:
58-
name = fw.sha256() if pakname is None else PurePath(pakname).stem
59-
await asyncio.to_thread(fw.extract, dest / name, args.force)
60-
fw.close()
58+
with fw:
59+
name = fw.sha256() if pakname is None else PurePath(pakname).stem
60+
await asyncio.to_thread(fw.extract, dest / name, args.force)
6161

6262

6363
def main() -> None:

0 commit comments

Comments
 (0)