Get Callable for specified string (for GUI-based editing)
511704
def eval_in_system_namespace(self, exec_str):
        
        ns = self.cmd_namespace
        try:
            return eval(exec_str, ns)
        except Exception as e:
            self.logger.warning('Could not execute %s, gave error %s', exec_str, e)
            return None
25109
function getInlineEditors(hostEditor) {
        var inlineEditors = [];

        if (hostEditor) {
            hostEditor.getInlineWidgets().forEach(function (widget) {
                if (widget instanceof InlineTextEditor && widget.editor) {
                    inlineEditors.push(widget.editor);
                }
            });
        }

        return inlineEditors;
    }
1353231
def createEditor(self, delegate, parent, option):
        
        return UntypedCtiEditor(self, delegate, parent=parent)
517187
def _fromGUI(self, value):
        

        # One or more of the underlying text control implementations
        # issue an intermediate EVT_TEXT when replacing the control's
        # value, where the intermediate value is an empty string.
        # So, to ensure consistency and to prevent spurious ValueErrors,
        # we make the following test, and react accordingly:
        #
        if value == '':
            if not self.IsNoneAllowed():
                return 0
            else:
                return
        else:
            try:
                return int(value)
            except ValueError:
                if self.IsLongAllowed():
                    try:
                        return long(value)
                    except ValueError:
                        wx.TextCtrl.SetValue(self, "0")
                        return 0
                else:
                    raise
518476
def _get_shortcut_string(shortcut):
    """"""
    if shortcut is None:
        return ''
    if isinstance(shortcut, (tuple, list)):
        return ', '.join([_get_shortcut_string(s) for s in shortcut])
    if isinstance(shortcut, string_types):
        if hasattr(QKeySequence, shortcut):
            shortcut = QKeySequence(getattr(QKeySequence, shortcut))
        else:
            return shortcut.lower()
    assert isinstance(shortcut, QKeySequence)
    s = shortcut.toString() or ''
    return str(s).lower()
652854
def createEditor(self, delegate, parent, option):
        
        return IntCtiEditor(self, delegate, parent=parent)
1024690
def _tool_from_string(name):
    
    known_tools = sorted(_known_tools.keys())

    if name in known_tools:
        tool_fn = _known_tools[name]

        if isinstance(tool_fn, string_types):
            tool_fn = _known_tools[tool_fn]

        return tool_fn()
    else:
        matches, text = difflib.get_close_matches(name.lower(), known_tools), "similar"

        if not matches:
            matches, text = known_tools, "possible"

        raise ValueError("unexpected tool name '%s', %s tools are %s" % (name, text, nice_join(matches)))
551827
function getNestedEditableIn( editablesContainer, remainingEditables ) {
		if ( remainingEditables == null )
			remainingEditables = findNestedEditables( editablesContainer );

		var editable;

		while ( ( editable = remainingEditables.shift() ) ) {
			if ( isIterableEditable( editable ) )
				return { element: editable, remaining: remainingEditables };
		}

		return null;
	}
1045954
def editorValue(self, editor):
        
        value, success = projexui.widgetValue(editor)
        if not success:
            return None
        return value
423044
def str_repl(self, inputstring, **kwargs):
        """"""
        out = []
        comment = None
        string = None

        for i, c in enumerate(append_it(inputstring, None)):
            try:

                if comment is not None:
                    if c is not None and c in nums:
                        comment += c
                    elif c == unwrapper and comment:
                        ref = self.get_ref("comment", comment)
                        if out and not out[-1].endswith("\n"):
                            out[-1] = out[-1].rstrip(" ")
                            if not self.minify:
                                out[-1] += "  "  # put two spaces before comment
                        out.append("#" + ref)
                        comment = None
                    else:
                        raise CoconutInternalException("invalid comment marker in", getline(i, inputstring))
                elif string is not None:
                    if c is not None and c in nums:
                        string += c
                    elif c == unwrapper and string:
                        text, strchar = self.get_ref("str", string)
                        out.append(strchar + text + strchar)
                        string = None
                    else:
                        raise CoconutInternalException("invalid string marker in", getline(i, inputstring))
                elif c is not None:
                    if c == "#":
                        comment = ""
                    elif c == strwrapper:
                        string = ""
                    else:
                        out.append(c)

            except CoconutInternalException as err:
                complain(err)
                if comment is not None:
                    out.append(comment)
                    comment = None
                if string is not None:
                    out.append(string)
                    string = None
                out.append(c)

        return "".join(out)
970645
def _callable_contents(obj):
    
    try:
        # Test if obj is a method.
        return _function_contents(obj.__func__)

    except AttributeError:
        try:
            # Test if obj is a callable object.
            return _function_contents(obj.__call__.__func__)

        except AttributeError:
            try:
                # Test if obj is a code object.
                return _code_contents(obj)

            except AttributeError:
                # Test if obj is a function object.
                return _function_contents(obj)
