Changeset 67642f7 in sasview for src/sas/qtgui/convertUI.py


Ignore:
Timestamp:
Jul 13, 2018 4:09:00 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
ecbfddd
Parents:
18f11a6
Message:

check whether .py files are outdated before generating them from .ui or .qrc files (huge startup speed-up)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/convertUI.py

    rc03692f r67642f7  
    1313    os.system(execute) 
    1414 
     15def file_in_newer(file_in, file_out): 
     16    """ 
     17    Check whether file_in is newer than file_out, if file_out exists. 
     18 
     19    Returns True if file_in is newer, or if file_out doesn't exist; False 
     20    otherwise. 
     21    """ 
     22    try: 
     23        out_stat = os.stat(file_out) 
     24    except OSError: 
     25        # file_out does not exist 
     26        return True 
     27 
     28    in_stat = os.stat(file_in) 
     29 
     30    # simple comparison of modification time 
     31    return in_stat.st_mtime >= out_stat.st_mtime 
     32 
    1533# look for .ui files 
    1634for root, dirs, files in os.walk("."): 
     
    1937            file_in = os.path.join(root, file) 
    2038            file_out = os.path.splitext(file_in)[0]+'.py' 
    21             pyuic(file_in, file_out) 
     39            if file_in_newer(file_in, file_out): 
     40                print("Generating " + file_out + " ...") 
     41                pyuic(file_in, file_out) 
    2242 
    2343# RC file in UI directory 
     
    2747out_file = 'main_resources_rc.py' 
    2848 
    29 pyrrc(os.path.join(ui_root, rc_file), os.path.join(ui_root, out_file)) 
     49in_file = os.path.join(ui_root, rc_file) 
     50out_file = os.path.join(ui_root, out_file) 
     51 
     52if file_in_newer(in_file, out_file): 
     53    print("Generating " + out_file + " ...") 
     54    pyrrc(in_file, out_file) 
    3055 
    3156# Images 
     
    3459rc_file = 'images.qrc' 
    3560out_file = 'images_rc.py' 
    36 pyrrc(os.path.join(images_root, rc_file), os.path.join(out_root, out_file)) 
     61 
     62in_file = os.path.join(images_root, rc_file) 
     63out_file = os.path.join(ui_root, out_file) 
     64 
     65if file_in_newer(in_file, out_file): 
     66    print("Generating " + out_file + " ...") 
     67    pyrrc(in_file, out_file) 
     68 
Note: See TracChangeset for help on using the changeset viewer.