Perform static object analysis on all python files in the project

    Note that this might be really time consuming.
559276
def analyze_modules(project, task_handle=taskhandle.NullTaskHandle()):
    
    resources = project.get_python_files()
    job_set = task_handle.create_jobset('Analyzing Modules', len(resources))
    for resource in resources:
        job_set.started_job(resource.path)
        analyze_module(project, resource)
        job_set.finished_job()
1049304
public function main()
  {
    // Get base info about project.
    $this->prepareProjectData();

    // Get all info about source files.
    $this->getInfoSourceFiles();

    // Get all info about resource files.
    $this->getInfoResourceFiles();

    // Prepare all place holders.
    $this->preparePlaceHolders();

    // Replace references to resource files with references to optimized/minimized resource files.
    $this->processingSourceFiles();

    // Compress and rename files with hash.
    $this->processResourceFiles();

    // Create pre-compressed versions of the optimized/minimized resource files.
    if ($this->gzipFlag) $this->gzipCompressOptimizedResourceFiles();

    // Remove original resource files that are optimized/minimized.
    $this->unlinkResourceFiles();
  }
112331
def init(scope, app, settings):
    """"""
    cfg = settings.get('rw.static', {})
    static = Static()
    scope['static'] = static
    scope['template_env'].globals['static'] = static
    for base_uri, sources in cfg.items():
        full_paths = []
        for source in sources:
            if isinstance(source, dict):
                full_path = source['path']
                full_paths.append(full_path.format(**os.environ))
                continue
            elif ',' in source:
                module_name, path = [part.strip()
                                     for part in source.split(',')]
            else:
                module_name = source
                path = 'static'
            full_path = pkg_resources.resource_filename(module_name, path)
            full_paths.append(full_path)

        app.root.mount('/' + base_uri + '/<h>/<path:path>',
                       StaticHandler, {'path': full_paths},
                       name='static_' + base_uri.replace('.', '_'))

        static.handlers.append((base_uri, StaticHandler, full_paths))
    static.setup()
359441
def collect_static_files(src_map, dst):
    
    for rel_src, abs_src in src_map.iteritems():
        abs_dst = os.path.join(dst, rel_src)
        copy_file(abs_src, abs_dst)
791698
def _preprocess(project_dict):
        
        handlers = {
            ('archive',): _list_if_none,
            ('on-run-start',): _list_if_none_or_string,
            ('on-run-end',): _list_if_none_or_string,
        }

        for k in ('models', 'seeds'):
            handlers[(k,)] = _dict_if_none
            handlers[(k, 'vars')] = _dict_if_none
            handlers[(k, 'pre-hook')] = _list_if_none_or_string
            handlers[(k, 'post-hook')] = _list_if_none_or_string
        handlers[('seeds', 'column_types')] = _dict_if_none

        def converter(value, keypath):
            if keypath in handlers:
                handler = handlers[keypath]
                return handler(value)
            else:
                return value

        return deep_map(converter, project_dict)
1304437
def StaticServe(base_path='/views/static/'):
    
    def get_file(path=RAW_INVOCATION_ARGS):
        fullpath = get_config('project_path') + os.path.join(base_path, path)
        try:
            mime, encoding = mimetypes.guess_type(fullpath)
            return open(fullpath, 'rb'), mime or 'application/octet-stream'
        except IOError:
            raise DataNotFound("File does not exist")

    class StaticServe(Program):
        controllers = ['http-get']
        model = [get_file]
        view = FileView()

    return StaticServe()
1173016
def precompile_python_code(context: Context):
    
    from compileall import compile_dir

    kwargs = {}
    if context.verbosity < 2:
        kwargs['quiet'] = True
    compile_dir(context.app.django_app_name, **kwargs)
304520
def cli(sequencepath, report, refseq_database):
    
    main(sequencepath, report, refseq_database, num_threads=multiprocessing.cpu_count())
1091975
private function analyze()
	{
		// Check if we have component, module, plugin etc.
		if (!file_exists($this->getSourceFolder() . "/administrator/components/com_" . $this->getExtensionName())
			&& !file_exists($this->getSourceFolder() . "/components/com_" . $this->getExtensionName()))
		{
			$this->say("Extension has no component");
			$this->hasComponent = false;
		}

		if (!file_exists($this->getSourceFolder() . "/modules"))
		{
			$this->hasModules = false;
		}

		if (!file_exists($this->getSourceFolder() . "/plugins"))
		{
			$this->hasPlugins = false;
		}

		if (!file_exists($this->getSourceFolder() . "/templates"))
		{
			$this->hasTemplates = false;
		}

		if (!file_exists($this->getSourceFolder() . "/libraries"))
		{
			$this->hasLibraries = false;
		}

		if (!file_exists($this->getSourceFolder() . "/administrator/manifests/packages"))
		{
			$this->hasPackage = false;
		}

		if (!file_exists($this->getSourceFolder() . "/components/com_comprofiler"))
		{
			$this->hasCBPlugins = false;
		}
	}
