1
0
mirror of synced 2025-02-25 14:25:26 +01:00

Update Changelog + fix format and lint

This commit is contained in:
Stepland 2024-07-27 11:14:03 +02:00
parent 65c86de19c
commit 89cd632836
3 changed files with 13 additions and 8 deletions

View File

@ -7,6 +7,11 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
For version numbers I try to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v2.1.1
### Fixed
- Attempting to guess the file format of a non UTF-16 file would crash the
yubiosi 2.0 format guesser, not anymore.
## v2.1.0
### Added
- [yubiosi] 🎉 initial yubiosi support !

View File

@ -13,7 +13,7 @@ def guess_format(path: Path) -> Format:
format is unknown"""
if path.is_dir():
raise ValueError("Can't guess chart format for a folder")
contents = path.read_bytes()
return guess_file_format(contents)
@ -238,4 +238,4 @@ def line_has_yubiosi_tag(line: str) -> bool:
def looks_like_yubiosi_2_0(contents: bytes) -> bool:
text = contents.decode("utf-16")
lines = text.splitlines()
return lines and lines[0] == "//Yubiosi 2.0"
return len(lines) >= 1 and lines[0] == "//Yubiosi 2.0"

View File

@ -1,13 +1,13 @@
from pathlib import Path
import hypothesis.strategies as st
from hypothesis import given, settings
from hypothesis import given
from .. import guess
@given(st.binary())
def test_that_guess_format_only_raises_the_specific_value_error(contents: bytes):
def test_that_guess_format_only_raises_the_specific_value_error(
contents: bytes,
) -> None:
try:
guess.guess_file_format(contents)
except ValueError as e:
@ -15,7 +15,7 @@ def test_that_guess_format_only_raises_the_specific_value_error(contents: bytes)
raise
def test_that_yubiosi_2_0_detection_does_not_raise_exception_for_non_utf16_files():
def test_that_yubiosi_2_0_detection_does_not_raise_exception_for_non_utf16_files() -> None:
text = "blablabla"
bytes_ = text.encode("ascii")
guess.looks_like_yubiosi_2_0(bytes_)
guess.looks_like_yubiosi_2_0(bytes_)