973 |
973 |
974 ####################################################################### |
974 ####################################################################### |
975 ## License handling methods below |
975 ## License handling methods below |
976 ####################################################################### |
976 ####################################################################### |
977 |
977 |
978 def getLicenses(self, envName, summary=False): |
978 def getLicenses(self, envName, localPackages=True, usersite=False, |
|
979 summary=False): |
979 """ |
980 """ |
980 Public method to get the licenses per package for a given environment. |
981 Public method to get the licenses per package for a given environment. |
981 |
982 |
982 @param envName name of the environment to get the licenses for |
983 @param envName name of the environment to get the licenses for |
983 @type str |
984 @type str |
|
985 @param localPackages flag indicating to get the licenses for local |
|
986 packages only |
|
987 @type bool |
|
988 @param usersite flag indicating to get the licenses for packages |
|
989 installed in user-site directory only |
|
990 @type bool |
984 @param summary flag indicating to get a summary listing (defaults to |
991 @param summary flag indicating to get a summary listing (defaults to |
985 False) |
992 False) |
986 @type bool (optional) |
993 @type bool (optional) |
987 @return list of dictionaries containing the license and version per |
994 @return list of dictionaries containing the license and version per |
988 package |
995 package |
1017 with contextlib.suppress(json.JSONDecodeError): |
1026 with contextlib.suppress(json.JSONDecodeError): |
1018 licenses = json.loads(output) |
1027 licenses = json.loads(output) |
1019 |
1028 |
1020 return licenses |
1029 return licenses |
1021 |
1030 |
1022 def getLicensesSummary(self, envName): |
1031 def getLicensesSummary(self, envName, localPackages=True, usersite=False): |
1023 """ |
1032 """ |
1024 Public method to get a summary of licenses found in a given |
1033 Public method to get a summary of licenses found in a given |
1025 environment. |
1034 environment. |
1026 |
1035 |
1027 @param envName name of the environment to get the licenses summary for |
1036 @param envName name of the environment to get the licenses summary for |
1028 @type str |
1037 @type str |
|
1038 @param localPackages flag indicating to get the licenses summary for |
|
1039 local packages only |
|
1040 @type bool |
|
1041 @param usersite flag indicating to get the licenses summary for |
|
1042 packages installed in user-site directory only |
|
1043 @type bool |
1029 @return list of dictionaries containing the license and the count of |
1044 @return list of dictionaries containing the license and the count of |
1030 packages |
1045 packages |
1031 @rtype dict |
1046 @rtype dict |
1032 """ |
1047 """ |
1033 return self.getLicenses(envName, summary=True) |
1048 return self.getLicenses(envName, localPackages=localPackages, |
|
1049 usersite=usersite, summary=True) |