Loading utils/oids/oid.md +51 −51 Original line number Diff line number Diff line Loading @@ -3,67 +3,67 @@ graph TD; 0["itu-t (0)"] 0.4["identified-organization (4)"] 0-->0.4 0.4.0["etsi (0)"] 0.4-->0.4.0 0.4.0.3280["common-parameters (3280)"] 0.4.0.2["securityDomain (2)"] 0.4.0-->0.4.0.2 0.4.0.2.4["informationHandover (4)"] 0.4.0.2.2["lawfulIntercept (2)"] 0.4.0.2-->0.4.0.2.2 0.4.0.2.3["retainedData (3)"] 0.4.0.3280.261["version261 (261)"] 0.4.0.2.2.1["hi2 (1)"] 0.4.0.2.2.0["hi1 (0)"] 0.4.0.2.2-->0.4.0.2.2.0 0.4.0.2.3.0["rdHeader (0)"] 0.4.0.2.4.0["ilhi (0)"] 0.4.0.2.2.5["li-ps (5)"] 0.4.0.2.2.4["l2Access (4)"] 0.4.0.2.2.5.3["iPAccess (3)"] 0.4.0.2.2.4.10["version10 (10)"] 0.4.0.2.2.5.2["email (2)"] 0.4.0.2.3.0.33["version33 (33)"] 0.4.0.2.2.0.1["notificationOperations (1)"] 0.4.0.2.2.0-->0.4.0.2.2.0.1 0.4.0.2.2.0.1.7["version7 (7)"] 0.4.0.2.2.0.1-->0.4.0.2.2.0.1.7 0.4.0.2.2.1["hi2 (1)"] 0.4.0.2.2-->0.4.0.2.2.1 0.4.0.2.4.0.0["ilhiPdu (0)"] 0.4.0.2.2.5.5["iPMultimedia (5)"] 0.4.0.2.2.1.18["version17 (18)"] 0.4.0.2.2.1-->0.4.0.2.2.1.18 0.4.0.2.2.5["li-ps (5)"] 0.4.0.2.2-->0.4.0.2.2.5 0.4.0.2.2.5.6["pstnIsdn (6)"] 0.4.0.2.2.5.1["genHeader (1)"] 0.4.0.2.2.5-->0.4.0.2.2.5.1 0.4.0.2.2.5.1.40["version40 (40)"] 0.4.0.2.2.5.6.6["version6 (6)"] 0.4.0.2.2.5.3.20["version20 (20)"] 0.4.0.2.2.5.2.20["version20 (20)"] 0.4.0.2.2.5.5.17["version17 (17)"] 0.4.0.2.2.0.1.7["version7 (7)"] 0.4.0.2.4.0.0.2["version2 (2)"] 0.4.0.2.2.4-->0.4.0.2.2.4.10 0.4.0.2.4.0.0-->0.4.0.2.4.0.0.2 0.4.0.2.2.5.1-->0.4.0.2.2.5.1.40 0.4.0.2.2.5.2["email (2)"] 0.4.0.2.2.5-->0.4.0.2.2.5.1 0.4.0.2.2.5-->0.4.0.2.2.5.6 0.4.0.2.2.5-->0.4.0.2.2.5.3 0.4.0-->0.4.0.3280 0.4.0-->0.4.0.2 0.4.0.2.2.0-->0.4.0.2.2.0.1 0.4.0.2.2.5-->0.4.0.2.2.5.2 0.4.0.2.2.5.2.20["version20 (20)"] 0.4.0.2.2.5.2-->0.4.0.2.2.5.2.20 0.4.0.2.2.5.3["iPAccess (3)"] 0.4.0.2.2.5-->0.4.0.2.2.5.3 0.4.0.2.2.5.3.20["version20 (20)"] 0.4.0.2.2.5.3-->0.4.0.2.2.5.3.20 0.4.0.2.2.5.5["iPMultimedia (5)"] 0.4.0.2.2.5-->0.4.0.2.2.5.5 0.4.0.2.2.5.5.17["version17 (17)"] 0.4.0.2.2-->0.4.0.2.2.4 0.4.0.2.2.1-->0.4.0.2.2.1.18 0.4.0.2.2.5.5-->0.4.0.2.2.5.5.17 0.4.0.2.2.5.6["pstnIsdn (6)"] 0.4.0.2.2.5-->0.4.0.2.2.5.6 0.4.0.2.2.5.6.6["version6 (6)"] 0.4.0.2.4.0-->0.4.0.2.4.0.0 0.4-->0.4.0 0.4.0.2.2-->0.4.0.2.2.0 0-->0.4 0.4.0.2.3-->0.4.0.2.3.0 0.4.0.2.2.5.3-->0.4.0.2.2.5.3.20 0.4.0.2.2-->0.4.0.2.2.1 0.4.0.2.2.5.6-->0.4.0.2.2.5.6.6 0.4.0.2.2.4["l2Access (4)"] 0.4.0.2.2-->0.4.0.2.2.4 0.4.0.2.2.4.10["version10 (10)"] 0.4.0.2.2.4-->0.4.0.2.2.4.10 0.4.0.2.3["retainedData (3)"] 0.4.0.2-->0.4.0.2.3 0.4.0.2.3.0["rdHeader (0)"] 0.4.0.2.3-->0.4.0.2.3.0 0.4.0.2.3.0.33["version33 (33)"] 0.4.0.2.3.0-->0.4.0.2.3.0.33 0.4.0.2.4["informationHandover (4)"] 0.4.0.2-->0.4.0.2.4 0.4.0.2.4.0["ilhi (0)"] 0.4.0.2.2-->0.4.0.2.2.5 0.4.0.2-->0.4.0.2.2 0.4.0.2.4-->0.4.0.2.4.0 0.4.0.2.4.0.0["ilhiPdu (0)"] 0.4.0.2.4.0-->0.4.0.2.4.0.0 0.4.0.2.4.0.0.2["version2 (2)"] 0.4.0.2.4.0.0-->0.4.0.2.4.0.0.2 0.4.0.3280["common-parameters (3280)"] 0.4.0-->0.4.0.3280 0.4.0.3280.261["version261 (261)"] 0.4.0.2.2.5-->0.4.0.2.2.5.5 0.4.0.3280-->0.4.0.3280.261 0.4.0.2.3.0-->0.4.0.2.3.0.33 0.4.0.2.2.0.1-->0.4.0.2.2.0.1.7 ``` # OID list | Spec | Module name | Version | OID relative to {itu-t(0) identified-organization(4) etsi(0)} | Loading utils/oids/oid.py +34 −53 Original line number Diff line number Diff line Loading @@ -4,6 +4,18 @@ import re class OIDArc: ARC_REGEX = re.compile(r"(.+?)\(([0-9]+?)\)") def parse(s: str): oids = s.replace("\n","").replace("\r","").strip() oids = [x.strip() for x in oids.split(" ") if x != ""] arc_list = [OIDArc(oid) for oid in oids] for i, arc in enumerate(arc_list): if i > 0: arc.parent = arc_list[i - 1] if i < len(arc_list) - 1: arc.child = arc_list[i + 1] return arc_list[-1] def __init__(self, s: str): m = OIDArc.ARC_REGEX.match(s) if m is None: Loading @@ -11,7 +23,7 @@ class OIDArc: self.label = m[1] self.value = int(m[2]) self.parent = None self.children = [] self.child = None def __repr__(self): return f"<OIDArc {self.as_numerical()}>" Loading @@ -26,12 +38,6 @@ class OIDArc: parents = self.hierarchy()[starting_depth:] return " ".join([f"{p.label}({p.value})" for p in parents]) def get_child_by_value(self, index): for c in self.children: if c.value == index: return c return None def hierarchy(self) -> list: r = [self] p = self.parent Loading @@ -46,37 +52,6 @@ class OIDArc: return self return self.hierarchy()[0] def merge(self, other): if self.root().value != other.root().value: raise ValueError (f"Cannot merge OIDs with different roots ({self.root()} and {other.root()})") this_arc = self.root() other_arc = other.root() while len(other_arc.children) > 0: if len(other_arc.children) > 1: raise ValueError(f"Can't merge with {other} as it has too many children ({len(other_arc.children)})") other_next_arc = other_arc.children[0] this_next_arc = this_arc.get_child_by_value(other_next_arc.value) if this_next_arc is None: other_next_arc.parent = this_arc this_arc.children.append(other_next_arc) return this_arc = this_next_arc other_arc = other_next_arc raise ValueError(f"OIDs {self} and {other} do not intersect") def parse_oid_string(s: str): oids = s.replace("\n","").replace("\r","").strip() oids = [x.strip() for x in oids.split(" ") if x != ""] arc_list = [OIDArc(oid) for oid in oids] for i, arc in enumerate(arc_list): if i > 0: arc.parent = arc_list[i - 1] if i < len(arc_list) - 1: arc.children.append(arc_list[i + 1]) return arc_list[-1] regex = re.compile(r"^(.+?){(.*?)}", re.DOTALL) arc_regex = re.compile(r"(.+?)\(([0-9]+?)\)") root = Path("./") Loading @@ -87,7 +62,7 @@ markdown_string = "# OID list\n" markdown_string += "| Spec | Module name | Version | OID relative to {itu-t(0) identified-organization(4) etsi(0)} |\n" markdown_string += "| ---- | ----------- | ------- | -------- |\n" oid_tree = None oids = [] for asn_file in asn_files: if asn_file.parts[0] == "testing": Loading @@ -99,26 +74,32 @@ for asn_file in asn_files: for match in matches: module_name = match[0].strip() link = f"[{module_name}]({url})" oid = parse_oid_string(match[1]) oid = OIDArc.parse(match[1]) relative_oids = oid.as_relative(3) if oid_tree is None: oid_tree = oid.root() else: oid_tree.merge(oid) oids.append(oid) markdown_string += f"|[{spec}](https://forge.etsi.org/rep/li/schemas-definitions/-/blob/main/{'/'.join(asn_file.parts[:-1])})|{link}|{oid.value}|{relative_oids}|\n" oid_arc_sets = [] oid_arc_edges = set() for oid in oids: arc_list = oid.hierarchy() for i, a in enumerate(arc_list): if len(oid_arc_sets) < i + 1: oid_arc_sets.append(set()) oid_arc_sets[i].add(f'{a.as_numerical()}["{a.label} ({a.value})"]\n') if a.child is not None: oid_arc_edges.add(f'{a.as_numerical()}-->{a.child.as_numerical()}\n') dia_string = "# OID hierarchy\n" dia_string += '```mermaid\ngraph TD;\n 0["itu-t (0)"]\n' dia_string += '```mermaid\ngraph TD;\n' for level in oid_arc_sets: for item in level: dia_string += item def draw_tree(d : OIDArc): global dia_string for child in d.children: dia_string += f'{child.as_numerical()}["{child.label} ({child.value})"]\n' dia_string += f" {d.as_numerical()}-->{child.as_numerical()}\n" draw_tree(child) for edge in oid_arc_edges: dia_string += edge draw_tree(oid_tree) dia_string += "```" out_file = Path("./utils/oids/oid.md") Loading Loading
utils/oids/oid.md +51 −51 Original line number Diff line number Diff line Loading @@ -3,67 +3,67 @@ graph TD; 0["itu-t (0)"] 0.4["identified-organization (4)"] 0-->0.4 0.4.0["etsi (0)"] 0.4-->0.4.0 0.4.0.3280["common-parameters (3280)"] 0.4.0.2["securityDomain (2)"] 0.4.0-->0.4.0.2 0.4.0.2.4["informationHandover (4)"] 0.4.0.2.2["lawfulIntercept (2)"] 0.4.0.2-->0.4.0.2.2 0.4.0.2.3["retainedData (3)"] 0.4.0.3280.261["version261 (261)"] 0.4.0.2.2.1["hi2 (1)"] 0.4.0.2.2.0["hi1 (0)"] 0.4.0.2.2-->0.4.0.2.2.0 0.4.0.2.3.0["rdHeader (0)"] 0.4.0.2.4.0["ilhi (0)"] 0.4.0.2.2.5["li-ps (5)"] 0.4.0.2.2.4["l2Access (4)"] 0.4.0.2.2.5.3["iPAccess (3)"] 0.4.0.2.2.4.10["version10 (10)"] 0.4.0.2.2.5.2["email (2)"] 0.4.0.2.3.0.33["version33 (33)"] 0.4.0.2.2.0.1["notificationOperations (1)"] 0.4.0.2.2.0-->0.4.0.2.2.0.1 0.4.0.2.2.0.1.7["version7 (7)"] 0.4.0.2.2.0.1-->0.4.0.2.2.0.1.7 0.4.0.2.2.1["hi2 (1)"] 0.4.0.2.2-->0.4.0.2.2.1 0.4.0.2.4.0.0["ilhiPdu (0)"] 0.4.0.2.2.5.5["iPMultimedia (5)"] 0.4.0.2.2.1.18["version17 (18)"] 0.4.0.2.2.1-->0.4.0.2.2.1.18 0.4.0.2.2.5["li-ps (5)"] 0.4.0.2.2-->0.4.0.2.2.5 0.4.0.2.2.5.6["pstnIsdn (6)"] 0.4.0.2.2.5.1["genHeader (1)"] 0.4.0.2.2.5-->0.4.0.2.2.5.1 0.4.0.2.2.5.1.40["version40 (40)"] 0.4.0.2.2.5.6.6["version6 (6)"] 0.4.0.2.2.5.3.20["version20 (20)"] 0.4.0.2.2.5.2.20["version20 (20)"] 0.4.0.2.2.5.5.17["version17 (17)"] 0.4.0.2.2.0.1.7["version7 (7)"] 0.4.0.2.4.0.0.2["version2 (2)"] 0.4.0.2.2.4-->0.4.0.2.2.4.10 0.4.0.2.4.0.0-->0.4.0.2.4.0.0.2 0.4.0.2.2.5.1-->0.4.0.2.2.5.1.40 0.4.0.2.2.5.2["email (2)"] 0.4.0.2.2.5-->0.4.0.2.2.5.1 0.4.0.2.2.5-->0.4.0.2.2.5.6 0.4.0.2.2.5-->0.4.0.2.2.5.3 0.4.0-->0.4.0.3280 0.4.0-->0.4.0.2 0.4.0.2.2.0-->0.4.0.2.2.0.1 0.4.0.2.2.5-->0.4.0.2.2.5.2 0.4.0.2.2.5.2.20["version20 (20)"] 0.4.0.2.2.5.2-->0.4.0.2.2.5.2.20 0.4.0.2.2.5.3["iPAccess (3)"] 0.4.0.2.2.5-->0.4.0.2.2.5.3 0.4.0.2.2.5.3.20["version20 (20)"] 0.4.0.2.2.5.3-->0.4.0.2.2.5.3.20 0.4.0.2.2.5.5["iPMultimedia (5)"] 0.4.0.2.2.5-->0.4.0.2.2.5.5 0.4.0.2.2.5.5.17["version17 (17)"] 0.4.0.2.2-->0.4.0.2.2.4 0.4.0.2.2.1-->0.4.0.2.2.1.18 0.4.0.2.2.5.5-->0.4.0.2.2.5.5.17 0.4.0.2.2.5.6["pstnIsdn (6)"] 0.4.0.2.2.5-->0.4.0.2.2.5.6 0.4.0.2.2.5.6.6["version6 (6)"] 0.4.0.2.4.0-->0.4.0.2.4.0.0 0.4-->0.4.0 0.4.0.2.2-->0.4.0.2.2.0 0-->0.4 0.4.0.2.3-->0.4.0.2.3.0 0.4.0.2.2.5.3-->0.4.0.2.2.5.3.20 0.4.0.2.2-->0.4.0.2.2.1 0.4.0.2.2.5.6-->0.4.0.2.2.5.6.6 0.4.0.2.2.4["l2Access (4)"] 0.4.0.2.2-->0.4.0.2.2.4 0.4.0.2.2.4.10["version10 (10)"] 0.4.0.2.2.4-->0.4.0.2.2.4.10 0.4.0.2.3["retainedData (3)"] 0.4.0.2-->0.4.0.2.3 0.4.0.2.3.0["rdHeader (0)"] 0.4.0.2.3-->0.4.0.2.3.0 0.4.0.2.3.0.33["version33 (33)"] 0.4.0.2.3.0-->0.4.0.2.3.0.33 0.4.0.2.4["informationHandover (4)"] 0.4.0.2-->0.4.0.2.4 0.4.0.2.4.0["ilhi (0)"] 0.4.0.2.2-->0.4.0.2.2.5 0.4.0.2-->0.4.0.2.2 0.4.0.2.4-->0.4.0.2.4.0 0.4.0.2.4.0.0["ilhiPdu (0)"] 0.4.0.2.4.0-->0.4.0.2.4.0.0 0.4.0.2.4.0.0.2["version2 (2)"] 0.4.0.2.4.0.0-->0.4.0.2.4.0.0.2 0.4.0.3280["common-parameters (3280)"] 0.4.0-->0.4.0.3280 0.4.0.3280.261["version261 (261)"] 0.4.0.2.2.5-->0.4.0.2.2.5.5 0.4.0.3280-->0.4.0.3280.261 0.4.0.2.3.0-->0.4.0.2.3.0.33 0.4.0.2.2.0.1-->0.4.0.2.2.0.1.7 ``` # OID list | Spec | Module name | Version | OID relative to {itu-t(0) identified-organization(4) etsi(0)} | Loading
utils/oids/oid.py +34 −53 Original line number Diff line number Diff line Loading @@ -4,6 +4,18 @@ import re class OIDArc: ARC_REGEX = re.compile(r"(.+?)\(([0-9]+?)\)") def parse(s: str): oids = s.replace("\n","").replace("\r","").strip() oids = [x.strip() for x in oids.split(" ") if x != ""] arc_list = [OIDArc(oid) for oid in oids] for i, arc in enumerate(arc_list): if i > 0: arc.parent = arc_list[i - 1] if i < len(arc_list) - 1: arc.child = arc_list[i + 1] return arc_list[-1] def __init__(self, s: str): m = OIDArc.ARC_REGEX.match(s) if m is None: Loading @@ -11,7 +23,7 @@ class OIDArc: self.label = m[1] self.value = int(m[2]) self.parent = None self.children = [] self.child = None def __repr__(self): return f"<OIDArc {self.as_numerical()}>" Loading @@ -26,12 +38,6 @@ class OIDArc: parents = self.hierarchy()[starting_depth:] return " ".join([f"{p.label}({p.value})" for p in parents]) def get_child_by_value(self, index): for c in self.children: if c.value == index: return c return None def hierarchy(self) -> list: r = [self] p = self.parent Loading @@ -46,37 +52,6 @@ class OIDArc: return self return self.hierarchy()[0] def merge(self, other): if self.root().value != other.root().value: raise ValueError (f"Cannot merge OIDs with different roots ({self.root()} and {other.root()})") this_arc = self.root() other_arc = other.root() while len(other_arc.children) > 0: if len(other_arc.children) > 1: raise ValueError(f"Can't merge with {other} as it has too many children ({len(other_arc.children)})") other_next_arc = other_arc.children[0] this_next_arc = this_arc.get_child_by_value(other_next_arc.value) if this_next_arc is None: other_next_arc.parent = this_arc this_arc.children.append(other_next_arc) return this_arc = this_next_arc other_arc = other_next_arc raise ValueError(f"OIDs {self} and {other} do not intersect") def parse_oid_string(s: str): oids = s.replace("\n","").replace("\r","").strip() oids = [x.strip() for x in oids.split(" ") if x != ""] arc_list = [OIDArc(oid) for oid in oids] for i, arc in enumerate(arc_list): if i > 0: arc.parent = arc_list[i - 1] if i < len(arc_list) - 1: arc.children.append(arc_list[i + 1]) return arc_list[-1] regex = re.compile(r"^(.+?){(.*?)}", re.DOTALL) arc_regex = re.compile(r"(.+?)\(([0-9]+?)\)") root = Path("./") Loading @@ -87,7 +62,7 @@ markdown_string = "# OID list\n" markdown_string += "| Spec | Module name | Version | OID relative to {itu-t(0) identified-organization(4) etsi(0)} |\n" markdown_string += "| ---- | ----------- | ------- | -------- |\n" oid_tree = None oids = [] for asn_file in asn_files: if asn_file.parts[0] == "testing": Loading @@ -99,26 +74,32 @@ for asn_file in asn_files: for match in matches: module_name = match[0].strip() link = f"[{module_name}]({url})" oid = parse_oid_string(match[1]) oid = OIDArc.parse(match[1]) relative_oids = oid.as_relative(3) if oid_tree is None: oid_tree = oid.root() else: oid_tree.merge(oid) oids.append(oid) markdown_string += f"|[{spec}](https://forge.etsi.org/rep/li/schemas-definitions/-/blob/main/{'/'.join(asn_file.parts[:-1])})|{link}|{oid.value}|{relative_oids}|\n" oid_arc_sets = [] oid_arc_edges = set() for oid in oids: arc_list = oid.hierarchy() for i, a in enumerate(arc_list): if len(oid_arc_sets) < i + 1: oid_arc_sets.append(set()) oid_arc_sets[i].add(f'{a.as_numerical()}["{a.label} ({a.value})"]\n') if a.child is not None: oid_arc_edges.add(f'{a.as_numerical()}-->{a.child.as_numerical()}\n') dia_string = "# OID hierarchy\n" dia_string += '```mermaid\ngraph TD;\n 0["itu-t (0)"]\n' dia_string += '```mermaid\ngraph TD;\n' for level in oid_arc_sets: for item in level: dia_string += item def draw_tree(d : OIDArc): global dia_string for child in d.children: dia_string += f'{child.as_numerical()}["{child.label} ({child.value})"]\n' dia_string += f" {d.as_numerical()}-->{child.as_numerical()}\n" draw_tree(child) for edge in oid_arc_edges: dia_string += edge draw_tree(oid_tree) dia_string += "```" out_file = Path("./utils/oids/oid.md") Loading