194764
function AnalyzeSourceCodeMiddleware (context)
{
  var grunt = context.grunt;

  //--------------------------------------------------------------------------------------------------------------------
  // PUBLIC API
  //--------------------------------------------------------------------------------------------------------------------

  this.analyze = function (filesArray)
  {
    var src = util.sortFilesBeforeSubfolders (filesArray.src);

    // Load the script files and scan them for module definitions.
    src.forEach (function (path)
    {

      if (!grunt.file.exists (path)) {
        warn ('Source file "' + path + '" not found.');
        return;
      }
      // Read the script and scan it for module declarations.
      var script = grunt.file.read (path);
      /** @type {ModuleHeaderInfo[]} */
      var moduleHeaders;
      try {
        moduleHeaders = sourceExtract.extractModuleHeaders (script);
      }
      catch (e) {
        if (typeof e === 'string')
          return warn (e + NL + reportErrorLocation (path));
        throw e;
      }

      // Ignore irrelevant files.
      if (!moduleHeaders.length) {
        if (!filesArray.forceInclude || !grunt.file.isMatch ({matchBase: true}, filesArray.forceInclude, path)) {
          info ('Ignored file: %', path.cyan);
          return;
        }
        context.standaloneScripts.push ({
          path:    path,
          content: script
        });
      }
      else moduleHeaders.forEach (function (header)
      {
        setupModuleInfo (header, script, path);
      });
    });

  };

  this.trace = function (module)
  {
    /* jshint unused: vars */
    // Do nothing
  };

  this.build = function (targetScript)
  {
    /* jshint unused: vars */
    // Do nothing
  };

  //--------------------------------------------------------------------------------------------------------------------
  // PRIVATE
  //--------------------------------------------------------------------------------------------------------------------

  /**
   * Store information about the specified module retrieved from the given source code on the specified file.
   *
   * @param {ModuleHeaderInfo} moduleHeader
   * @param {string} fileContent
   * @param {string} filePath
   */
  function setupModuleInfo (moduleHeader, fileContent, filePath)
  {
    // Get information about the specified module.
    var module = context.modules[moduleHeader.name];
    // If this is the first time a specific module is mentioned, create the respective information record.
    if (!module)
      module = context.modules[moduleHeader.name] = new ModuleDef (moduleHeader.name);
    // Skip the file if it defines an external module.
    else if (module.external)
      return;
    // Reject additional attempts to redeclare a module (only appending is allowed).
    else if (module.head && !moduleHeader.append)
      fatal ('Can\'t redeclare module <cyan>%</cyan>', moduleHeader.name);
    // The file is appending definitions to a module declared elsewhere.
    if (moduleHeader.append) {
      // Append the file path to the paths list.
      if (!~module.bodyPaths.indexOf (filePath)) {
        module.bodies.push (fileContent);
        module.bodyPaths.push (filePath);
      }
    }
    // Otherwise, the file contains a module declaration.
    else {
      if (module.head)
        fatal ('Duplicate module definition: <cyan>%</cyan>', moduleHeader.name);
      module.head = fileContent;
      module.headPath = filePath;
      module.requires = moduleHeader.requires;
    }
    module.configFn = moduleHeader.configFn;
  }

}
360768
def create_analysis(name, kernel, src_dir, scaffold_name):
    """"""

    # analysis folder
    folder = os.path.join(os.getcwd(), 'analyses', name)
    if not os.path.exists(folder):
        os.makedirs(folder)
    else:
        log.warning('Analysis folder {} already exists.'.format(folder))

    # copy all other files
    for f in os.listdir(src_dir):
        if f in ('__pycache__',) or \
           any(f.endswith(ending) for ending in ('.pyc',)):
            continue
        copy_scaffold_file(os.path.join(src_dir, f),
                           os.path.join(folder, f),
                           name, scaffold_name)
82031
public boolean run(boolean compileTimeView, int maxDepth) throws IOException {
        try {
            // parse each packaged module or classpath archive
            if (apiOnly) {
                finder.parseExportedAPIs(rootArchives.stream());
            } else {
                finder.parse(rootArchives.stream());
            }
            archives.addAll(rootArchives);

            int depth = maxDepth > 0 ? maxDepth : Integer.MAX_VALUE;

            // transitive analysis
            if (depth > 1) {
                if (compileTimeView)
                    transitiveArchiveDeps(depth-1);
                else
                    transitiveDeps(depth-1);
            }

            Set<Archive> archives = archives();

            // analyze the dependencies collected
            analyzer.run(archives, finder.locationToArchive());

            if (writer != null) {
                writer.generateOutput(archives, analyzer);
            }
        } finally {
            finder.shutdown();
        }
        return true;
    }
