49 @brief Update xls field with package summary
50 @param l_package_info : list with package infos
53 worksheet = xls_creator.workbook.active
54 worksheet.title =
"PackageInfo"
55 for i, title
in enumerate(L_PACKAGE_INFO_TITLE):
56 xls_creator.set_cell(worksheet, 1, i + 1, title, bold=
True)
59 for package
in l_package_info:
60 if package
not in l_added_package:
61 l_added_package.append(package)
62 for i, value
in enumerate(package):
63 if isinstance(value, list):
67 value =
"\n".join(value)
68 elif isinstance(value, str):
72 xls_creator.set_cell(worksheet, i_package + 2, i + 1, str(value))
74 xls_creator.set_table(worksheet, max_col=len(l_added_package[0]), max_row=len(l_added_package) + 1)
75 xls_creator.set_column_autowidth(worksheet)
76 worksheet.freeze_panes =
"C2"
77 xls_creator.save(filename=
"PackageInfos.xlsx")
78 log.info(
"Write %s package infos to file", len(l_added_package))
83 @brief Upgrade package from text file to latest version
84 @param package : check latest version of this package
88 url = f
"https://pypi.org/pypi/{package}/json"
89 response = requests.get(url, timeout=I_TIMEOUT)
90 response.raise_for_status()
91 d_package_info = response.json()
92 except requests.exceptions.RequestException
as e:
93 log.error(
"Error occurred: %s", e)
96 l_requires_dist: list[str] = []
97 requires_dist = d_package_info[
"info"][
"requires_dist"]
99 for req
in requires_dist:
100 l_requires_dist.append(req)
102 d_package_info[
"info"][
"version"],
103 d_package_info[
"info"][
"author"],
104 d_package_info[
"info"][
"author_email"],
105 d_package_info[
"info"][
"license"],
106 d_package_info[
"info"][
"home_page"],
107 d_package_info[
"info"][
"package_url"],
109 d_package_info[
"info"][
"requires_python"])
115 @brief Update package from text file to latest version
116 @param filename : file name
117 @return list with updated packages
119 with open(filename, mode=
"r", encoding=
"utf-8")
as file:
120 lines = file.readlines()
126 if re.match(
r"^\s*#", line):
127 updated_lines.append(line)
128 elif re.match(
r"^\s*([\w\-]+)==([\w\.\-]+)\s*(#.*)?$", line):
129 package, version, comment = re.findall(
r"^\s*([\w\-]+)==([\w\.\-]+)\s*(#.*)?$", line)[0]
131 comment = f
" {comment}"
133 if (package_info
is not None)
and (package
not in L_IGNORE_PACKAGES):
134 if package_info.version
and (package_info.version != version):
135 updated_lines.append(f
"{package}=={package_info.version}{comment}\n")
137 log.info(
"Updated: %s %s", package, package_info.version)
139 updated_lines.append(line)
141 l_package_info.append(package_info)
143 updated_lines.append(line)
146 updated_lines.append(line)
149 if package_info
is not None:
150 l_package_info.append(package_info)
153 with open(filename, mode=
"w", encoding=
"utf-8")
as file:
154 file.writelines(updated_lines)
155 log.info(
"%s packages updates in %s\n", i_update_cnt, filename)
156 return l_package_info