1045 |
1045 |
1046 ####################################################################### |
1046 ####################################################################### |
1047 ## License handling methods below |
1047 ## License handling methods below |
1048 ####################################################################### |
1048 ####################################################################### |
1049 |
1049 |
1050 def getLicenses(self, envName, summary=False): |
1050 def getLicenses(self, envName): |
1051 """ |
1051 """ |
1052 Public method to get the licenses per package for a given environment. |
1052 Public method to get the licenses per package for a given environment. |
1053 |
1053 |
1054 @param envName name of the environment to get the licenses for |
1054 @param envName name of the environment to get the licenses for |
1055 @type str |
1055 @type str |
1056 @param summary flag indicating to get a summary listing (defaults to |
|
1057 False) |
|
1058 @type bool (optional) |
|
1059 @return list of dictionaries containing the license and version per |
1056 @return list of dictionaries containing the license and version per |
1060 package |
1057 package |
1061 @rtype dict |
1058 @rtype dict |
1062 """ |
1059 """ |
1063 licenses = [] |
1060 licenses = [] |
1087 ).strip() |
1082 ).strip() |
1088 with contextlib.suppress(json.JSONDecodeError): |
1083 with contextlib.suppress(json.JSONDecodeError): |
1089 licenses = json.loads(output) |
1084 licenses = json.loads(output) |
1090 |
1085 |
1091 return licenses |
1086 return licenses |
1092 |
|
1093 def getLicensesSummary(self, envName): |
|
1094 """ |
|
1095 Public method to get a summary of licenses found in a given |
|
1096 environment. |
|
1097 |
|
1098 @param envName name of the environment to get the licenses summary for |
|
1099 @type str |
|
1100 @return list of dictionaries containing the license and the count of |
|
1101 packages |
|
1102 @rtype dict |
|
1103 """ |
|
1104 return self.getLicenses(envName, summary=True) |
|