How to use graft method in avocado

Best Python code snippet using avocado_python

client.py

Source:client.py Github

copy

Full Screen

...28 more natural than composing functions.29 Therefore, this client considers a graft with no parameters to represent30 the value it returns. A graft with parameters is considered an actual function.31 In practice, in::32 apply_graft("add", {"x": 1, "returns": "x"}, {"y": 2, "returns": "y"})33 the arguments are considered as the values at their ``"returns"`` keys34 (keys ``x`` and ``y``), rather than "add" being a higher-order function which takes35 two other functions. So the result of this call is something like::36 {"x": 1, "y": 2, "res": ["add", "x", "y"], "returns": "ret"}37 where just the keys ``x`` and ``y`` are given to the ``"add"`` function,38 rather than the two whole grafts.39 Compare this to::40 apply_graft(41 "apply_a_func", {"parameters": ["a"], "returns": "a"}, {"x": 1, "returns": "x"}42 )43 which gives something like::44 {45 "0": {"parameters": ["a"], "returns": "a"},46 "x": 1,47 "1": ["apply_a_func", "0", "x"],48 "returns": "1",49 }50 Notice that the function (``{"parameters": ["a"], "returns": "a"}``)51 is inserted as a subgraft under a new, generated key (``"0"``),52 while the graft of the value (``x``) is copied in directly.53 In general, this graft client handles these concerns correctly for54 you---that's what it's for.55"""56import itertools57import contextlib58from .. import syntax59NO_INITIAL = "_no_initial_"60PARAM = "__param__"61GUID_COUNTER = itertools.count()62# use `itertools.count()` as a lock-free threadsafe counter,63# which only works due to a CPython implementation detail64# (because `count` is implemented in C, holding the GIL for the entirety of its execution)65# https://mail.python.org/pipermail//python-ideas/2016-August/041871.html66# https://stackoverflow.com/a/27062830/1051995367def guid():68 return str(next(GUID_COUNTER))69def is_delayed(x):70 "Whether x is a delayed-like: ``x.graft`` is a graft-like mapping"71 try:72 return syntax.is_graft(x.graft)73 except AttributeError:74 return False75def value_graft(value, key=None):76 """77 The graft, as a dict, for a value.78 Parameters79 ----------80 value: delayed-like object or JSON-serializable value81 If a JSON-serializable value, returns the graft representing that value82 (a function with no parameters that returns the value).83 If a delayed-like object, returns ``value.graft``.84 Returns85 -------86 graft: dict87 """88 if is_delayed(value):89 return value.graft90 if key is None:91 key = guid()92 elif not syntax.is_key(key):93 raise TypeError(94 "Key must be a string, and not one of {}".format(syntax.RESERVED_WORDS)95 )96 if isinstance(value, syntax.PRIMITIVE_TYPES):97 return {key: value, "returns": key}98 elif isinstance(value, (tuple, list, dict)):99 # Quoted JSON100 return {key: [value], "returns": key}101 else:102 raise TypeError(103 "Value must be a delayed-like object, primitve (one of {}), or JSON-serializable "104 "sequence or mapping, not {}: {}".format(105 syntax.PRIMITIVE_TYPES, type(value), value106 )107 )108def keyref_graft(key):109 """110 Graft for referring to an arbitrary key.111 Useful for referring to parameters of functions, or builtins.112 Parameters113 ----------114 key: str115 """116 if not syntax.is_key(key):117 raise ValueError(118 "Key must be a string, and not one of {}".format(syntax.RESERVED_WORDS)119 )120 return {"returns": key}121def is_keyref_graft(value):122 return syntax.is_graft(value) and len(value) == 1 and next(iter(value)) == "returns"123def apply_graft(function, *args, **kwargs):124 """125 The graft for calling a function with the given positional and keyword arguments.126 Arguments can be given as Python values, in which case `value_graft`127 will be called on them first, or as delayed-like objects or graft-like mappings.128 Parameters129 ----------130 function: str, graft-like mapping, or delayed-like object131 The function to apply132 **args: delayed-like object, graft-like mapping, or JSON-serializable value133 Positional arguments to apply function to134 **kwargs: delayed-like object, graft-like mapping, or JSON-serializable value135 Named arguments to apply function to136 Returns137 -------138 result_graft: dict139 Graft representing ``function`` applied to ``args`` and ``kwargs``140 """141 pos_args_grafts = [142 arg if syntax.is_graft(arg) else value_graft(arg) for arg in args143 ]144 named_arg_grafts = {145 name: (arg if syntax.is_graft(arg) else value_graft(arg))146 for name, arg in kwargs.items()147 }148 if is_delayed(function):149 function = function.graft150 result_graft = {}151 function_key = None152 if isinstance(function, str):153 function_key = function154 elif syntax.is_graft(function):155 if "parameters" in function:156 # function considered an actual function object, insert it as a subgraft157 param_names = function.get("parameters", [])158 syntax.check_args(len(args), kwargs.keys(), param_names)159 function_key = guid()160 result_graft[function_key] = function161 else:162 # function considered the value it returns; inline its graft.163 # this is the case with higher-order functions,164 # where `function` is an apply expression that returns another function.165 # we don't check args because that would require interpreting the graft.166 result_graft.update(function)167 function_key = function["returns"]168 else:169 raise TypeError(170 "Expected a graft dict, a delayed-like object, or a string as the function; "171 "got {}".format(function)172 )173 positional_args = []174 named_args = {}175 for name, arg_graft in itertools.chain(176 zip(itertools.repeat(None), pos_args_grafts), named_arg_grafts.items()177 ):178 if graft_is_function_graft(arg_graft):179 # argument considered an actual function object, insert it as a subgraft180 arg_key = guid()181 result_graft[arg_key] = arg_graft182 else:183 # argument considered the value it returns; inline its graft184 result_graft.update(arg_graft)185 arg_key = arg_graft["returns"]186 if name is None:187 positional_args.append(arg_key)188 else:189 named_args[name] = arg_key190 expr = [function_key] + positional_args191 if len(named_args) > 0:192 expr.append(named_args)193 key = guid()194 result_graft[key] = expr195 result_graft["returns"] = key196 return result_graft197def is_function_graft(graft):198 return syntax.is_graft(graft) and graft_is_function_graft(graft)199def graft_is_function_graft(graft):200 return "parameters" in graft201def function_graft(result, *parameters, **kwargs):202 """203 Graft for a function that returns ``result``.204 Parameters205 ----------206 result: graft-like mapping or delayed-like object207 The value to be returned by the function.208 If a value graft (no ``"parameters"`` key), produces a function209 that returns that value.210 If a function graft (has ``"parameters"``), produces a higher-order211 function (function that itself returns a function).212 *parameters: str or keyref graft213 Names of the parameters to the function, or keyref grafts representing them.214 The graft of ``result`` should include dependencies to these names215 (using `keyref_graft`), but this is not validated. Forgetting to include216 a parameter name required somewhere within ``result`` could result217 in unexpected runtime behavior.218 first_guid: optional, str or None, default None219 The value of `guid` when the logical scope of this function begins.220 If given, any keys that show up in ``result`` that strictly precede ``first_guid``221 (when compared as ints, not lexicographically) are assumed to be references222 to an outer scope level, and are moved outside the body of the function.223 This is important to use when delaying Python functions by passing dummy224 delayed-like objects through them, since otherwise references to objects in225 outer scopes in Python will get "inlined" into the functions graft, which could226 have performance implications if the function is called repeatedly.227 Note that this only searches the keys of ``result``, and does not traverse228 into any sub-grafts it might contain, so this doesn't work on higher-order229 functions. If ``result`` itself returns a sub-function, and that sub-function230 references a key preceding ``first_guid``, it won't be removed from the sub-function's231 graft.232 Returns233 -------234 function_graft: dict235 Graft representing a function that returns ``result`` and takes ``parameters``.236 """237 first_guid = kwargs.pop("first_guid", None)238 if len(kwargs) > 0:239 raise TypeError(240 "Unexpected keyword arguments {}".format(", ".join(map(repr, kwargs)))241 )242 if first_guid is not None:243 first_guid = int(first_guid)244 parameters = [245 param["returns"] if is_keyref_graft(param) else param for param in parameters246 ]247 if not syntax.is_params(parameters):248 raise ValueError(249 "Invalid parameters for a graft (must be a sequence of strings, "250 "none of which are in {}): {}".format(syntax.RESERVED_WORDS, parameters)251 )252 result_graft = result if syntax.is_graft(result) else value_graft(result)253 if first_guid is not None:254 orig_result_graft = result_graft255 result_graft = orig_result_graft.copy()256 containing_scope = {257 k: result_graft.pop(k)258 for k in orig_result_graft259 if _is_outer_scope(k, first_guid)260 }261 else:262 containing_scope = {}263 if graft_is_function_graft(result_graft):264 # Graft that returns a function object; i.e. has a "parameters" key265 key = guid()266 containing_scope.update(267 {"parameters": parameters, key: result_graft, "returns": key}268 )269 return containing_scope270 else:271 # Graft that returns the value referred to by result272 func_graft = dict(result_graft, parameters=parameters)273 if len(containing_scope) == 0:274 return func_graft275 else:276 key = guid()277 containing_scope[key] = func_graft278 containing_scope["returns"] = key279 return containing_scope280def _is_outer_scope(key, first_guid):281 try:282 return int(key) < first_guid283 except ValueError:284 return False285def merge_value_grafts(**grafts):286 """287 Merge zero-argument grafts into one, with return values available under new names.288 Lets you take multiple grafts that return values (such as ``{'x': 1, 'returns': 'x'}``),289 and construct a graft in which those _returned_ values are available under the names290 specified as keyword arguments---as _values_, not as callables.291 Parameters292 ----------293 **grafts: delayed-like object, graft-like mapping, or JSON-serializable value294 Grafts that take no arguments: delayed-like objects with no dependencies on parameters,295 JSON-serializable values, or grafts without parameters.296 The value _returned_ by each graft will be available as the name given297 by its keyword argument.298 Except for JSON-serializable values, each graft will be kept as a sub-graft within its own scope,299 so overlapping keys between the grafts will not collide.300 Caution: this function accepts both grafts and JSON values, so be careful301 that you do not pass in a JSON value that looks like a graft, since it will not get quoted.302 """303 merged = {}304 for name, value in grafts.items():305 if name in syntax.RESERVED_WORDS:306 raise ValueError(307 "Cannot use reserved name {!r} as a key in a graft".format(name)308 )309 if isinstance(value, syntax.PRIMITIVE_TYPES):310 # fastpath for simple case311 merged[name] = value312 else:313 subgraft = value if syntax.is_graft(value) else value_graft(value)314 parameters = subgraft.get("parameters", ())315 if len(parameters) > 0:316 raise ValueError(317 "Value graft for {}: expected a graft that takes no parameters, "318 "but this one takes {}".format(name, parameters)319 )320 try:321 returned = subgraft[subgraft["returns"]]322 except KeyError as e:323 raise KeyError(324 "In subgraft {!r}: returned key {} is undefined".format(name, e)325 )326 if syntax.is_literal(returned) or syntax.is_quoted_json(returned):327 merged[name] = returned328 else:329 # insert actual subgraft under a different name330 subkey = "_{}".format(name)331 merged[subkey] = subgraft332 # actual name is the invocation of that subgraft, with no arguments333 merged[name] = [subkey, {}]334 return merged335def isolate_keys(graft, wrap_function=False):336 """337 Isolate a value graft to its own subscope, to prevent key collisions.338 If ``graft`` already uses valid GUID keys, this ensures that subsequent `apply_graft`339 operations on ``graft`` won't collide with its existing keys.340 Essentially, "key-namespace isolation".341 Usually a value graft, i.e. a graft with no ``"parameters"`` key342 that refers to the original value of ``graft``. See the ``wrap_function``343 argument for details.344 Parameters345 ----------346 graft: graft-like mapping or delayed-like object347 The graft or delayed object to scope-isolate.348 wrap_function: bool, optional, default False349 If a function graft is given (contains a ``"parameters"`` key),350 whether to wrap it in an outer graft.351 Usually, this is not necessary, since `apply_graft` would never352 add additional keys to a function graft, making collisions with new353 keys impossible. In some cases though, it may be preferable to always354 get a value graft back, regardless of whether ``graft`` was a function355 graft or a value graft.356 If False (default), function grafts are returned unmodified.357 If True and ``graft`` is a function graft, a value graft is returned358 that refers to that function.359 Returns360 -------361 isolated_graft: dict362 Value graft representing the same value as ``graft``,363 but isolated to a subscope. Or, if ``graft`` was a function graft,364 and ``wrap_function`` is False, it's returned unmodified.365 """366 graft = graft if syntax.is_graft(graft) else value_graft(graft)367 if graft_is_function_graft(graft):368 if not wrap_function:369 return graft370 else:371 subgraft_key = guid()372 return {subgraft_key: graft, "returns": subgraft_key}373 else:374 subgraft_key = guid()375 result_key = guid()376 return {subgraft_key: graft, result_key: [subgraft_key], "returns": result_key}377def parametrize(graft, **params):378 """379 Isolate ``graft`` to its own subscope, in which ``params`` are defined.380 Parameters381 ----------...

