<commit_before>"""
Steam profile/account reading and ID resolution
Copyright (c) 2010-2013, <NAME> <<EMAIL>>
Distributed under the ISC License (see LICENSE)
"""

import time
import os
from . import api


class ProfileError(api.APIError):
    pass


class ProfileNotFoundError(ProfileError):
    pass


class VanityError(ProfileError):
    pass


class BansError(ProfileError):
    pass


class BansNotFoundError(BansError):
    pass


class vanity_url(object):
    """ Class for holding a vanity URL and its id64 """

    @property
    def id64(self):
        if self._cache:
            return self._cache

        res = None
        try:
            res = self._api["response"]
            self._cache = int(res["steamid"])
        except KeyError:
            if not self._cache:
                if res:
                    raise VanityError(res.get("message",
                                              "Invalid vanity response"))
                else:
                    raise VanityError("Empty vanity response")

        return self._cache

    def __str__(self):
        return str(self.id64)

    def __init__(self, vanity, **kwargs):
        """ Takes a vanity URL part and tries
        to resolve it. """
        vanity = os.path.basename(str(vanity).strip('/'))

        self._cache = None
        self._api = api.interface("ISteamUser").ResolveVanityURL(vanityurl=vanity, **kwargs)


class profile(object):
    """ Functions for reading user account data """

    @property
    def id64(self):
        """ Returns the 64 bit steam ID (use with other API requests) """
        return int(self._prof["steamid"])

    @property
    def id32(self):
        """ Returns the 32 bit steam ID """
        return int(self.id64) - 76561197960265728

    @property
    def persona(self):
        """ Returns the user's persona (what you usually see in-game) """
        return self._prof["personaname"]

    @property
    def profile_url(self):
        """ Returns a URL to the user's Community profile page """
        return self._prof["profileurl"]

    @property
    def vanity(self):
        """ Returns the user's vanity url if it exists, None otherwise """
        purl = self.profile_url.strip('/')
        if purl.find("/id/") != -1:
            return os.path.basename(purl)

    @property
    def avatar_small(self):
        return self._prof["avatar"]

    @property
    def avatar_medium(self):
        return self._prof["avatarmedium"]

    @property
    def avatar_large(self):
        return self._prof["avatarfull"]

    @property
    def status(self):
        """ Returns the user's status.
        0: offline
        1: online
        2: busy
        3: away
        4: snooze
        5: looking to trade
        6: looking to play
        If player's profile is private, this will always be 0.
        """
        return self._prof["personastate"]

    @property
    def visibility(self):
        """ Returns the visibility setting of the profile.
        1: private
        2: friends only
        3: public
        """
        return self._prof["communityvisibilitystate"]

    @property
    def configured(self):
        """ Returns true if the user has created a Community profile """
        return bool(self._prof.get("profilestate"))

    @property
    def last_online(self):
        """ Returns the last time the user was online as a localtime
        time.struct_time struct """
        return time.localtime(self._prof["lastlogoff"])

    @property
    def comments_enabled(self):
        """ Returns true if the profile allows public comments """
        return bool(self._prof.get("commentpermission"))

    @property
    def real_name(self):
        """ Returns the user's real name if it's set and public """
        return self._prof.get("realname")

    @property<commit_msg>Adds property access for personastateflags<commit_after>"""
Steam profile/account reading and ID resolution
Copyright (c) 2010-2013, <NAME> <<EMAIL>>
Distributed under the ISC License (see LICENSE)
"""

import time
import os
from . import api


class ProfileError(api.APIError):
    pass


class ProfileNotFoundError(ProfileError):
    pass


class VanityError(ProfileError):
    pass


class BansError(ProfileError):
    pass


class BansNotFoundError(BansError):
    pass


class vanity_url(object):
    """ Class for holding a vanity URL and its id64 """

    @property
    def id64(self):
        if self._cache:
            return self._cache

        res = None
        try:
            res = self._api["response"]
            self._cache = int(res["steamid"])
        except KeyError:
            if not self._cache:
                if res:
                    raise VanityError(res.get("message",
                                              "Invalid vanity response"))
                else:
                    raise VanityError("Empty vanity response")

        return self._cache

    def __str__(self):
        return str(self.id64)

    def __init__(self, vanity, **kwargs):
        """ Takes a vanity URL part and tries
        to resolve it. """
        vanity = os.path.basename(str(vanity).strip('/'))

        self._cache = None
        self._api = api.interface("ISteamUser").ResolveVanityURL(vanityurl=vanity, **kwargs)


class profile(object):
    """ Functions for reading user account data """

    @property
    def id64(self):
        """ Returns the 64 bit steam ID (use with other API requests) """
        return int(self._prof["steamid"])

    @property
    def id32(self):
        """ Returns the 32 bit steam ID """
        return int(self.id64) - 76561197960265728

    @property
    def persona(self):
        """ Returns the user's persona (what you usually see in-game) """
        return self._prof["personaname"]

    @property
    def profile_url(self):
        """ Returns a URL to the user's Community profile page """
        return self._prof["profileurl"]

    @property
    def vanity(self):
        """ Returns the user's vanity url if it exists, None otherwise """
        purl = self.profile_url.strip('/')
        if purl.find("/id/") != -1:
            return os.path.basename(purl)

    @property
    def avatar_small(self):
        return self._prof["avatar"]

    @property
    def avatar_medium(self):
        return self._prof["avatarmedium"]

    @property
    def avatar_large(self):
        return self._prof["avatarfull"]

    @property
    def status(self):
        """ Returns the user's status.
        0: offline
        1: online
        2: busy
        3: away
        4: snooze
        5: looking to trade
        6: looking to play
        If player's profile is private, this will always be 0.
        """
        return self._prof["personastate"]

    @property
    def persona_state_flags(self):
        """ personastateflags
           0: NONE
           1: Has Rich Presence
           2: In Joinable Game
           4: Golden
           8: Remote Play Together
         256: Client Type Web
         512: Client Type Mobile
        1024: Client Type Tenfoot
        2048: Client Type VR
        4096: Launch Type Gamepad
        8182: Launch Type CompatTool
        """
        return self._prof["personastateflags"]

    @property
    def visibility(self):
        """ Returns the visibility setting of the profile.
        1: private
        2: friends only
        3: public
        """
        return self._prof["communityvisibilitystate"]

    @property
    def configured(self):
        """ Returns true if the user has created a Community profile """
        return bool(self._prof.get("profilestate"))

    @property
    def last_online(self):
        """ Returns the last time the user was online as a localtime
        time.struct_time struct """
        return time.localtime(self._prof["lastlogoff"])

    @property
    def comments_enabled(self):
        """ Returns true if the profile allows public comments """
        return bool(self._prof.get("commentpermission"))

    @property
    def real_name(self):
        """ Returns the user's real name if it's set and public """
        return self._prof.get("realname")

    @property
{'fraction_non_alphanumeric': 0.10124093869025678, 'fraction_numerical': 0.016341073841995332, 'mean_word_length': 2.140432098765432, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2041460', 'n_tokens_mistral': 2336, 'n_tokens_neox': 2150, 'n_words': 703}