<commit_before>"""
gw2copilot/playerinfo.py

The latest version of this package is available at:
<https://github.com/jantman/gw2copilot>

################################################################################
Copyright 2016 <NAME> <<EMAIL>> <http://www.jasonantman.com>

    This file is part of gw2copilot.

    gw2copilot is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    gw2copilot is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with gw2copilot.  If not, see <http://www.gnu.org/licenses/>.

The Copyright and Authors attributions contained herein may not be removed or
otherwise altered, except to add the Author attribution of a contributor to
this work. (Additional Terms pursuant to Section 7b of the AGPL v3)
################################################################################
While not legally required, I sincerely request that anyone who finds
bugs please submit them at <https://github.com/jantman/gw2copilot> or
to me via email, and that you send any contributions or improvements
either as a pull request on GitHub, or to me via email.
################################################################################

AUTHORS:
<NAME> <<EMAIL>> <http://www.jasonantman.com>
################################################################################
"""

import logging
import requests
import math

logger = logging.getLogger()


class PlayerInfo(object):
    """
    Class to store MumbleLink- and API-derived data about the current player.
    """

    def __init__(self, cache):
        """
        Initialize the object.

        :param cache: the CachingAPIClient instance to use to get/set cache
        :type cache: :py:class:`~.CachingAPIClient`
        """
        self._cache = cache
        self._mumble_link_data = {}
        self._current_map = -1
        self._current_map_data = {}
        # calculated values
        self._facing_direction = 0
        self._elevation = 0
        self._continent_id = 0
        self._continent_name = ''
        self._region_id = 0
        self._region_name = ''
        self._map_name = ''
        self._position = [0, 0]

    @property
    def as_dict(self):
        """
        Return a dictionary representation of relevant information about the
        current player.

        :return: player information
        :rtype: dict
        """
        return {
            'facing_direction': self._facing_direction,
            'elevation': self._elevation,
            'map_id': self._current_map,
            'name': self._mumble_link_data['identity']['name'],
            'profession_id': self._mumble_link_data['identity']['profession'],
            'race_id': self._mumble_link_data['identity']['race'],
            'continent_id': self._continent_id,
            'continent_name': self._continent_name,
            'region_id': self._region_id,
            'region_name': self._region_name,
            'map_name': self._map_name,
            'map_level_range': '%d-%d' % (
                self._current_map_data['min_level'],
                self._current_map_data['max_level']
            ),
            'position': self._position<commit_msg>add race and profession names to playerinfo<commit_after>"""
gw2copilot/playerinfo.py

The latest version of this package is available at:
<https://github.com/jantman/gw2copilot>

################################################################################
Copyright 2016 <NAME> <<EMAIL>> <http://www.jasonantman.com>

    This file is part of gw2copilot.

    gw2copilot is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    gw2copilot is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with gw2copilot.  If not, see <http://www.gnu.org/licenses/>.

The Copyright and Authors attributions contained herein may not be removed or
otherwise altered, except to add the Author attribution of a contributor to
this work. (Additional Terms pursuant to Section 7b of the AGPL v3)
################################################################################
While not legally required, I sincerely request that anyone who finds
bugs please submit them at <https://github.com/jantman/gw2copilot> or
to me via email, and that you send any contributions or improvements
either as a pull request on GitHub, or to me via email.
################################################################################

AUTHORS:
<NAME> <<EMAIL>> <http://www.jasonantman.com>
################################################################################
"""

import logging
import requests
import math

logger = logging.getLogger()


class PlayerInfo(object):
    """
    Class to store MumbleLink- and API-derived data about the current player.
    """

    professions = [
        'Guardian',
        'Warrior',
        'Engineer',
        'Ranger',
        'Thief',
        'Elementalist',
        'Mesmer',
        'Necromancer',
        'Revenant'
    ]
    races = [
        'Asura',
        'Charr',
        'Human',
        'Norn',
        'Sylvari'
    ]

    def __init__(self, cache):
        """
        Initialize the object.

        :param cache: the CachingAPIClient instance to use to get/set cache
        :type cache: :py:class:`~.CachingAPIClient`
        """
        self._cache = cache
        self._mumble_link_data = {}
        self._current_map = -1
        self._current_map_data = {}
        # calculated values
        self._facing_direction = 0
        self._elevation = 0
        self._continent_id = 0
        self._continent_name = ''
        self._region_id = 0
        self._region_name = ''
        self._map_name = ''
        self._position = [0, 0]

    @property
    def as_dict(self):
        """
        Return a dictionary representation of relevant information about the
        current player.

        :return: player information
        :rtype: dict
        """
        return {
            'facing_direction': self._facing_direction,
            'elevation': self._elevation,
            'map_id': self._current_map,
            'name': self._mumble_link_data['identity']['name'],
            'profession_id': self._mumble_link_data['identity']['profession'],
            'profession_name': self.professions[
                self._mumble_link_data['identity']['profession']
            ],
            'race_id': self._mumble_link_data['identity']['race'],
            'race_name': self.races[
                self._mumble_link_data['identity']['race']
            ],
            'continent_id': self._continent_id,
            'continent_name': self._continent_name,
            'region_id': self._region_id,
            'region_name': self._region_name,
            'map_name': self._map_name,
            'map_level_range': '%d-%d' % (
                self._current_map_data['min_level'],
                self._current_map_data['max_level']
            ),
            'position': self._position
{'fraction_non_alphanumeric': 0.1650907232302581, 'fraction_numerical': 0.005366726296958855, 'mean_word_length': 2.803206997084548, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '6578536', 'n_tokens_mistral': 2114, 'n_tokens_neox': 2009, 'n_words': 655}