def trim_json_suffix(name): """ Description: generate c language for parse json map string object Interface: None History: 2019-06-17 """ if name.endswith(JSON_SUFFIX) or name.endswith(REF_SUFFIX): name = name[:-len(JSON_SUFFIX)] return helpers.conv_to_c_style(name.replace('.', '_').replace('-', '_'))
def make_ref_name(refname, reffile): """ Description: generate c language for parse json map string object Interface: None History: 2019-06-17 """ prefix = get_prefix_from_file(reffile) if refname == "" or prefix.endswith(refname): return prefix return prefix + "_" + helpers.conv_to_c_style(refname)
def get_prefix_package(filepath, rootpath): """ Description: generate c language for parse json map string object Interface: None History: 2019-06-17 """ realpath = os.path.realpath(filepath) if realpath.startswith(rootpath) and len(realpath) > len(rootpath): return helpers.conv_to_c_style(os.path.dirname(realpath)[(len(rootpath) + 1):]) else: raise RuntimeError('schema path \"%s\" is not in scope of root path \"%s\"' \ % (realpath, rootpath))