Discover and extract all components
555513
public function discoverCommand()
    {
        $setup = $this->objectManager->get(BackendConfigurationManager::class)->getTypoScriptSetup();
        /** @var TypoScriptService $typoscriptService */
        $typoscriptService = $this->objectManager->get(TypoScriptService::class);
        $config            = $typoscriptService->convertTypoScriptArrayToPlainArray((array)$setup['plugin.']['tx_twcomponentlibrary.']);

        // Register common stylesheets & scripts
        FluidTemplate::addCommonStylesheets($config['settings']['stylesheets']);
        FluidTemplate::addCommonHeaderScripts($config['settings']['headerScripts']);
        FluidTemplate::addCommonFooterScripts($config['settings']['footerScripts']);

        echo json_encode(Scanner::discoverAll(), JSON_PRETTY_PRINT);
    }
380142
def build_components(components):
    
    component_list = []

    for comp in components:
        component = ea.Component()

        # id
        component.id = comp.get('id')

        # type
        component.type = comp.get('type')

        # asset, if available
        component.asset = comp.get('asset')

        # DOI
        component.doi = comp.get('doi')

        if component_title(comp) != '':
            component.title = component_title(comp)

        # Subtitle
        if comp.get('type') in ['supplementary-material', 'fig']:

            if comp.get('full_caption'):
                subtitle = comp.get('full_caption')
                subtitle = clean_abstract(subtitle)
                component.subtitle = subtitle

        # Mime type
        if comp.get('type') in ['abstract', 'table-wrap', 'sub-article',
                                'chem-struct-wrap', 'boxed-text']:
            component.mime_type = 'text/plain'
        if comp.get('type') in ['fig']:
            component.mime_type = 'image/tiff'
        elif comp.get('type') in ['media', 'supplementary-material']:
            if comp.get('mimetype') and comp.get('mime-subtype'):
                component.mime_type = (comp.get('mimetype') + '/'
                                       + comp.get('mime-subtype'))

        # Permissions
        component.permissions = comp.get('permissions')

        # Append it to our list of components
        component_list.append(component)

    return component_list
1206702
def get_components(self):
        
        components = []
        for app_id in self.components:
            components.append(self.components[app_id])
        return components
22883
function findComponents(directory, components = []) {
  const items = fs.readdirSync(directory);

  items.forEach(item => {
    const itemPath = path.resolve(directory, item);

    if (fs.statSync(itemPath).isDirectory()) {
      findComponents(itemPath, components);
      return;
    }

    if (!componentRegex.test(item)) {
      return;
    }

    components.push({
      filename: itemPath,
    });
  });

  return components;
}
49334
def filter_components_by_name(name, components_list, type_=T_RPM):
    """"""
    for components in components_list:
        for component in components:
            if component['type'] == type_ and component['name'] == name:
                yield component
1002296
def all(self, components_in_and=True):
        ''''''
        self.components_in_and = components_in_and
        return [obj for obj in iter(self)]
261940
function fetchComponent(compName, filter, options) {
    var componentFiles = [];
    _.each(filter, function(destDir, expression) {
      var fileInfo = path.parse(path.resolve(BOWER_DIRECTORY, compName, expression));
      var sourceDir = fileInfo.dir;

      var dirContent = fs.readdirSync(sourceDir);
      var expressionObj = {};
      expressionObj[expression] = destDir;

      dirContent = dirContent.map(function(file) {
        return path.resolve(BOWER_DIRECTORY, compName, file);
      });

      Array.prototype.push.apply(componentFiles,
        filterByExpression(dirContent, expressionObj, options));

    });
    console.log(componentFiles.length + ' file(s) found for ' + compName);
    var bowerObj = getBower(compName);
    return new Component(bowerObj, componentFiles);
  }
708239
function findComponentConfigFile(config, component) {
  var componentConfigFile;

  if (config.get('include-self') && component === config.get('bower.json').name) {
    return config.get('bower.json');
  }

  ['bower.json', '.bower.json', 'component.json', 'package.json'].
    forEach(function (configFile) {
      configFile = $.path.join(config.get('bower-directory'), component, configFile);

      if (!$._.isObject(componentConfigFile) && $.fs.existsSync(configFile)) {
        componentConfigFile = JSON.parse($.fs.readFileSync(configFile));
      }
    });

  return componentConfigFile;
}
78674
function(collection) {
            var array = [];
            for(var i=0, len=collection.components.length; i<len; ++i) {
                array.push(this.extractGeometry.apply(this, [collection.components[i]]));
            }
            return array.join(',');
        }
