Return a JSON Schema for the given state function(s)

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' sys.state_schema
        salt '*' sys.state_schema pkg.installed
14499
def state_schema(module=''):
    '''
    
    '''
    specs = state_argspec(module)

    schemas = []
    for state_mod, state_spec in specs.items():
        schemas.append(_argspec_to_schema(state_mod, state_spec))

    return schemas
1314166
def package_install(name, **kwargs):
    '''
    
    '''
    cmd = DETAILS['url']+'package/install/'+name
    if kwargs.get('version', False):
        cmd += '/'+kwargs['version']
    else:
        cmd += '/1.0'
    r = salt.utils.http.query(cmd, decode_type='json', decode=True)
    return r['dict']
1003966
def schema(self):
        
        if self.key_type is None:
            return "%s %s" % (self.name, self.data_type)
        else:
            return "%s %s %s KEY" % (self.name, self.data_type, self.key_type)
1208674
def get_state(self, caller):
        

        if caller in self.state:
            return self.state[caller]
        else:
            rv = self.state[caller] = DictObject()
            return rv
515531
function Schema (sc, size) {
  if (!(this instanceof Schema)) return new Schema(sc);
  debug('======BUILDING PHASE======');
  helpers.validate(sc);
  debug('schema size=%d being built', size);
  this._schema = this;
  this._document = helpers.build(sc, '$root', this);
  this._state = { // serve as global state
    index: -1,
    size: size,
    counter: []
  };
  debug('======BUILDING ENDS======');
}
1232860
def schema_helper(self, name, _, schema=None, **kwargs):
        
        if schema is None:
            return None

        schema_instance = resolve_schema_instance(schema)

        schema_key = make_schema_key(schema_instance)
        self.warn_if_schema_already_in_spec(schema_key)
        self.openapi.refs[schema_key] = name

        json_schema = self.openapi.schema2jsonschema(schema_instance)

        return json_schema
721055
def _create_metadata_from_state(self, state, ts):
        
        if state is None:
            return None

        def _f(elem, ts):
            if isinstance(elem, dict):
                return {_: _f(elem[_], ts) for _ in elem.keys()}
            if isinstance(elem, list):
                return [_f(_, ts) for _ in elem]
            return {"timestamp": ts}
        return _f(state, ts)
1339364
def schema(self) -> str:
        
        if self._ssl:
            return "https"
        proxy = bool(self.app and self.app.proxy)
        if not proxy:
            return "http"
        proto = cast(str, self.get("X-Forwarded-Proto") or "http")
        return proto.split(",")[0].strip()
306684
def build_state(
            cls,
            db: BaseAtomicDB,
            header: BlockHeader,
            previous_hashes: Iterable[Hash32] = ()) -> BaseState:
        

        execution_context = header.create_execution_context(previous_hashes)
        return cls.get_state_class()(db, execution_context, header.state_root)
131934
def get_schema(repo, content_type):
    
    try:
        with open(
                os.path.join(repo.working_dir,
                             '_schemas',
                             '%s.avsc' % (content_type,)), 'r') as fp:
            data = fp.read()
            return avro.schema.parse(data)
    except IOError:  # pragma: no cover
        raise NotFound('Schema does not exist.')
1076998
def config_schema(self):
        """"""
        from rez.config import _plugin_config_dict
        d = _plugin_config_dict.get(self.type_name, {})

        for name, plugin_class in self.plugin_classes.iteritems():
            if hasattr(plugin_class, "schema_dict") \
                    and plugin_class.schema_dict:
                d_ = {name: plugin_class.schema_dict}
                deep_update(d, d_)
        return dict_to_schema(d, required=True, modifier=expand_system_vars)
166763
def from_schemafile(cls, schemafile):
        
        with open(schemafile) as f:
            return cls(json.load(f))
1247181
def dict2schema(dct, schema_class=ma.Schema):
    
    attrs = dct.copy()

    class Meta(object):
        if MARSHMALLOW_VERSION_INFO[0] < 3:
            strict = True
        else:
            register = False

    attrs["Meta"] = Meta
    return type(str(""), (schema_class,), attrs)
418069
def _handle_state_decls(self, state, sls, saltenv, errors):
        '''
        
        '''
        for name in state:
            if not isinstance(state[name], dict):
                if name == '__extend__':
                    continue
                if name == '__exclude__':
                    continue

                if isinstance(state[name], six.string_types):
                    # Is this is a short state, it needs to be padded
                    if '.' in state[name]:
                        comps = state[name].split('.')
                        state[name] = {'__sls__': sls,
                                       '__env__': saltenv,
                                       comps[0]: [comps[1]]}
                        continue
                errors.append(
                    'ID {0} in SLS {1} is not a dictionary'.format(name, sls)
                )
                continue
            skeys = set()
            for key in list(state[name]):
                if key.startswith('_'):
                    continue
                if not isinstance(state[name][key], list):
                    continue
                if '.' in key:
                    comps = key.split('.')
                    # Salt doesn't support state files such as:
                    #
                    #     /etc/redis/redis.conf:
                    #       file.managed:
                    #         - source: salt://redis/redis.conf
                    #         - user: redis
                    #         - group: redis
                    #         - mode: 644
                    #       file.comment:
                    #           - regex: ^requirepass
                    if comps[0] in skeys:
                        errors.append(
                            'ID \'{0}\' in SLS \'{1}\' contains multiple state '
                            'declarations of the same type'.format(name, sls)
                        )
                        continue
                    state[name][comps[0]] = state[name].pop(key)
                    state[name][comps[0]].append(comps[1])
                    skeys.add(comps[0])
                    continue
                skeys.add(key)
            if '__sls__' not in state[name]:
                state[name]['__sls__'] = sls
            if '__env__' not in state[name]:
                state[name]['__env__'] = saltenv
814665
def layout_json_schema(self):
        """"""
        if self._layout_json_schema is None and self.layout_json_schema_file is not None:
            if os.path.isfile(self.layout_json_schema_file):
                with open(self.layout_json_schema_file) as fh:
                    self._layout_json_schema = json.load(fh)
        return self._layout_json_schema
403315
def schema():
    
    tables = orca.list_tables()
    cols = {t: orca.get_table(t).columns for t in tables}
    steps = orca.list_steps()
    injectables = orca.list_injectables()
    broadcasts = orca.list_broadcasts()

    return jsonify(
        tables=tables, columns=cols, steps=steps, injectables=injectables,
        broadcasts=broadcasts)
362528
def get_state(self):
        
        return {
            REG_X: self.index_x.value,
            REG_Y: self.index_y.value,

            REG_U: self.user_stack_pointer.value,
            REG_S: self.system_stack_pointer.value,

            REG_PC: self.program_counter.value,

            REG_A: self.accu_a.value,
            REG_B: self.accu_b.value,

            REG_DP: self.direct_page.value,
            REG_CC: self.get_cc_value(),

            "cycles": self.cycles,
            "RAM": tuple(self.memory._mem) # copy of array.array() values,
        }