Return the percentage of providers of a project
    that are new to the providers database.
12056
def new_providers(pronac, dt):
    
    info = data.providers_info
    df = info[info['PRONAC'] == pronac]
    providers_count = data.providers_count.to_dict()[0]

    new_providers = []
    segment_id = None

    for _, row in df.iterrows():
        cnpj = row['nrCNPJCPF']
        cnpj_count = providers_count.get(cnpj, 0)
        segment_id = row['idSegmento']

        if cnpj_count <= 1:
            item_id = row['idPlanilhaAprovacao']
            item_name = row['Item']
            provider_name = row['nmFornecedor']

            new_provider = {
                'nome': provider_name,
                'cnpj': cnpj,
                'itens': {
                    item_id: {
                        'nome': item_name,
                        'tem_comprovante': True
                    }
                }
            }
            new_providers.append(new_provider)

    providers_amount = len(df['nrCNPJCPF'].unique())

    new_providers_amount = len(new_providers)

    new_providers_percentage = new_providers_amount / providers_amount

    averages = data.average_percentage_of_new_providers.to_dict()
    segments_average = averages['segments_average_percentage']
    all_projects_average = list(averages['all_projects_average'].values())[0]
    if new_providers:
        new_providers.sort(key=lambda provider: provider['nome'])

    return {
        'lista_de_novos_fornecedores': new_providers,
        'valor': new_providers_amount,
        'new_providers_percentage': new_providers_percentage,
        'is_outlier': new_providers_percentage > segments_average[segment_id],
        'segment_average_percentage': segments_average[segment_id],
        'all_projects_average_percentage': all_projects_average,
    }
1373940
public synchronized void getUpdatedData() {
        if (!isUpdateDataNeeded()) {
            return;
        }

        this._projectResult = new ProjectLrResults();

        _workedBuilds = new ArrayList<Integer>();

        RunList<? extends Run> projectBuilds = currentProject.getBuilds();

        // updateLastBuild();

        for (Run run : projectBuilds) {
            PerformanceJobReportAction performanceJobReportAction = run.getAction(PerformanceJobReportAction.class);
            if (performanceJobReportAction == null) {
                continue;
            }
            if (run.isBuilding()) {
                continue;
            }

            int runNumber = run.getNumber();
            if (_workedBuilds.contains(runNumber)) {
                continue;
            }



            _workedBuilds.add(runNumber);
            LrJobResults jobLrResult = performanceJobReportAction.getLrResultBuildDataset();

            // get all the ran scenario results from this run and insert them into the project
            for (Map.Entry<String, JobLrScenarioResult> runResult : jobLrResult.getLrScenarioResults().entrySet()) {
                // add the scenario if it's the first time it's ran in this build (allows scenarios to be also added
                // at diffrent time)
                if (!_projectResult.getScenarioResults().containsKey(runResult.getKey())) {
                    _projectResult.addScenario(new LrProjectScenarioResults(runResult.getKey()));
                }
                // Join the SLA rule results
                LrProjectScenarioResults lrProjectScenarioResults =
                        _projectResult.getScenarioResults().get(runResult.getKey());
                if(lrProjectScenarioResults.getBuildCount() > MAX_DISPLAY_BUILDS)
                {
                    continue;
                }
                lrProjectScenarioResults.incBuildCount();
                JobLrScenarioResult scenarioRunResult = runResult.getValue();
                for (GoalResult goalResult : scenarioRunResult.scenarioSlaResults) {
                    scenarioGoalResult(runNumber, lrProjectScenarioResults, goalResult);
                }

                // Join sceanrio stats
                joinSceanrioConnectionsStats(runNumber, lrProjectScenarioResults, scenarioRunResult);
                joinVUserScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult);
                joinTransactionScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult);
                joinDurationStats(runNumber, lrProjectScenarioResults, scenarioRunResult);

            }

        }
    }
454963
def get_proficiencies_for_resource_on_date(self, resource_id, from_, to):
        """"""
        # Implemented from azosid template for -
        # osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_template
        if self._can('lookup'):
            return self._provider_session.get_proficiencies_for_resource_on_date(resource_id, from_, to)
        self._check_lookup_conditions()  # raises PermissionDenied
        query = self._query_session.get_proficiency_query()
        query.match_source_id(resource_id, match=True)
        query.match_date(from_, to, match=True)
        return self._try_harder(query)
1034288
def fill_package_digests(generated_project: Project) -> Project:
    """"""
    for package_version in chain(generated_project.pipfile_lock.packages, generated_project.pipfile_lock.dev_packages):
        if package_version.hashes:
            # Already filled from the last run.
            continue

        if package_version.index:
            scanned_hashes = package_version.index.get_package_hashes(
                package_version.name, package_version.locked_version
            )
        else:
            for source in generated_project.pipfile.meta.sources.values():
                try:
                    scanned_hashes = source.get_package_hashes(package_version.name, package_version.locked_version)
                    break
                except Exception:
                    continue
            else:
                raise ValueError("Unable to find package hashes")

        for entry in scanned_hashes:
            package_version.hashes.append("sha256:" + entry["sha256"])

    return generated_project
