Get class constants
8570
private function getClassConstants()
    {
        $pgClass = $this->entity->pgClass;

        $this->class->classComponents[] = new ClassConstant(
            'TABLE',
            new Sformatf( "const TABLE = '%s';", $pgClass->getFullyQualifiedName() )
        );
        $this->class->classComponents[] = new ClassConstant(
            'PARENT',
            new Sformatf(
                "const PARENT = %s;",
                $pgClass->isInherited($parent) ? "'{$parent->getFullyQualifiedName()}'" : 'null'
            )
        );
    }
1217616
def get_py3_info():
    
    # get all documented constants and their values
    constants, values = get_variable_docstrings("../py3status/py3.py")
    # we only care about ones defined in Py3
    constants = constants["Py3"]
    # sort them alphabetically
    constants = [(k, v) for k, v in sorted(constants.items())]

    # filter values as we only care about values defined in Py3
    values = dict([(v, k[4:]) for k, v in values.items() if k.startswith("Py3.")])

    def make_value(attr, arg, default):
        """
        If the methods parameter is defined as a constant then do a
        replacement.  Otherwise return the values representation.
        """
        if (attr, arg) in CONSTANT_PARAMS and default in values:
            return values[default]
        return repr(default)

    # inspect Py3 to find it's methods etc
    py3 = Py3()
    # no private ones
    attrs = [x for x in dir(py3) if not x.startswith("_")]
    exceptions = []
    methods = []
    for attr in attrs:
        item = getattr(py3, attr)
        if "method" in str(item):
            # a method so we need to get the call parameters
            args, vargs, kw, defaults = inspect.getargspec(item)
            args = args[1:]
            len_defaults = len(defaults) if defaults else 0
            len_args = len(args)

            sig = []
            for index, arg in enumerate(args):
                # default values set?
                if len_args - index <= len_defaults:
                    default = defaults[len_defaults - len_args + index]
                    sig.append("%s=%s" % (arg, make_value(attr, arg, default)))
                else:
                    sig.append(arg)

            definition = "%s(%s)" % (attr, ", ".join(sig))
            methods.append((definition, item.__doc__))
            continue
        try:
            # find any exceptions
            if isinstance(item(), Exception):
                exceptions.append((attr, item.__doc__))
                continue
        except:  # noqa e722
            pass
    return {"methods": methods, "exceptions": exceptions, "constants": constants}
764647
def get_properties(cls):
        """"""
        property_names = [p for p in dir(cls)
                          if isinstance(getattr(cls, p), property)]
        return property_names
31025
def code_constants(self):
        
        # TODO: remove link register values
        return [const.value for block in self.blocks for const in block.vex.constants]
18117
final public static function getMembers(): array
    {
        if (!isset(self::$constants[static::class])) {
            $reflection = new ReflectionClass(static::class);
            $constants = self::sortConstants($reflection);
            self::guardConstants($constants);
            self::$constants[static::class] = $constants;
        }

        return self::$constants[static::class];
    }
730203
def pretty_constants(self):
        

        for i in range(1, len(self.consts)):
            t, v = self.pretty_const(i)
            if t:
                yield (i, t, v)
1281010
def __get_constants(self):
        
        helper = ConstantClass(self._constants_class_name, self._io)
        helper.reload()
        constants = helper.constants()

        for name, value in constants.items():
            self._add_replace_pair(name, value, True)

        self._io.text('Read {0} constants for substitution from <fso>{1}</fso>'.
                      format(len(constants), helper.file_name()))
753935
def p_class_constant_declaration(p):
    ''''''
    if len(p) == 6:
        p[0] = p[1] + [ast.ClassConstant(p[3], p[5], lineno=p.lineno(2))]
    else:
        p[0] = [ast.ClassConstant(p[2], p[4], lineno=p.lineno(1))]
1102638
def constants_from_value(data=@value)
      data.scan(escape_pattern).flatten.collect { |value| value.strip }
    end
847276
public function getConstant($name, $object = null)
    {
        if ($object !== null) {
            $name = sprintf('%s::%s', get_class($object), $name);
        }

        return constant($name);
    }
1084719
def generate
      constants = inspector.inspect_constants(
        inspector.constant,
        options[:ignore].dup
      )

      constants = constants.sort

      group_constants(constants).each do |root, names|
        filepath  = File.join(directory, "#{root.snake_case}.rb")
        constants = []

        if File.file?(filepath) and !options[:overwrite]
          next
        end

        names.each do |name|
          current_inspector = Inspector.new(name)
          inspected_methods = inspect_methods(current_inspector)
          superclass        = nil

          if current_inspector.inspect_superclass
            superclass = current_inspector.inspect_superclass.to_s
          end

          constant = GeneratedConstant.new(
            :name       => current_inspector.constant_name,
            :constant   => current_inspector.constant,
            :methods    => method_information(inspected_methods),
            :superclass => superclass,

            # Kernel is ignored since its included already in core/object.rb
            :modules    => current_inspector.inspect_modules - [Kernel]
          )

          constants << constant
        end

        render_template(filepath, template, constants)
      end
    end
1126252
def grep(source, regex, stop_on_first=False):
    """"""
    loader = ClassLoader(source, max_cache=-1)
    r = re.compile(regex)

    def _matches(constant):
        return r.match(constant.value)

    for klass in loader.classes:
        it = loader.search_constant_pool(path=klass, type_=UTF8, f=_matches)
        if next(it, None):
            print(klass)
            if stop_on_first:
                break
580993
public static final function values() {
		$calledClass = get_called_class();

		// let's check the cache so we don't have to call reflection constantly
		if (empty(self::$cachedValues[$calledClass])) {
			$class = new \ReflectionClass($calledClass);
			self::$cachedValues[$calledClass] = $class->getConstants();
		}

		return self::$cachedValues[$calledClass];
	}
604098
def get_constants namespace, context = ''
      namespace ||= ''
      cached = cache.get_constants(namespace, context)
      return cached.clone unless cached.nil?
      skip = []
      result = []
      bases = context.split('::')
      while bases.length > 0
        built = bases.join('::')
        fqns = qualify(namespace, built)
        visibility = [:public]
        visibility.push :private if fqns == context
        result.concat inner_get_constants(fqns, visibility, skip)
        bases.pop
      end
      fqns = qualify(namespace, '')
      visibility = [:public]
      visibility.push :private if fqns == context
      result.concat inner_get_constants(fqns, visibility, skip)
      cache.set_constants(namespace, context, result)
      result
    end
948777
def to_class(name)
      # I wanted to use Module.const_defined?() here to avoid relying
      # on exceptions for normal program flow but it's of no use.
      # If class autoloading is enabled, the constant may be undefined
      # but turn out to be present when we actually try to use it.
      begin
        constant = name.constantize
      rescue NameError
        return nil
      rescue LoadError => e
        $stderr.puts "failed to load '#{name}', ignoring (#{e.class}: #{e.message})"
        return nil
      end

      return constant.is_a?(Class) ? constant : nil
    end
69998
public static function getConstList() : array
    {
        if (static::$constList === null) {
            $reflection        = new ReflectionClass(get_called_class());
            static::$constList = array_values($reflection->getConstants());
        }

        return static::$constList;
    }
1230150
def get_all_constants():
    
    return filter(
        lambda key: key.upper() == key and type(globals()[key]) in _ALLOWED,

        filter(                               # filter _PRIVATE variables
            lambda x: not x.startswith("_"),
            globals()
        )
    )