Full Screen

Full Screen

test_interpreter.py

Source:test_interpreter.py Github

copy

Full Screen

1import pytest2from unittest import mock3import operator4from .. import interpreter5class TestInterpreter(object):6 def test_literal(self):7 graft = {"x": 1, "returns": "x"}8 func = interpreter.interpret(graft)9 assert func() == 110 def test_literal_str(self):11 graft = {"x": "foo", "returns": "x"}12 func = interpreter.interpret(graft)13 assert func() == "foo"14 @pytest.mark.parametrize(15 "json",16 [17 [1, 2, 3],18 [1, 2, "foo", 3, {"four": 5, "six": [7, 8]}],19 [1],20 [[1]],21 [{"y": 2}],22 [{"a": 1, "returns": "a"}],23 [{"parameters": ["x"], "a": 1, "returns": "a"}],24 ["not_function_application"],25 ],26 )27 def test_quoted_json(self, json):28 graft = {"x": [json], "returns": "x"}29 func = interpreter.interpret(graft)30 assert func() == json31 @pytest.mark.parametrize(32 "graft",33 [34 # positional only35 {"x": 1, "y": 2, "z": ["add", "x", "y"], "returns": "z"},36 # positional and named37 {"x": 1, "y": 2, "z": ["add", "x", {"b": "y"}], "returns": "z"},38 # named only39 {"x": 1, "y": 2, "z": ["add", {"a": "x", "b": "y"}], "returns": "z"},40 # positional only, with empty parameters tossed in41 {"parameters": [], "x": 1, "y": 2, "z": ["add", "x", "y"], "returns": "z"},42 ],43 )44 def test_apply(self, graft):45 func = interpreter.interpret(graft, builtins={"add": lambda a, b: a + b})46 assert func() == 347 def test_apply_to_param(self):48 graft = {"parameters": ["x"], "y": 2, "z": ["add", "x", "y"], "returns": "z"}49 func = interpreter.interpret(graft, builtins={"add": operator.add})50 assert func(5) == func(x=5) == 751 @pytest.mark.parametrize(52 "graft",53 [54 {"x": ["do_foo"], "returns": "x"}, # no named args55 {"x": ["do_foo", {}], "returns": "x"}, # empty named args56 ],57 )58 def test_apply_noargs(self, graft):59 func = interpreter.interpret(graft, builtins={"do_foo": lambda: "foo"})60 assert func() == "foo"61 @pytest.mark.parametrize(62 "apply_expr",63 [64 ["adder", "x"], # apply arguments positionally65 ["adder", {"p": "x"}], # apply arguments by name66 ],67 )68 def test_funcdef(self, apply_expr):69 graft = {70 "x": 1,71 "adder": {72 "parameters": ["p"],73 "one": 1,74 "res": ["add", "p", "one"],75 "returns": "res",76 },77 "z": apply_expr,78 "returns": "z",79 }80 func = interpreter.interpret(graft, builtins={"add": operator.add})81 assert func() == 282 def test_funcdef_closure(self):83 graft = {84 "one": 1,85 "adder": {86 "parameters": ["p"],87 "res": ["add", "p", "one"],88 "returns": "res",89 },90 "y": 5.5,91 "z": ["adder", "y"],92 "returns": "z",93 }94 func = interpreter.interpret(graft, builtins={"add": operator.add})95 assert func() == 6.596 def test_closure_shadows_parent(self):97 graft = {98 "shadowme": 1,99 "foo": {100 "parameters": ["x"],101 "shadowme": 2,102 "y": ["add", "x", "shadowme"],103 "returns": "y",104 },105 "two": 2,106 "three": ["add", "two", "shadowme"],107 "res": ["foo", "three"],108 "returns": "res",109 }110 func = interpreter.interpret(111 graft, builtins={"add": operator.add, "foo": lambda x: -1, "shadowme": -100}112 )113 assert func() == 5114 def test_higher_order_function(self):115 graft = {116 "two": 2,117 "factory": {118 "parameters": ["p"],119 "half_p": ["div", "p", "two"],120 "func": {121 "parameters": ["x"],122 "one": 1,123 "half_p_plus_one": ["add", "one", "half_p"],124 "x_plus_half_p_plus_one": ["add", "x", "half_p_plus_one"],125 "returns": "x_plus_half_p_plus_one",126 },127 "returns": "func",128 },129 "ten": 10,130 "half_ten_plus_one_adder": ["factory", "ten"],131 "res1": ["half_ten_plus_one_adder", "two"], # (10 / 2) + 1 + 2 == 8132 "half_eight_plus_one_adder": ["factory", "res1"],133 "five": 5,134 "res2": ["half_eight_plus_one_adder", "five"], # (8 / 2) + 1 + 5 == 10135 "returns": "res2",136 }137 func = interpreter.interpret(138 graft, builtins={"add": operator.add, "div": operator.truediv}139 )140 assert func() == 10141 def test_reuse_shared_dependency(self):142 getBaseVal = mock.Mock()143 getBaseVal.return_value = 10144 graft = {145 "base_val": ["getBaseVal"],146 "five": 5,147 "low": ["sub", "base_val", "five"],148 "high": ["add", "base_val", "five"],149 "res": ["sub", "high", "low"],150 "returns": "res",151 }152 func = interpreter.interpret(153 graft,154 builtins={155 "add": operator.add,156 "sub": operator.sub,157 "getBaseVal": getBaseVal,158 },159 )160 assert func() == 10161 getBaseVal.assert_called_once()162 def test_reuse_shared_dependency_in_closure(self):163 getBaseVal = mock.Mock()164 getBaseVal.return_value = 10165 graft = {166 "base_val": ["getBaseVal"],167 "get_low": {168 "parameters": ["x"],169 "res": ["sub", "base_val", "x"],170 "returns": "res",171 },172 "get_high": {173 "parameters": ["x"],174 "res": ["add", "base_val", "x"],175 "returns": "res",176 },177 "five": 5,178 "low": ["get_low", "five"],179 "high": ["get_high", "five"],180 "res": ["sub", "high", "low"],181 "returns": "res",182 }183 func = interpreter.interpret(184 graft,185 builtins={186 "add": operator.add,187 "sub": operator.sub,188 "getBaseVal": getBaseVal,189 },190 )191 assert func() == 10192 getBaseVal.assert_called_once()193class TestErrors(object):194 def test_syntax_error_no_return(self):195 graft = {"x": 1}196 with pytest.raises(197 interpreter.exceptions.GraftSyntaxError, match="missing a 'returns' key"198 ):199 interpreter.interpret(graft)200 # def test_syntax_error_no_return_nested(self):201 # graft = {"x": {"y": 0}, "z": ["x"], "returns": "z"}202 # with pytest.raises(203 # interpreter.exceptions.GraftSyntaxError, match="missing a 'returns' key"204 # ):205 # interpreter.interpret(graft)()206 def test_syntax_error_invalid_return(self):207 graft = {"returns": 99}208 with pytest.raises(209 interpreter.exceptions.GraftSyntaxError,210 match="Invalid value for a 'returns' key",211 ):212 interpreter.interpret(graft)213 @pytest.mark.parametrize("name", ["returns", "parameters"])214 def test_syntax_error_reserved_name(self, name):215 graft = {"x": [name], "returns": "x"}216 with pytest.raises(217 interpreter.exceptions.GraftSyntaxError,218 match=r"Not a valid expression: \[{!r}\]".format(name),219 ):220 interpreter.interpret(graft)()221 @pytest.mark.parametrize(222 "invalid_expr",223 [224 [1, 2, 3],225 {},226 {"parameters": ["y"]},227 {"y": 1},228 ["function", "a", {"param": "foo"}, "b"],229 ["function", {"param": "foo"}, "b"],230 ["function", {"param": True}],231 ["function", True],232 [0, "y"],233 [1],234 [True],235 [None],236 ],237 )238 def test_syntax_error_invalid_expr(self, invalid_expr):239 graft = {"x": invalid_expr, "returns": "x"}240 with pytest.raises(241 interpreter.exceptions.GraftSyntaxError, match="Not a valid expression"242 ):243 interpreter.interpret(graft)()244 @pytest.mark.parametrize(245 "expr",246 [247 ["foo", "doesnt_exist"],248 ["foo", {"x": "doesnt_exist"}],249 ["doesnt_exist", "one"],250 ["doesnt_exist", {"x": "one"}],251 ["doesnt_exist", "doesnt_exist"],252 ],253 )254 def test_name_error(self, expr):255 graft = {"one": 1, "y": expr, "returns": "y"}256 with pytest.raises(interpreter.exceptions.GraftNameError, match="doesnt_exist"):257 interpreter.interpret(graft, builtins={"foo": lambda x: x})()258 @pytest.mark.parametrize("apply_expr", [["func"], ["func", {}]])259 def test_missing_argument(self, apply_expr):260 graft = {261 "func": {"parameters": ["param"], "returns": "param"},262 "x": apply_expr,263 "returns": "x",264 }265 with pytest.raises(266 interpreter.exceptions.GraftTypeError,267 match="Missing required argument 'param'",268 ):269 interpreter.interpret(graft)()270 @pytest.mark.parametrize(271 ["apply_expr", "missing", "plural"],272 [273 (["func", "one"], "'param2'", False),274 (["func", {"param": "one"}], "'param2'", False),275 (["func", {"param2": "one"}], "'param'", False),276 (["func"], "'param', 'param2'", True),277 ],278 )279 def test_missing_argument_multi(self, apply_expr, missing, plural):280 graft = {281 "func": {"parameters": ["param", "param2"], "returns": "param"},282 "one": 1,283 "x": apply_expr,284 "returns": "x",285 }286 with pytest.raises(287 interpreter.exceptions.GraftTypeError,288 match="Missing required argument{} {}".format(289 "s" if plural else "", missing290 ),291 ):292 interpreter.interpret(graft)()293 @pytest.mark.parametrize(294 ["apply_expr", "msg"],295 [296 (["func", {"bad_arg": "one"}], "Unexpected named argument 'bad_arg'"),297 (298 ["func", {"bad_arg": "one", "terrible_arg": "one"}],299 "Unexpected named arguments 'bad_arg', 'terrible_arg'",300 ),301 (302 ["func", "one", "one"],303 "Too many positional arguments: expected 1, got 2",304 ),305 ],306 )307 def test_unexpected_argument(self, apply_expr, msg):308 graft = {309 "func": {"parameters": ["param"], "returns": "param"},310 "one": 1,311 "x": apply_expr,312 "returns": "x",313 }314 with pytest.raises(interpreter.exceptions.GraftTypeError, match=msg):...

Full Screen

Full Screen

Ui_HgGraftDialog.py

Source:Ui_HgGraftDialog.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Form implementation generated from reading ui file 'eric\eric6\Plugins\VcsPlugins\vcsMercurial\HgGraftDialog.ui'3#4# Created by: PyQt5 UI code generator 5.15.45#6# WARNING: Any manual changes made to this file will be lost when pyuic5 is7# run again. Do not edit this file unless you know what you are doing.8from PyQt5 import QtCore, QtGui, QtWidgets9class Ui_HgGraftDialog(object):10 def setupUi(self, HgGraftDialog):11 HgGraftDialog.setObjectName("HgGraftDialog")12 HgGraftDialog.resize(450, 500)13 HgGraftDialog.setSizeGripEnabled(True)14 self.verticalLayout_2 = QtWidgets.QVBoxLayout(HgGraftDialog)15 self.verticalLayout_2.setObjectName("verticalLayout_2")16 self.groupBox = QtWidgets.QGroupBox(HgGraftDialog)17 self.groupBox.setObjectName("groupBox")18 self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox)19 self.verticalLayout.setObjectName("verticalLayout")20 self.revisionsEdit = QtWidgets.QPlainTextEdit(self.groupBox)21 self.revisionsEdit.setTabChangesFocus(True)22 self.revisionsEdit.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)23 self.revisionsEdit.setObjectName("revisionsEdit")24 self.verticalLayout.addWidget(self.revisionsEdit)25 self.verticalLayout_2.addWidget(self.groupBox)26 self.userGroup = QtWidgets.QGroupBox(HgGraftDialog)27 self.userGroup.setCheckable(True)28 self.userGroup.setChecked(False)29 self.userGroup.setObjectName("userGroup")30 self.gridLayout = QtWidgets.QGridLayout(self.userGroup)31 self.gridLayout.setObjectName("gridLayout")32 self.currentUserCheckBox = QtWidgets.QCheckBox(self.userGroup)33 self.currentUserCheckBox.setObjectName("currentUserCheckBox")34 self.gridLayout.addWidget(self.currentUserCheckBox, 0, 0, 1, 2)35 self.label_3 = QtWidgets.QLabel(self.userGroup)36 self.label_3.setObjectName("label_3")37 self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1)38 self.userEdit = QtWidgets.QLineEdit(self.userGroup)39 self.userEdit.setObjectName("userEdit")40 self.gridLayout.addWidget(self.userEdit, 1, 1, 1, 1)41 self.verticalLayout_2.addWidget(self.userGroup)42 self.dateGroup = QtWidgets.QGroupBox(HgGraftDialog)43 self.dateGroup.setCheckable(True)44 self.dateGroup.setChecked(False)45 self.dateGroup.setObjectName("dateGroup")46 self.gridLayout_2 = QtWidgets.QGridLayout(self.dateGroup)47 self.gridLayout_2.setObjectName("gridLayout_2")48 self.currentDateCheckBox = QtWidgets.QCheckBox(self.dateGroup)49 self.currentDateCheckBox.setObjectName("currentDateCheckBox")50 self.gridLayout_2.addWidget(self.currentDateCheckBox, 0, 0, 1, 3)51 self.label_4 = QtWidgets.QLabel(self.dateGroup)52 self.label_4.setObjectName("label_4")53 self.gridLayout_2.addWidget(self.label_4, 1, 0, 1, 1)54 self.dateTimeEdit = QtWidgets.QDateTimeEdit(self.dateGroup)55 self.dateTimeEdit.setDisplayFormat("yyyy-MM-dd hh:mm")56 self.dateTimeEdit.setCalendarPopup(True)57 self.dateTimeEdit.setObjectName("dateTimeEdit")58 self.gridLayout_2.addWidget(self.dateTimeEdit, 1, 1, 1, 1)59 spacerItem = QtWidgets.QSpacerItem(241, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)60 self.gridLayout_2.addItem(spacerItem, 1, 2, 1, 1)61 self.verticalLayout_2.addWidget(self.dateGroup)62 self.logCheckBox = QtWidgets.QCheckBox(HgGraftDialog)63 self.logCheckBox.setChecked(True)64 self.logCheckBox.setObjectName("logCheckBox")65 self.verticalLayout_2.addWidget(self.logCheckBox)66 self.dryRunCheckBox = QtWidgets.QCheckBox(HgGraftDialog)67 self.dryRunCheckBox.setObjectName("dryRunCheckBox")68 self.verticalLayout_2.addWidget(self.dryRunCheckBox)69 self.noCommitCheckBox = QtWidgets.QCheckBox(HgGraftDialog)70 self.noCommitCheckBox.setObjectName("noCommitCheckBox")71 self.verticalLayout_2.addWidget(self.noCommitCheckBox)72 self.buttonBox = QtWidgets.QDialogButtonBox(HgGraftDialog)73 self.buttonBox.setOrientation(QtCore.Qt.Horizontal)74 self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)75 self.buttonBox.setObjectName("buttonBox")76 self.verticalLayout_2.addWidget(self.buttonBox)77 self.retranslateUi(HgGraftDialog)78 self.buttonBox.accepted.connect(HgGraftDialog.accept)79 self.buttonBox.rejected.connect(HgGraftDialog.reject)80 self.currentUserCheckBox.toggled['bool'].connect(self.label_3.setDisabled)81 self.currentUserCheckBox.toggled['bool'].connect(self.userEdit.setDisabled)82 self.currentDateCheckBox.toggled['bool'].connect(self.label_4.setDisabled)83 self.currentDateCheckBox.toggled['bool'].connect(self.dateTimeEdit.setDisabled)84 QtCore.QMetaObject.connectSlotsByName(HgGraftDialog)85 HgGraftDialog.setTabOrder(self.revisionsEdit, self.userGroup)86 HgGraftDialog.setTabOrder(self.userGroup, self.currentUserCheckBox)87 HgGraftDialog.setTabOrder(self.currentUserCheckBox, self.userEdit)88 HgGraftDialog.setTabOrder(self.userEdit, self.dateGroup)89 HgGraftDialog.setTabOrder(self.dateGroup, self.currentDateCheckBox)90 HgGraftDialog.setTabOrder(self.currentDateCheckBox, self.dateTimeEdit)91 HgGraftDialog.setTabOrder(self.dateTimeEdit, self.logCheckBox)92 HgGraftDialog.setTabOrder(self.logCheckBox, self.dryRunCheckBox)93 HgGraftDialog.setTabOrder(self.dryRunCheckBox, self.buttonBox)94 def retranslateUi(self, HgGraftDialog):95 _translate = QtCore.QCoreApplication.translate96 HgGraftDialog.setWindowTitle(_translate("HgGraftDialog", "Copy Changesets"))97 self.groupBox.setTitle(_translate("HgGraftDialog", "Revisions"))98 self.revisionsEdit.setToolTip(_translate("HgGraftDialog", "Enter changesets by number, id, range or revset expression one per line"))99 self.userGroup.setToolTip(_translate("HgGraftDialog", "Select to give user information"))100 self.userGroup.setTitle(_translate("HgGraftDialog", "User"))101 self.currentUserCheckBox.setToolTip(_translate("HgGraftDialog", "Select to use the name of the current user"))102 self.currentUserCheckBox.setText(_translate("HgGraftDialog", "Use current user"))103 self.label_3.setText(_translate("HgGraftDialog", "Username:"))104 self.userEdit.setToolTip(_translate("HgGraftDialog", "Enter the user name to be used"))105 self.dateGroup.setToolTip(_translate("HgGraftDialog", "Select to give date and time information"))106 self.dateGroup.setTitle(_translate("HgGraftDialog", "Date and Time"))107 self.currentDateCheckBox.setToolTip(_translate("HgGraftDialog", "Select to use the current date and time"))108 self.currentDateCheckBox.setText(_translate("HgGraftDialog", "Use current date and time"))109 self.label_4.setText(_translate("HgGraftDialog", "Date/Time:"))110 self.dateTimeEdit.setToolTip(_translate("HgGraftDialog", "Enter the date and time to be used"))111 self.logCheckBox.setToolTip(_translate("HgGraftDialog", "Select to append graft info to the log message"))112 self.logCheckBox.setText(_translate("HgGraftDialog", "Append Graft &Info"))113 self.dryRunCheckBox.setToolTip(_translate("HgGraftDialog", "Select to perform a dry-run of the graft operation"))114 self.dryRunCheckBox.setText(_translate("HgGraftDialog", "Perform Dry-Run"))115 self.noCommitCheckBox.setToolTip(_translate("HgGraftDialog", "Select to not commit the copied changesets"))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful