Skip to content

Commit d98b456

Browse files
committed
add 'NPKMagicBytesError' for #1
1 parent d1513c2 commit d98b456

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

npkpy/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,9 @@ class NPKIdError(BaseException):
6666
pass
6767

6868

69+
class NPKMagicBytesError(BaseException):
70+
pass
71+
72+
6973
class NPKError(BaseException):
7074
pass

npkpy/npk/npk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import struct
22
from pathlib import Path
33

4-
from npkpy.common import NPKError, NPKIdError
4+
from npkpy.common import NPKError, NPKIdError, NPKMagicBytesError
55
from npkpy.npk.npk_constants import CNT_HANDLER
66
from npkpy.npk.cnt_basic import BYTES_LEN_CNT_ID, BYTES_LEN_CNT_PAYLOAD_LEN
77
from npkpy.npk.npk_file_basic import FileBasic
@@ -99,4 +99,4 @@ def __get_cnt(self, offset):
9999

100100
def _check_magic_bytes(self, error_msg):
101101
if not self.pck_magic_bytes == MAGIC_BYTES:
102-
raise NPKError(error_msg)
102+
raise NPKMagicBytesError(error_msg)

tests/npk_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import unittest
44
from pathlib import Path
55

6-
from npkpy.common import NPKError, NPKIdError
6+
from npkpy.common import NPKError, NPKIdError, NPKMagicBytesError
77
from npkpy.npk.npk import Npk
88
from npkpy.npk.pck_header import PckHeader
99
from tests.constants import DummyHeaderCnt, MAGIC_BYTES, get_dummy_npk_binary
@@ -18,7 +18,7 @@ def setUp(self) -> None:
1818
def test_fileIsNoNpkFile(self):
1919
self.npkFile.write_bytes(b"NoMagicBytesAtHeadOfFile")
2020

21-
with self.assertRaises(NPKError) as e:
21+
with self.assertRaises(NPKMagicBytesError) as e:
2222
_ = Npk(self.npkFile).pck_magic_bytes
2323
self.assertEqual(e.exception.args[0], "Magic bytes not found in Npk file")
2424

0 commit comments

Comments
 (0)