def type(self, value): """ """ language = self.specification.monolithe_config.language if self.specification and self.specification.monolithe_config else 'python' self._type = SDKUtils.massage_type_name(type_name=value) self.local_type = SDKUtils.get_type_name_in_language(type_name=value, sub_type=self.subtype, language=language)
def entity_name(self, value): """ """ self._entity_name = value if value: self.instance_name = SDKUtils.get_python_name(value) self.entity_name_plural = SDKUtils.get_entity_name_plural(value) self.instance_name_plural = SDKUtils.get_python_name(self.entity_name_plural)
def rest_name(self, value): """ """ self._rest_name = value if self.specification and self.specification.monolithe_config: self.local_name = SDKUtils.get_python_name( self.specification.monolithe_config.map_attribute( self.specification.rest_name, value)) else: self.local_name = SDKUtils.get_python_name(value)
def rest_name(self, value): """ """ self._rest_name = value if self.specification and self.specification.monolithe_config: self.local_name = SDKUtils.get_python_name( self.specification.monolithe_config.map_attribute(self.specification.rest_name, value) ) else: self.local_name = SDKUtils.get_python_name(value)
def name(self, value): """ """ self._name = value language = self.specification.monolithe_config.language if self.specification and self.specification.monolithe_config else 'python' if self.specification and self.specification.monolithe_config: self.local_name = SDKUtils.get_idiomatic_name_in_language(name=self.specification.monolithe_config.map_attribute(self.specification.rest_name, value), language=language) else: self.local_name = SDKUtils.get_idiomatic_name_in_language(name=value, language=language)
def entity_name(self, value): """ """ self._entity_name = value language = self.monolithe_config.language if self.monolithe_config else 'python' if value: self.instance_name = SDKUtils.get_idiomatic_name_in_language(name=value, language=language) self.entity_name_plural = SDKUtils.get_plural(singular_name=value) self.instance_name_plural = SDKUtils.get_idiomatic_name_in_language(name=self.entity_name_plural, language=language)
def entity_name(self, value): """ """ self._entity_name = value language = self.monolithe_config.language if self.monolithe_config else 'python' if value: self.instance_name = SDKUtils.get_idiomatic_name_in_language( name=value, language=language) self.entity_name_plural = SDKUtils.get_plural(singular_name=value) self.instance_name_plural = SDKUtils.get_idiomatic_name_in_language( name=self.entity_name_plural, language=language)
def __init__(self, monolithe_config, api_info): """ Initializes a _JavaSDKAPIVersionFileWriter """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.java") self.api_version = api_info["version"] self._api_version_string = SDKUtils.get_string_version( self.api_version) self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option( "output", "transformer") self._name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = "" self._product_accronym = self.monolithe_config.get_option( "product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self._url = self.monolithe_config.get_option("url", "transformer") self._package_prefix = self._get_package_prefix(self._url) self._package_name = self._package_prefix + '.' + self._name + '.' + SDKUtils.get_string_version( self.api_version) self._package_subdir = self._package_name.replace('.', '/') self._base_output_directory = "%s/java" % (self._output) self.output_directory = "%s/src/main/java/%s" % ( self._base_output_directory, self._package_subdir) self.override_folder = os.path.normpath("%s/__overrides" % self._base_output_directory) self.fetchers_path = "/fetchers/" self.attrs_defaults = RawConfigParser() path = "%s/java/__attributes_defaults/attrs_defaults.ini" % self._output self.attrs_defaults.optionxform = str self.attrs_defaults.read(path) self.attrs_types = RawConfigParser() path = "%s/java/__attributes_defaults/attrs_types.ini" % self._output self.attrs_types.optionxform = str self.attrs_types.read(path) self.library_version = self.monolithe_config.get_option( "version", "transformer") with open("%s/java/__code_header" % self._output, "r") as f: self.header_content = f.read()
def assertPluralNameEquals(self, singular_name, entity_name_plural): """ Check that the remote name is well converted to the python name """ self.assertEqual(SDKUtils.get_plural(singular_name), entity_name_plural)
def __init__(self, monolithe_config, api_info): """ Initializes a _JavaSDKAPIVersionFileWriter """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.java") self.api_version = api_info["version"] self._api_version_string = SDKUtils.get_string_version(self.api_version) self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option("output", "transformer") self._name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = "" self._product_accronym = self.monolithe_config.get_option("product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/java/%s/%s" % (self._output, self._name, self._api_version_string) self.override_folder = os.path.normpath("%s/../../__overrides" % self.output_directory) self.fetchers_path = "/fetchers/" self.enums_path = "/enums" with open("%s/java/__code_header" % self._output, "r") as f: self.header_content = f.read()
def __init__(self, monolithe_config, api_info): """ Initializes a _JavaSDKAPIVersionFileWriter """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.java") self.api_version = api_info["version"] self._api_version_string = SDKUtils.get_string_version(self.api_version) self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option("output", "transformer") self._name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = "" self._product_accronym = self.monolithe_config.get_option("product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self._url = self.monolithe_config.get_option("url", "transformer") self._package_prefix = self._get_package_prefix(self._url) self._package_name = self._package_prefix + '.' + self._name + '.' + SDKUtils.get_string_version(self.api_version) self._package_subdir = self._package_name.replace('.', '/') self._base_output_directory = "%s/java" % (self._output) self.output_directory = "%s/src/main/java/%s" % (self._base_output_directory, self._package_subdir) self.override_folder = os.path.normpath("%s/__overrides" % self._base_output_directory) self.fetchers_path = "/fetchers/" self.attrs_defaults = RawConfigParser() path = "%s/java/__attributes_defaults/attrs_defaults.ini" % self._output self.attrs_defaults.optionxform = str self.attrs_defaults.read(path) self.attrs_types = RawConfigParser() path = "%s/java/__attributes_defaults/attrs_types.ini" % self._output self.attrs_types.optionxform = str self.attrs_types.read(path) library_info = RawConfigParser() path = "%s/java/__attributes_defaults/library.ini" % self._output library_info.optionxform = str library_info.read(path) self.library_version = library_info.get(self.api_version, "libraryVersion") with open("%s/java/__code_header" % self._output, "r") as f: self.header_content = f.read()
def _write_documentation(self, apiversions): destination = "%s/doc" % self.output_directory self.write( destination=destination, filename="index.rst", template_name="index.rst.tpl", apiversions=[SDKUtils.get_string_version(version) for version in apiversions] )
def write(self): """ """ task_manager = TaskManager() self.writer = SDKDocFileWriter(self.monolithe_config) self.writer.write_index() self.writer.write_conf() self.writer.write_general_concepts() # bambou bambou_module = importlib.import_module("bambou") bambou_classes = self._parse_module(bambou_module) self.writer.write_bambou_reference() for bambou_class in bambou_classes: task_manager.start_task(self._write_class_references, bambou_class, "bambou", "bambou", "bambou") # sdk generated_sdk_path = "%s/%s" % (self._sdk_output, self._sdk_name) for folder in os.listdir(generated_sdk_path): if folder == "cli": continue if not os.path.isdir("%s/%s" % (generated_sdk_path, folder)): continue version = SDKUtils.get_float_version(folder) self.writer.write_sdk_version_reference(version) # sdk model sdk_model_module_name = "%s.%s" % (self._sdk_name, folder) sdk_model_module = importlib.import_module(sdk_model_module_name) sdk_model_classes = self._parse_module(sdk_model_module) for sdk_model_class in sdk_model_classes: task_manager.start_task(self._write_class_references, sdk_model_class, sdk_model_module_name, "models", "%s/%s" % (self._sdk_name, version)) # sdk fetchers sdk_fetcher_module_name = "%s.%s.fetchers" % (self._sdk_name, folder) sdk_fetcher_module = importlib.import_module( sdk_fetcher_module_name) sdk_fetcher_classes = self._parse_module(sdk_fetcher_module) for sdk_fetcher_class in sdk_fetcher_classes: task_manager.start_task(self._write_class_references, sdk_fetcher_class, sdk_fetcher_module_name, "fetchers", "%s/%s" % (self._sdk_name, version)) task_manager.wait_until_exit()
def _write_documentation(self, apiversions): destination = "%s/doc" % self.output_directory self.write(destination=destination, filename="index.rst", template_name="index.rst.tpl", apiversions=[ SDKUtils.get_string_version(version) for version in apiversions ])
def _write_manifest(self, apiversions): """ """ self.write(destination=self.output_directory, filename="MANIFEST.in", template_name="MANIFEST.in.tpl", name=self._transformation_name, apiversions=[ SDKUtils.get_string_version(version) for version in apiversions ])
def _write_main_index(self, apiversions): """ """ versions = {} for v in apiversions: versions[v] = SDKUtils.get_string_version(v) self.write(destination=self.output_directory, filename="index.html", template_name="main_index.html.tpl", apiversion=versions, product_name=self._product_name)
def __init__(self, monolithe_config, api_info): """ """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.html") self.monolithe_config = monolithe_config self._api_version = api_info["version"] self._output = self.monolithe_config.get_option("output", "transformer") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/html/%s" % (self._output, SDKUtils.get_string_version(self._api_version))
def __init__(self, monolithe_config, api_info): super(DocumentationWriter, self).__init__(package="monolithe.generators.lang.python") self.api_version = api_info["version"] self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option("output", "transformer") self._transformation_name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = self.monolithe_config.get_option("class_prefix", "transformer") self._product_accronym = self.monolithe_config.get_option("product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/python/doc/%s" % (self._output, SDKUtils.get_string_version(self.api_version))
def write(self): """ """ task_manager = TaskManager() self.writer = SDKDocFileWriter(self.monolithe_config) self.writer.write_index() self.writer.write_conf() self.writer.write_general_concepts() # bambou bambou_module = importlib.import_module("bambou") bambou_classes = self._parse_module(bambou_module) self.writer.write_bambou_reference() for bambou_class in bambou_classes: task_manager.start_task(self._write_class_references, bambou_class, "bambou", "bambou", "bambou") # sdk generated_sdk_path = "%s/%s" % (self._sdk_output, self._sdk_name) for folder in os.listdir(generated_sdk_path): if folder == "cli": continue if not os.path.isdir("%s/%s" % (generated_sdk_path, folder)): continue version = SDKUtils.get_float_version(folder) self.writer.write_sdk_version_reference(version) # sdk model sdk_model_module_name = "%s.%s" % (self._sdk_name, folder) sdk_model_module = importlib.import_module(sdk_model_module_name) sdk_model_classes = self._parse_module(sdk_model_module) for sdk_model_class in sdk_model_classes: task_manager.start_task(self._write_class_references, sdk_model_class, sdk_model_module_name, "models", "%s/%s" % (self._sdk_name, version)) # sdk fetchers sdk_fetcher_module_name = "%s.%s.fetchers" % (self._sdk_name, folder) sdk_fetcher_module = importlib.import_module(sdk_fetcher_module_name) sdk_fetcher_classes = self._parse_module(sdk_fetcher_module) for sdk_fetcher_class in sdk_fetcher_classes: task_manager.start_task(self._write_class_references, sdk_fetcher_class, sdk_fetcher_module_name, "fetchers", "%s/%s" % (self._sdk_name, version)) task_manager.wait_until_exit()
def __init__(self, monolithe_config, api_info): """ """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.html") self.monolithe_config = monolithe_config self._api_version = api_info["version"] self._output = self.monolithe_config.get_option( "output", "transformer") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/html/%s" % ( self._output, SDKUtils.get_string_version(self._api_version))
def __init__(self, monolithe_config, api_info): super(DocumentationWriter, self).__init__(package="monolithe.generators.lang.python") self.api_version = api_info["version"] self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option( "output", "transformer") self._transformation_name = self.monolithe_config.get_option( "name", "transformer") self._class_prefix = self.monolithe_config.get_option( "class_prefix", "transformer") self._product_accronym = self.monolithe_config.get_option( "product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/python/doc/%s" % ( self._output, SDKUtils.get_string_version(self.api_version))
def __init__(self, monolithe_config, api_info): """ Initializes a _SDKAPIVersionFileWriter """ super(_SDKAPIVersionFileWriter, self).__init__(package="monolithe.generators.sdk") self.api_version = api_info["version"] self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._sdk_output = self.monolithe_config.get_option("sdk_output", "sdk") self._sdk_name = self.monolithe_config.get_option("sdk_name", "sdk") self._sdk_class_prefix = self.monolithe_config.get_option("sdk_class_prefix", "sdk") self._product_accronym = self.monolithe_config.get_option("product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self.output_directory = "%s/%s/%s" % (self._sdk_output, self._sdk_name, SDKUtils.get_string_version(self.api_version)) self.override_folder = os.path.normpath("%s/../../__overrides" % self.output_directory) self.fetchers_path = "/fetchers/" with open("%s/__code_header" % self._sdk_output, "r") as f: self.header_content = f.read()
def type(self, value): """ """ self._type = SDKUtils.massage_type_name(type_name=value) self.local_type = SDKUtils.get_python_type_name(type_name=value)
def _write_manifest(self, apiversions): """ """ self.write(destination=self.output_directory, filename="MANIFEST.in", template_name="MANIFEST.in.tpl", name=self._transformation_name, apiversions=[SDKUtils.get_string_version(version) for version in apiversions])
def __init__(self, monolithe_config, api_info): """ Initializes a _JavaSDKAPIVersionFileWriter """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.vro") self.api_version = api_info["version"] self._api_version_string = SDKUtils.get_string_version( self.api_version) self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option( "output", "transformer") self._name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = "" self._product_accronym = self.monolithe_config.get_option( "product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self._url = self.monolithe_config.get_option("url", "transformer") self._package_prefix = self._get_package_prefix(self._url) self._package_name = self._package_prefix + ".vro." + self._name self._package_subdir = self._package_name.replace('.', '/') self.output_directory = "%s/vro" % (self._output) self.override_folder = os.path.normpath("%s/__overrides" % self.output_directory) self.fetchers_path = "/fetchers/" self.enums_path = "/enums/" self.attrs_defaults = RawConfigParser() path = "%s/vro/__attributes_defaults/attrs_defaults.ini" % self._output self.attrs_defaults.optionxform = str self.attrs_defaults.read(path) self.inventory_entities = RawConfigParser() path = "%s/vro/__attributes_defaults/inventory_entities.ini" % self._output self.inventory_entities.optionxform = str self.inventory_entities.read(path) self.workflow_attrs = RawConfigParser() path = "%s/vro/__attributes_defaults/workflow_attrs.ini" % self._output self.workflow_attrs.optionxform = str self.workflow_attrs.read(path) self.attrs_types = RawConfigParser() path = "%s/vro/__attributes_defaults/attrs_types.ini" % self._output self.attrs_types.optionxform = str self.attrs_types.read(path) plugin_info = RawConfigParser() path = "%s/vro/__attributes_defaults/plugin.ini" % self._output plugin_info.optionxform = str plugin_info.read(path) self.plugin_version = plugin_info.get(self.api_version, "pluginVersion") workflow_info = RawConfigParser() path = "%s/vro/__attributes_defaults/workflow.ini" % self._output workflow_info.optionxform = str workflow_info.read(path) self.workflow_version = workflow_info.get(self.api_version, "workflowVersion") with open("%s/vro/__code_header" % self._output, "r") as f: self.header_content = f.read()
def assertPluralNameEquals(self, singular_name, entity_name_plural): """ Check that the remote name is well converted to the python name """ self.assertEqual(SDKUtils.get_entity_name_plural(singular_name), entity_name_plural)
def __init__(self, monolithe_config, api_info): """ Initializes a _JavaSDKAPIVersionFileWriter """ super(APIVersionWriter, self).__init__(package="monolithe.generators.lang.vro") self.api_version = api_info["version"] self._api_version_string = SDKUtils.get_string_version(self.api_version) self.api_root = api_info["root"] self.api_prefix = api_info["prefix"] self.monolithe_config = monolithe_config self._output = self.monolithe_config.get_option("output", "transformer") self._name = self.monolithe_config.get_option("name", "transformer") self._class_prefix = "" self._product_accronym = self.monolithe_config.get_option("product_accronym") self._product_name = self.monolithe_config.get_option("product_name") self._url = self.monolithe_config.get_option("url", "transformer") self._package_prefix = self._get_package_prefix(self._url) self._package_name = self._package_prefix + ".vro." + self._name self._package_subdir = self._package_name.replace('.', '/') self.output_directory = "%s/vro" % (self._output) self.override_folder = os.path.normpath("%s/__overrides" % self.output_directory) self.fetchers_path = "/fetchers/" self.enums_path = "/enums/" self.attrs_defaults = RawConfigParser() path = "%s/vro/__attributes_defaults/attrs_defaults.ini" % self._output self.attrs_defaults.optionxform = str self.attrs_defaults.read(path) self.inventory_entities = RawConfigParser() path = "%s/vro/__attributes_defaults/inventory_entities.ini" % self._output self.inventory_entities.optionxform = str self.inventory_entities.read(path) self.workflow_attrs = RawConfigParser() path = "%s/vro/__attributes_defaults/workflow_attrs.ini" % self._output self.workflow_attrs.optionxform = str self.workflow_attrs.read(path) self.attrs_types = RawConfigParser() path = "%s/vro/__attributes_defaults/attrs_types.ini" % self._output self.attrs_types.optionxform = str self.attrs_types.read(path) plugin_info = RawConfigParser() path = "%s/vro/__attributes_defaults/plugin.ini" % self._output plugin_info.optionxform = str plugin_info.read(path) self.plugin_version = plugin_info.get(self.api_version, "pluginVersion") workflow_info = RawConfigParser() path = "%s/vro/__attributes_defaults/workflow.ini" % self._output workflow_info.optionxform = str workflow_info.read(path) self.workflow_version = workflow_info.get(self.api_version, "workflowVersion") with open("%s/vro/__code_header" % self._output, "r") as f: self.header_content = f.read()
def assertPythonNameEquals(self, rest_name, python_name): """ Check that the remote name is well converted to the python name """ self.assertEqual(SDKUtils.get_python_name(rest_name), python_name)
def assertPythonNameEquals(self, rest_name, python_name): """ Check that the remote name is well converted to the python name """ self.assertEqual(SDKUtils.get_idiomatic_name_in_language(rest_name, 'python'), python_name)