Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.py #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class Attribute(enum.Enum):
@enum.unique
class Category(enum.Enum):
SOURCE = "source"
HEADER = "header"

attr: Attribute
category: Category
Expand Down Expand Up @@ -280,7 +281,8 @@ def text(element: etree.ElementBase, name: str, is_attribute: bool = False, null

if (not value) and nullable:
return None

if value[0].text is None:
return ""
if len(value) != 1:
raise ValueError(f"Only one '{name}' tag per tree is supported, {len(value)} found")
return value[0].text
Expand Down Expand Up @@ -613,6 +615,8 @@ def new(cls, project_file_path: str) -> 'UVisionProject':
file_type = FileType.CPP_SOURCE
elif filename.endswith(".h"):
file_type = FileType.TEXT_DOCUMENT
elif filename.endswith(".hpp"):
file_type = FileType.TEXT_DOCUMENT
else:
warnings.warn(f"Unknown RTE file type '{file.instance}': {file}")
continue
Expand Down Expand Up @@ -657,6 +661,8 @@ def source_files(self) -> Iterator[Tuple[File, Optional[Language], Optional[str]
lang = Language.ASM
elif file.type == FileType.C_SOURCE:
lang = Language.C
elif file.type == FileType.CPP_SOURCE:
lang = Language.CPP
elif file.type == FileType.TEXT_DOCUMENT:
lang = None
else:
Expand Down