pybase16384 0.3.5__pp310-pypy310_pp73-win_amd64.whl → 0.3.7__pp310-pypy310_pp73-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pybase16384 might be problematic. Click here for more details.

@@ -6,18 +6,27 @@ from cpython.object cimport PyObject_HasAttrString
6
6
  from libc.stdint cimport int32_t, uint8_t
7
7
 
8
8
  from pybase16384.backends.cython.base16384 cimport (
9
- b14_decode, b14_decode_fd, b14_decode_file, b14_decode_len, b14_encode,
10
- b14_encode_fd, b14_encode_file, b14_encode_len,
11
- base16384_err_fopen_input_file, base16384_err_fopen_output_file,
12
- base16384_err_get_file_size, base16384_err_map_input_file,
13
- base16384_err_ok, base16384_err_open_input_file, base16384_err_t, BASE16384_ENCBUFSZ,
14
- BASE16384_DECBUFSZ,
9
+ BASE16384_DECBUFSZ, BASE16384_ENCBUFSZ,
10
+ BASE16384_FLAG_DO_SUM_CHECK_FORCELY, BASE16384_FLAG_NOHEADER,
11
+ BASE16384_FLAG_SUM_CHECK_ON_REMAIN, b14_decode, b14_decode_fd,
12
+ b14_decode_fd_detailed, b14_decode_file, b14_decode_file_detailed,
13
+ b14_decode_len, b14_decode_safe, b14_encode, b14_encode_fd,
14
+ b14_encode_fd_detailed, b14_encode_file, b14_encode_file_detailed,
15
+ b14_encode_len, b14_encode_safe, base16384_err_fopen_input_file,
16
+ base16384_err_fopen_output_file, base16384_err_get_file_size,
17
+ base16384_err_invalid_commandline_parameter,
18
+ base16384_err_invalid_decoding_checksum, base16384_err_invalid_file_name,
19
+ base16384_err_map_input_file, base16384_err_ok,
20
+ base16384_err_open_input_file, base16384_err_read_file, base16384_err_t,
15
21
  base16384_err_write_file, pybase16384_64bits)
16
22
 
17
23
  from pathlib import Path
18
24
 
19
25
  ENCBUFSZ = BASE16384_ENCBUFSZ
20
26
  DECBUFSZ = BASE16384_DECBUFSZ
27
+ FLAG_NOHEADER = BASE16384_FLAG_NOHEADER
28
+ FLAG_SUM_CHECK_ON_REMAIN = BASE16384_FLAG_SUM_CHECK_ON_REMAIN
29
+ FLAG_DO_SUM_CHECK_FORCELY = BASE16384_FLAG_DO_SUM_CHECK_FORCELY
21
30
 
22
31
  cdef inline bytes ensure_bytes(object inp):
23
32
  if isinstance(inp, unicode):
@@ -57,6 +66,22 @@ cpdef inline bytes _encode(const uint8_t[::1] data):
57
66
  finally:
58
67
  PyMem_Free(output_buf)
59
68
 
69
+ cpdef inline bytes _encode_safe(const uint8_t[::1] data):
70
+ cdef size_t length = data.shape[0]
71
+ cdef size_t output_size = <size_t> b14_encode_len(<int>length)
72
+ cdef char *output_buf = <char*>PyMem_Malloc(output_size)
73
+ if output_buf == NULL:
74
+ raise MemoryError
75
+ cdef int count
76
+ with nogil:
77
+ count = b14_encode_safe(<const char*> &data[0],
78
+ <int>length,
79
+ output_buf) # encode 整数倍的那个
80
+ try:
81
+ return <bytes>output_buf[:count]
82
+ finally:
83
+ PyMem_Free(output_buf)
84
+
60
85
  cpdef inline bytes _decode(const uint8_t[::1] data):
61
86
  cdef size_t length = data.shape[0]
62
87
  cdef size_t output_size = <size_t> b14_decode_len(<int>length, 0) + 16
