Return the value of the ast object.
480487
def _get_value_from_ast(self, obj):
        
        if isinstance(obj, ast.Num):
            return obj.n
        elif isinstance(obj, ast.Str):
            return obj.s
        elif isinstance(obj, ast.List):
            return [self._get_value_from_ast(e) for e in obj.elts]
        elif isinstance(obj, ast.Tuple):
            return tuple([self._get_value_from_ast(e) for e in obj.elts])

        # None, True and False are NameConstants in Py3.4 and above.
        elif sys.version_info.major >= 3 and isinstance(obj, ast.NameConstant):
            return obj.value

        # For python versions below 3.4
        elif isinstance(obj, ast.Name) and (obj.id in ["True", "False", "None"]):
            return string_to_constant[obj.id]

        # Probably passed a variable name.
        # Or passed a single word without wrapping it in quotes as an argument
        # ex: p.inflect("I plural(see)") instead of p.inflect("I plural('see')")
        raise NameError("name '%s' is not defined" % obj.id)
108292
def to_ast(value):
    

    if isinstance(value, (type(None), bool)):
        return builtin_folding(value)
    if sys.version_info[0] == 2 and isinstance(value, long):
        from pythran.syntax import PythranSyntaxError
        raise PythranSyntaxError("constant folding results in big int")
    if any(value is t for t in (bool, int, float)):
        iinfo = np.iinfo(int)
        if isinstance(value, int) and not (iinfo.min <= value <= iinfo.max):
            from pythran.syntax import PythranSyntaxError
            raise PythranSyntaxError("constant folding results in big int")
        return builtin_folding(value)
    elif isinstance(value, np.generic):
        return to_ast(np.asscalar(value))
    elif isinstance(value, numbers.Number):
        return ast.Num(value)
    elif isinstance(value, str):
        return ast.Str(value)
    elif isinstance(value, (list, tuple, set, dict, np.ndarray)):
        return size_container_folding(value)
    elif hasattr(value, "__module__") and value.__module__ == "__builtin__":
        # TODO Can be done the same way for others modules
        return builtin_folding(value)
    # only meaningful for python3
    elif sys.version_info.major == 3:
        if isinstance(value, (filter, map, zip)):
            return to_ast(list(value))
    raise ToNotEval()
1123936
def get_value(self, key, args, kwargs):
        """"""
        if hasattr(self._item, key):
            return getattr(self._item, key)
        return super().get_value(key, args, kwargs)
907598
def _value(self):
        """"""
        if self.data is not None:
            value = self.data._data.get(self.field.to_field.name)
            return str(value)
        return ''
517418
def get_version():
    """"""
    # Grab the first assignment to __version__
    version = None
    init_py = os.path.join(os.path.dirname(__file__),
                           'asv', '__init__.py')
    with open(init_py, 'r') as f:
        source = f.read()
    tree = ast.parse(source)
    for statement in tree.body:
        if (isinstance(statement, ast.Assign) and
            len(statement.targets) == 1 and
            statement.targets[0].id == '__version__'):
            version = statement.value.s
            break

    if not version:
        raise RuntimeError("Failed to parse version from {}".format(init_py))

    if 'dev' in version and not version.endswith('.dev'):
        raise RuntimeError("Dev version string in {} doesn't end in .dev".format(
            init_py))

    return version
