From bb03a0ed3da6df9cdae82bb118022990b01c2f4e Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 11 Oct 2023 10:45:09 -0500 Subject: [PATCH] Support conan version 1 & 2 --- uiucprescon/build/conan/files.py | 14 +++++++------- uiucprescon/build/conan/v1.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/uiucprescon/build/conan/files.py b/uiucprescon/build/conan/files.py index 2ce3aa5..8a2c66c 100644 --- a/uiucprescon/build/conan/files.py +++ b/uiucprescon/build/conan/files.py @@ -6,7 +6,7 @@ def __init__(self, fp): self._fp = fp def parse(self) -> Dict[str, List[str]]: - data = dict() + data = {} for subject_chunk in self.iter_subject_chunk(): subject_title = subject_chunk[0][1:-1] @@ -70,7 +70,7 @@ class ConanBuildInfoTXT(AbsConanBuildInfo): def parse(self, filename: str) -> ConanBuildInfo: # def parse(self, filename: str) -> Dict[str, Union[str, List[str]]]: - with open(filename, "r") as f: + with open(filename, "r", encoding="utf-8") as f: parser = ConanBuildInfoParser(f) data = parser.parse() definitions = data['defines'] @@ -78,11 +78,11 @@ def parse(self, filename: str) -> ConanBuildInfo: lib_paths = data['libdirs'] bin_paths = data['bindirs'] libs = data['libs'] - names = [] - for value in data.keys(): - if not value.startswith("name_"): - continue - names.append(value.replace("name_", "")) + names: List[str] = [ + value.replace("name_", "") + for value in data + if value.startswith("name_") + ] # print(names) libsmetadata: Dict[str, ConanLibraryMetadata] = {} for library_name in names: diff --git a/uiucprescon/build/conan/v1.py b/uiucprescon/build/conan/v1.py index c8a6c54..a8259a3 100644 --- a/uiucprescon/build/conan/v1.py +++ b/uiucprescon/build/conan/v1.py @@ -106,7 +106,7 @@ def build_deps_with_conan( # conaninfotext = os.path.join(build_dir, "conaninfo.txt") if os.path.exists(conaninfotext) and announce: - with open(conaninfotext) as r: + with open(conaninfotext, "r", encoding="utf-8") as r: announce(r.read(), 5) build_locations = [ build_dir,