From be0a1fbd444b5cfa1ae78422cc67572b0f706e94 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Sun, 17 Nov 2024 10:50:19 +1300 Subject: [PATCH] Handle spaces in filenames for .include #150 --- lcapy/netfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lcapy/netfile.py b/lcapy/netfile.py index f5163654..457056c7 100644 --- a/lcapy/netfile.py +++ b/lcapy/netfile.py @@ -36,9 +36,15 @@ def _make_anon_node_name(self): def _include(self, string): - parts = string.split(' ') - if len(parts) < 2 or parts[0] != '.include': + from re import match + + pattern = r'(\.include)\s+(.+?)\s+(as)\s+(\w+)' + matches = match(pattern, string) + if matches: + parts = list(matches.groups()) + else: raise ValueError('Expecting include filename in %s' % string) + filename = parts[1] if len(parts) == 2: return self._netfile_add(filename, self.namespace)