From 6407cf22def09de43ec2ec02692c0e4ea3b17742 Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 23 Sep 2025 11:38:46 -0400 Subject: Add interpretation tests, fix some interpretation issues --- pom_parser/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pom_parser/__init__.py') diff --git a/pom_parser/__init__.py b/pom_parser/__init__.py index 3f1cce2..8c86e7b 100644 --- a/pom_parser/__init__.py +++ b/pom_parser/__init__.py @@ -1,3 +1,6 @@ +# TODO: +# - clean up read_conf example +# - add all_functions example r'''Configuration for the [POM configuration file format](https://www.pom.computer). \mainpage pom_parser @@ -93,6 +96,8 @@ Attributes return None if not all(c in '0123456789' for c in s): return None + if s == '': + return None value = int(s) if value >> 53: return None @@ -120,7 +125,10 @@ Attributes if c == '.' and (i == 0 or i == len(value)-1 or \ not value[i+1].isdigit() or not value[i-1].isdigit()): return None - return float(value) + try: + return float(value) + except ValueError: + return None def _parse_bool(self) -> Optional[bool]: value = self.value @@ -136,7 +144,7 @@ Attributes entry: list[str] = [] while (c := next(chars, '')): if c == ',': - list_.append(''.join(entry).strip(' \t')) + list_.append(''.join(entry).strip(' \t\n')) entry = [] elif c == '\\': c = next(chars, '') @@ -145,7 +153,7 @@ Attributes entry.append(c) else: entry.append(c) - last_entry = ''.join(entry).strip(' \t') + last_entry = ''.join(entry).strip(' \t\n') if last_entry: list_.append(last_entry) return list_ -- cgit v1.2.3