317806
def components(self):
    
    skel, forest = self._compute_components()

    if len(forest) == 0:
      return []
    elif len(forest) == 1:
      return [ skel ]

    orig_verts = { tuple(coord): i for i, coord in enumerate(skel.vertices) }      

    skeletons = []
    for edge_list in forest:
      edge_list = np.array(edge_list, dtype=np.uint32)
      edge_list = np.unique(edge_list, axis=0)
      vert_idx = np.unique(edge_list.flatten())
      vert_list = skel.vertices[vert_idx]
      radii = skel.radii[vert_idx]
      vtypes = skel.vertex_types[vert_idx]

      new_verts = { orig_verts[tuple(coord)]: i for i, coord in enumerate(vert_list) }

      edge_vector_map = np.vectorize(lambda x: new_verts[x])
      edge_list = edge_vector_map(edge_list)

      skeletons.append(
        PrecomputedSkeleton(vert_list, edge_list, radii, vtypes, skel.id)
      )

    return skeletons
1305407
def source_components(self):
        
        raw_sccs = self._component_graph()

        # Construct a dictionary mapping each vertex to the root of its scc.
        vertex_to_root = self.vertex_dict()

        # And keep track of which SCCs have incoming edges.
        non_sources = self.vertex_set()

        # Build maps from vertices to roots, and identify the sccs that *are*
        # reachable from other components.
        for scc in raw_sccs:
            root = scc[0][1]
            for item_type, w in scc:
                if item_type == 'VERTEX':
                    vertex_to_root[w] = root
                elif item_type == 'EDGE':
                    non_sources.add(vertex_to_root[w])

        sccs = []
        for raw_scc in raw_sccs:
            root = raw_scc[0][1]
            if root not in non_sources:
                sccs.append([v for vtype, v in raw_scc if vtype == 'VERTEX'])

        return [self.full_subgraph(scc) for scc in sccs]
879086
def extract_code_objects(pe):
    """"""
    script_res = _get_scripts_resource(pe)
    dump = _resource_dump(pe, script_res)
    return _get_co_from_dump(dump)
