Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d96a983 authored by Markus Heiser's avatar Markus Heiser
Browse files

[format.python] initial formatting of the python code

This patch was generated by black [1]::

    make format.python

[1] https://github.com/psf/black



Signed-off-by: default avatarMarkus Heiser <markus.heiser@darmarit.de>
parent fcdc2c2c
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ if settings is not None:

_unset = object()


def get_setting(name, default=_unset):
    """Returns the value to which ``name`` point.  If there is no such name in the
    settings and the ``default`` is unset, a :py:obj:`KeyError` is raised.
@@ -80,14 +81,9 @@ def logging_config_debug():
            'levelname': {'color': 8},
            'name': {'color': 8},
            'programname': {'color': 'cyan'},
            'username': {'color': 'yellow'}
            'username': {'color': 'yellow'},
        }
        coloredlogs.install(
            level=log_level,
            level_styles=level_styles,
            field_styles=field_styles,
            fmt=LOG_FORMAT_DEBUG
        )
        coloredlogs.install(level=log_level, level_styles=level_styles, field_styles=field_styles, fmt=LOG_FORMAT_DEBUG)
    else:
        logging.basicConfig(level=logging.getLevelName(log_level), format=LOG_FORMAT_DEBUG)

+14 −11
Original line number Diff line number Diff line
@@ -13,8 +13,7 @@ random_string_letters = string.ascii_lowercase + string.digits + string.ascii_up


def random_characters():
    return [random.choice(random_string_letters)
            for _ in range(random.randint(8, 32))]
    return [random.choice(random_string_letters) for _ in range(random.randint(8, 32))]


def random_string():
@@ -39,11 +38,13 @@ def random_uuid():
    return str(uuid.uuid4())


random_types = {'string': random_string,
random_types = {
    'string': random_string,
    'int': random_int,
    'float': random_float,
    'sha256': random_sha256,
                'uuid': random_uuid}
    'uuid': random_uuid,
}


# required answerer function
@@ -62,6 +63,8 @@ def answer(query):
# required answerer function
# returns information about the answerer
def self_info():
    return {'name': gettext('Random value generator'),
    return {
        'name': gettext('Random value generator'),
        'description': gettext('Generate different random values'),
            'examples': ['random {}'.format(x) for x in random_types]}
        'examples': ['random {}'.format(x) for x in random_types],
    }
+6 −8
Original line number Diff line number Diff line
@@ -4,11 +4,7 @@ from operator import mul
from flask_babel import gettext


keywords = ('min',
            'max',
            'avg',
            'sum',
            'prod')
keywords = ('min', 'max', 'avg', 'sum', 'prod')


# required answerer function
@@ -47,6 +43,8 @@ def answer(query):
# required answerer function
# returns information about the answerer
def self_info():
    return {'name': gettext('Statistics functions'),
    return {
        'name': gettext('Statistics functions'),
        'description': gettext('Compute {functions} of the arguments').format(functions='/'.join(keywords)),
            'examples': ['avg 123 548 2.04 24.2']}
        'examples': ['avg 123 548 2.04 24.2'],
    }
+9 −8
Original line number Diff line number Diff line
@@ -120,13 +120,14 @@ def wikipedia(query, lang):
    return []


backends = {'dbpedia': dbpedia,
backends = {
    'dbpedia': dbpedia,
    'duckduckgo': duckduckgo,
    'google': google,
    'startpage': startpage,
    'swisscows': swisscows,
    'qwant': qwant,
            'wikipedia': wikipedia
    'wikipedia': wikipedia,
}


+3 −0
Original line number Diff line number Diff line
@@ -23,10 +23,12 @@ from pathlib import Path

data_dir = Path(__file__).parent


def _load(filename):
    with open(data_dir / filename, encoding='utf-8') as f:
        return json.load(f)


def ahmia_blacklist_loader():
    """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
    names.  The MD5 values are fetched by::
@@ -39,6 +41,7 @@ def ahmia_blacklist_loader():
    with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
        return f.read().split()


ENGINES_LANGUAGES = _load('engines_languages.json')
CURRENCIES = _load('currencies.json')
USER_AGENTS = _load('useragents.json')
Loading