Make a usage, storing its definition id.
169541
def create_usage(self, def_id):
        """"""
        usage_id = self._next_id("u")
        self._usages[usage_id] = def_id
        return usage_id
369636
def use(self, func, when='whenever'):
        '''  '''
        #NOTE A middleware Object ?
        # self.use() is usually called from initialize(), so no logger yet
        print('registering middleware {}'.format(func.__name__))
        self.middlewares.append({
            'call': func,
            'name': func.__name__,
            'args': func.func_code.co_varnames,
            'when': when
        })
1192883
def build_defines(defines):
    

    return ['-D"%s=%s"' % (x, str(y)) for x, y in defines.items() if y is not None]
1077627
def make_id(self):
        """"""
        if self.url_id is None:  # Set id only if empty
            self.url_id = select([func.coalesce(func.max(self.__class__.url_id + 1), 1)],
                self.__class__.parent == self.parent)
1090213
def _storeLog(self, nick, time, uid):
        """"""
        query = dict(uid=uid)
        update = {'$set': dict(nick=nick, time=time)}
        self.db.pastes.update(query, update)
1094173
def set_definition_node(self, node, name):
        """"""
        definition = self.get_definition(name)
        if definition:
            definition.node = node
1072898
def t_ID(self, t):
        """

        # If the value is a reserved name, give it the appropriate type (not ID)
        if t.value in self.reserved:
            t.type = self.reserved[t.value]

        # If it's a function, give it the FUNC type
        elif t.value in self.functions:
            t.type = 'FUNC'

        return t
445892
def _make_definition(self, definition):
        
        if not definition:
            return EndpointDefinition()
        if isinstance(definition, EndpointDefinition):
            return definition
        elif len(definition) == 1:
            return EndpointDefinition(
                func=definition[0],
            )
        elif len(definition) == 2:
            return EndpointDefinition(
                func=definition[0],
                response_schema=definition[1],
            )
        elif len(definition) == 3:
            return EndpointDefinition(
                func=definition[0],
                request_schema=definition[1],
                response_schema=definition[2],
            )
        elif len(definition) == 4:
            return EndpointDefinition(
                func=definition[0],
                request_schema=definition[1],
                response_schema=definition[2],
                header_func=definition[3],
            )
389958
def write_usage(self, prog, args='', prefix='Usage: '):
        
        prefix = '%*s%s' % (self.current_indent, prefix, prog)
        self.write(prefix)

        text_width = max(self.width - self.current_indent - term_len(prefix), 10)
        indent = ' ' * (term_len(prefix) + 1)
        self.write(wrap_text(args, text_width,
                             initial_indent=' ',
                             subsequent_indent=indent))

        self.write('\n')
171162
def _define(self, key, default=_UNSET, help=_UNSET, validate=_UNSET):
        
        if default is not _UNSET:
            self.setdefault(key, default)
        if help is not _UNSET:
            self.meta_set(key, 'help', help)
        if validate is not _UNSET:
            self.meta_set(key, 'validate', validate)
780576
def copy_id(self):
        '''
        
        '''
        stdout, stderr, retcode = self._run_cmd(self._copy_id_str_old())
        if salt.defaults.exitcodes.EX_OK != retcode and 'Usage' in stderr:
            stdout, stderr, retcode = self._run_cmd(self._copy_id_str_new())
        return stdout, stderr, retcode
880164
def store(self, record, value):
        """"""
        record._values[self.name][record.id] = value
627033
private void rewriteDefinition(Node definitionSite, String newMethodName) {
    final Node function;
    final Node subtreeToRemove;
    final Node nameSource;

    switch (definitionSite.getToken()) {
      case GETPROP:
        function = definitionSite.getParent().getLastChild();
        nameSource = definitionSite.getLastChild();
        subtreeToRemove = NodeUtil.getEnclosingStatement(definitionSite);
        break;

      case STRING_KEY:
      case MEMBER_FUNCTION_DEF:
        function = definitionSite.getLastChild();
        nameSource = definitionSite;
        subtreeToRemove = definitionSite;
        break;

      default:
        throw new IllegalArgumentException(definitionSite.toString());
    }

    // Define a new variable after the original declaration.
    Node statement = NodeUtil.getEnclosingStatement(definitionSite);
    Node newNameNode = IR.name(newMethodName).useSourceInfoIfMissingFrom(nameSource);
    Node newVarNode = IR.var(newNameNode).useSourceInfoIfMissingFrom(nameSource);
    statement.getParent().addChildBefore(newVarNode, statement);

    // Attatch the function to the new variable.
    function.detach();
    newNameNode.addChildToFront(function);

    // Create the `this` param.
    String selfName = newMethodName + "$self";
    Node paramList = function.getSecondChild();
    paramList.addChildToFront(IR.name(selfName).useSourceInfoIfMissingFrom(function));
    compiler.reportChangeToEnclosingScope(paramList);

    // Eliminate `this`.
    replaceReferencesToThis(function.getSecondChild(), selfName); // In default param values.
    replaceReferencesToThis(function.getLastChild(), selfName); // In function body.

    fixFunctionType(function);

    // Clean up dangling AST.
    NodeUtil.deleteNode(subtreeToRemove, compiler);
    compiler.reportChangeToEnclosingScope(newVarNode);
  }
399418
function makeRequire(id, path) {
  var expr = callExpression(identifier('require'), [literal(path)]);
  return makeDeclaration(id, expr);
}
169707
def usable_id(cls, id):
        
        try:
            # id is maybe a sshkey name
            qry_id = cls.from_name(id)
            if not qry_id:
                qry_id = int(id)
        except DuplicateResults as exc:
            cls.error(exc.errors)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
370614
def _hook_id(self, info):
        
        if isinstance(info, dict) and 'id' in info.keys():
            self.id = info['id']
885148
def copy(self):
        """"""
        new_dict = IDict(std=self._std)
        new_dict.update(self.store)
        return new_dict