<commit_before>import xml.etree.ElementTree as ElementTree
import autosar.base

class Element(object):
   def __init__(self, name, parent=None, adminData=None):
      if isinstance(adminData, dict):
         adminDataObj=autosar.base.createAdminData(adminData)
      else:
         adminDataObj = adminData
      if (adminDataObj is not None) and not isinstance(adminDataObj, autosar.base.AdminData):
         raise ValueError("adminData must be of type dict or autosar.base.AdminData")
      self.name=name
      self.adminData=adminDataObj
      self.parent=parent
      
   @property
   def ref(self):
      if self.parent is not None:
         return self.parent.ref+'/%s'%self.name
      else:
         return None
   
   def asdict(self):
      data={'type': self.__class__.__name__}
      for key, value in self.__dict__.items():
         if value is not None:
            if key=='adminData':
               if self.adminData is not None:
                  data['adminData']=self.adminData.asdict()
            elif key=='parent':
               continue
            else:
               if hasattr(value,'asdict'):
                  #print('complex'+str(type(value)))
                  data[key]=value.asdict()
               else:
                  #print('simple'+str(type(value)))
                  data[key]=value
      return data
   
   def rootWS(self):
      if self.parent is None:
         return None
      else:
         return self.parent.rootWS()
   
   def __deepcopy__(self,memo):
      raise NotImplementedError(type(self))

class DataElement(Element):
   def tag(self,version): return "VARIABLE-DATA-PROTOTYPE" if version >= 4.0 else "DATA-ELEMENT-PROTOTYPE"
   def __init__(self, name, typeRef, isQueued=False, softwareAddressMethodRef=None, swCalibrationAccess=None, swImplPolicy = None, parent=None, adminData=None):
      super().__init__(name,parent,adminData)
      if isinstance(typeRef,str):
         self.typeRef=typeRef
      elif hasattr(typeRef,'ref'):
         assert(isinstance(typeRef.ref,str))
         self.typeRef=typeRef.ref
      else:
         raise ValueError("unsupported type for argument: typeRef")
      assert(isinstance(isQueued,bool))
      self.isQueued=isQueued
      self.swAddressMethodRef = softwareAddressMethodRef
      self.swCalibrationAccess = swCalibrationAccess
      self.swImplPolicy = swImplPolicy
      self.dataConstraintRef = None
         
   @property
   def swImplPolicy(self):
      return self._swImplPolicy

   @swImplPolicy.setter
   def swImplPolicy(self, value):
      if value is None:
         self._swImplPolicy=None
      else:
         ucvalue=str(value).upper()
         enum_values = ["CONST", "FIXED", "MEASUREMENT-POINT", "QUEUED", "STANDARD"]
         if ucvalue in enum_values:
            self._swImplPolicy = ucvalue
            if ucvalue == 'QUEUED':
               self.isQueued = True
         else:
            raise ValueError('invalid swImplPolicy value: ' +  value)
 
   def setProps(self, variant):
      if isinstance(variant, autosar.base.SwDataDefPropsConditional):
         self.swCalibrationAccess=variant.swCalibrationAccess
         self.swAddressMethodRef = variant.swAddressMethodRef
         self.swImplPolicy = variant.swImplPolicy
         self.dataConstraintRef = variant.dataConstraintRef
      else:<commit_msg>Renaming<commit_after>import xml.etree.ElementTree as ElementTree
import autosar.base

class Element(object):
   def __init__(self, name, parent=None, adminData=None):
      if isinstance(adminData, dict):
         adminDataObj=autosar.base.createAdminData(adminData)
      else:
         adminDataObj = adminData
      if (adminDataObj is not None) and not isinstance(adminDataObj, autosar.base.AdminData):
         raise ValueError("adminData must be of type dict or autosar.base.AdminData")
      self.name=name
      self.adminData=adminDataObj
      self.parent=parent
      
   @property
   def ref(self):
      if self.parent is not None:
         return self.parent.ref+'/%s'%self.name
      else:
         return None
   
   def asdict(self):
      data={'type': self.__class__.__name__}
      for key, value in self.__dict__.items():
         if value is not None:
            if key=='adminData':
               if self.adminData is not None:
                  data['adminData']=self.adminData.asdict()
            elif key=='parent':
               continue
            else:
               if hasattr(value,'asdict'):
                  #print('complex'+str(type(value)))
                  data[key]=value.asdict()
               else:
                  #print('simple'+str(type(value)))
                  data[key]=value
      return data
   
   def rootWS(self):
      if self.parent is None:
         return None
      else:
         return self.parent.rootWS()
   
   def __deepcopy__(self,memo):
      raise NotImplementedError(type(self))

class DataElement(Element):
   def tag(self,version): return "VARIABLE-DATA-PROTOTYPE" if version >= 4.0 else "DATA-ELEMENT-PROTOTYPE"
   def __init__(self, name, typeRef, isQueued=False, swAddressMethodRef=None, swCalibrationAccess=None, swImplPolicy = None, parent=None, adminData=None):
      super().__init__(name,parent,adminData)
      if isinstance(typeRef,str):
         self.typeRef=typeRef
      elif hasattr(typeRef,'ref'):
         assert(isinstance(typeRef.ref,str))
         self.typeRef=typeRef.ref
      else:
         raise ValueError("unsupported type for argument: typeRef")
      assert(isinstance(isQueued,bool))
      self.isQueued=isQueued
      self.swAddressMethodRef = swAddressMethodRef
      self.swCalibrationAccess = swCalibrationAccess
      self.swImplPolicy = swImplPolicy
      self.dataConstraintRef = None
         
   @property
   def swImplPolicy(self):
      return self._swImplPolicy

   @swImplPolicy.setter
   def swImplPolicy(self, value):
      if value is None:
         self._swImplPolicy=None
      else:
         ucvalue=str(value).upper()
         enum_values = ["CONST", "FIXED", "MEASUREMENT-POINT", "QUEUED", "STANDARD"]
         if ucvalue in enum_values:
            self._swImplPolicy = ucvalue
            if ucvalue == 'QUEUED':
               self.isQueued = True
         else:
            raise ValueError('invalid swImplPolicy value: ' +  value)
 
   def setProps(self, variant):
      if isinstance(variant, autosar.base.SwDataDefPropsConditional):
         self.swCalibrationAccess=variant.swCalibrationAccess
         self.swAddressMethodRef = variant.swAddressMethodRef
         self.swImplPolicy = variant.swImplPolicy
         self.dataConstraintRef = variant.dataConstraintRef
      else:
{'fraction_non_alphanumeric': 0.09661399548532731, 'fraction_numerical': 0.0006019563581640331, 'mean_word_length': 2.4850550603041426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7512967', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1889, 'n_words': 407}