Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4344f95

Browse files
committedMay 23, 2025
fixed Int to Unit references
1 parent f409270 commit 4344f95

15 files changed

+502
-503
lines changed
 

‎osbot_utils/helpers/safe_int/Safe_Int__Byte.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎osbot_utils/helpers/safe_int/Safe_Int__FileSize.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎osbot_utils/helpers/safe_int/Safe_Int__Percentage.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎osbot_utils/helpers/safe_int/Safe_Int__Port.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎osbot_utils/helpers/safe_int/Safe_Int__UInt.py renamed to ‎osbot_utils/helpers/safe_int/Safe_UInt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from osbot_utils.helpers.safe_int.Safe_Int import Safe_Int
22

3-
class Safe_Int__UInt(Safe_Int): # Unsigned Integer - only accepts non-negative integer values
3+
class Safe_UInt(Safe_Int): # Unsigned Integer - only accepts non-negative integer values
44

55
min_value = 0 # Unsigned means >= 0
66
max_value = None # No upper limit by default
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from osbot_utils.helpers.safe_int.Safe_UInt import Safe_UInt
2+
3+
TYPE_SAFE_UINT__BYTE__MIN_VALUE = 0
4+
TYPE_SAFE_UINT__BYTE__MAX_VALUE = 255
5+
6+
class Safe_UInt__Byte(Safe_UInt): # Single byte value (0-255)
7+
8+
min_value = TYPE_SAFE_UINT__BYTE__MIN_VALUE
9+
max_value = TYPE_SAFE_UINT__BYTE__MAX_VALUE
10+
allow_bool = False
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from osbot_utils.helpers.safe_int.Safe_UInt import Safe_UInt
2+
3+
TYPE_SAFE_UINT__FILE_SIZE__MIN_VALUE = 0
4+
TYPE_SAFE_UINT__FILE_SIZE__MAX_VALUE = 2 ** 63 - 1 # Max file size on most systems
5+
6+
class Safe_UInt__FileSize(Safe_UInt): # File size in bytes
7+
8+
min_value = TYPE_SAFE_UINT__FILE_SIZE__MIN_VALUE
9+
max_value = TYPE_SAFE_UINT__FILE_SIZE__MAX_VALUE
10+
allow_bool = False
11+
12+
def to_kb(self) -> float:
13+
return self / 1024
14+
15+
def to_mb(self) -> float:
16+
return self / (1024 * 1024)
17+
18+
def to_gb(self) -> float:
19+
return self / (1024 * 1024 * 1024)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from osbot_utils.helpers.safe_int.Safe_UInt import Safe_UInt
2+
3+
TYPE_SAFE_UINT__PERCENTAGE__MIN_VALUE = 0
4+
TYPE_SAFE_UINT__PERCENTAGE__MAX_VALUE = 100
5+
6+
class Safe_UInt__Percentage(Safe_UInt): # Percentage value (0-100)
7+
8+
min_value = TYPE_SAFE_UINT__PERCENTAGE__MIN_VALUE
9+
max_value = TYPE_SAFE_UINT__PERCENTAGE__MAX_VALUE
10+
allow_bool = False
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from osbot_utils.helpers.safe_int.Safe_UInt import Safe_UInt
2+
3+
TYPE_SAFE_UINT__PORT__MIN_VALUE = 0
4+
TYPE_SAFE_UINT__PORT__MAX_VALUE = 65535
5+
6+
class Safe_UInt__Port(Safe_UInt): # Network port number (0-65535)
7+
8+
min_value = TYPE_SAFE_UINT__PORT__MIN_VALUE
9+
max_value = TYPE_SAFE_UINT__PORT__MAX_VALUE
10+
allow_bool = False
11+
allow_none = False # don't allow 0 as port value since that is a really weird value for a port

‎tests/unit/helpers/safe_int/test_Safe_Int__Percentage.py

Lines changed: 0 additions & 175 deletions
This file was deleted.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.