Generate classes with loaders for the given Schema Salad description.
5571
def codegen(lang,             # type: str
            i,                # type: List[Dict[Text, Any]]
            schema_metadata,  # type: Dict[Text, Any]
            loader            # type: Loader
           ):  # type: (...) -> None
    """"""

    j = schema.extend_and_specialize(i, loader)

    gen = None  # type: Optional[CodeGenBase]
    if lang == "python":
        gen = PythonCodeGen(sys.stdout)
    elif lang == "java":
        gen = JavaCodeGen(schema_metadata.get("$base", schema_metadata.get("id")))
    else:
        raise Exception("Unsupported code generation language '%s'" % lang)
    assert gen is not None

    gen.prologue()

    document_roots = []

    for rec in j:
        if rec["type"] in ("enum", "record"):
            gen.type_loader(rec)
            gen.add_vocab(shortname(rec["name"]), rec["name"])

    for rec in j:
        if rec["type"] == "enum":
            for symbol in rec["symbols"]:
                gen.add_vocab(shortname(symbol), symbol)

        if rec["type"] == "record":
            if rec.get("documentRoot"):
                document_roots.append(rec["name"])

            field_names = []
            for field in rec.get("fields", []):
                field_names.append(shortname(field["name"]))

            idfield = ""
            for field in rec.get("fields", []):
                if field.get("jsonldPredicate") == "@id":
                    idfield = field.get("name")

            gen.begin_class(rec["name"], aslist(rec.get("extends", [])), rec.get("doc", ""),
                            rec.get("abstract", False), field_names, idfield)
            gen.add_vocab(shortname(rec["name"]), rec["name"])

            for field in rec.get("fields", []):
                if field.get("jsonldPredicate") == "@id":
                    fieldpred = field["name"]
                    optional = bool("https://w3id.org/cwl/salad#null" in field["type"])
                    uri_loader = gen.uri_loader(gen.type_loader(field["type"]), True, False, None)
                    gen.declare_id_field(fieldpred, uri_loader, field.get("doc"), optional)
                    break

            for field in rec.get("fields", []):
                optional = bool("https://w3id.org/cwl/salad#null" in field["type"])
                type_loader = gen.type_loader(field["type"])
                jld = field.get("jsonldPredicate")
                fieldpred = field["name"]
                if isinstance(jld, MutableMapping):
                    ref_scope = jld.get("refScope")

                    if jld.get("typeDSL"):
                        type_loader = gen.typedsl_loader(type_loader, ref_scope)
                    elif jld.get("_type") == "@id":
                        type_loader = gen.uri_loader(type_loader, jld.get("identity", False),
                                                     False, ref_scope)
                    elif jld.get("_type") == "@vocab":
                        type_loader = gen.uri_loader(type_loader, False, True, ref_scope)

                    map_subject = jld.get("mapSubject")
                    if map_subject:
                        type_loader = gen.idmap_loader(
                            field["name"], type_loader, map_subject, jld.get("mapPredicate"))

                    if "_id" in jld and jld["_id"][0] != "@":
                        fieldpred = jld["_id"]

                if jld == "@id":
                    continue

                gen.declare_field(fieldpred, type_loader, field.get("doc"), optional)

            gen.end_class(rec["name"], field_names)

    root_type = list(document_roots)
    root_type.append({
        "type": "array",
        "items": document_roots
    })

    gen.epilogue(gen.type_loader(root_type))
326359
def generate_and_merge_schemas(samples):
    
    merged = generate_schema_for_sample(next(iter(samples)))

    for sample in samples:
        merged = merge_schema(merged, generate_schema_for_sample(sample))

    return merged
733204
protected void generateClasses(RoundEnvironment roundEnv) throws Exception {
		for (SQLiteDatabaseSchema currentSchema : schemas) {
			// first of all, order table look for its dependencies
			BindTableGenerator.generate(elementUtils, filer, currentSchema, currentSchema.generatedEntities);
			BindDaoBuilder.generate(elementUtils, filer, currentSchema);
			if (currentSchema.generateCursor)
				BindCursorBuilder.generate(elementUtils, filer, currentSchema);
			if (currentSchema.generateAsyncTask)
				BindAsyncTaskBuilder.generate(elementUtils, filer, currentSchema);

			BindDataSourceBuilder.generate(elementUtils, filer, currentSchema);
			if (currentSchema.generateContentProvider) {
				BindContentProviderBuilder.generate(elementUtils, filer, currentSchema);
			}

		}
	}