1130580
private function loadAll(): void
  {
    $this->findSourceFiles();
    $this->detectNameConflicts();
    $this->getColumnTypes();
    $this->readStoredRoutineMetadata();
    $this->getConstants();
    $this->getOldStoredRoutinesInfo();
    $this->getCorrectSqlMode();

    $this->loadStoredRoutines();

    // Drop obsolete stored routines.
    $this->dropObsoleteRoutines();

    // Remove metadata of stored routines that have been removed.
    $this->removeObsoleteMetadata();

    $this->io->writeln('');

    // Write the metadata to file.
    $this->writeStoredRoutineMetadata();
  }
162520
function () {
            count++;

            // all modules have been added have been added.
            if (count === modules.length) {
                // check if solution file content needs to be updated.
                if (isDirty) {
                    writeSolutionFileContents();
                    return;
                }

                // slight delay to ensure future tasks can interact with module files.
                setTimeout(done, 500);
                return;
            }

            var moduleName = modules[count];
            
            // ignore directory when module doesn't contain .csproj file.
            if (!fs.existsSync(path.join(options.modules, moduleName, moduleName + '.csproj'))) {
                addNextModule();
                return;
            }

            helpers.getProjectGuid(path.join(options.modules, moduleName, moduleName + '.csproj'), function (moduleGuid) {
                // module already exists in the solution, move onto the next one.
                if (alreadyInSolution(moduleGuid)) {
                    addNextModule();
                    return;
                }

                var projectReference = '\r\nProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "' + moduleName + '", "Orchard.Web\\Modules\\' + moduleName + '\\' + moduleName + '.csproj", "' + moduleGuid + '"\r\nEndProject\r\n';
                var projectConfiguationPlatforms = '\t\t' + moduleGuid + '.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t' + moduleGuid + '.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t' + moduleGuid + '.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t' + moduleGuid + '.Release|Any CPU.Build.0 = Release|Any CPU\r\n';

                solutionFileContents = _s.insert(solutionFileContents, solutionFileContents.lastIndexOf('EndProject') + 10, projectReference)
                
                var sectionStart = solutionFileContents.indexOf("GlobalSection(ProjectConfigurationPlatforms)");
                var sectionEnd = sectionStart + solutionFileContents.substring(sectionStart).indexOf('EndGlobalSection');

                solutionFileContents = _s.insert(solutionFileContents, sectionEnd, projectConfiguationPlatforms);

                sectionStart = solutionFileContents.indexOf("GlobalSection(NestedProjects)");
                sectionEnd = sectionStart + solutionFileContents.substring(sectionStart).indexOf('EndGlobalSection');
                solutionFileContents = _s.insert(solutionFileContents, sectionEnd, '\t' + moduleGuid + ' = {' + SOLUTION_DIRECTORY_MODULES + '}\r\n\t');

                isDirty = true;

                addNextModule();
            });
        }
1357709
def run
      require_dependencies

      # Find any missing steps in each file, and keep track of unused steps
      clean = true
      filenames.each do |file|
        result = audit_file(file)
        clean &&= result # set to false if any result is false
      end

      # At the end, report any unused steps
      report_unused_steps

      # If the audit was clean, make sure the user knows
      puts "\nAudit clean - no missing steps.".colorize(:light_green) if clean

      true
    end
199671
private void collectClassFiles(List<WorkItem> resources, Map<IPath, IPath> outLocations, Project fbProject) {
        for (WorkItem workItem : resources) {
            workItem.addFilesToProject(fbProject, outLocations);
        }
    }
904980
def analyze_lib(lib_dir, cover_filename, *, ignore_existing=False):
  
  work = {}
  stats = collections.OrderedDict(((k, 0) for k in("files", "albums", "missing covers", "errors")))
  with tqdm.tqdm(desc="Analyzing library",
                 unit="dir",
                 postfix=stats) as progress, \
          tqdm_logging.redirect_logging(progress):
    for rootpath, rel_dirpaths, rel_filepaths in os.walk(lib_dir):
      metadata = analyze_dir(stats,
                             rootpath,
                             rel_filepaths,
                             cover_filename,
                             ignore_existing=ignore_existing)
      progress.set_postfix(stats, refresh=False)
      progress.update(1)
      if all(metadata[:-1]):
        work[rootpath] = metadata[:-1]
  return work