def getPluginFileList(debugInspection=None, showProgress=None): """Find plugin.tml files in subdirectories of paths in C{sys.path} @type debugInspection: C{None} or a callable taking one argument @param debugInspection: If not None, this is invoked with strings containing debug information about the loading process. If it is any other true value, this debug information is written to stdout (This behavior is deprecated). @type showProgress: C{None} or a callable taking one argument. @param showProgress: If not None, this is invoked with floating point values between 0 and 1 describing the progress of the loading process. If it is any other true value, this progress information is written to stdout. (This behavior is deprecated). @rtype: C{list} of C{str} @return: A list of the plugin.tml files found. """ if isinstance(debugInspection, types.IntType): warnings.warn( "int parameter for debugInspection is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2) if isinstance(showProgress, types.IntType): warnings.warn( "int parameter for showProgress is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2) debugInspection, showProgress = _prepCallbacks(debugInspection, showProgress) exists = os.path.exists join = os.sep.join result = [] loaded = {} seenNames = {} # XXX Some people claim to have found non-strings in sys.path (an empty # list, in particular). Instead of tracking down the cause for their # presence, they decided it was better to discard them unconditionally # without further investigation. At some point, someone should track # down where non-strings are coming from and do something about them. paths = [ cacheTransform(p) for p in sys.path if isinstance(p, str) and os.path.isdir(p) ] # special case for commonly used directories we *know* shouldn't be checked # and really slow down mktap and such-like in real installations for p in ("/usr/bin", "/usr/local/bin"): try: paths.remove(p) except ValueError: pass progress = 0.0 increments = 1.0 / len(paths) for (index, d) in zip(range(len(paths)), paths): showProgress(progress) if loaded.has_key(d): debugInspection('Already saw ' + d) continue else: debugInspection('Recursing through ' + d) try: subDirs = os.listdir(d) except OSError, (err, s): # Permission denied, carry on if err == errno.EACCES: debugInspection('Permission denied on ' + d) else: raise else: # filter out files we obviously don't need to check - ones with '.' in them subDirs = [s for s in subDirs if "." not in s] if not subDirs: continue incr = increments * (1.0 / len(subDirs)) for plugindir in subDirs: if seenNames.has_key(plugindir): debugInspection('Seen %s already' % plugindir) continue tmlname = join((d, plugindir, "plugins.tml")) if isAModule(join((d, plugindir))): seenNames[plugindir] = 1 if exists(tmlname): result.append(tmlname) debugInspection('Found ' + tmlname) else: debugInspection('Failed ' + tmlname) else: debugInspection('Not a module ' + tmlname) progress = progress + incr showProgress(progress)
def getPluginFileList(debugInspection=None, showProgress=None): """Find plugin.tml files in subdirectories of paths in C{sys.path} @type debugInspection: C{None} or a callable taking one argument @param debugInspection: If not None, this is invoked with strings containing debug information about the loading process. If it is any other true value, this debug information is written to stdout (This behavior is deprecated). @type showProgress: C{None} or a callable taking one argument. @param showProgress: If not None, this is invoked with floating point values between 0 and 1 describing the progress of the loading process. If it is any other true value, this progress information is written to stdout. (This behavior is deprecated). @rtype: C{list} of C{str} @return: A list of the plugin.tml files found. """ if isinstance(debugInspection, types.IntType): warnings.warn( "int parameter for debugInspection is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2 ) if isinstance(showProgress, types.IntType): warnings.warn( "int parameter for showProgress is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2 ) debugInspection, showProgress = _prepCallbacks(debugInspection, showProgress) exists = os.path.exists join = os.sep.join result = [] loaded = {} seenNames = {} # XXX Some people claim to have found non-strings in sys.path (an empty # list, in particular). Instead of tracking down the cause for their # presence, they decided it was better to discard them unconditionally # without further investigation. At some point, someone should track # down where non-strings are coming from and do something about them. paths = [cacheTransform(p) for p in sys.path if isinstance(p, str) and os.path.isdir(p)] # special case for commonly used directories we *know* shouldn't be checked # and really slow down mktap and such-like in real installations for p in ("/usr/bin", "/usr/local/bin"): try: paths.remove(p) except ValueError: pass progress = 0.0 increments = 1.0 / len(paths) for (index, d) in zip(range(len(paths)), paths): showProgress(progress) if loaded.has_key(d): debugInspection('Already saw ' + d) continue else: debugInspection('Recursing through ' + d) try: subDirs = os.listdir(d) except OSError, (err, s): # Permission denied, carry on if err == errno.EACCES: debugInspection('Permission denied on ' + d) else: raise else: # filter out files we obviously don't need to check - ones with '.' in them subDirs = [s for s in subDirs if "." not in s] if not subDirs: continue incr = increments * (1.0 / len(subDirs)) for plugindir in subDirs: if seenNames.has_key(plugindir): debugInspection('Seen %s already' % plugindir) continue tmlname = join((d, plugindir, "plugins.tml")) if isAModule(join((d,plugindir))): seenNames[plugindir] = 1 if exists(tmlname): result.append(tmlname) debugInspection('Found ' + tmlname) else: debugInspection('Failed ' + tmlname) else: debugInspection('Not a module ' + tmlname) progress = progress + incr showProgress(progress)
def getPluginFileList(debugInspection=None, showProgress=None): """Find plugin.tml files in subdirectories of paths in C{sys.path} @type debugInspection: C{None} or a callable taking one argument @param debugInspection: If not None, this is invoked with strings containing debug information about the loading process. If it is any other true value, this debug information is written to stdout (This behavior is deprecated). @type showProgress: C{None} or a callable taking one argument. @param showProgress: If not None, this is invoked with floating point values between 0 and 1 describing the progress of the loading process. If it is any other true value, this progress information is written to stdout. (This behavior is deprecated). @rtype: C{list} of C{str} @return: A list of the plugin.tml files found. """ if isinstance(debugInspection, types.IntType): warnings.warn( "int parameter for debugInspection is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2 ) if isinstance(showProgress, types.IntType): warnings.warn( "int parameter for showProgress is deprecated, pass None or " "a function that takes a single argument instead.", DeprecationWarning, 2 ) debugInspection, showProgress = _prepCallbacks(debugInspection, showProgress) exists = os.path.exists join = os.sep.join result = [] loaded = {} seenNames = {} paths = [cacheTransform(p) for p in sys.path if isinstance(p, str) and os.path.isdir(p)] for p in ("/usr/bin", "/usr/local/bin"): try: paths.remove(p) except ValueError: pass progress = 0.0 increments = 1.0 / len(paths) for (index, d) in zip(range(len(paths)), paths): showProgress(progress) if loaded.has_key(d): debugInspection('Already saw ' + d) continue else: debugInspection('Recursing through ' + d) try: subDirs = os.listdir(d) except OSError, (err, s): if err == errno.EACCES: debugInspection('Permission denied on ' + d) else: raise else: subDirs = [s for s in subDirs if "." not in s] if not subDirs: continue incr = increments * (1.0 / len(subDirs)) for plugindir in subDirs: if seenNames.has_key(plugindir): debugInspection('Seen %s already' % plugindir) continue tmlname = join((d, plugindir, "plugins.tml")) if isAModule(join((d,plugindir))): seenNames[plugindir] = 1 if exists(tmlname): result.append(tmlname) debugInspection('Found ' + tmlname) else: debugInspection('Failed ' + tmlname) else: debugInspection('Not a module ' + tmlname) progress = progress + incr showProgress(progress)