111014
def process_components(self):
        
        message = m.Message()
        warning_heading = m.Heading(
            tr('Report Generation issue'), **WARNING_STYLE)
        message.add(warning_heading)
        failed_extract_context = m.Heading(tr(
            'Failed to extract context'), **WARNING_STYLE)
        failed_render_context = m.Heading(tr(
            'Failed to render context'), **WARNING_STYLE)
        failed_find_extractor = m.Heading(tr(
            'Failed to load extractor method'), **WARNING_STYLE)
        failed_find_renderer = m.Heading(tr(
            'Failed to load renderer method'), **WARNING_STYLE)

        generation_error_code = self.REPORT_GENERATION_SUCCESS

        for component in self.metadata.components:
            # load extractors
            try:
                if not component.context:
                    if isinstance(component.extractor, collections.Callable):
                        _extractor_method = component.extractor
                    else:
                        _package_name = (
                            '%(report-key)s.extractors.%(component-key)s')
                        _package_name %= {
                            'report-key': self.metadata.key,
                            'component-key': component.key
                        }
                        # replace dash with underscores
                        _package_name = _package_name.replace('-', '_')
                        _extractor_path = os.path.join(
                            self.metadata.template_folder,
                            component.extractor
                        )
                        _module = imp.load_source(
                            _package_name, _extractor_path)
                        _extractor_method = getattr(_module, 'extractor')
                else:
                    LOGGER.info('Predefined context. Extractor not needed.')
            except Exception as e:  # pylint: disable=broad-except
                generation_error_code = self.REPORT_GENERATION_FAILED
                LOGGER.info(e)
                if not self.impact_function.use_rounding:
                    raise
                else:
                    message.add(failed_find_extractor)
                    message.add(component.info)
                    message.add(get_error_message(e))
                    continue

            # method signature:
            #  - this ImpactReport
            #  - this component
            try:
                if not component.context:
                    context = _extractor_method(self, component)
                    component.context = context
                else:
                    LOGGER.info('Using predefined context.')
            except Exception as e:  # pylint: disable=broad-except
                generation_error_code = self.REPORT_GENERATION_FAILED
                LOGGER.info(e)
                if not self.impact_function.use_rounding:
                    raise
                else:
                    message.add(failed_extract_context)
                    message.add(get_error_message(e))
                    continue

            try:
                # load processor
                if isinstance(component.processor, collections.Callable):
                    _renderer = component.processor
                else:
                    _package_name = '%(report-key)s.renderer.%(component-key)s'
                    _package_name %= {
                        'report-key': self.metadata.key,
                        'component-key': component.key
                    }
                    # replace dash with underscores
                    _package_name = _package_name.replace('-', '_')
                    _renderer_path = os.path.join(
                        self.metadata.template_folder,
                        component.processor
                    )
                    _module = imp.load_source(_package_name, _renderer_path)
                    _renderer = getattr(_module, 'renderer')
            except Exception as e:  # pylint: disable=broad-except
                generation_error_code = self.REPORT_GENERATION_FAILED
                LOGGER.info(e)
                if not self.impact_function.use_rounding:
                    raise
                else:
                    message.add(failed_find_renderer)
                    message.add(component.info)
                    message.add(get_error_message(e))
                    continue

            # method signature:
            #  - this ImpactReport
            #  - this component
            if component.context:
                try:
                    output = _renderer(self, component)
                    output_path = self.component_absolute_output_path(
                        component.key)
                    if isinstance(output_path, dict):
                        try:
                            dirname = os.path.dirname(output_path.get('doc'))
                        except BaseException:
                            dirname = os.path.dirname(output_path.get('map'))
                    else:
                        dirname = os.path.dirname(output_path)
                    if component.resources:
                        for resource in component.resources:
                            target_resource = os.path.basename(resource)
                            target_dir = os.path.join(
                                dirname, 'resources', target_resource)
                            # copy here
                            if os.path.exists(target_dir):
                                shutil.rmtree(target_dir)
                            shutil.copytree(resource, target_dir)
                    component.output = output
                except Exception as e:  # pylint: disable=broad-except
                    generation_error_code = self.REPORT_GENERATION_FAILED
                    LOGGER.info(e)
                    if not self.impact_function.use_rounding:
                        raise
                    else:
                        message.add(failed_render_context)
                        message.add(get_error_message(e))
                        continue

        return generation_error_code, message
765086
function analyzeDependencies(component) {
  const checkList = ['base'];

  search(
    dependencyTree({
      directory: dir,
      filename: path.join(dir, component, 'index.js'),
      filter: path => !~path.indexOf('node_modules')
    }),
    component,
    checkList
  );

  if (!whiteList.includes(component)) {
    checkList.push(component);
  }

  return checkList.filter(item => checkComponentHasStyle(item));
}
1050680
def _extract_all(node, name, limit_count=None):
    """"""

    seq = []

    for i in range(0, len(node.getElementsByTagName(name))):
        if len(seq) == limit_count:
            break

        seq.append(_extract(node, name, i))

    return seq
136059
function(collection) {
            var len = collection.components.length;
            var array = new Array(len);
            for(var i=0; i<len; ++i) {
                array[i] = this.extract.geometry.apply(
                    this, [collection.components[i]]
                );
            }
            return array;
        }
1357898
function fetchComponents(filter, options) {
    console.log('Fetching dependencies...');

    var componentList = [];

    if (_.isObject(filter) || _.isArray(filter)) {
      var dependencies = fetchBowerComponents();
      _.each(dependencies, function(dep) {
        var bowerObj = getBower(dep);
        if (bowerObj) {
          var mainFiles = fetchMainFiles(bowerObj);

          var componentFiles = [];
          _.each(filter, function(destDir, expression) {
            var expressionObj = {};
            expressionObj[expression] = destDir;

            var filteredValues = filterByExpression(mainFiles, expressionObj, options);

            Array.prototype.push.apply(componentFiles,
              filteredValues);
          });

          // create Component class and encapsulate Component
          // related info in that.
          componentList.push(new Component(bowerObj, componentFiles));

          console.log(componentFiles.length + ' file(s) found for ' + dep);
        }
      });

      console.log('##### Total dependencie(s) found ' + componentList.length);
    }

    return componentList;
  }