1045 |
1045 |
1046 ####################################################################### |
1046 ####################################################################### |
1047 ## License handling methods below |
1047 ## License handling methods below |
1048 ####################################################################### |
1048 ####################################################################### |
1049 |
1049 |
1050 def getLicenses(self, envName, localPackages=True, usersite=False, summary=False): |
1050 def getLicenses(self, envName, summary=False): |
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 localPackages flag indicating to get the licenses for local |
|
1057 packages only |
|
1058 @type bool |
|
1059 @param usersite flag indicating to get the licenses for packages |
|
1060 installed in user-site directory only |
|
1061 @type bool |
|
1062 @param summary flag indicating to get a summary listing (defaults to |
1056 @param summary flag indicating to get a summary listing (defaults to |
1063 False) |
1057 False) |
1064 @type bool (optional) |
1058 @type bool (optional) |
1065 @return list of dictionaries containing the license and version per |
1059 @return list of dictionaries containing the license and version per |
1066 package |
1060 package |
1098 with contextlib.suppress(json.JSONDecodeError): |
1088 with contextlib.suppress(json.JSONDecodeError): |
1099 licenses = json.loads(output) |
1089 licenses = json.loads(output) |
1100 |
1090 |
1101 return licenses |
1091 return licenses |
1102 |
1092 |
1103 def getLicensesSummary(self, envName, localPackages=True, usersite=False): |
1093 def getLicensesSummary(self, envName): |
1104 """ |
1094 """ |
1105 Public method to get a summary of licenses found in a given |
1095 Public method to get a summary of licenses found in a given |
1106 environment. |
1096 environment. |
1107 |
1097 |
1108 @param envName name of the environment to get the licenses summary for |
1098 @param envName name of the environment to get the licenses summary for |
1109 @type str |
1099 @type str |
1110 @param localPackages flag indicating to get the licenses summary for |
|
1111 local packages only |
|
1112 @type bool |
|
1113 @param usersite flag indicating to get the licenses summary for |
|
1114 packages installed in user-site directory only |
|
1115 @type bool |
|
1116 @return list of dictionaries containing the license and the count of |
1100 @return list of dictionaries containing the license and the count of |
1117 packages |
1101 packages |
1118 @rtype dict |
1102 @rtype dict |
1119 """ |
1103 """ |
1120 return self.getLicenses( |
1104 return self.getLicenses(envName, summary=True) |
1121 envName, localPackages=localPackages, usersite=usersite, summary=True |
|
1122 ) |
|