Skip to content

Commit

Permalink
color warnings in yellow
Browse files Browse the repository at this point in the history
  • Loading branch information
lreiher committed Nov 26, 2024
1 parent 66cb7f9 commit 7429c2a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions utils/codegen/codegen-py/asn1CodeGenerationUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# SOFTWARE.
# ==============================================================================

import logging
import re
import warnings
import sys
from datetime import datetime
from typing import Dict, List, Optional, Tuple
Expand All @@ -33,6 +33,11 @@
import numpy as np


# color logging levels in output
logging.addLevelName(logging.WARNING, "\033[1;33m%s\033[1;0m" % logging.getLevelName(logging.WARNING))
logging.addLevelName(logging.ERROR, "\033[1;31m%s\033[1;0m" % logging.getLevelName(logging.ERROR))


GIT_REPO = git.Repo(search_parent_directories=True)
AUTO_GENERATE_COMMAND = "python3 " + " ".join(sys.argv)
AUTO_GENERATE_DATE = datetime.now().replace(microsecond=0).isoformat()
Expand Down Expand Up @@ -390,7 +395,7 @@ def checkTypeMembersInAsn1(asn1_types: Dict[str, Dict]):
# check if type is known
if member["type"] not in known_types:
if ".&" in member["type"]:
warnings.warn(
logging.warning(
f"Type '{member['type']}' of member '{member['name']}' "
f"in '{t_name}' seems to relate to a 'CLASS' type, not "
f"yet supported")
Expand All @@ -414,7 +419,7 @@ def asn1TypeToJinjaContext(t_name: str, asn1: Dict, asn1_types: Dict[str, Dict],
"""

if "components-of" in asn1: # TODO
warnings.warn(f"Handling of 'components-of' in '{t_name}' not yet supported.")
logging.warning(f"Handling of 'components-of' in '{t_name}' not yet supported")
return { # generate in a way such that compilation will not succeed
"asn1_definition": None,
"comments": [],
Expand Down Expand Up @@ -647,7 +652,7 @@ def asn1TypeToJinjaContext(t_name: str, asn1: Dict, asn1_types: Dict[str, Dict],
array_type = asn1['element']['type']

if array_type == "RegionalExtension":
warnings.warn(f"Handling of 'RegionalExtension' in '{t_name}' not yet supported.")
logging.warning(f"Handling of 'RegionalExtension' in '{t_name}' not yet supported")
return None

member_context = {
Expand Down Expand Up @@ -725,7 +730,7 @@ def asn1TypeToJinjaContext(t_name: str, asn1: Dict, asn1_types: Dict[str, Dict],
elif type in asn1_types:

if type == "RegionalExtension":
warnings.warn(f"Handling of 'RegionalExtension' in '{t_name}' not yet supported.")
logging.warning(f"Handling of 'RegionalExtension' in '{t_name}' not yet supported")
return None

name_cc = asn1["name"] if "name" in asn1 else "value"
Expand Down Expand Up @@ -776,6 +781,6 @@ def asn1TypeToJinjaContext(t_name: str, asn1: Dict, asn1_types: Dict[str, Dict],

else:

warnings.warn(f"Cannot handle type '{type}'")
logging.warning(f"Cannot handle type '{type}'")

return context

0 comments on commit 7429c2a

Please sign in to comment.