diff --git a/Orange/data/io_base.py b/Orange/data/io_base.py index 6a6d189200..4b0b74e021 100644 --- a/Orange/data/io_base.py +++ b/Orange/data/io_base.py @@ -174,11 +174,11 @@ def _header1(cls, headers: List[List[str]]) -> Tuple[List, List, List]: for vartype in Variable.registry.values()) if len(t) == 1]).upper() # CNDST - res = ('^(?:(' + res = ('^((?P' f'[{roles}{types}]|' - f'(?:[{roles}][{types}])|' - f'(?:[{types}][{roles}])' - ')#)?(.*)') + f'([{roles}][{types}])|' + f'([{types}][{roles}])' + ')#)?(?P.*)') header1_re = re.compile(res) @@ -186,7 +186,7 @@ def _header1(cls, headers: List[List[str]]) -> Tuple[List, List, List]: names = [] for i in headers[0]: m = header1_re.match(i) - f, n = m.group(1), m.group(2) + f, n = m.group("flags", "name") flags.append('' if f is None else f) names.append(n) diff --git a/Orange/data/tests/test_io_base.py b/Orange/data/tests/test_io_base.py index ed28f6b1f9..f0912051de 100644 --- a/Orange/data/tests/test_io_base.py +++ b/Orange/data/tests/test_io_base.py @@ -72,10 +72,12 @@ def test_get_header_data_1_flags2(self): def test_get_header_data_1_hashes(self): names, types, flags = _TableHeader.create_header_data( - [["Some long text#and here", "vd#Invalid spec", "C#Valid spec"]]) - names_ = ["Some long text#and here", "vd#Invalid spec", "Valid spec"] - types_ = ["", "", "c"] - flags_ = ["", "", ""] + [["Some long text#and here", "vd#Invalid spec", "C#Valid spec", + "m#Meta", "cD#Discrete class", "Si#Ignored string"]]) + names_ = ["Some long text#and here", "vd#Invalid spec", "Valid spec", + "Meta", "Discrete class", "Ignored string"] + types_ = ["", "", "c", "", "d", "s"] + flags_ = ["", "", "", "m", "c", "i"] self.assertListEqual(names, names_) self.assertListEqual(types, types_) self.assertListEqual(flags, flags_) diff --git a/i18n/si/msgs.jaml b/i18n/si/msgs.jaml index c8d819fe7f..c95d30fe77 100644 --- a/i18n/si/msgs.jaml +++ b/i18n/si/msgs.jaml @@ -1155,6 +1155,15 @@ data/io_base.py: ^\s*( |{}|)*\s*$: false class `_TableHeader`: '#': false + def `_header1`: + TYPE_HEADERS: false + ^((?P: false + [{roles}{types}]|: false + ([{roles}][{types}])|: false + ([{types}][{roles}]): false + )#)?(?P.*): false + flags: false + name: false class `_TableBuilder`: def `__init__`: 'Feature ': false