<commit_before>"""
Module to take in Open Api Specification and convert it to HYDRA Api Doc

"""
import yaml
import json
from typing import Any, Dict, Match, Optional, Tuple, Union, List, Set
from hydrus.hydraspec.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp


def try_catch_replacement(block: Any, get_this: str, default: Any) -> str:
    """
    Replacement for the try catch blocks. HELPER FUNCTION
    :param block: Data from where information has to be parsed
    :param get_this: The key using which we have to fetch values from the block
    :param default: default value incase the key does not exist
    :return: string containing the value
    """
    try:
        return block[get_this]
    except KeyError:
        return default


def schema_parser(schema_block,class_name,global_,path=""):
    if class_name not in global_["class_names"]:
        ref = ""
        try :
            ref = schema_block["$ref"]
        except KeyError:
            # throw not supported error asking user to enter ref for now
            # ERROR
            pass
        if ref.split('/')[0]!="#":
            # means its a url
            return ref
        else:
            # class defined in the doc
            get_class_details(
                global_,
                get_data_at_location(
                    schema_block["$ref"]),
                class_name,
                path=path)
            return "vocab:" + class_name



def generateEntrypoint(api_doc: HydraDoc) -> None:
    """
    Generates Entrypoint , Base Collection and Base Resource for the documentation
    :param api_doc: contains the Hydra Doc created
    """
    api_doc.add_baseCollection()
    api_doc.add_baseResource()
    api_doc.gen_EntryPoint()


def generate_empty_object() -> Dict[str, Any]:
    """
    Generate Empty object
    :return: empty object
    """
    object = {
        "class_name": "",
        "class_definition": HydraClass,<commit_msg>removed schema parser method<commit_after>"""
Module to take in Open Api Specification and convert it to HYDRA Api Doc

"""
import yaml
import json
from typing import Any, Dict, Match, Optional, Tuple, Union, List, Set
from hydrus.hydraspec.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp


def try_catch_replacement(block: Any, get_this: str, default: Any) -> str:
    """
    Replacement for the try catch blocks. HELPER FUNCTION
    :param block: Data from where information has to be parsed
    :param get_this: The key using which we have to fetch values from the block
    :param default: default value incase the key does not exist
    :return: string containing the value
    """
    try:
        return block[get_this]
    except KeyError:
        return default



def generateEntrypoint(api_doc: HydraDoc) -> None:
    """
    Generates Entrypoint , Base Collection and Base Resource for the documentation
    :param api_doc: contains the Hydra Doc created
    """
    api_doc.add_baseCollection()
    api_doc.add_baseResource()
    api_doc.gen_EntryPoint()


def generate_empty_object() -> Dict[str, Any]:
    """
    Generate Empty object
    :return: empty object
    """
    object = {
        "class_name": "",
        "class_definition": HydraClass,
{'fraction_non_alphanumeric': 0.08156355801785165, 'fraction_numerical': 0.0003077870113881194, 'mean_word_length': 2.7442396313364057, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2990571', 'n_tokens_mistral': 948, 'n_tokens_neox': 904, 'n_words': 325}