Module azcam.utils
azcam_console.utils contains general purpose support commands used throughout azcam_console.
Functions
def add_searchfolder(search_folder: str = '', include_subfolders: bool = True) ‑> None
-
Appends search_folder (and by default all its subfolders) to the current python search path. Default is current folder and its subfolders. Subfolders beginning with "_" are not included.
Args
search_folder
- Name of folder to add to sys.path
include_subfolders
- True to include all subfolders in sys.path
def check_keyboard(wait: bool = False) ‑> str
-
Checks keyboard for a key press. For Windows OS only.
Args
wait
- True to wait until a key is pressed
Returns
key which was pressed or empty string.
def curdir(folder: str = '') ‑> str
-
Gets and sets the working folder. If folder is not specified then just return the current working folder.
Args
folder
- name of folder set.
Returns
the current folder (after changing).
def fix_path(path: str = '', no_drive_letter: bool = True) ‑> str
-
Makes a nice absolute path, leaving only forward slashes.
Args
path
- name of path to cleanup.
bool no_drive_letter: Removes leading drive letter.
Returns
cleaned path name.
def get_datatype(value) ‑> list
-
Determine the data type for an object and set the type if possible. A string such as "1.23" will result in a type "float" and "2" will result in type "int".
Args
value
- object to be typed
Returns
list [type, value] of data type as a code and object with that type
def make_image_filename(imagefile: str) ‑> str
-
Returns the absolute file imagefile, with forward slashes. Appends ".fits" if no extension is included.
Args
imagefile
- image filename to be expanded
Returns
expanded image filename.
def parse(string: str, set_type=0) ‑> List[str]
-
Parse a string into tokens using the standard azcam rules. If setType is true, try and set data data type for each token.
Args
string
- String to be parsed into tokens
set_type
- True to try and set the type of each token ("1" to 1)
Returns
list of parsed tokens
def prompt(prompt_message: str = 'Enter a string', default: str = '') ‑> str
-
Prints a message and waits for user input.
Args
prompt_message
- string to be printed
default
- string to be returned if no value is entered
Returns
string entered or default value
-
Interative: Show a menu and wait for selection. "blank" may be used to display an empty line. print() is allowed here as this is for interactive use only.
Args
configs
- Dictionary of strings which are menu items
Returns
string associated with item selected or empty string.