Internal cassandra nodetool wrapper. Some functions are not
    available via pycassa so we must rely on nodetool.
4157
def _nodetool(cmd):
    '''
    
    '''
    nodetool = __salt__['config.option']('cassandra.nodetool')
    host = __salt__['config.option']('cassandra.host')
    return __salt__['cmd.run_stdout']('{0} -h {1} {2}'.format(nodetool, host, cmd))
56288
@Override
  protected PyExpr visitCallBasicNode(CallBasicNode node) {
    String calleeName = node.getCalleeName();

    // Build the Python expr text for the callee.
    String calleeExprText;
    TemplateNode template = getTemplateIfInSameFile(node);
    if (template != null) {
      // If in the same module no namespace is required.
      calleeExprText = getLocalTemplateName(template);
    } else {
      // If in another module, the module name is required along with the function name.
      int secondToLastDotIndex = calleeName.lastIndexOf('.', calleeName.lastIndexOf('.') - 1);
      calleeExprText = calleeName.substring(secondToLastDotIndex + 1);
    }

    String callExprText = calleeExprText + "(" + genObjToPass(node) + ", ijData)";
    return escapeCall(callExprText, node.getEscapingDirectives());
  }
1227197
def get_cql_models(app, connection=None, keyspace=None):
    
    from .models import DjangoCassandraModel
    models = []
    single_cassandra_connection = len(list(get_cassandra_connections())) == 1
    is_default_connection = connection == DEFAULT_DB_ALIAS or \
        single_cassandra_connection

    for name, obj in inspect.getmembers(app):
        cql_model_types = (
            cqlengine.models.Model,
            DjangoCassandraModel
        )
        if (
            inspect.isclass(obj) and issubclass(obj, cql_model_types) and
            not obj.__abstract__
        ):
            if obj.__connection__ == connection or \
                    (obj.__connection__ is None and is_default_connection) or \
                    obj.__connection__ is None and obj.__keyspace__ is not None and obj.__keyspace__ == keyspace:
                models.append(obj)

    return models
725831
def wrap(self, alias=None):
        
        field_names = self.get_field_names()
        query = Query(self.connection).from_table(deepcopy(self), alias=alias)
        self.__dict__.update(query.__dict__)

        # set explicit field names
        self.tables[0].set_fields(field_names)
        field_names = self.get_field_names()

        return self
224684
function (functionName, arguments) {
                var self = this;
                var args = self._getArgs(arguments);
                var callback = self._getCallback(arguments);

                return self._generic(functionName, args)
                    .nodeify(callback);
            }
745074
def data_structure_builder(func):
    
    @wraps(func)
    def ds_builder_wrapper(function, *args, **kwargs):
        try:
            function = DSBuilder(function)
        except NoBuilder:
            pass
        return func(function, *args, **kwargs)

    return ds_builder_wrapper
383257
def get_summary(name)
      counts = {}
      @cassandra.get_range(:totals, {:start => '', :finish => '', :count => @max_classes}).each do |key_slice|
        # keyslice is a clunky thrift object, map into a ruby hash
        row = key_slice.columns.inject({}){|hsh, c| hsh[c.column.name] = c.column.value; hsh}
        counts[key_slice.key.to_sym] = row[name].to_f
      end
      counts
    end
126140
function wrapped (del1, del2, pattFn, nodeFn, inp) {
    if (inp.takeAPeek(del1)) {
      var res = pattFn(inp.skipWs());
      if (inp.skipWs().takeAPeek(del2)) return nodeFn(res);
      else syntaxError(inp, "Expected " + del2);
    }
  }
721188
def replace_function_node(node, annotation):
    
    target, funcs = parse_nni_function(annotation)
    FuncReplacer(funcs, target).visit(node)
    return node
161820
def _getDecoratorsName(node):
    
    # For setter properties pylint fails so we use a custom code.
    decorators = []
    if not node.decorators:
        return decorators

    for decorator in node.decorators.nodes:
        decorators.append(decorator.as_string())
    return decorators
781615
def wrap_node(self, node, options):
        '''
        
        '''
        job_kwargs = {
            'queue': options.get('queue', 'default'),
            'connection': options.get('connection', self.redis_connection),
            'timeout': options.get('timeout', None),
            'result_ttl': options.get('result_ttl', 500),
        }

        return job(**job_kwargs)(node)