@@ -73,6 +98,22 @@ cpdef inline bytes _decode(const uint8_t[::1] data):
73
98
  finally:
74
99
  PyMem_Free(output_buf)
75
100
 
101
+ cpdef inline bytes _decode_safe(const uint8_t[::1] data):
102
+ cdef size_t length = data.shape[0]
103
+ cdef size_t output_size = <size_t> b14_decode_len(<int>length, 0)
104
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
105
+ if output_buf == NULL:
106
+ raise MemoryError
107
+ cdef int count
108
+ with nogil:
109
+ count = b14_decode_safe(<const char *> &data[0],
110
+ <int> length,
111
+ output_buf) # decode
112
+ try:
113
+ return <bytes> output_buf[:count]
114
+ finally:
115
+ PyMem_Free(output_buf)
116
+
76
117
  cpdef inline int _encode_into(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
77
118
  cdef size_t input_size = data.shape[0]
78
119
  cdef size_t output_size = <size_t> b14_encode_len(<int> input_size)
@@ -84,6 +125,17 @@ cpdef inline int _encode_into(const uint8_t[::1] data, uint8_t[::1] dest) except
84
125
  <int> input_size,
85
126
  <char *> &dest[0])
86
127
 
128
+ cpdef inline int _encode_into_safe(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
129
+ cdef size_t input_size = data.shape[0]
130
+ cdef size_t output_size = <size_t> b14_encode_len(<int> input_size)
131
+ cdef size_t output_buf_size = dest.shape[0]
132
+ if output_buf_size < output_size:
133
+ raise ValueError("Buffer is too small to hold result")
134
+ with nogil:
135
+ return b14_encode_safe(<const char *> &data[0],
136
+ <int> input_size,
137
+ <char *> &dest[0])
138
+
87
139
  cpdef inline int _decode_into(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
88
140
  cdef size_t input_size = data.shape[0]
89
141
  cdef size_t output_size = <size_t> b14_decode_len(<int> input_size, 0)
@@ -95,6 +147,16 @@ cpdef inline int _decode_into(const uint8_t[::1] data, uint8_t[::1] dest) except
95
147
  <int> input_size,
96
148
  <char *> &dest[0])
97
149
 
150
+ cpdef inline int _decode_into_safe(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
151
+ cdef size_t input_size = data.shape[0]
152
+ cdef size_t output_size = <size_t> b14_decode_len(<int> input_size, 0)
153
+ cdef size_t output_buf_size = dest.shape[0]
154
+ if output_buf_size < output_size:
155
+ raise ValueError("Buffer is too small to hold result")
156
+ with nogil:
157
+ return b14_decode_safe(<const char *> &data[0],
158
+ <int> input_size,
159
+ <char *> &dest[0])
98
160
 
99
161
  def encode_file(object input,
100
162
  object output,
@@ -143,6 +205,53 @@ def encode_file(object input,
143
205
  finally:
144
206
  PyMem_Free(output_buf)
145
207
 
208
+ def encode_file_safe(object input,
209
+ object output,
210
+ bint write_head = False,
211
+ int32_t buf_rate = 10):
212
+ if not PyFile_Check(input):
213
+ raise TypeError("input except a file-like object, got %s" % type(input).__name__)
214
+ if not PyFile_Check(output):
215
+ raise TypeError("output except a file-like object, got %s" % type(output).__name__)
216
+ if buf_rate <= 0:
217
+ buf_rate = 1
218
+
219
+ if write_head:
220
+ output.write(b'\xfe\xff')
221
+
222
+ cdef int32_t current_buf_len = buf_rate * 7 # 一次读取这么多字节
223
+ cdef size_t output_size = <size_t> b14_encode_len(<int> current_buf_len) # 因为encode_len不是单调的 这16备用
224
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
225
+ if output_buf == NULL:
226
+ raise MemoryError
227
+
228
+ cdef Py_ssize_t size
229
+ cdef uint8_t first_check = 1 # 检查一次就行了 怎么可能出现第一次读出来是bytes 以后又变卦了的对象呢 不会吧不会吧
230
+ cdef int count = 0
231
+ cdef const char *chunk_ptr
232
+ try:
233
+ while True:
234
+ chunk = input.read(current_buf_len)
235
+ if first_check:
236
+ first_check = 0
237
+ if not PyBytes_Check(chunk):
238
+ raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
239
+ size = PyBytes_Size(chunk)
240
+ if <int32_t> size < current_buf_len: # 数据不够了 要减小一次读取的量
241
+ if buf_rate > 1: # 重新设置一次读取的大小 重新设置流的位置 当然要是已经是一次读取7字节了 那就不能再变小了 直接encode吧
242
+ buf_rate = buf_rate / 2
243
+ current_buf_len = buf_rate * 7
244
+ input.seek(-size, 1)
245
+ continue
246
+ chunk_ptr = <const char*>PyBytes_AS_STRING(chunk)
247
+ with nogil:
248
+ count = b14_encode_safe(chunk_ptr, <int>size, output_buf)
249
+ output.write(<bytes>output_buf[:count])
250
+ if size < 7:
251
+ break
252
+ finally:
253
+ PyMem_Free(output_buf)
254
+
146
255
  def decode_file(object input,
147
256
  object output,
148
257
  int32_t buf_rate = 10):
@@ -195,6 +304,58 @@ def decode_file(object input,
195
304
  finally:
196
305
  PyMem_Free(output_buf)
197
306
 
307
+ def decode_file_safe(object input,
308
+ object output,
309
+ int32_t buf_rate = 10):
310
+ if not PyFile_Check(input):
311
+ raise TypeError("input except a file-like object, got %s" % type(input).__name__)
312
+ if not PyFile_Check(output):
313
+ raise TypeError("output except a file-like object, got %s" % type(output).__name__)
314
+ if buf_rate <= 0:
315
+ buf_rate = 1
316
+
317
+ chunk = input.read(1) # type: bytes
318
+ if not PyBytes_Check(chunk):
319
+ raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
320
+ if chunk == b"\xfe": # 去头
321
+ input.read(1)
322
+ else:
323
+ input.seek(0, 0) # 没有头 回到开头
324
+
325
+ cdef int32_t current_buf_len = buf_rate * 8
326
+ cdef size_t output_size = <size_t> b14_decode_len(<int> current_buf_len, 0)
327
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
328
+ if output_buf == NULL:
329
+ raise MemoryError
330
+ cdef Py_ssize_t size
331
+ cdef int count = 0
332
+ cdef const char *chunk_ptr
333
+ try:
334
+ while True:
335
+ chunk = input.read(current_buf_len) # 8的倍数
336
+ size = PyBytes_Size(chunk)
337
+ if size == 0:
338
+ break
339
+ if <int32_t> size < current_buf_len: # 长度不够了
340
+ if buf_rate > 1: # 还能继续变小
341
+ buf_rate = buf_rate / 2 # 重新设置一次读取的大小
342
+ current_buf_len = buf_rate * 8
343
+ input.seek(-size, 1)
344
+ continue
345
+ tmp = input.read(2) # type: bytes
346
+ if PyBytes_Size(tmp) == 2:
347
+ if tmp[0] == 61: # = stream完了 一次解码8n+2个字节
348
+ chunk += tmp
349
+ size += 2
350
+ else:
351
+ input.seek(-2, 1)
352
+ chunk_ptr = <const char *> PyBytes_AS_STRING(chunk)
353
+ with nogil:
354
+ count = b14_decode_safe(chunk_ptr, <int> size, output_buf)
355
+ output.write(<bytes>output_buf[:count])
356
+ finally:
357
+ PyMem_Free(output_buf)
358
+
198
359
  cpdef inline bint is_64bits() nogil:
199
360
  return pybase16384_64bits()
200
361
 
@@ -211,6 +372,14 @@ cdef inline str err_to_str(base16384_err_t ret):
211
372
  return "base16384_err_open_input_file"
212
373
  elif ret == base16384_err_map_input_file:
213
374
  return "base16384_err_map_input_file"
375
+ elif ret == base16384_err_read_file:
376
+ return "base16384_err_read_file"
377
+ elif ret == base16384_err_invalid_file_name:
378
+ return "base16384_err_invalid_file_name"
379
+ elif ret == base16384_err_invalid_commandline_parameter:
380
+ return "base16384_err_invalid_commandline_parameter"
381
+ elif ret == base16384_err_invalid_decoding_checksum:
382
+ return "base16384_err_invalid_decoding_checksum"
214
383
 
215
384
  cpdef inline encode_local_file(object inp, object out):
216
385
  cdef bytes inp_name = ensure_bytes(inp)
@@ -291,3 +460,84 @@ cpdef inline decode_fd(int inp, int out):
291
460
  finally:
292
461
  PyMem_Free(encbuf)
293
462
  PyMem_Free(decbuf)
463
+
464
+ # detailed
465
+ cpdef inline encode_local_file_detailed(object inp, object out, int flag):
466
+ cdef bytes inp_name = ensure_bytes(inp)
467
+ cdef bytes out_name = ensure_bytes(out)
468
+ cdef const char * inp_name_ptr = <const char *> inp_name
469
+ cdef const char * out_name_ptr = <const char *> out_name
470
+ cdef char * encbuf = <char*>PyMem_Malloc(<size_t>BASE16384_ENCBUFSZ)
471
+ if encbuf == NULL:
472
+ raise MemoryError
473
+ cdef char * decbuf = <char*>PyMem_Malloc(<size_t>BASE16384_DECBUFSZ)
474
+ if decbuf == NULL:
475
+ PyMem_Free(encbuf)
476
+ raise MemoryError
477
+ cdef base16384_err_t ret
478
+ try:
479
+ with nogil:
480
+ ret = b14_encode_file_detailed(inp_name_ptr, out_name_ptr, encbuf, decbuf, flag)
481
+ if ret != base16384_err_ok:
482
+ raise ValueError(err_to_str(ret))
483
+ finally:
484
+ PyMem_Free(encbuf)
485
+ PyMem_Free(decbuf)
486
+
487
+ cpdef inline decode_local_file_detailed(object inp, object out, int flag):
488
+ cdef bytes inp_name = ensure_bytes(inp)
489
+ cdef bytes out_name = ensure_bytes(out)
490
+ cdef const char * inp_name_ptr = <const char *> inp_name
491
+ cdef const char * out_name_ptr = <const char *> out_name
492
+ cdef char * encbuf = <char*>PyMem_Malloc(<size_t>BASE16384_ENCBUFSZ)
493
+ if encbuf == NULL:
494
+ raise MemoryError
495
+ cdef char * decbuf = <char*>PyMem_Malloc(<size_t>BASE16384_DECBUFSZ)
496
+ if decbuf == NULL:
497
+ PyMem_Free(encbuf)
498
+ raise MemoryError
499
+ cdef base16384_err_t ret
500
+ try:
501
+ with nogil:
502
+ ret = b14_decode_file_detailed(inp_name_ptr, out_name_ptr, encbuf, decbuf, flag)
503
+ if ret != base16384_err_ok:
504
+ raise ValueError(err_to_str(ret))
505
+ finally:
506
+ PyMem_Free(encbuf)
507
+ PyMem_Free(decbuf)
508
+
509
+ cpdef inline encode_fd_detailed(int inp, int out, int flag):
510
+ cdef char * encbuf = <char *> PyMem_Malloc(<size_t>BASE16384_ENCBUFSZ)
511
+ if encbuf == NULL:
512
+ raise MemoryError
513
+ cdef char * decbuf = <char *> PyMem_Malloc(<size_t>BASE16384_DECBUFSZ)
514
+ if decbuf == NULL:
515
+ PyMem_Free(encbuf)
516
+ raise MemoryError
517
+ cdef base16384_err_t ret
518
+ try:
519
+ with nogil:
520
+ ret = b14_encode_fd_detailed(inp, out, encbuf, decbuf, flag)
521
+ if ret != base16384_err_ok:
522
+ raise ValueError(err_to_str(ret))
523
+ finally:
524
+ PyMem_Free(encbuf)
525
+ PyMem_Free(decbuf)
526
+
527
+ cpdef inline decode_fd_detailed(int inp, int out, int flag):
528
+ cdef char * encbuf = <char *> PyMem_Malloc(<size_t>BASE16384_ENCBUFSZ)
529
+ if encbuf == NULL:
530
+ raise MemoryError
531
+ cdef char * decbuf = <char *> PyMem_Malloc(<size_t>BASE16384_DECBUFSZ)
532
+ if decbuf == NULL:
533
+ PyMem_Free(encbuf)
534
+ raise MemoryError
535
+ cdef base16384_err_t ret
536
+ try:
537
+ with nogil:
538
+ ret = b14_decode_fd_detailed(inp, out, encbuf, decbuf, flag)
539
+ if ret != base16384_err_ok:
540
+ raise ValueError(err_to_str(ret))
541
+ finally:
542
+ PyMem_Free(encbuf)
543
+ PyMem_Free(decbuf)
@@ -7,6 +7,11 @@ from libc.stdio cimport FILE
7
7
  cdef extern from "base16384.h" nogil:
8
8
  int BASE16384_ENCBUFSZ
9
9
  int BASE16384_DECBUFSZ
10
+
11
+ int BASE16384_FLAG_NOHEADER
12
+ int BASE16384_FLAG_SUM_CHECK_ON_REMAIN
13
+ int BASE16384_FLAG_DO_SUM_CHECK_FORCELY
14
+
10
15
  ctypedef enum base16384_err_t:
11
16
  base16384_err_ok
12
17
  base16384_err_get_file_size
@@ -15,16 +20,27 @@ cdef extern from "base16384.h" nogil:
15
20
  base16384_err_write_file
16
21
  base16384_err_open_input_file
17
22
  base16384_err_map_input_file
23
+ base16384_err_read_file
24
+ base16384_err_invalid_file_name
25
+ base16384_err_invalid_commandline_parameter
26
+ base16384_err_invalid_decoding_checksum
18
27
  # encode_len calc min buf size to fill encode result
19
28
  int b14_encode_len "base16384_encode_len" (int dlen)
20
29
  # decode_len calc min buf size to fill decode result
21
30
  int b14_decode_len "base16384_decode_len" (int dlen, int offset)
22
31
 
32
+ int b14_encode_safe "base16384_encode_safe" (const char * data, int dlen, char * buf)
23
33
  # encode data and write result into buf
24
34
  int b14_encode "base16384_encode" (const char* data, int dlen, char* buf)
35
+
36
+ int b14_encode_unsafe "base16384_encode_unsafe" (const char * data, int dlen, char * buf)
25
37
  # decode data and write result into buf
38
+ int b14_decode_safe "base16384_decode_safe" (const char * data, int dlen, char * buf)
39
+
26
40
  int b14_decode "base16384_decode" (const char* data, int dlen, char* buf)
27
41
 
42
+ int b14_decode_unsafe "base16384_decode_unsafe"(const char * data, int dlen, char * buf)
43
+
28
44
  base16384_err_t b14_encode_file "base16384_encode_file" (const char * input, const char * output, char * encbuf, char * decbuf)
29
45
  base16384_err_t b14_decode_file "base16384_decode_file" (const char * input, const char * output, char * encbuf, char * decbuf)
30
46
 
@@ -43,12 +59,40 @@ cdef extern from "base16384.h" nogil:
43
59
  # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
44
60
  base16384_err_t b14_decode_fd "base16384_decode_fd"(int input, int output, char* encbuf, char* decbuf)
45
61
 
62
+ # detailed
63
+ # base16384_encode_file_detailed encodes input file to output file.
64
+ # use `-` to specify stdin/stdout
65
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
66
+ base16384_err_t b14_encode_file_detailed "base16384_encode_file_detailed" (const char* input, const char* output, char* encbuf, char* decbuf, int flag)
67
+
68
+ # base16384_encode_fp_detailed encodes input file to output file.
69
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
70
+ base16384_err_t b14_encode_fp_detailed "base16384_encode_fp_detailed" (FILE* input, FILE* output, char* encbuf, char* decbuf, int flag)
71
+
72
+ # base16384_encode_fd_detailed encodes input fd to output fd.
73
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
74
+ base16384_err_t b14_encode_fd_detailed "base16384_encode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
75
+
76
+ # base16384_decode_file_detailed decodes input file to output file.
77
+ # use `-` to specify stdin/stdout
78
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
79
+ base16384_err_t b14_decode_file_detailed "base16384_decode_file_detailed" (const char* input, const char* output, char* encbuf, char* decbuf, int flag)
80
+
81
+ # base16384_decode_fp_detailed decodes input file to output file.
82
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
83
+ base16384_err_t b14_decode_fp_detailed "base16384_decode_fp_detailed" (FILE* input, FILE* output, char* encbuf, char* decbuf, int flag)
84
+
85
+ # base16384_decode_fd_detailed decodes input fd to output fd.
86
+ # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
87
+ base16384_err_t b14_decode_fd_detailed "base16384_decode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
88
+
89
+
46
90
  cdef extern from * nogil:
47
91
  """
48
92
  #ifdef CPUBIT32
49
- #define pybase16384_64bits() 0
93
+ #define pybase16384_64bits() (0)
50
94
  #else
51
- #define pybase16384_64bits() 1
95
+ #define pybase16384_64bits() (1)
52
96
  #endif
53
97
  """
54
98
  int32_t pybase16384_64bits()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybase16384
3
- Version: 0.3.5
3
+ Version: 0.3.7
4
4
  Summary: fast base16384 encode and decode
5
5
  Home-page: https://github.com/synodriver/pybase16384
6
6
  Author: synodriver
@@ -78,37 +78,77 @@ for i in range(1):
78
78
 
79
79
  ### 公开函数
80
80
  ```python
81
+ from typing import IO
82
+
81
83
  def encode_len(dlen: int) -> int: ...
82
84
 
83
85
  def decode_len(dlen: int, offset: int) -> int: ...
84
86
 
87
+ ENCBUFSZ: int
88
+ DECBUFSZ: int
89
+ FLAG_NOHEADER: int
90
+ FLAG_SUM_CHECK_ON_REMAIN: int
91
+ FLAG_DO_SUM_CHECK_FORCELY: int
92
+
93
+ def is_64bits() -> bool: ...
94
+
95
+ def encode_file(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
96
+
97
+ def encode_file_safe(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
98
+
99
+ def decode_file(input: IO, output: IO, buf_rate: int = ...): ...
100
+
101
+ def decode_file_safe(input: IO, output: IO, buf_rate: int = ...): ...
102
+
103
+ def ensure_bytes(inp) -> bytes: ...
104
+
105
+ def encode_local_file(inp, out) -> None: ...
106
+
107
+ def decode_local_file(inp, out) -> None: ...
108
+
109
+ def encode_fd(inp: int, out: int) -> None: ...
110
+
111
+ def decode_fd(inp: int, out: int) -> None: ...
112
+
113
+ def encode_local_file_detailed(inp, out, flag: int) -> None: ...
114
+
115
+ def decode_local_file_detailed(inp, out, flag: int) -> None: ...
116
+
117
+ def encode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
118
+
119
+ def decode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
120
+
85
121
  def encode(data: bytes) -> bytes: ...
86
122
 
123
+ def encode_safe(data: bytes) -> bytes: ...
124
+
87
125
  def decode(data: bytes) -> bytes: ...
88
126
 
89
- def decode_file(input: BinaryIO, output: BinaryIO, buf_rate: int = 10) -> None: ...
127
+ def decode_safe(data: bytes) -> bytes: ...
90
128
 
91
- def encode_file(input: BinaryIO, output: BinaryIO, boolwrite_head: bool = False, buf_rate: int = 10) -> None: ...
129
+ def encode_from_string(data: str, write_head: bool = ...) -> bytes: ...
92
130
 
93
- def encode_from_string(data: str, write_head: bool = False) -> bytes: ...
131
+ def encode_from_string_safe(data: str, write_head: bool = ...) -> bytes: ...
94
132
 
95
133
  def encode_to_string(data: bytes) -> str: ...
96
134
 
135
+ def encode_to_string_safe(data: bytes) -> str: ...
136
+
97
137
  def encode_string(data: str) -> str: ...
98
138
 
139
+ def encode_string_safe(data: str) -> str: ...
140
+
99
141
  def decode_from_bytes(data: bytes) -> str: ...
100
142
 
101
- def decode_from_string(data: str) -> bytes: ...
143
+ def decode_from_bytes_safe(data: bytes) -> str: ...
102
144
 
103
- def decode_string(data: str) -> str: ...
145
+ def decode_from_string(data: str) -> bytes: ...
104
146
 
105
- def encode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
147
+ def decode_from_string_safe(data: str) -> bytes: ...
106
148
 
107
- def decode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
149
+ def decode_string(data: str) -> str: ...
108
150
 
109
- def encode_fd(inp: int, out: int) -> None: ...
110
-
111
- def decode_fd(inp: int, out: int) -> None: ...
151
+ def decode_string_safe(data: str) -> str: ...
112
152
  ```
113
153
  - write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
114
154
 
@@ -124,12 +164,20 @@ def decode_fd(inp: int, out: int) -> None: ...
124
164
  ```python
125
165
  def _encode(data: BufferProtocol) -> bytes: ...
126
166
 
167
+ def _encode_safe(data: BufferProtocol) -> bytes: ...
168
+
127
169
  def _decode(data: BufferProtocol) -> bytes: ...
128
170
 
171
+ def _decode_safe(data: BufferProtocol) -> bytes: ...
172
+
129
173
  def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
130
174
 
175
+ def _encode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
176
+
131
177
  def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
132
178
 
179
+ def _decode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
180
+
133
181
  def is_64bits() -> bool: ...
134
182
  ```
135
183
  - ```_decode```在解码```b'='```开头的数据时***不安全***:***解释器异常***
@@ -0,0 +1,16 @@
1
+ pybase16384/__init__.py,sha256=I4fq10U7x38tDhMUUp_K_tzArZfRkU_4M8QvaIER5no,4970
2
+ pybase16384/backends/__init__.py,sha256=9aG9WOI42Hcgaj9QGw99OIvKZTG-sYNlLBUctorc4Kg,56
3
+ pybase16384/backends/cffi/__init__.py,sha256=4wLAqQkOhzMU06rHjiP3vsq4tLpA3BSE-ZRWIyXQISk,14451
4
+ pybase16384/backends/cffi/_core.pypy310-pp73-win_amd64.pyd,sha256=kVDS7yebI7ayvs3VpyakB0_KU1TMnh9ctZqQmYEzdSQ,25088
5
+ pybase16384/backends/cffi/build.py,sha256=m585-SvsiRrx4stB6C0nrl2NpLOvn-faTir86PSiEdc,4693
6
+ pybase16384/backends/cython/__init__.py,sha256=sNk05eduO-ErnMqUjnES6X4KnWfdpcCQnd_EYAyFFCg,714
7
+ pybase16384/backends/cython/_core.c,sha256=kn3l1f2RQOuSIMx9CnqGIdWrgOqkbs7cAWnAkxoU5Hc,1538911
8
+ pybase16384/backends/cython/_core.pxi,sha256=SPgwG7QKofRYdJDRrhx2TWRvOuBuwTjRGg2WvGUrQw4,542
9
+ pybase16384/backends/cython/_core.pypy310-pp73-win_amd64.pyd,sha256=cOsAT4opDHOVQrf5HEF_9tOIw3khn9fmPR1If5o6NVA,206848
10
+ pybase16384/backends/cython/_core.pyx,sha256=p4p59Yqlmo-_2bG0T-f_0yyjUIE9S4XgGF14q2OsF0U,22414
11
+ pybase16384/backends/cython/base16384.pxd,sha256=6KgB5vEipJXw1v1nZPE3JgQapxDtO6yHoGz0FPP7JDE,4941
12
+ pybase16384-0.3.7.dist-info/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
13
+ pybase16384-0.3.7.dist-info/METADATA,sha256=dUK9Dwj9bE6KH2tZGan1kv5KaaQnAKRztTYzK0UvUJs,6699
14
+ pybase16384-0.3.7.dist-info/WHEEL,sha256=u9DzvV4qYT6mp5CaQX4NQqgypzNQL4M7-mWtPosVmCI,109
15
+ pybase16384-0.3.7.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
16
+ pybase16384-0.3.7.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- pybase16384/__init__.py,sha256=l9vuFXikNNKgrtNT-Ix6EPQwc-G_QipKoHaYzSlVtIQ,2540
2
- pybase16384/backends/__init__.py,sha256=9aG9WOI42Hcgaj9QGw99OIvKZTG-sYNlLBUctorc4Kg,56
3
- pybase16384/backends/cffi/__init__.py,sha256=FZdJJtnYanH8-3Lls_UPjm0xOicDOofwrOziIPHBUk8,7604
4
- pybase16384/backends/cffi/_core.pypy310-pp73-win_amd64.pyd,sha256=s1p2kClh1i9qY7XKtnEPqcIZNMHkeynazY4AlEKKmuI,18944
5
- pybase16384/backends/cffi/build.py,sha256=YNZh1_n6d5WMvqEEgvx3MyY8GeeR0mavjiJ9i6-xpP4,3095
6
- pybase16384/backends/cython/__init__.py,sha256=zoKnXRa8Zz5ZsMFj_8cjveOZ0XJfpx5Ic7jmub2d8ec,353
7
- pybase16384/backends/cython/_core.c,sha256=3CpP9r0tvL2IQzf2vHe8f76s3mUJo_Bt9hu_z9zpEsA,1296347
8
- pybase16384/backends/cython/_core.pxi,sha256=SPgwG7QKofRYdJDRrhx2TWRvOuBuwTjRGg2WvGUrQw4,542
9
- pybase16384/backends/cython/_core.pypy310-pp73-win_amd64.pyd,sha256=sAItRO-maYSQ3630Xpn1BbsK14OU-un7hp9oq9Zsaxw,169984
10
- pybase16384/backends/cython/_core.pyx,sha256=VYqH9aNFqavFZRC7-VoW7S8WwvaJITXTjo9tjI7LFy8,11775
11
- pybase16384/backends/cython/base16384.pxd,sha256=IiicckRLe7L9Pi6-OuPC6PIpQgqzzHRsJUcHyKQ5uRI,2326
12
- pybase16384-0.3.5.dist-info/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
13
- pybase16384-0.3.5.dist-info/METADATA,sha256=pssEzcLOnmL8WmuNZ0v_4JEV16k8xHAJsHTrRwhnxhI,5539
14
- pybase16384-0.3.5.dist-info/WHEEL,sha256=u9DzvV4qYT6mp5CaQX4NQqgypzNQL4M7-mWtPosVmCI,109
15
- pybase16384-0.3.5.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
16
- pybase16384-0.3.5.dist-info/RECORD,,