Skip to content

Commit

Permalink
Added the datatypes_utils.py to the autosarfactory implementation cor…
Browse files Browse the repository at this point in the history
…responding to each of the releases
  • Loading branch information
Girish Chandran committed Nov 29, 2023
1 parent 11f4bd6 commit f868234
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 0 deletions.
37 changes: 37 additions & 0 deletions autosar_releases/autosar403/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar422/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar430/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar442/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar445/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar446/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar447/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar448/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar449/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
37 changes: 37 additions & 0 deletions autosar_releases/autosar450/datatype_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_int_value(text):
text = text.strip()
if len(text) > 1 and text[:1] == '0':
second_char = text[1:2]
if second_char == 'x' or second_char == 'X':
# hexa-decimal value
return int(text[2:], 16)
elif second_char == 'b' or second_char == 'B':
# binary value
return int(text[2:], 2)
else:
try:
# octal value
return int(text[2:], 8)
except:
# return as decimal value if the oct conversion doesn't work in the try
return int(text)
else:
# decimal value
return int(text)


def get_float_value(text):
text = text.strip()
return float(text)


def get_bool_value(text):
text = text.strip()
if text == '1' or text.lower() == 'true':
return True
else:
return False


def get_string_value(text):
return text.strip()
Loading

0 comments on commit f868234

Please sign in to comment.