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"
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
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
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"
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
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"
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
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
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
# -*- 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()
# -*- 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"])
# -*- 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"])
# -*- 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"])
# -*- 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()
# -*- 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()
# -*- 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"])
# -*- 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()
# -*- 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"])
# -*- 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()
def test_no_getter(): get_test = Getter(providing_args=["foo"]) assert get_test.get() is None
# -*- 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()
# -*- 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"])