Undo affect of __str__
432121
def from_str(self, instr):
        ''''''
        if not instr:
            return FlexiDate()

        out = self.our_re.match(instr)
        if out is None:  # no match TODO: raise Exception?
            return None
        else:
            return FlexiDate(
                out.group('year'),
                out.group('month'),
                out.group('day'),
                out.group('hour'),
                out.group('minute'),
                out.group('second'),
                out.group('microsecond'),
                qualifier=out.group('qualifier')
            )
772601
def _usage_unallocated(raw):
    '''
    
    '''
    ret = {}
    for line in raw.split("\n")[1:]:
        keyset = re.sub(r"\s+", " ", line.strip()).split(" ")
        if len(keyset) == 2:
            ret[keyset[0]] = keyset[1]

    return ret
124073
def undo(self, key_value, modifier_mask):
        
        # TODO re-organize as request to controller which holds source-editor-view or any parent to it
        for key, tab in gui_singletons.main_window_controller.get_controller('states_editor_ctrl').tabs.items():
            if tab['controller'].get_controller('source_ctrl') is not None and \
                    react_to_event(self.view, tab['controller'].get_controller('source_ctrl').view.textview,
                                   (key_value, modifier_mask)) or \
                tab['controller'].get_controller('description_ctrl') is not None and \
                    react_to_event(self.view, tab['controller'].get_controller('description_ctrl').view.textview,
                                   (key_value, modifier_mask)):
                return False
        if self._selected_sm_model is not None:
            self._selected_sm_model.history.undo()
            return True
        else:
            logger.debug("Undo is not possible now as long as no state_machine is selected.")
839544
def undo where
      raise "not yet used"
      return unless @delete_buffer
      case @delete_buffer[0]
      when Array
        @delete_buffer.each do |r| 
          insert where, r 
        end
      else
        insert where, @delete_buffer
      end
    end
615566
def undo_filter_sub(filter_unit, scanline, previous, result):
    """"""

    ai = 0
    # Loops starts at index fu.  Observe that the initial part
    # of the result is already filled in correctly with
    # scanline.
    for i in range(filter_unit, len(result)):
        x = scanline[i]
        a = result[ai]
        result[i] = (x + a) & 0xff
        ai += 1
1247764
def _revert_tag_in_init(self):
        
        for line in fileinput.input(self.init_file, inplace=1):
            if line.strip().startswith("__version__"):
                line = "__version__ = \"" + self.init_version + "\""
            print(line.strip("\n"))
        
        print("reverted __init__.__version__ back to {}"
              .format(self.init_version))
979612
def reset(self):
        
        old_value = self._value
        old_raw_str_value = self.raw_str_value

        self._value = not_set
        self.raw_str_value = not_set

        new_value = self._value

        if old_value is not_set:
            # Nothing to report
            return

        if self.section:
            self.section.dispatch_event(
                self.section.hooks.item_value_changed,
                item=self,
                old_value=old_value,
                new_value=new_value,
                old_raw_str_value=old_raw_str_value,
                new_raw_str_value=self.raw_str_value,
            )
465637
def restore(s, t):
    
    t = (c for c in t)
    return ''.join(next(t) if not is_blacksquare(c) else c for c in s)
233305
def do_rmpostfix(self, arg):
        """"""
        altered = False
        if arg in self.curargs["functions"]:
            del self.curargs["functions"][arg]
            altered = True
        elif arg == "*":
            for varname in list(self.curargs["functions"].keys()):
                del self.curargs["functions"][varname]
            altered = True
        if altered:
            self.do_postfix("list")
1341225
def removeBitPadding(str, blocksize=AES_blocksize):
    ''
    pad_len = 0    
    for char in str[::-1]: # str[::-1] reverses string
        if char == '\0':
            pad_len += 1
        else:
            break
    pad_len += 1
    str = str[:-pad_len]
   
    return str
183536
def trunc_str(s: str) -> str:
    """"""
    if len(s) > max_str_size:
        i = max(0, (max_str_size - 3) // 2)
        j = max(0, max_str_size - 3 - i)
        s = s[:i] + "..." + s[-j:]
    return s
107043
def ensure_str(s):
    
    """
    try:
        return s.decode()
    except AttributeError:
        if isinstance(s, str):
            return s
    return repr(s)
873837
def _remove_exact(self, needle, keep_field):
        """"""
        for i, param in enumerate(self.params):
            if param is needle:
                if keep_field:
                    self._blank_param_value(param.value)
                else:
                    self._fix_dependendent_params(i)
                    self.params.pop(i)
                return
        raise ValueError(needle)
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)
925450
function strEndWith(str,substr){
    return str.lastIndexOf(substr) + substr.length === str.length;
}
1324646
function unstashString(param, stash) {
  if (!/^:[a-zA-Z][\w.]+$/.test(param)) {
    return param.replace(/([^\\])(:[a-zA-Z][\w.]+)/g, function (param, prefix, prop) {
      return prefix + prop.replace(/:[a-zA-Z][\w.]+/g, function (match) {
        return unstashString(match, stash)
      })
    }).replace(/\\(:[a-zA-Z][\w.]+)/g, '$1')
  }

  var name = param.slice(param.indexOf(':') + 1).split('.')[0]
  var pointer = stash[name]
  var params = param.match(/\.\w+/g)

  if (params === null) {
    return pointer
  }

  for (var j = 0; j < params.length; j++) {
    pointer = pointer[params[j].slice(1)]
  }

  return pointer
}
615384
def _can_undo(comps, trans_list):
    
    comps = list(comps)
    accent_list = list(map(accent.get_accent_char, comps[1]))
    mark_list = list(map(mark.get_mark_char, utils.join(comps)))
    action_list = list(map(lambda x: _get_action(x), trans_list))

    def atomic_check(action):
        """
        Check if the `action` created one of the marks, accents, or characters
        in `comps`.
        """
        return (action[0] == _Action.ADD_ACCENT and action[1] in accent_list) \
                or (action[0] == _Action.ADD_MARK and action[1] in mark_list) \
                or (action[0] == _Action.ADD_CHAR and action[1] == \
                    accent.remove_accent_char(comps[1][-1]))  # ơ, ư

    return any(map(atomic_check, action_list))