Utility functions and classes that may make your coding life easier
and cleaner.
The functions and classes fall into the following categories.
Copyright Schrodinger, LLC. All rights reserved.
|
|
busy_icon_exec(master,
command)
Executes the 'command', waiting until it finishes and returning what
is returned from the command. |
|
|
|
|
parse_geometry(geometry)
Parses a standard X window geometry string (e.g., '35x70+0-0') to a
list of integers (e.g., [35, 70, 0, 0] for the previous string). |
|
|
|
|
resize_window(win)
Resizes the width of a given application window 'win' to its
requested size. |
|
|
|
|
resize_window2(win,
should_reset_minsize=False)
Resizes a given application window 'win' to its requested size. |
|
|
|
|
is_parent(parent,
child)
Returns True if 'parent' is the parent widget of the 'child', or
False otherwise. |
|
|
|
|
get_entry_id(entry_name)
Returns the ID of an entry whose entry name being 'entry_name', or
None if there is no such an entry. |
|
|
|
|
remove_file(basename,
prefix=None,
suffix=None)
Deletes an existing file whose name is 'fname'. |
|
|
|
|
write_n_ct(fname,
struc)
Writes a list of CTs to a file with the name as given by 'fname'. |
|
|
|
|
chdir(dir_name)
Changes the current directory to the one of the name 'dir_name'. |
|
|
|
|
parent_dir(dir_name,
up=1)
Returns the parent directory name. |
|
|
|
|
relpath(xpath,
refpath=None)
Given two paths ('xpath' and 'refpath'), returns the relative path of
'xpath' with respect to 'refpath'. |
|
|
|
|
symlink(src_fname,
des_fname)
Creates a symbolic link on the current directory to a file as given
by 'src_fname'. |
|
|
|
|
is_subdir(xpath,
refpath=None)
Given two paths ('xpath' and 'refpath'), returns True if 'xpath' is a
direct or indirect subdirectory of 'refpath'. |
|
|
|
|
append_comment(fname,
comment)
Appends a string 'comment' to a file 'fname'. |
|
|
|
|
random_string(n,
char_pool='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890')
Returns a random string with 'n' chars. |
|
|
|
|
getlogin()
Returns the login name if it can be found, or otherwise
'unidentified_user'. |
|
|
|
|
get_cmd_string(cmd)
Converts a command ('cmd') given as a list of strings to a single
string representing the command in shells. |
|
|
|
|
|
|
|
expand_macro(s,
macro_dict)
Replaces the macros in the string 's' using the values given by the
macro dictionary 'macro_dict'. |
|
|
|
|
print_if(condition,
content)
Prints the string 'content' if 'condition' evalutes True. |
|
|
|
|
time_duration(start_time,
end_time,
scale=1)
Given the start time and the end time, returns a string that says the
duration between the two time points in the format of 'xh y'
z"', where 'x', 'y', and 'z' are hours, minutes, and seconds,
respectively. |
|
|
|
|
|
|
|
is_powerof2(x)
Returns True if 'x' is a power of 2, or False otherwise. |
|
|
|
|
|
|
|
unique(li)
Returns a list containing unique elements from li and at
the same time preserving the order of the elements as in
li. |
|
|
|
|
get_indices(slice_list,
length)
Returns unique indices from a list of slice objects. |
|
|
|
|
parse_slice(s,
inclusive=False)
Parses slice expression and returns slice object. |
|
|