472259
def _selection_by_callable(self, view, num_slices, non_empty_slices):
        """"""

        selected = [sl for sl in non_empty_slices
                    if self._sampler(self._get_axis(self._image, view, sl))]

        return selected[:num_slices]
451251
public EditText getEditText(String text)
	{
		if(config.commandLogging){
		Log.d(config.commandLoggingTag, "getEditText(\""+text+"\")");
	}
	
		return getter.getView(EditText.class, text, false);
	}
188622
function captureEditorCommand(ed, captureCommandFunc, captureCallFunc) {
  var origCallKeyboardHandlers = ed.keyBinding.$callKeyboardHandlers,
      commandExecHandler = ed.commands.addEventListener('exec', function(e) {
        uninstall();
        e.stopPropagation(); e.preventDefault();
        captureCommandFunc && captureCommandFunc(e.command, e);
        return true;
      });

  var orig = ed.keyBinding.$callKeyboardHandlers;
  ed.keyBinding.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
    captureCallFunc && captureCallFunc(hashId, keyString, keyCode, e);
    return orig.call(this, hashId, keyString, keyCode, e);
  };

  return uninstall;

  // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  function uninstall() {
    commandExecHandler && ed.commands.removeEventListener('exec', commandExecHandler);
    ed.keyBinding.$callKeyboardHandlers = orig;
  }

}
1288161
def require_editable(f):
    

    def wrapper(self, *args, **kwargs):
        if not self._edit:
            raise RegistryKeyNotEditable("The key is not set as editable.")
        return f(self, *args, **kwargs)

    return wrapper
720027
def _close_callable(self, node, force=False):
        """"""
        # Only nodes that have a line number can be considered for closing
        # callables. Similarly, only nodes with lines greater than the one
        # already processed can be considered for closing callables
        try:
            lineno = node.lineno
        except AttributeError:
            return
        if lineno <= self._processed_line:
            return
        # [[[cog
        # code = """
        # print(pcolor('Close callable @ line = {0}'.format(lineno), 'green'))
        # """
        # cog.out(code)
        # ]]]
        # [[[end]]]
        # Extract node name for property closing. Once a property is found,
        # it can only be closed out by a node type that has a name
        name = ""
        try:
            name = (
                node.name
                if hasattr(node, "name")
                else (
                    node.targets[0].id
                    if hasattr(node.targets[0], "id")
                    else node.targets[0].value.id
                )
            )
        except AttributeError:
            pass
        # Traverse backwards through call stack and close callables as needed
        indent = self._get_indent(node)
        count = -1
        # [[[cog
        # code = """
        # print(
        #     pcolor(
        #         '    Name {0} @ {1}, indent = {2}'.format(
        #             name if name else 'None', lineno, indent
        #         ),
        #         'yellow'
        #     )
        # )
        # """
        # cog.out(code)
        # ]]]
        # [[[end]]]
        dlist = []
        while count >= -len(self._indent_stack):
            element_full_name = self._indent_stack[count]["full_name"]
            edict = self._callables_db.get(element_full_name, None)
            stack_indent = self._indent_stack[count]["level"]
            open_callable = element_full_name and (not edict["last_lineno"])
            # [[[cog
            # code = """
            # print(
            #     pcolor(
            #         '    Name {0}, indent, {1}, stack_indent {2}'.format(
            #             element_full_name, indent, stack_indent
            #         ),
            #         'yellow'
            #     )
            # )
            # """
            # cog.out(code)
            # ]]]
            # [[[end]]]
            if open_callable and (
                force
                or (indent < stack_indent)
                or (
                    (indent == stack_indent)
                    and (
                        (edict["type"] != "prop")
                        or (
                            (edict["type"] == "prop")
                            and (name and (name != element_full_name))
                        )
                    )
                )
            ):
                # [[[cog
                # code = """
                # print(
                #     pcolor(
                #         '    Closing {0} @ {1}'.format(
                #             element_full_name, lineno-1
                #         ),
                #         'yellow'
                #     )
                # )
                # """
                # cog.out(code)
                # ]]]
                # [[[end]]]
                edict["last_lineno"] = lineno - 1
                dlist.append(count)
            if indent > stack_indent:
                break
            count -= 1
        # Callables have to be removed from stack when they are closed,
        # otherwise if a callable is subsequently followed after a few
        # lines by another callable at a further indentation level (like a for
        # loop) the second callable would incorrectly appear within the scope
        # of the first callable
        stack = self._indent_stack
        stack_length = len(self._indent_stack)
        dlist = [item for item in dlist if stack[item]["type"] != "module"]
        for item in dlist:
            del self._indent_stack[stack_length + item]
1080948
def apply_if_callable(maybe_callable, obj, **kwargs):
    

    if callable(maybe_callable):
        return maybe_callable(obj, **kwargs)

    return maybe_callable