ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
enlighten.util Namespace Reference

Functions

 _json_object_hook (d)
 
 add_combobox_item (combobox, name)
 
 apply_min_max (widget)
 
 clean_json (s)
 Assuming JSON has been rendered with indentation, leave the dicts indented but flatten arrays to single lines.
 
 clean_list (a)
 
 decr_spinbox (spinbox)
 
str determine_encoding (str pathname)
 
 find_file (filename, dirs)
 File Helpers.
 
 force_size (widget, width, height)
 
 get_bullet ()
 
 get_combobox_item_index (combobox, name)
 
 incr_spinbox (spinbox)
 
 is_today (mon, day, year=None)
 Date/Time Helpers.
 
 join_valid (delim, tokens)
 String Helpers.
 
 json2obj (text)
 JSON helpers.
 
 normalize_decimal (obj)
 Recurse down a potentially nested structure of dicts and lists, converting every Decimal into a float.
 
 normalize_filename (filename)
 Some filenames are auto-populated from the on-screen labels used on thumbnails and graph traces.
 
 normalize_history (x, hi=65535.0)
 Qt Helpers.
 
 pluralize (count, singular, plural)
 
 pluralize_spectra (count)
 This made Chris Paul happy.
 
str printable (str s)
 bang (!) through tilde (~)
 
 python_version ()
 
 remove_combobox_item (combobox, name)
 
 safe_mkdirp (directory)
 create a directory tree, optionally requiring user expansion (~), without throwing exceptions
 
 set_checkbox_quietly (cb, flag)
 
 set_enabled (w, flag, tooltip=None)
 Enable or disable a QWidget, while simultaneous restoring or clearing its QToolTip.
 
 set_min_max (widget, lo, hi, value=None)
 
 set_table_row_color (table, row, color)
 should be e.g.
 
 sets_intersect (s1, s2, case_insensitive=False)
 
 undent (s)
 
 unwrap (s)
 

Variables

 log = logging.getLogger(__name__)
 

Function Documentation

◆ _json_object_hook()

enlighten.util._json_object_hook ( d)
protected

◆ add_combobox_item()

enlighten.util.add_combobox_item ( combobox,
name )
Todo
move to GUI

◆ apply_min_max()

enlighten.util.apply_min_max ( widget)
Todo
move to GUI

◆ clean_json()

enlighten.util.clean_json ( s)

Assuming JSON has been rendered with indentation, leave the dicts indented but flatten arrays to single lines.

Also, normalize NaN.

Note
this is assuming arrays of numbers...if the input JSON includes arrays of strings, and strings could contain ] characters, this would probably corrupt data.

◆ clean_list()

enlighten.util.clean_list ( a)

◆ decr_spinbox()

enlighten.util.decr_spinbox ( spinbox)
Todo
move to GUI

◆ determine_encoding()

str enlighten.util.determine_encoding ( str pathname)

◆ find_file()

enlighten.util.find_file ( filename,
dirs )

File Helpers.

Todo
move to FileManager

◆ force_size()

enlighten.util.force_size ( widget,
width,
height )

◆ get_bullet()

enlighten.util.get_bullet ( )

◆ get_combobox_item_index()

enlighten.util.get_combobox_item_index ( combobox,
name )
Todo
move to GUI

◆ incr_spinbox()

enlighten.util.incr_spinbox ( spinbox)
Todo
move to GUI

◆ is_today()

enlighten.util.is_today ( mon,
day,
year = None )

Date/Time Helpers.

◆ join_valid()

enlighten.util.join_valid ( delim,
tokens )

String Helpers.

join list, tossing any nulls / empty strings

◆ json2obj()

enlighten.util.json2obj ( text)

JSON helpers.

This didn't seem to work, but I'm not taking time to troubleshoot it now. Explore later as a way to minimize the number of dicts vs objects passed externally.

See also
https://stackoverflow.com/a/15882054/11615696

◆ normalize_decimal()

enlighten.util.normalize_decimal ( obj)

Recurse down a potentially nested structure of dicts and lists, converting every Decimal into a float.

Used to normalize results from AWS DynamoDB. (Is there a way to make boto default to this?)

◆ normalize_filename()

enlighten.util.normalize_filename ( filename)

Some filenames are auto-populated from the on-screen labels used on thumbnails and graph traces.

However, those labels may include characters that aren't valid (or wise) in filenames, like colon, slash, and backslash, so normalize those out.

◆ normalize_history()

enlighten.util.normalize_history ( x,
hi = 65535.0 )

◆ pluralize()

enlighten.util.pluralize ( count,
singular,
plural )

◆ pluralize_spectra()

enlighten.util.pluralize_spectra ( count)

This made Chris Paul happy.

◆ printable()

str enlighten.util.printable ( str s)

bang (!) through tilde (~)

◆ python_version()

enlighten.util.python_version ( )

◆ remove_combobox_item()

enlighten.util.remove_combobox_item ( combobox,
name )
Todo
move to GUI

◆ safe_mkdirp()

enlighten.util.safe_mkdirp ( directory)

create a directory tree, optionally requiring user expansion (~), without throwing exceptions

Todo
move to FileManager

◆ set_checkbox_quietly()

enlighten.util.set_checkbox_quietly ( cb,
flag )

◆ set_enabled()

enlighten.util.set_enabled ( w,
flag,
tooltip = None )

Enable or disable a QWidget, while simultaneous restoring or clearing its QToolTip.

Normally you can't disable or hide a tooltip. In this case, I would like to change the tooltip behavior for disabled widgets.

Todo
move to GUI

◆ set_min_max()

enlighten.util.set_min_max ( widget,
lo,
hi,
value = None )
Todo
move to GUI

◆ set_table_row_color()

enlighten.util.set_table_row_color ( table,
row,
color )

should be e.g.

QtGui.QColor(0,125,0)

Todo

replace with Colors

move to GUI

◆ sets_intersect()

enlighten.util.sets_intersect ( s1,
s2,
case_insensitive = False )
Returns
whether any elements of set 1 appear in set 2
Todo

could memoize if this ever became performance-critical

best option would be to maintain sets in lowercase

◆ undent()

enlighten.util.undent ( s)

◆ unwrap()

enlighten.util.unwrap ( s)

Variable Documentation

◆ log

enlighten.util.log = logging.getLogger(__name__)