GLXCurses.libs.Utils module¶
-
GLXCurses.libs.Utils.
glxc_type
(thing_to_test=None)[source]¶ Internal method for check if object pass as argument is GLXCurses Type Object
:param thing_to_test = A object to test :type thing_to_test: object :return: True or False :rtype: bool
-
GLXCurses.libs.Utils.
resize_text_wrap_char
(text='', max_width=0)[source]¶ Resize the text , and return a new text
example: return ‘123’ for ‘123456789’ where max_width = 3
Parameters: - text (str) – the original text to resize
- max_width (int) – the size of the text
Returns: a resize text
Return type: str
-
GLXCurses.libs.Utils.
sizeof
(value=None)[source]¶ Convert a num to a human readable thing it use metric prefix.
Parameters: value (int or float) – a value
to translate for a future displayReturns: str Raises: TypeError – when value
argument is not a int or float
-
GLXCurses.libs.Utils.
disk_usage
(path)[source]¶ Return something like: 94G/458G (20%).
It use teh File system it self and just request it about the drive space where is store teh file pass in argument.
Parameters: path – Type: Returns: something like 94G/458G (20%) with ‘.’ as path
argument
-
GLXCurses.libs.Utils.
round_up
(n, decimals=0)[source]¶ https://realpython.com/python-rounding/
Parameters: - n –
- decimals –
Returns:
-
GLXCurses.libs.Utils.
round_down
(n, decimals=0)[source]¶ https://realpython.com/python-rounding/
Parameters: - n (int or float) – the number
- decimals (int) – number of decimal
Returns: the rounded value
Return type: int or float
-
GLXCurses.libs.Utils.
round_half_up
(n, decimals=0)[source]¶ https://realpython.com/python-rounding/
Parameters: - n –
- decimals –
Returns:
-
GLXCurses.libs.Utils.
round_half_down
(n, decimals=0)[source]¶ https://realpython.com/python-rounding/
Parameters: - n –
- decimals –
Returns:
-
GLXCurses.libs.Utils.
resize_text
(text='', max_width=0, separator='~')[source]¶ Resize the text , and return a new text
example: return ‘123~789’ for ‘123456789’ where max_width = 7 or 8
Parameters: - text (str) – the original text to resize
- max_width (int) – the size of the text
- separator (str) – a separator a in middle of the resize text
Returns: a resize text
Return type: str
-
GLXCurses.libs.Utils.
clamp_to_zero
(value=None)[source]¶ Convert any int value to positive int
Parameters: value (int or None) – a integer Returns: a integer Return type: int
-
GLXCurses.libs.Utils.
clamp
(value=None, smallest=None, largest=None)[source]¶ Back
value
insidesmallest
andlargest
value range.Parameters: - value (int or float) – The value it have to be clamped
- smallest – The lower value
- largest – The upper value
Returns: The clamped value it depend of parameters value type, int or float will be preserve.
Return type: int or float
-
GLXCurses.libs.Utils.
new_id
()[source]¶ Generate a GLXCurses ID like ‘E59E8457’, two chars by two chars it’s a random HEX
Default size: 8 Default chars: ‘ABCDEF0123456789’
- Benchmark
Iteration Duration CPU Information 10000000 99.114s Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz 1000000 9.920s Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz 100000 0.998s Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz 10000 0.108s Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
Returns: a string it represent a unique ID Return type: str
-
GLXCurses.libs.Utils.
is_valid_id
(value)[source]¶ Check if it’s a valid id
Parameters: value – a id to verify Returns: bool