36012
def get_tasks(self, task_id=None, state='completed', json_file=None):
        """"""
        if self.project is None:
            raise ProjectError

        loader = create_tasks_loader(self.project.id, task_id,
                                     state, json_file, self.all)
        self.tasks = loader.load()

        self._check_project_has_tasks()
        self.tasks_df = dataframer.create_data_frame(self.tasks)
698079
def get_projects(bq_service):
    """"""
    projects_request = bq_service.projects().list().execute()

    projects = []
    for project in projects_request.get('projects', []):
        project_data = {
            'id': project['id'],
            'name': project['friendlyName']
        }
        projects.append(project_data)
    return projects
890437
def _get_database(self, options):
        """"""
        database_name = options.get('database')
        if not database_name:
            if len(settings.DATABASES) > 1:
                errmsg = "Because this project contains more than one database, you"\
                    " must specify the --database option."
                raise CommandError(errmsg)
            database_name = list(settings.DATABASES.keys())[0]
        if database_name not in settings.DATABASES:
            raise CommandError("Database %s does not exist." % database_name)
        return database_name, settings.DATABASES[database_name]
170684
def get_provider(self, name):
        """"""
        if name not in self.providers:
            cls = self.provider_classes[name]
            # instantiate the provider
            self.providers[name] = cls(self)
        return self.providers[name]
558591
def compute_percentile(self, percentage):
        
        all_patches = self.get_all_patches()
        return all_patches[
            int(len(all_patches) * percentage / 100)
        ].start_position
491651
def percentage_progress(self):
        

        if self.total_progress != 0:
            return float(self.progress) / self.total_progress
        else:
            return self.progress
223229
def pull(self):
        """"""

        topic_stats = txlib.api.statistics.Statistics.get(
            project_slug=self.tx_project_slug,
            resource_slug=self.TOPIC_STRINGS_SLUG,
        )

        translated = {}

        # for each language
        for locale in self.enabled_locales:

            if not self._process_locale(locale):
                continue

            locale_stats = getattr(topic_stats, locale, None)
            if locale_stats is None:
                self.log.debug('Locale %s not present when pulling topics.' %
                               (locale,))
                continue

            if locale_stats['completed'] == '100%':
                # get the resource from Tx
                translation = txlib.api.translations.Translation.get(
                    project_slug=self.tx_project_slug,
                    slug=self.TOPIC_STRINGS_SLUG,
                    lang=locale,
                )

                translated[locale] = babel.messages.pofile.read_po(
                    StringIO(translation.content.encode('utf-8'))
                )

        # now that we've pulled everything from Tx, upload to Desk
        for topic in self.desk.topics():

            for locale in translated:

                if topic.name in translated[locale]:

                    self.log.debug(
                        'Updating topic (%s) for locale (%s)' %
                        (topic.name, locale),
                    )

                    if locale in topic.translations:
                        topic.translations[locale].update(
                            name=translated[locale][topic.name].string,
                        )
                    else:
                        topic.translations.create(
                            locale=locale,
                            name=translated[locale][topic.name].string,
                        )
                else:

                    self.log.error(
                        'Topic name (%s) does not exist in locale (%s)' %
                        (topic['name'], locale),
                    )
309177
def get_percent(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return 100 * (self.get_rating() / self.field.range)
129523
def percent_of_the_time(p):
    
    def decorator(fn):

        def wrapped(*args, **kwargs):
            if in_percentage(p):
                fn(*args, **kwargs)

        return wrapped

    return decorator
995681
def get_dependants(project_name):
    """"""
    for package in get_installed_distributions(user_only=ENABLE_USER_SITE):
        if is_dependant(package, project_name):
            yield package.project_name
1344820
def modified_files_coverage_table
      unless @project.nil?
        line = ''
        if all_modified_files_coverage.count > 0
          line << "File | Coverage\n"
          line << "-----|-----\n"
          all_modified_files_coverage.each do |coverage_file|
            file_name = coverage_file.source_file_pathname_relative_to_repo_root.to_s
            percentage = @project.decimal_f([coverage_file.percentage_lines_tested])
            line << "#{file_name} | **`#{percentage}%`**\n"
          end
        end
        return line
      end
    end
15842
def complete_percentage_in(lang)
      if self.keys.blank?
        100
      else
        accepted_keys = accepted_keys(lang)
        100 * accepted_keys.count / self.keys.count
      end
    end
1108541
def _get_enabled():
    """"""
    providers = Provider.objects.all()
    return [p for p in providers if p.enabled()]