735182
def generate_html(self, jdoc, schema, schemas):
        ''''''

        params = {'functions': sorted([j for j in jdoc \
                   if (j.schema_name == schema.object_name and j.object_type \
                       in ['function', 'procedure', 'trigger'])], \
                                      key=lambda x: x.object_name),
                   'tables': sorted([j for j in jdoc \
                   if (j.schema_name == schema.object_name and j.object_type \
                       in ['table', 'view', 'materialized view', 'foreign table'])], \
                                    key=lambda x: x.object_name),
                   'schema_name': schema.object_name,
                   'schemas': sorted(schemas, key=lambda x: x.object_name),
                   'project': self.project_name,
                   'title': '{}: schema {}'.format(self.project_name,
                                                   schema.object_name)}
        template = self.lookup.get_template('schema.mako')
        html = template.render_unicode(**params)

        return html
74834
def generate(size, output, schema):
    """"""
    pii_data = randomnames.NameList(size)

    if schema is not None:
        raise NotImplementedError

    randomnames.save_csv(
        pii_data.names,
        [f.identifier for f in pii_data.SCHEMA.fields],
        output)
725219
public void generateClasses() throws IOException {
		for (PrefsEntity item : model.getEntities()) {
			BindSharedPreferencesBuilder.generate(elementUtils, filer, item);
		}
	}
132294
def synthesize(self, modules, use_string, x64, native):
        """"""
        # code_opts = CodeOpts(
        #     str.lower, None if use_string else hash_func,
        #     'reloc_delta', '->',
        #     True)
        # gen_opts = GenOpts('defs', transformed)
        print(hash_func)
        groups = group_by(modules, ends_with_punctuation)
        sources = self.make_source(groups, self.database)
        if sources:
            return stylify_files(
                {'defs.h': sources[0], 'init.c': sources[1]}
            )
        else:
            return ''
1315958
private void generateClassFiles(ClassTree classtree) throws DocletException {
        SortedSet<PackageElement> packages = configuration.typeElementCatalog.packages();
        for (PackageElement pkg : packages) {
            generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree);
        }
    }
1228066
def gen_references(self) -> str:
        
        rval = []
        for cls in self.schema.classes.values():
            pkeys = self.primary_keys_for(cls)
            for pk in pkeys:
                pk_slot = self.schema.slots[pk]
                classname = camelcase(cls.name) + camelcase(pk)
                if cls.is_a and getattr(self.schema.classes[cls.is_a], pk, None):
                    parent = self.range_type_name(pk_slot, cls.is_a)
                else:
                    parent = self.python_name_for(pk_slot.range)
                rval.append(f'class {classname}({parent}):\n\tpass')
        return '\n\n\n'.join(rval)
664877
protected void generateClassFiles(RootDoc root, ClassTree classtree) {
        generateClassFiles(classtree);
        PackageDoc[] packages = root.specifiedPackages();
        for (int i = 0; i < packages.length; i++) {
            generateClassFiles(packages[i].allClasses(), classtree);
        }
    }
600560
def generate
      Dir["app/models/*.rb"].each do |path|
        result = File.basename(path).scan(/^(.+)\.rb/)[0][0]
        model = eval(ActiveSupport::Inflector.camelize(result))
        next if model.respond_to?(:abstract_class) && model.abstract_class
        next unless model < ActiveRecord::Base
        @annotations[model] = generate_annotation(model) unless @annotations.keys.include?(model)
      end
    end
578101
public void generateSchema(Class... classes)
        throws JAXBException, IOException {
        if (!baseDir.exists()) {
            baseDir.mkdirs();
        }

        JAXBContext context = JAXBContext.newInstance(classes);
        context.generateSchema(this);
    }