1253328
def visit_Str(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        return repr(node.s)
185341
def on_subscript(self, node):    # ('value', 'slice', 'ctx')
        """"""
        val = self.run(node.value)
        nslice = self.run(node.slice)
        ctx = node.ctx.__class__
        if ctx in (ast.Load, ast.Store):
            if isinstance(node.slice, (ast.Index, ast.Slice, ast.Ellipsis)):
                return val.__getitem__(nslice)
            elif isinstance(node.slice, ast.ExtSlice):
                return val[nslice]
        else:
            msg = "subscript with unknown context"
            self.raise_exception(node, msg=msg)
752095
def visit_Attribute(self, node: ast.Attribute) -> Any:
        """"""
        value = self.visit(node=node.value)
        if not isinstance(node.ctx, ast.Load):
            raise NotImplementedError(
                "Can only compute a value of Load on the attribute {}, but got context: {}".format(node.attr, node.ctx))

        result = getattr(value, node.attr)

        self.recomputed_values[node] = result
        return result
373551
def fval(self, instance):
        """"""
        try:
            val = instance.__dict__[self.instance_field_name]
        except KeyError as e:
            #raise AttributeError(str(e))
            val = None

        return val
831786
def visit_Str(self, node: ast.Str) -> str:
        """"""
        result = node.s

        self.recomputed_values[node] = result
        return result
201142
def getvalue(self) -> str:
        """"""
        return self.buffer.byte_buf.decode(encoding=self.encoding, errors=self.errors)
482616
def get():
        """"""
        return {
            attr: getattr(Conf, attr)
            for attr in dir(Conf()) if not callable(getattr(Conf, attr)) and not attr.startswith("__")
        }
580991
def getStat(cls, obj, name):
    """"""
    objClass = type(obj)
    for theClass in objClass.__mro__:
      if theClass == object:
        break
      for value in theClass.__dict__.values():
        if isinstance(value, Stat) and value.getName() == name:
          return value
1025935
def value_from_ast(value_ast, type, variables=None):
    # type: (Optional[Node], GraphQLType, Optional[Dict[str, Union[List, Dict, int, float, bool, str, None]]]) -> Union[List, Dict, int, float, bool, str, None]
    """"""
    if isinstance(type, GraphQLNonNull):
        # Note: we're not checking that the result of coerceValueAST is non-null.
        # We're assuming that this query has been validated and the value used here is of the correct type.
        return value_from_ast(value_ast, type.of_type, variables)

    if value_ast is None:
        return None

    if isinstance(value_ast, ast.Variable):
        variable_name = value_ast.name.value
        if not variables or variable_name not in variables:
            return None

        # Note: we're not doing any checking that this variable is correct. We're assuming that this query
        # has been validated and the variable usage here is of the correct type.
        return variables.get(variable_name)

    if isinstance(type, GraphQLList):
        item_type = type.of_type
        if isinstance(value_ast, ast.ListValue):
            return [
                value_from_ast(item_ast, item_type, variables)
                for item_ast in value_ast.values
            ]

        else:
            return [value_from_ast(value_ast, item_type, variables)]

    if isinstance(type, GraphQLInputObjectType):
        fields = type.fields
        if not isinstance(value_ast, ast.ObjectValue):
            return None

        field_asts = {}

        for field_ast in value_ast.fields:
            field_asts[field_ast.name.value] = field_ast

        obj = {}
        for field_name, field in fields.items():
            if field_name not in field_asts:
                if field.default_value is not None:
                    # We use out_name as the output name for the
                    # dict if exists
                    obj[field.out_name or field_name] = field.default_value

                continue

            field_ast = field_asts[field_name]
            field_value_ast = field_ast.value
            field_value = value_from_ast(field_value_ast, field.type, variables)

            # We use out_name as the output name for the
            # dict if exists
            obj[field.out_name or field_name] = field_value

        return type.create_container(obj)

    assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), "Must be input type"

    return type.parse_literal(value_ast)
19777
def find_value_at_cursor(ast_tree, filename, line, col, root_env=gcl.default_env):
  """"""
  q = gcl.SourceQuery(filename, line, col)
  rootpath = ast_tree.find_tokens(q)
  rootpath = path_until(rootpath, is_thunk)

  if len(rootpath) <= 1:
    # Just the file tuple itself, or some non-thunk element at the top level
    return None

  tup = inflate_context_tuple(rootpath, root_env)
  try:
    if isinstance(rootpath[-1], ast.Inherit):
      # Special case handling of 'Inherit' nodes, show the value that's being
      # inherited.
      return tup[rootpath[-1].name]
    return rootpath[-1].eval(tup.env(tup))
  except gcl.EvaluationError as e:
    return e
1211449
def getitem(self, obj, argument):
        """"""
        try:
            return obj[argument]
        except (TypeError, LookupError):
            if isinstance(argument, basestring):
                try:
                    attr = str(argument)
                except:
                    pass
                else:
                    try:
                        value = getattr(obj, attr)
                    except AttributeError:
                        pass
                    else:
                        if self.is_safe_attribute(obj, argument, value):
                            return value
                        return self.unsafe_undefined(obj, argument)
        return self.undefined(obj=obj, name=argument)
634999
def get_val(source, extract=None, transform=None):
  """"""
  if extract is None:
    raw_value = source
  else:
    raw_value = extract(source)

  if transform is None:
    return raw_value
  else:
    return transform(raw_value)