def _add(self, arg): if not arg: raise ValueError('add: Need reference to work with.') ref, snip = qmk.left_word_and_rest(arg) if not snip: snip = qmk.Clipboard.text() if not snip: raise ValueError('add: Need explicit snippet or clipboard.') nodes, leaf = self.__nodes_and_leaf(ref) d = self._stash sn = [] for n in nodes: sn.append(n) if n not in d: d[n] = {} elif not isinstance(d[n], dict): raise ValueError( 'add: %s is invalid. There is a snippet @ %s' % (ref, '.'.join(sn))) d = d[n] if self._valid_subnode(d, leaf): # XXX: Ask if this is what's wanted. raise ValueError('add: trying to blow away extant sub-list @ %s' % ref) d[leaf] = snip self._stash_stash()
def _add(self, arg): if not arg: raise ValueError('add: Need reference to work with.') ref, snip = qmk.left_word_and_rest(arg) if not snip: snip = qmk.Clipboard.text() if not snip: raise ValueError('add: Need explicit snippet or clipboard.') nodes, leaf = self.__nodes_and_leaf(ref) d = self._stash sn = [] for n in nodes: sn.append(n) if n not in d: d[n] = {} elif not isinstance(d[n], dict): raise ValueError( 'add: %s is invalid. There is a snippet @ %s' % ( ref, '.'.join(sn))) d = d[n] if self._valid_subnode(d, leaf): # XXX: Ask if this is what's wanted. raise ValueError( 'add: trying to blow away extant sub-list @ %s' % ref) d[leaf] = snip self._stash_stash()
def __ref_only(self, arg, pre=''): ref, _x = qmk.left_word_and_rest(arg) if _x: raise ValueError('%sJust need reference.' % pre) if not ref: ref = qmk.Clipboard.text() if not ref: raise ValueError('%sNeed reference to work with.' % pre) return ref
def action(self, arg): if arg is None: return act, subarg = qmk.left_word_and_rest(arg) if act in MFTSCommand.sub_cmds: getattr(self, '_%s' % act)(subarg) return self._get(arg)
def __ref_only(self, arg, pre = ''): ref, _x = qmk.left_word_and_rest(arg) if _x: raise ValueError('%sJust need reference.' % pre) if not ref: ref = qmk.Clipboard.text() if not ref: raise ValueError('%sNeed reference to work with.' % pre) return ref