コード例 #1
0
ファイル: tba.py プロジェクト: Glossawy/FRS
class urls:
    TEAMS = ConfigValue(
        TbawUrlDefinition('^t/{team_number}/$',
                          {'team_number': r'(?P<team_number>\d+)'}),
        condition=is_type(
            TbawUrlDefinition))  # type: ConfigValue[TbawUrlDefinition]
    EVENTS = ConfigValue(
        TbawUrlDefinition('^e/{key}/$',
                          {'key': r'(?P<event_key>\d{4}[a-zA-Z\d]*)'}),
        condition=is_type(
            TbawUrlDefinition))  # type: ConfigValue[TbawUrlDefinition]
コード例 #2
0
ファイル: base.py プロジェクト: Glossawy/FRS
from typing import Set
from FRS.config._cfg import ConfigValue, is_type, contained_type, join
from funcy.types import is_set

import os

BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '/../../')
DEBUG = True

ALLOWED_HOSTS = {'*'}

BASE_DIR = ConfigValue(BASE_DIR,
                       condition=is_type(str))  # type: ConfigValue[str]
DEBUG = ConfigValue(DEBUG, condition=is_type(bool))  # type: ConfigValue[bool]
ALLOWED_HOSTS = ConfigValue(
    ALLOWED_HOSTS,
    condition=join(is_set, contained_type(str)))  # type: ConfigValue[Set[str]]

LOGGING_DIR = ConfigValue(os.path.join(BASE_DIR.value, 'logs'),
                          condition=is_type(str))  # type: ConfigValue[str]
コード例 #3
0
ファイル: security.py プロジェクト: Glossawy/FRS
from FRS.config._cfg import ConfigValue, is_type

from django.utils.crypto import get_random_string
import os

# Import secret key or generate new secret key
try:
    import FRS.secret_key as sk
except ImportError:
    # Generate Secret Key the same way django-admin's startproject does
    SETTINGS_DIR = os.path.abspath(os.path.dirname(__file__) + '/../')
    SECRET_KEY_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
    with open(os.path.join(SETTINGS_DIR, 'secret_key.py'), 'w') as f:
        f.write("SECRET_KEY = \"%s\"" %
                (get_random_string(50, SECRET_KEY_CHARS)))
    import secret_key as sk

SECRET_KEY = ConfigValue(sk.SECRET_KEY,
                         condition=is_type(str))  # type: ConfigValue[str]
コード例 #4
0
ファイル: trueskill.py プロジェクト: Glossawy/FRS
# GENERAL DEFAULTS FOR "REASONABLE" RESULTS:
#   mu          = 25
#   sigma       = mu/3
#   beta        = sigma/2
#   tau         = sigma/100

MU = 1500  # Assumed Initial Skill
SIGMA = MU / 3  # Assumed Initial Standard Deviation (Assumed Uncertainty,
BETA = SIGMA / 2  # Assumed "Skill Chain Length", if Player 1 is BETA skill about Player 2, they are expected to win 80% of the time
TAU = SIGMA / 100  # Dynamicity of Skills, tends to be directly proportional with volatility

nonegative_number = join(is_number, nonnegative)
zero_one_float = join(is_number, clamped(0, 1))

MU = ConfigValue(MU, condition=nonegative_number)  # type: ConfigValue[float]
SIGMA = ConfigValue(SIGMA,
                    condition=nonegative_number)  # type: ConfigValue[float]
BETA = ConfigValue(BETA,
                   condition=nonegative_number)  # type: ConfigValue[float]
TAU = ConfigValue(TAU, condition=nonegative_number)  # type: ConfigValue[float]

# Likelihood of a Draw
DRAW_PROBABILITY = ConfigValue(
    0.1, condition=zero_one_float)  # type: ConfigValue[float]

# TODO Should we even acknowledge decay?
# ELO Decay Shape Parameter
# elo_mu = default_mu + (elo_mu - default_mu)*(1 - decay_alpha)^t
#
# The ELO Decay function after t iterations follows the above exponential decay function. This can be interpreted
コード例 #5
0
ファイル: tba.py プロジェクト: Glossawy/FRS
        return len(varnames_from_fmt(definition.urlpattern)) == 0

    @staticmethod
    def ensure_validity(definition: 'TbawUrlDefinition'):
        if not TbawUrlDefinition.check_validity(definition):
            raise AssertionError(
                'TBAW URL Definition is invalid, urlpattern as not fully built: "%s" still needs %s'
                % (definition.urlpattern,
                   varnames_from_fmt(definition._url_template)))

    def __str__(self):
        return 'TbawUrl[fmt={}, pattern={}]'.format(self._url_template,
                                                    self._django_url)


APP_ID = ConfigValue('frs:frs:1',
                     condition=is_type(str))  # type: ConfigValue[str]


class urls:
    TEAMS = ConfigValue(
        TbawUrlDefinition('^t/{team_number}/$',
                          {'team_number': r'(?P<team_number>\d+)'}),
        condition=is_type(
            TbawUrlDefinition))  # type: ConfigValue[TbawUrlDefinition]
    EVENTS = ConfigValue(
        TbawUrlDefinition('^e/{key}/$',
                          {'key': r'(?P<event_key>\d{4}[a-zA-Z\d]*)'}),
        condition=is_type(
            TbawUrlDefinition))  # type: ConfigValue[TbawUrlDefinition]
コード例 #6
0
class names:
    PUBLIC_TEAMS = ConfigValue(
        'teampub', condition=is_type(str))  # type: ConfigValue[str]
    PUBLIC_EVENTS = ConfigValue(
        'eventpub', condition=is_type(str))  # type: ConfigValue[str]
コード例 #7
0
class schemas:
    PUBLIC_TEAMS_SCHEMA = ConfigValue(
        'PublicTeam', condition=is_type(str))  # type: ConfigValue[str]
    PUBLIC_EVENTS_SCHEMA = ConfigValue(
        'PublicEvent', condition=is_type(str))  # type: ConfigValue[str]