f846e56a0ea748eb8ae7210b267170600ffaa3ff,cellprofiler/utilities/walk_in_background.py,,walk_in_background,#Any#Any#Any#Any#,13

Before Change


        import subimager.omexml as O
        import urllib
        
    stop = [False]
    def stop_me():
        stop[0] = True
        
    def report(dirpath, dirnames, filenames):

After Change


    THREAD_RESUME
    """
        
    checkpoint = Checkpoint()
        
    def report(dirpath, dirnames, filenames):
        if checkpoint.state != THREAD_STOP:
            callback_fn(dirpath, dirnames, filenames)

    def metadata_report(metadata):
        if checkpoint.state != THREAD_STOP:
            metadata_fn(path, metadata)
            
    def complete():
        if checkpoint.state != THREAD_STOP:
            completed_fn()
            
    def fn():
        try:
            path_list = []
            for dirpath, dirnames, filenames in os.walk(path):
                checkpoint.wait()
                wx.CallAfter(report, dirpath, dirnames, filenames)
                if metadata_fn is not None:
                    path_list += [os.path.join(dirpath, filename)
                                  for filename in filenames]
            for subpath in sorted(path_list):
                checkpoint.wait()
                try:
                    metadata = get_metadata("file:" + urllib.pathname2url(subpath))
                    wx.CallAfter(metadata_fn, subpath, metadata)
                except:
                    logger.info("Failed to read image metadata for %s" % subpath)
        except InterruptException:
            logger.info("Exiting after request to stop")
        except:
            logger.exception("Exiting background walk after unhandled exception")
        finally:
            if completed_fn is not None:
                wx.CallAfter(complete)
    thread = threading.Thread(target = fn)
    thread.start()
    return checkpoint.set_state

def get_metadata_in_background(pathnames, fn_callback, fn_completed = None):
    """Get image metadata for each path
    
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: CellProfiler/CellProfiler
Commit Name: f846e56a0ea748eb8ae7210b267170600ffaa3ff
Time: 2012-01-10
Author: leek@broadinstitute.org
File Name: cellprofiler/utilities/walk_in_background.py
Class Name:
Method Name: walk_in_background


Project Name: tensorflow/models
Commit Name: 40f8e23e39c37058182b239dab26594bf5465a5d
Time: 2018-03-06
Author: allenl@google.com
File Name: official/mnist/mnist_eager.py
Class Name:
Method Name: main


Project Name: CellProfiler/CellProfiler
Commit Name: f846e56a0ea748eb8ae7210b267170600ffaa3ff
Time: 2012-01-10
Author: leek@broadinstitute.org
File Name: cellprofiler/utilities/walk_in_background.py
Class Name:
Method Name: get_metadata_in_background