<commit_before>import requests
from bs4 import BeautifulSoup
from django.core.cache import cache


def privileged_members(group_name: str) -> list:
    key = 'privileged_members_{:s}'.format(group_name)
    members = cache.get('privileged_members_{:s}'.format(group_name))

    if not members:
        members = privileged_members_raw(group_name)
        cache.set(key, members, 60 * 60)

    return members


def privileged_members_raw(group_name: str) -> list:
    res = requests.get('http://steamcommunity.com/groups/{:s}/members'.format(group_name), {
        'content_only': True
    })

    if res.status_code is not 200:
        raise SteamScraperError('Can\'t retrieve group members page')

    members = parse_privileged_member_names(res.text)

    return [steam_id_by_name_raw(m) for m in members]


def steam_id_by_name(name: str) -> list:
    key = 'steam_id_by_name_{:s}'.format(name)
    steam_id = cache.get(key)

    if not steam_id:
        steam_id = steam_id_by_name(name)
        cache.set(key, steam_id, 60 * 60 * 24 * 30)

    return steam_id


def steam_id_by_name_raw(name: str) -> str:
    res = requests.get('http://steamcommunity.com/id/{:s}'.format(name), {
        'xml': 1
    })

    if res.status_code is not 200:
        raise SteamScraperError('Can\'t retrieve user profile')

    return parse_steam_id(res.text)


def parse_steam_id(xml: str) -> str:
    root = BeautifulSoup(xml, "lxml-xml")
    return str(root.find('steamID64').contents[0])


def parse_privileged_member_names(html: str) -> list:
    root = BeautifulSoup(html, 'lxml')
    members_child = root.find_all('div', class_='rank_icon')
    members = [m.parent.find('a', class_='linkFriend').get('href').split('/')[-1] for m in members_child]
    return members


class SteamScraperError(Exception):
    pass<commit_msg>fix mis-function call<commit_after>import requests
from bs4 import BeautifulSoup
from django.core.cache import cache


def privileged_members(group_name: str) -> list:
    key = 'privileged_members_{:s}'.format(group_name)
    members = cache.get(key)

    if not members:
        members = __privileged_members(group_name)
        cache.set(key, members, 60 * 60)

    return members


def __privileged_members(group_name: str) -> list:
    res = requests.get('http://steamcommunity.com/groups/{:s}/members'.format(group_name), {
        'content_only': True
    })

    if res.status_code is not 200:
        raise SteamScraperError('Can\'t retrieve group members page')

    members = parse_privileged_member_names(res.text)

    return [steam_id_by_name(m) for m in members]


def steam_id_by_name(name: str) -> list:
    key = 'steam_id_by_name_{:s}'.format(name)
    steam_id = cache.get(key)

    if not steam_id:
        steam_id = __steam_id_by_name(name)
        cache.set(key, steam_id, 60 * 60 * 24 * 30)

    return steam_id


def __steam_id_by_name(name: str) -> str:
    res = requests.get('http://steamcommunity.com/id/{:s}'.format(name), {
        'xml': 1
    })

    if res.status_code is not 200:
        raise SteamScraperError('Can\'t retrieve user profile')

    return parse_steam_id(res.text)


def parse_steam_id(xml: str) -> str:
    root = BeautifulSoup(xml, "lxml-xml")
    return str(root.find('steamID64').contents[0])


def parse_privileged_member_names(html: str) -> list:
    root = BeautifulSoup(html, 'lxml')
    members_child = root.find_all('div', class_='rank_icon')
    members = [m.parent.find('a', class_='linkFriend').get('href').split('/')[-1] for m in members_child]
    return members


class SteamScraperError(Exception):
    pass
{'fraction_non_alphanumeric': 0.12934631432545202, 'fraction_numerical': 0.013351877607788595, 'mean_word_length': 3.6762028608582575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '1032375', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1224, 'n_words': 257}