Call each module

    module_gen should be a iterator
10201
def call_multiple_modules(module_gen):
    
    for args_seq in module_gen:
        module_name_or_path = args_seq[0]
        with replace_sys_args(args_seq):
            if re.match(VALID_PACKAGE_RE, module_name_or_path):
                runpy.run_module(module_name_or_path,
                                 run_name='__main__')
            else:
                runpy.run_path(module_name_or_path,
                               run_name='__main__')
826765
def iterate_over_fields(cls):
        """"""
        for attr in dir(cls):
            clsattr = getattr(cls, attr)
            if isinstance(clsattr, BaseField):
                yield attr, clsattr
676019
function each(obj, iterator, context) {
    var i;

    if (!obj) {
        return;
    }

    if (obj.forEach) {
        obj.forEach(iterator, context);
    } else if (obj.length !== undefined) {
        i = 0;
        while (i < obj.length) {
            iterator.call(context, obj[i], i, obj);
            i++;
        }
    } else {
        for (i in obj) {
            obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
        }
    }
}
1339845
def print_modules(self):
		
		shutit_global.shutit_global_object.yield_to_draw()
		cfg = self.cfg
		module_string = ''
		module_string += 'Modules: \n'
		module_string += '    Run order    Build    Remove    Module ID\n'
		for module_id in self.module_ids():
			module_string += '    ' + str(self.shutit_map[module_id].run_order) + '        ' + str(
				cfg[module_id]['shutit.core.module.build']) + '    ' + str(
				cfg[module_id]['shutit.core.module.remove']) + '    ' + module_id + '\n'
		return module_string
851241
function runModules(str, modules) {
    var replacements = [],
        module;

    if (Array.isArray(modules) === false) {
        modules = [modules];
    }

    modules.forEach(function forEachModule(module) {
        if (!module) {
            throw new Error("Unknown module '" + module + "'");
        }

        runModule(module, str, replacements);
    });

    return replacements;
}
1308018
def _iter_lexerclasses(plugins=True):
    """"""
    for key in sorted(LEXERS):
        module_name, name = LEXERS[key][:2]
        if name not in _lexer_cache:
            _load_lexers(module_name)
        yield _lexer_cache[name]
    if plugins:
        for lexer in find_plugin_lexers():
            yield lexer
790380
def generate(self, api):
        """"""
        for namespace in api.namespaces.values():
            # One module per namespace is created. The module takes the name
            # of the namespace.
            with self.output_to_relative_path('{}.py'.format(namespace.name)):
                self._generate_namespace_module(namespace)
359689
def modules(self):
        
        for modname in self.module_names:
            module = importlib.import_module(modname)
            yield module
1250932
def execute(self, *args, **kwargs):
        '''
        
        '''
        run_modules = []
        orig_arguments = self.arguments

        if args or kwargs:
            self._set_arguments(list(args), kwargs)

        # Run all modules
        for module in self.list():
            obj = self.run(module)

        # Add all loaded modules that marked themselves as enabled to the
        # run_modules list
        for (module, obj) in iterator(self.executed_modules):
            # Report the results if the module is enabled and if it is a
            # primary module or if it reported any results/errors
            if obj.enabled and (obj.PRIMARY or obj.results or obj.errors):
                run_modules.append(obj)

        self.arguments = orig_arguments

        return run_modules
1346241
def each_object(collection):
    """"""
    c_path = collection_path(collection)
    paths = glob('%s/*.%s' % (c_path, _ext))
    for path in paths:
        yield load_object_at_path(path)
1020735
def iteritems(cls):
        
        for key in dir(cls):
            val = getattr(cls, key)
            if isinstance(cls, val):
                yield (key, val)
1191387
function (options, callback) {
        options = extend({}, MODULE_LOADER_DEFAULTS, options)
        var modulesFolder = options.uri

        iterateFiles(modulesFolder, loadModule, callback, isJsFile)

        function loadModule(fileName) {
            if (options.skip && options.skip.test(fileName)) {
                return
            }
            var module = require(fileName)
            var name = path.relative(options.uri, fileName)
            options.core.add(name, module)
        }
    }
879714
function Iterator() {
    var items = Array.prototype.slice.call(arguments, 0);

    this.items = (items.length == 1 && Array.isArray(items[0])) ? items[0] : items;
    this.reset();
}
487089
def module_include(base, mod)
      old_methods = {}

      mod.instance_methods.each do |sym|
        old_methods[sym] = base.instance_method(sym) if base.method_defined?(sym)
      end

      mod.instance_methods.each do |sym|
        method = mod.instance_method(sym)
        base.send(:define_method, sym, method)
      end

      yield
    ensure
      mod.instance_methods.each do |sym|
        base.send(:undef_method, sym) if base.method_defined?(sym)
      end
      old_methods.each do |sym, method|
        base.send(:define_method, sym, method)
      end
    end
341944
def process_modules(modules):
    '''
    '''
    for mod in modules['client']:
        directory = '%s/client_modules' % HERE
        if not exists(directory):
            makedirs(directory)
        write_module_file(mod, directory, 'pyeapi')

    for mod in modules['api']:
        directory = '%s/api_modules' % HERE
        if not exists(directory):
            makedirs(directory)
        write_module_file(mod, directory, 'pyeapi.api')

    create_index(modules)
601833
def run_modules(self):
    """"""

    def _run_module_thread(module_description):
      """Runs the module's process() function.

      Waits for any blockers to have finished before running process(), then
      sets an Event flag declaring the module has completed.
      """
      for blocker in module_description['wants']:
        self.events[blocker].wait()
      module = self._module_pool[module_description['name']]
      try:
        module.process()
      except DFTimewolfError as error:
        self.add_error(error.message, critical=True)
      except Exception as error:  # pylint: disable=broad-except
        self.add_error(
            'An unknown error occurred: {0!s}\nFull traceback:\n{1:s}'.format(
                error, traceback.format_exc()),
            critical=True)
      print('Module {0:s} completed'.format(module_description['name']))
      self.events[module_description['name']].set()
      self.cleanup()

    threads = []
    for module_description in self.recipe['modules']:
      t = threading.Thread(
          target=_run_module_thread,
          args=(module_description, )
      )
      threads.append(t)
      t.start()
    for t in threads:
      t.join()

    self.check_errors(is_global=True)
382015
def do_first(self):
        
        # Load generator module and create instance if we haven't already
        if (not self.srcfile):
            raise IIIFError(text=("No generator specified"))
        if (not self.gen):
            try:
                (name, ext) = os.path.splitext(self.srcfile)
                (pack, mod) = os.path.split(name)
                module_name = 'iiif.generators.' + mod
                try:
                    module = sys.modules[module_name]
                except KeyError:
                    self.logger.debug(
                        "Loading generator module %s" % (module_name))
                    # Would be nice to use importlib but this is available only
                    # in python 2.7 and higher
                    pack = __import__(module_name)  # returns iiif package
                    module = getattr(pack.generators, mod)
                self.gen = module.PixelGen()
            except ImportError:
                raise IIIFError(
                    text=("Failed to load generator %s" % (str(self.srcfile))))
        (self.width, self.height) = self.gen.size