802058
def prepare(self, node):
        

        def register(name, module):
            """ Recursively save function typing and combiners for Pythonic."""
            for fname, function in module.items():
                if isinstance(function, dict):
                    register(name + "::" + fname, function)
                else:
                    tname = 'pythonic::{0}::functor::{1}'.format(name, fname)
                    self.result[function] = self.builder.NamedType(tname)
                    self.combiners[function] = function
                    if isinstance(function, Class):
                        register(name + "::" + fname, function.fields)

        for mname, module in MODULES.items():
            register(mname, module)
        super(Types, self).prepare(node)
524821
def _handle_function_exists(self, node, scope, ctxt, stream):
        
        res = fields.Int()
        try:
            func = self._handle_node(node.expr, scope, ctxt, stream)
            if isinstance(func, functions.BaseFunction):
                res._pfp__set_value(1)
            else:
                res._pfp__set_value(0)
        except errors.UnresolvedID:
            res._pfp__set_value(0)
        return res
365392
def _write_function(schema):
    
    def func(
        data,
        filename=None,
        schema=schema,
        taxon_col='uid',
        taxon_annotations=[],
        node_col='uid',
        node_annotations=[],
        branch_lengths=True,
        **kwargs):
        # Use generic write class to write data.
        return _write(
            data,
            filename=filename,
            schema=schema,
            taxon_col=taxon_col,
            taxon_annotations=taxon_annotations,
            node_col=node_col,
            node_annotations=node_annotations,
            branch_lengths=branch_lengths,
            **kwargs
        )
    # Update docs
    func.__doc__ = _write_doc_template(schema)
    return func
325851
def visit_FunctionDef(self, node):
        """"""
        # [[[cog
        # cog.out("print(pcolor('Enter function visitor', 'magenta'))")
        # ]]]
        # [[[end]]]
        in_class = self._in_class(node)
        decorator_list = [
            dobj.id if hasattr(dobj, "id") else dobj.attr
            for dobj in node.decorator_list
            if hasattr(dobj, "id") or hasattr(dobj, "attr")
        ]
        node.decorator_list = []
        # Callable can be:
        # a) A class property defined via decorated methods
        # b) A class method
        # c) A function
        # Get callable information (name, line number, etc.)
        action = (
            "getter"
            if "property" in decorator_list
            else (
                "setter"
                if "setter" in decorator_list
                else ("deleter" if "deleter" in decorator_list else None)
            )
        )
        element_type = "meth" if in_class else "func"
        element_full_name = self._pop_indent_stack(node, element_type, action=action)
        code_id = (self._fname, node.lineno)
        self._processed_line = node.lineno
        self._callables_db[element_full_name] = {
            "name": element_full_name,
            "type": element_type,
            "code_id": code_id,
            "last_lineno": None,
        }
        self._reverse_callables_db[code_id] = element_full_name
        # [[[cog
        # code = """
        # print(
        #     pcolor(
        #         'Visiting callable {0}  @ {1}'.format(
        #             element_full_name, code_id[1]
        #         ),
        #         'green'
        #     )
        # )
        # print(pcolor('    in_class = {}'.format(in_class), 'yellow'))
        # """
        # cog.out(code)
        # ]]]
        # [[[end]]]
        self.generic_visit(node)
275988
def _create_non_null_wrapper(name, t):
    ''
    def __new__(cls, json_data, selection_list=None):
        if json_data is None:
            raise ValueError(name + ' received null value')
        return t(json_data, selection_list)

    def __to_graphql_input__(value, indent=0, indent_string='  '):
        return t.__to_graphql_input__(value, indent, indent_string)

    return type(name, (t,), {
        '__new__': __new__,
        '_%s__auto_register' % name: False,
        '__to_graphql_input__': __to_graphql_input__,
    })
269977
def export(self, name, columns, points):
        """"""
        logger.debug("Export {} stats to Cassandra".format(name))

        # Remove non number stats and convert all to float (for Boolean)
        data = {k: float(v) for (k, v) in dict(zip(columns, points)).iteritems() if isinstance(v, Number)}

        # Write input to the Cassandra table
        try:

            stmt = "INSERT INTO {} (plugin, time, stat) VALUES (?, ?, ?)".format(self.table)
            query = self.session.prepare(stmt)
            self.session.execute(
                query,
                (name, uuid_from_time(datetime.now()), data)
            )
        except Exception as e:
            logger.error("Cannot export {} stats to Cassandra ({})".format(name, e))