def load_raw_schema(data: Union[str, TextIO],<EOL>source_file: str=None,<EOL>source_file_date: str=None,<EOL>source_file_size: int=None,<EOL>base_dir: Optional[str]=None) -> SchemaDefinition:
if isinstance(data, str):<EOL><INDENT>if '<STR_LIT:\n>' in data:<EOL><INDENT>return load_raw_schema((cast(TextIO, StringIO(data))))  <EOL><DEDENT>elif '<STR_LIT>' in data:<EOL><INDENT>req = Request(data)<EOL>req.add_header("<STR_LIT>", "<STR_LIT>")<EOL>with urlopen(req) as response:<EOL><INDENT>return load_raw_schema(response)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>fname = os.path.join(base_dir if base_dir else '<STR_LIT>', data)<EOL>with open(fname) as f:<EOL><INDENT>return load_raw_schema(f, data, time.ctime(os.path.getmtime(fname)), os.path.getsize(fname))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>schemadefs = yaml.load(data, DupCheckYamlLoader)<EOL>if '<STR_LIT:name>' in schemadefs:<EOL><INDENT>schemadefs = {schemadefs.pop('<STR_LIT:name>'): schemadefs}<EOL><DEDENT>elif '<STR_LIT:id>' in schemadefs:<EOL><INDENT>schemadefs = {schemadefs['<STR_LIT:id>']: schemadefs}<EOL><DEDENT>elif len(schemadefs) > <NUM_LIT:1> or not isinstance(list(schemadefs.values())[<NUM_LIT:0>], dict):<EOL><INDENT>schemadefs = {'<STR_LIT>': schemadefs}<EOL><DEDENT>schema: SchemaDefinition = None<EOL>for sname, sdef in {k: SchemaDefinition(name=k, **v) for k, v in schemadefs.items()}.items():<EOL><INDENT>if schema is None:<EOL><INDENT>schema = sdef<EOL>schema.source_file = os.path.basename(source_file) if source_file else None<EOL>schema.source_file_date = source_file_date<EOL>schema.source_file_size = source_file_size<EOL>schema.generation_date =  datetime.now().strftime("<STR_LIT>")<EOL>schema.metamodel_version = metamodel_version<EOL><DEDENT>else:<EOL><INDENT>merge_schemas(schema, sdef)<EOL><DEDENT><DEDENT>return schema<EOL><DEDENT>
Load and flatten SchemaDefinition from a file name, a URL or a block of text

    @param data: URL, file name or block of text
    @param source_file: Source file name for the schema
    @param source_file_date: timestamp of source file
    @param source_file_size: size of source file
    @param base_dir: Working directory of sources
    @return: Map from schema name to SchemaDefinition