reykit 1.1.9__py3-none-any.whl → 1.1.11__py3-none-any.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.
reykit/ros.py CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
 
12
12
  from __future__ import annotations
13
- from typing import Any, Literal, overload
13
+ from typing import Any, Literal, TextIO, BinaryIO, overload, TYPE_CHECKING
14
+ if TYPE_CHECKING:
15
+ from _typeshed import OpenTextMode, OpenBinaryMode
14
16
  from io import TextIOBase, BufferedIOBase
15
17
  from os import (
16
18
  walk as os_walk,
@@ -317,6 +319,84 @@ class RFile(object):
317
319
  self.path = os_abspath(path)
318
320
 
319
321
 
322
+ @overload
323
+ def open(
324
+ self,
325
+ mode: OpenTextMode = 'wb+'
326
+ ) -> TextIO: ...
327
+
328
+ @overload
329
+ def open(
330
+ self,
331
+ mode: OpenBinaryMode = 'wb+'
332
+ ) -> BinaryIO: ...
333
+
334
+ def open(
335
+ self,
336
+ mode: OpenTextMode | OpenBinaryMode = 'wb+'
337
+ ) -> TextIO | BinaryIO:
338
+ """
339
+ Open file.
340
+
341
+ Parameters
342
+ ----------
343
+ mode : Open mode.
344
+
345
+ Returns
346
+ -------
347
+ IO object.
348
+ """
349
+
350
+ # Get parameter.
351
+ if (
352
+ (
353
+ 'r' in mode
354
+ or '+' in mode
355
+ )
356
+ and 'b' not in mode
357
+ ):
358
+ encoding = 'utf-8'
359
+ else:
360
+ encoding = None
361
+
362
+ # Open.
363
+ io = open(self.path, mode, encoding=encoding)
364
+
365
+ return io
366
+
367
+
368
+ @overload
369
+ def __getattr__(self, name: Literal['open_r', 'open_w', 'open_a']) -> TextIO: ...
370
+
371
+ @overload
372
+ def __getattr__(self, name: Literal['open_rb', 'open_wb', 'open_ab']) -> BinaryIO: ...
373
+
374
+ def __getattr__(self, name: Literal['open_r', 'open_w', 'open_a', 'open_rb', 'open_wb', 'open_ab']) -> TextIO | BinaryIO:
375
+ """
376
+ Get attribute.
377
+
378
+ Parameters
379
+ ----------
380
+ name : Open mode.
381
+
382
+ Returns
383
+ -------
384
+ IO object.
385
+ """
386
+
387
+ if name in (
388
+ 'open_r',
389
+ 'open_w',
390
+ 'open_a',
391
+ 'open_rb',
392
+ 'open_wb',
393
+ 'open_ab'
394
+ ):
395
+ mode: Literal['r', 'w', 'a', 'rb', 'wb', 'ab'] = name[5:]
396
+ io = self.open(mode)
397
+ return io
398
+
399
+
320
400
  @overload
321
401
  def read(
322
402
  self,
@@ -351,13 +431,11 @@ class RFile(object):
351
431
  match type_:
352
432
  case 'bytes':
353
433
  mode = 'rb'
354
- encoding = None
355
434
  case 'str':
356
435
  mode = 'r'
357
- encoding='utf-8'
358
436
 
359
437
  # Read.
360
- with open(self.path, mode, encoding=encoding) as file:
438
+ with self.open(mode) as file:
361
439
  content = file.read()
362
440
 
363
441
  return content
@@ -398,7 +476,7 @@ class RFile(object):
398
476
  data = str(data)
399
477
 
400
478
  # Write.
401
- with open(self.path, mode) as file:
479
+ with self.open(mode) as file:
402
480
  file.write(data)
403
481
 
404
482
 
reykit/rrandom.py CHANGED
@@ -133,7 +133,22 @@ class RRandomSeed(object):
133
133
 
134
134
  @overload
135
135
  def randn(
136
- *thresholds: int,
136
+ *,
137
+ precision: None = None
138
+ ) -> int: ...
139
+
140
+ @overload
141
+ def randn(
142
+ high: int = 10,
143
+ *,
144
+ precision: None = None
145
+ ) -> int: ...
146
+
147
+ @overload
148
+ def randn(
149
+ low: int = 0,
150
+ high: int = 10,
151
+ *,
137
152
  precision: None = None
138
153
  ) -> int: ...
139
154
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.9
3
+ Version: 1.1.11
4
4
  Summary: Rey's kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -9,8 +9,8 @@ reykit/rlog.py,sha256=qhmATMv3_bJRaiuN9mo8hSf_95HH5Lw838aJFio98sg,25760
9
9
  reykit/rmonkey.py,sha256=RqhmKXabl11s2RJaGizpm00Q1yEkul1Je5uxw8_thUk,7584
10
10
  reykit/rmultitask.py,sha256=9UVAg8P85UsLS_exW-e6tZTa_b5r3ceL7LQRDrP8eAw,21981
11
11
  reykit/rnumber.py,sha256=XseLDNLDOt-XYP2P9oDbkKYuHudeSoWzIHsOENO8vvE,3196
12
- reykit/ros.py,sha256=UXX7FENgVCTR8m6-53CxzJvmPzHIzC7vLK2vyrkySiw,39096
13
- reykit/rrandom.py,sha256=NUtQhlu7_250h29UndQWh9q7KbHhiiytofHpTwI4m7g,9035
12
+ reykit/ros.py,sha256=6fHKCpxoWmCpxlRpGag5E-GzGsh0xt8YEmx9iqDvN_o,40780
13
+ reykit/rrandom.py,sha256=TfQKYXRw379MMRIZYfjBtCkmsartA9thhDIG1fc3tM4,9233
14
14
  reykit/rregex.py,sha256=XTlnDLior8yyncFdrTr9FsVlBcqMXvsWRfpmvQS-BR8,6089
15
15
  reykit/rschedule.py,sha256=7EH_6TdEhwV-T6YyBEGYEcy85I1vTSNutDci-e_veTY,5796
16
16
  reykit/rstdout.py,sha256=vSvD4QjYybNiGnowWLXRU6q1u9ERPjr8YTXgq82eYDU,9648
@@ -24,7 +24,7 @@ reykit/rzip.py,sha256=i6KkmeSWCnq025d-O1mbuCYezNRUhyY9OGVK0CRlNAM,3522
24
24
  reykit/rdll/__init__.py,sha256=vM9V7wSNno-WH9RrxgHTIgCkQm8LmBFoLFO8z7qovNo,306
25
25
  reykit/rdll/rdll_inject.py,sha256=bETl8tywtN1OiQudbA21u6GwBM_bqVX7jbiisNj_JBg,645
26
26
  reykit/rdll/rdll_inject_core.py,sha256=Trgh_pdJs_Lw-Y-0Kkn8kHr4BnilM9dBKnHnX25T_pM,5092
27
- reykit-1.1.9.dist-info/METADATA,sha256=1vIM9mjLyGd-eF21cBuHHmh--gGp4i5j3oGxckAFYC0,1888
28
- reykit-1.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- reykit-1.1.9.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
- reykit-1.1.9.dist-info/RECORD,,
27
+ reykit-1.1.11.dist-info/METADATA,sha256=-bdW79_QpDoJ8moBzretuJd4QKiiQP9ML7Z5iXp1y2Q,1889
28
+ reykit-1.1.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ reykit-1.1.11.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
+ reykit-1.1.11.dist-info/RECORD,,