408140
def build_model_classes(metadata):
    """"""
    i = importlib.import_module(metadata)
    env = get_jinja_env()
    model_template = env.get_template('model.py.jinja2')
    for model in i.models:
        with open(model_path(model.name.lower()), 'w') as t:
            t.write(model_template.render(model_md=model))
140645
def generate_docs(self, clspath, more_content):
        """"""
        obj = import_class(clspath)
        sourcename = 'docstring of %s' % clspath
        all_options = []
        indent = '    '
        config = obj.get_required_config()

        if config.options:
            # Go through options and figure out relevant information
            for option in config:
                if 'namespace' in self.options:
                    namespaced_key = self.options['namespace'] + '_' + option.key
                else:
                    namespaced_key = option.key

                if 'case' in self.options:
                    if self.options['case'] == 'upper':
                        namespaced_key = namespaced_key.upper()
                    elif self.options['case'] == 'lower':
                        namespaced_key = namespaced_key.lower()

                all_options.append({
                    'key': namespaced_key,
                    'parser': qualname(option.parser),
                    'doc': option.doc,
                    'default': option.default,
                })

        if 'hide-classname' not in self.options:
            modname, clsname = split_clspath(clspath)
            component_name = clspath
            component_index = clsname
        else:
            component_name = 'Configuration'
            component_index = 'Configuration'

        if all_options:
            # Add index entries for options first so they link to the right
            # place; we do it this way so that we don't have to make options a
            # real object type and then we don't get to use TypedField
            # formatting
            self.add_line('.. index::', sourcename)
            for option in all_options:
                self.add_line('   single: %s; (%s)' % (option['key'], component_index), sourcename)
            self.add_line('', '')

        # Add the classname or 'Configuration'
        self.add_line('.. everett:component:: %s' % component_name, sourcename)
        self.add_line('', sourcename)

        # Add the docstring if there is one and if show-docstring
        if 'show-docstring' in self.options:
            docstring_attr = self.options['show-docstring'] or '__doc__'
            docstring = getattr(obj, docstring_attr, None)
            if docstring:
                docstringlines = prepare_docstring(docstring, ignore=1)
                for i, line in enumerate(docstringlines):
                    self.add_line(indent + line, sourcename, i)
                self.add_line('', '')

        # Add content from the directive if there was any
        if more_content:
            for line, src in zip(more_content.data, more_content.items):
                self.add_line(indent + line, src[0], src[1])
            self.add_line('', '')

        if all_options:
            # Now list the options
            sourcename = 'class definition'

            for option in all_options:
                self.add_line(
                    '%s:option %s %s:' % (indent, option['parser'], option['key']),
                    sourcename
                )
                self.add_line('%s    %s' % (indent, option['doc']), sourcename)
                if option['default'] is not NO_VALUE:
                    self.add_line('', '')
                    self.add_line(
                        '%s    Defaults to ``%r``.' % (indent, option['default']),
                        sourcename
                    )
                self.add_line('', '')
287849
def build_collection_schema(**args)
      object.map { |object| self.class.new(object, context).build_schema(args) }
    end
1169429
def gen_classdef(self, clsname: str,  cls: ClassDefinition) -> str:
        
        parentref = f'({self.python_name_for(cls.is_a) if cls.is_a else "YAMLRoot"})'
        slotdefs = self.gen_slot_variables(cls)
        postinits = self.gen_postinits(cls)
        if not slotdefs:
            slotdefs = 'pass'
        wrapped_description = f'''
    """
    {wrapped_annotation(be(cls.description))}
    """''' if be(cls.description) else ''
        return f'''
@dataclass
class {camelcase(clsname)}{parentref}:{wrapped_description}
    {slotdefs}
    {postinits}'''
879303
def get_orm_classes(path):
    """"""
    ret = set()
    try:
        m = importlib.import_module(path)

    except ImportError:
        # we have a classpath
        m, klass = get_objects(path)
        if issubclass(klass, Orm):
            ret.add(klass)

    else:
        ret.update(get_subclasses(m, Orm))

    return ret