yum/FastTextPager
Compressed text paging over OSC.
git clone https://git.yummers.dev/yum/FastTextPager
0ebc793
master
1import os 2import sys 3import typing 4 5def getConfig (path :str )-> typing .Dict [str ,typing .Union [str ,float ,int ,bool ]]: 6# Helper functions to detect and convert the type 7def is_int (value :str )-> bool : 8try : 9int (value ) 10return True 11except ValueError : 12return False 13 14def is_float (value :str )-> bool : 15try : 16float (value ) 17return True 18except ValueError : 19return False 20 21def convert_value (key :str ,value :str ): 22if key .startswith (("enable_" ,"remove_" ,"use_" ,"clear_" )): 23return bool (int (value )) 24elif is_int (value ): 25return int (value ) 26elif is_float (value ): 27return float (value ) 28else : 29return value 30 31config = {} 32with open (path ,'r' )as file : 33for line in file : 34key_value = line .strip ().split (": " ,maxsplit = 1 ) 35key = key_value [0 ] 36value = key_value [1 ]if len (key_value )> 1 else "" 37config [key ]= convert_value (key ,value .strip ()) 38return config 39