<commit_before>#!/usr/bin/env conda-execute

# conda execute
# env:
#  - python
#  - conda-smithy
#  - pygithub 1.*
# channels:
#  - conda-forge
# run_with: python

import argparse
import os

from github import Github
import github
import jinja2
import yaml


parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('feedstocks_clone', help="The location of the feedstocks directory within the conda-forge/feedstocks clone.")

args = parser.parse_args()

from conda_smithy.github import gh_token


token = gh_token()

gh = Github(token)

conda_forge = gh.get_organization('conda-forge')
teams = {team.name: team for team in conda_forge.get_teams()}

feedstocks_path = args.feedstocks_clone


class NullUndefined(jinja2.Undefined):
    def __unicode__(self):
        return unicode(self._undefined_name)


def create_team(org, name, description, repos):
    # PyGithub creates secret teams, and has no way of turning that off! :(
    post_parameters = {
        "name": name,
        "description": description,
        "privacy": "closed",
    }
    post_parameters["repo_names"] = [element._identity for element in repos]
    headers, data = org._requester.requestJsonAndCheck(
        "POST",
        org.url + "/teams",
        input=post_parameters
    )
    return github.Team.Team(org._requester, headers, data, completed=True)


packages_visited = set()

all_members = set()
from random import choice
superlative = ['awesome', 'slick', 'formidable', 'awe-inspiring', 'breathtaking',
               'magnificent', 'wonderous', 'stunning', 'astonishing', 'superb',
               'splendid', 'impressive', 'unbeatable', 'excellent', 'top', 'outstanding',
               'exalted', 'standout', 'smashing']

# Go through each of the feedstocks and ensure that the team is up to date and that
# there is nobody in the team which doesn't belong (i.e. isn't in the maintainers list).
for package_name in os.listdir(feedstocks_path):
    packages_visited.add(package_name)
    feedstock = os.path.join(feedstocks_path, package_name)
    recipe = os.path.join(feedstock, 'recipe', 'meta.yaml')

    if not os.path.exists(recipe):
        print("The {} feedstock is recipe less".format(package_name))
        continue
    env = jinja2.Environment(undefined=NullUndefined)

    with open(recipe) as fh:
        contents = env.from_string(''.join(fh)).render(environ={})
    data = yaml.safe_load(contents)

    contributors = data.get('extra', {}).get('recipe-maintainers', [])
    if not isinstance(contributors, list):
        # Deal with a contribution list which has dashes but no spaces
        # (e.g. https://github.com/conda-forge/pandoc-feedstock/issues/1)
        contributors = [contributors.lstrip('-')]
    contributors = set(handle.lower() for handle in contributors)
    all_members.update(contributors)<commit_msg>Ensure that `environ` is defined as a silent empty dictionary.<commit_after>#!/usr/bin/env conda-execute

# conda execute
# env:
#  - python
#  - conda-smithy
#  - pygithub 1.*
# channels:
#  - conda-forge
# run_with: python

import argparse
import collections
import os

from github import Github
import github
import jinja2
import yaml


parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('feedstocks_clone', help="The location of the feedstocks directory within the conda-forge/feedstocks clone.")

args = parser.parse_args()

from conda_smithy.github import gh_token


token = gh_token()

gh = Github(token)

conda_forge = gh.get_organization('conda-forge')
teams = {team.name: team for team in conda_forge.get_teams()}

feedstocks_path = args.feedstocks_clone


class NullUndefined(jinja2.Undefined):
    def __unicode__(self):
        return unicode(self._undefined_name)

class SilentDict(collections.MutableMapping):
    def __init__(self, *args, **kwargs):
        self.store = dict()
        self.update(dict(*args, **kwargs))

    def __getitem__(self, key):
        try:
            return self.store[key]
        except KeyError:
            return None

    def __setitem__(self, key, value):
        self.store[key] = value

    def __delitem__(self, key):
        try:
            del self.store[key]
        except KeyError:
            pass

    def __iter__(self):
        return iter(self.store)

    def __len__(self):
        return len(self.store)


def create_team(org, name, description, repos):
    # PyGithub creates secret teams, and has no way of turning that off! :(
    post_parameters = {
        "name": name,
        "description": description,
        "privacy": "closed",
    }
    post_parameters["repo_names"] = [element._identity for element in repos]
    headers, data = org._requester.requestJsonAndCheck(
        "POST",
        org.url + "/teams",
        input=post_parameters
    )
    return github.Team.Team(org._requester, headers, data, completed=True)


packages_visited = set()

all_members = set()
from random import choice
superlative = ['awesome', 'slick', 'formidable', 'awe-inspiring', 'breathtaking',
               'magnificent', 'wonderous', 'stunning', 'astonishing', 'superb',
               'splendid', 'impressive', 'unbeatable', 'excellent', 'top', 'outstanding',
               'exalted', 'standout', 'smashing']

# Go through each of the feedstocks and ensure that the team is up to date and that
# there is nobody in the team which doesn't belong (i.e. isn't in the maintainers list).
for package_name in os.listdir(feedstocks_path):
    packages_visited.add(package_name)
    feedstock = os.path.join(feedstocks_path, package_name)
    recipe = os.path.join(feedstock, 'recipe', 'meta.yaml')

    if not os.path.exists(recipe):
        print("The {} feedstock is recipe less".format(package_name))
        continue
    env = jinja2.Environment(undefined=NullUndefined)

    with open(recipe) as fh:
        contents = env.from_string(''.join(fh)).render(environ=SilentDict())
    data = yaml.safe_load(contents)

    contributors = data.get('extra', {}).get('recipe-maintainers', [])
    if not isinstance(contributors, list):
        # Deal with a contribution list which has dashes but no spaces
        # (e.g. https://github.com/conda-forge/pandoc-feedstock/issues/1)
        contributors = [contributors.lstrip('-')]
    contributors = set(handle.lower() for handle in contributors)
    all_members.update(contributors)
{'fraction_non_alphanumeric': 0.11809791959956202, 'fraction_numerical': 0.001564210855623338, 'mean_word_length': 3.528328611898017, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1272163', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1959, 'n_words': 515}