コード例 #1
0
def test_getter():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test)
    def getter_for_get_test(*args, **kwargs):
        return 2

    assert get_test.get() == 2
コード例 #2
0
def test_getter_with_arg():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test)
    def getter_for_get_test(*args, **kwargs):
        return kwargs["foo"]

    assert get_test.get(foo=3) == 3
コード例 #3
0
def test_getter_with_with_sender_int():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test, sender=int)
    def getter_for_get_test(sender, *args, **kwargs):
        return kwargs["foo"] * 7

    assert get_test.get(int, foo=3) == 21
コード例 #4
0
def test_getter_multi_sender():
    get_test = Getter(providing_args=["foo"])

    @getter(get_test, sender=(str, int))
    def getter_for_get_test(sender, *args, **kwargs):
        return kwargs["foo"]

    assert get_test.get(str, foo="test") == "test"
    assert get_test.get(int, foo="test") == "test"
コード例 #5
0
def test_getter_with_with_sender():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test, sender=str)
    def getter_for_get_test(sender, *args, **kwargs):
        return kwargs["foo"]

    assert get_test.get(str, foo="BOOM") == "BOOM"
コード例 #6
0
def test_getter_with_with_sender_multi():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test)
    def getter_for_get_test(sender, *args, **kwargs):
        if sender is int:
            return kwargs["foo"] * 7
        return int(kwargs["foo"]) * 7

    assert get_test.get(str, foo="3") == 21
    assert get_test.get(int, foo=3) == 21
コード例 #7
0
def test_getter_handle_order_2():

    get_test = Getter(providing_args=["foo"])

    @getter(get_test)
    def getter_for_get_test(sender, *args, **kwargs):
        return 1

    @getter(get_test)
    def getter_for_get_test_2(sender, *args, **kwargs):
        return 2

    assert get_test.get(str, foo="bar") == 1
コード例 #8
0
def test_getter_handle_multi():

    get_test = Getter(providing_args=["foo"])
    get_test_2 = Getter(providing_args=["foo"])

    @getter([get_test, get_test_2])
    def getter_for_get_test(sender, *args, **kwargs):
        return kwargs["foo"]

    assert get_test.get(str, foo="test 1") == "test 1"
    assert get_test_2.get(str, foo="test 2") == "test 2"
コード例 #9
0
ファイル: utils.py プロジェクト: yiyibooks/pootle
def suppress_getter(getter):
    _orig_get = getter.get
    _orig_connect = getter.connect
    temp_getter = Getter()

    def suppressed_get(self, *args, **kwargs):
        return temp_getter.get(*args, **kwargs)

    def suppressed_connect(self, func, *args, **kwargs):
        return temp_getter.connect(func, *args, **kwargs)

    getter.get = types.MethodType(suppressed_get, getter)
    getter.connect = types.MethodType(suppressed_connect, getter)
    try:
        yield
    finally:
        getter.get = _orig_get
        getter.connect = _orig_connect
コード例 #10
0
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.


from pootle.core.plugin.delegate import Getter, Provider


config = Getter(providing_args=["instance"])
search_backend = Getter(providing_args=["instance"])
lang_mapper = Getter(providing_args=["instance"])
state = Getter()
response = Getter()
contributors = Getter()
display = Getter()
formats = Getter()
format_registration = Provider()
format_classes = Provider()
format_diffs = Provider()
format_updaters = Provider()
format_syncers = Provider()
frozen = Getter()
filetype_tool = Getter()
lifecycle = Getter()
stemmer = Getter()
terminology = Getter()
terminology_matcher = Getter()
コード例 #11
0
ファイル: delegate.py プロジェクト: RevelSystems/cat-pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

config = Getter(providing_args=["instance"])
search_backend = Getter(providing_args=["instance"])
lang_mapper = Getter(providing_args=["instance"])
state = Getter()
response = Getter()

serializers = Provider(providing_args=["instance"])
deserializers = Provider(providing_args=["instance"])
コード例 #12
0
ファイル: delegate.py プロジェクト: RevelSystems/cat-pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter

comment_should_not_be_saved = Getter(providing_args=["instance", "comment"])
コード例 #13
0
ファイル: delegate.py プロジェクト: r-o-b-b-i-e/pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

fs_file = Getter()
fs_finder = Getter()
fs_matcher = Getter()
fs_resources = Getter()
fs_translation_mapping_validator = Getter()
fs_url_validator = Getter()

# File system plugins such as git/mercurial/localfs
fs_plugins = Provider()

fs_pre_pull_handlers = Provider()
fs_post_pull_handlers = Provider()
fs_pre_push_handlers = Provider()
fs_post_push_handlers = Provider()
コード例 #14
0
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

config = Getter(providing_args=["instance"])
search_backend = Getter(providing_args=["instance"])
lang_mapper = Getter(providing_args=["instance"])
state = Getter()
response = Getter()
contributors = Getter()
formats = Getter()
format_registration = Provider()
format_classes = Provider()
format_diffs = Provider()
format_updaters = Provider()
format_syncers = Provider()
filetype_tool = Getter()
tp_tool = Getter()
data_tool = Getter()
data_updater = Getter()

language_team = Getter()
review = Getter()
revision = Getter()
revision_updater = Getter()
コード例 #15
0
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

config = Getter(providing_args=["instance"])
search_backend = Getter(providing_args=["instance"])
lang_mapper = Getter(providing_args=["instance"])
state = Getter()
response = Getter()
contributors = Getter()
formats = Getter()
format_registration = Provider()
format_classes = Provider()
format_diffs = Provider()
format_updaters = Provider()
format_syncers = Provider()
filetype_tool = Getter()
tp_tool = Getter()

serializers = Provider(providing_args=["instance"])
deserializers = Provider(providing_args=["instance"])
subcommands = Provider()

# view.context_data
context_data = Provider(providing_args=["view", "context"])
コード例 #16
0
ファイル: delegate.py プロジェクト: alexanderlaw/pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter

path_matcher = Getter()
vfolders_data_tool = Getter()
vfolder_finder = Getter()
コード例 #17
0
ファイル: delegate.py プロジェクト: RevelSystems/cat-pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter


config_should_not_be_set = Getter(providing_args=["instance", "key", "value"])
config_should_not_be_appended = Getter(providing_args=["instance", "key", "value"])
コード例 #18
0
ファイル: delegate.py プロジェクト: ratanasoth/zing
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
# Copyright (C) Zing contributors.
#
# This file is a part of the Zing project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

search_backend = Getter(providing_args=["instance"])
contributors = Getter()

# view.context_data
context_data = Provider(providing_args=["view", "context"])
コード例 #19
0
ファイル: delegate.py プロジェクト: unasettimana/pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

fs_file = Getter()
fs_finder = Getter()
fs_matcher = Getter()
fs_resources = Getter()

# File system plugins such as git/mercurial/localfs
fs_plugins = Provider()

fs_pre_pull_handlers = Provider()
fs_post_pull_handlers = Provider()
fs_pre_push_handlers = Provider()
fs_post_push_handlers = Provider()
コード例 #20
0
def test_no_getter():

    get_test = Getter(providing_args=["foo"])

    assert get_test.get() is None
コード例 #21
0
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter, Provider

config = Getter(providing_args=["instance"])
search_backend = Getter(providing_args=["instance"])
lang_mapper = Getter(providing_args=["instance"])
state = Getter()
response = Getter()
check_updater = Getter()
comparable_event = Getter()
contributors = Getter()
crud = Getter()
display = Getter()
event_score = Provider()
event_formatters = Provider()
formats = Getter()
format_registration = Provider()
format_classes = Provider()
format_diffs = Provider()
format_updaters = Provider()
format_syncers = Provider()
frozen = Getter()
filetype_tool = Getter()
grouped_events = Getter()
コード例 #22
0
ファイル: delegate.py プロジェクト: paxswill/pootle
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.

from pootle.core.plugin.delegate import Getter

search_backend = Getter(providing_args=["instance"])