trying to find out why there are so many different numbered versions
This commit is contained in:
14
CustomerType.txt
Normal file
14
CustomerType.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
def validate_StatusType1(self, value):
|
||||
# Validate type StatusType1, a restriction on xs:string.
|
||||
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
|
||||
if not isinstance(value, str):
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
|
||||
return False
|
||||
value = value
|
||||
enumerations = ['ALPINEBITS_HANDSHAKE']
|
||||
if value not in enumerations:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on StatusType1' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
|
||||
13
CustomerType125.txt
Normal file
13
CustomerType125.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
def validate_StatusType(self, value):
|
||||
# Validate type StatusType, a restriction on xs:string.
|
||||
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
|
||||
if not isinstance(value, str):
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
|
||||
return False
|
||||
value = value
|
||||
enumerations = ['ALPINEBITS_HANDSHAKE']
|
||||
if value not in enumerations:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on StatusType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
0
src/CustomerType.txt
Normal file
0
src/CustomerType.txt
Normal file
0
src/CustomerType125.txt
Normal file
0
src/CustomerType125.txt
Normal file
12
src/main.py
12
src/main.py
@@ -1,4 +1,5 @@
|
||||
from alpinebits_guestrequests import ResGuest, RoomStay
|
||||
from alpine_bits_classes import ResGuestType, ProfilesType, ProfileType, ProfileInfoType
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +8,17 @@ def main():
|
||||
print(guest1)
|
||||
|
||||
|
||||
profileInfo = ProfileInfoType()
|
||||
|
||||
profile = ProfileType()
|
||||
|
||||
|
||||
|
||||
profiles = ProfilesType()
|
||||
|
||||
resGuest = ResGuestType()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
77
src/postprocessing.py
Normal file
77
src/postprocessing.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Script to verify if all classes in alpine_bits_classes.py with the same base name (e.g., CustomerType, CustomerType125, CustomerType576)
|
||||
are structurally identical. This helps to identify duplicate dataclasses generated by generateDS.
|
||||
|
||||
Usage:
|
||||
python src/postprocessing.py
|
||||
|
||||
Requirements:
|
||||
- Only uses the standard library.
|
||||
"""
|
||||
|
||||
import ast
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
def get_class_basenames(classname):
|
||||
"""Returns the base name of a class (e.g., CustomerType125 -> CustomerType)"""
|
||||
return re.sub(r'\d+$', '', classname)
|
||||
|
||||
def extract_classes(filepath):
|
||||
"""Parse the file and extract all class definitions as AST nodes."""
|
||||
with open(filepath, "r", encoding="utf-8") as f:
|
||||
source = f.read()
|
||||
tree = ast.parse(source)
|
||||
classes = {}
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.ClassDef):
|
||||
classes[node.name] = node
|
||||
return classes
|
||||
|
||||
def class_struct_signature(class_node):
|
||||
"""Return a tuple representing the structure of the class: base classes, method names, attribute names."""
|
||||
bases = tuple(base.id if isinstance(base, ast.Name) else ast.dump(base) for base in class_node.bases)
|
||||
methods = []
|
||||
attrs = []
|
||||
for item in class_node.body:
|
||||
if isinstance(item, ast.FunctionDef):
|
||||
methods.append(item.name)
|
||||
elif isinstance(item, ast.Assign):
|
||||
for target in item.targets:
|
||||
if isinstance(target, ast.Name):
|
||||
attrs.append(target.id)
|
||||
return (bases, tuple(sorted(methods)), tuple(sorted(attrs)))
|
||||
|
||||
def main():
|
||||
file_path = Path(__file__).parent / "alpine_bits_classes.py"
|
||||
classes = extract_classes(file_path)
|
||||
grouped = defaultdict(list)
|
||||
for cname in classes:
|
||||
base = get_class_basenames(cname)
|
||||
grouped[base].append(cname)
|
||||
|
||||
identical = []
|
||||
different = []
|
||||
|
||||
for base, classnames in grouped.items():
|
||||
if len(classnames) > 1:
|
||||
sigs = [class_struct_signature(classes[c]) for c in classnames]
|
||||
if all(s == sigs[0] for s in sigs):
|
||||
identical.append((base, classnames))
|
||||
else:
|
||||
different.append((base, classnames))
|
||||
|
||||
print("=== Structurally Identical Groups ===")
|
||||
for base, classnames in identical:
|
||||
print(f"{base}: {', '.join(classnames)}")
|
||||
|
||||
print("\n=== Structurally Different Groups ===")
|
||||
for base, classnames in different:
|
||||
print(f"{base}: {', '.join(classnames)}")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user