diff options
author | Barry-Thomas-Paul: Moss <vibrationoflife@protonmail.com> | 2024-10-13 19:04:07 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-11-03 18:31:14 +0100 |
commit | c8c66eb20d8c3e51a425514ed82f6a07f3e7928f (patch) | |
tree | 55b740f6e29deaeb6f9bb0a229f9ad6417297c7a /scripting | |
parent | 1e2b4e9765503f0beb30cc5298c36ededc0063c1 (diff) |
Updated getPackageName2PathMap
Update getPackageName2PathMap to use ExtensionManager
Change-Id: I22c00aeb27913f138da00d304b9f238787459d28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174877
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/pyprov/pythonscript.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py index 77d554920a7e..6d5d81e5df65 100644 --- a/scripting/source/pyprov/pythonscript.py +++ b/scripting/source/pyprov/pythonscript.py @@ -833,27 +833,35 @@ def mapStorageType2PackageContext( storageType ): ret = "user" return ret -def getPackageName2PathMap( sfa, storageType ): +def getPackageName2PathMap(sfa, storageType): ret = {} - packageManagerFactory = uno.getComponentContext().getValueByName( - "/singletons/com.sun.star.deployment.thePackageManagerFactory" ) - packageManager = packageManagerFactory.getPackageManager( - mapStorageType2PackageContext(storageType)) -# packageManager.addModifyListener( ModifyListener() ) - log.debug( "pythonscript: getPackageName2PathMap start getDeployedPackages" ) - packages = packageManager.getDeployedPackages( - packageManager.createAbortChannel(), CommandEnvironment( ) ) - log.debug( "pythonscript: getPackageName2PathMap end getDeployedPackages (" + str(len(packages))+")" ) - - for i in packages: - log.debug( "inspecting package " + i.Name + "("+i.Identifier.Value+")" ) - transientPathElement = penultimateElement( i.URL ) - j = expandUri( i.URL ) - paths = getPathsFromPackage( j, sfa ) - if len( paths ) > 0: + + ext_mgr = uno.getComponentContext().getValueByName( + "/singletons/com.sun.star.deployment.ExtensionManager" + ) + + log.debug("pythonscript: getPackageName2PathMap start getDeployedPackages") + packages = ext_mgr.getDeployedExtensions( + mapStorageType2PackageContext(storageType), + ext_mgr.createAbortChannel(), + CommandEnvironment(), + ) + + log.debug( + "pythonscript: getPackageName2PathMap end getDeployedPackages (" + + str(len(packages)) + + ")" + ) + + for pkg in packages: + log.debug("inspecting package " + pkg.Name + "(" + pkg.Identifier.Value + ")") # type: ignore + transientPathElement = penultimateElement(pkg.URL) # type: ignore + exp_uri = expandUri(pkg.URL) # type: ignore + paths = getPathsFromPackage(exp_uri, sfa) + if len(paths) > 0: # map package name to url, we need this later - log.debug( "adding Package " + transientPathElement + " " + str( paths ) ) - ret[ lastElement( j ) ] = Package( paths, transientPathElement ) + log.debug("adding Package " + transientPathElement + " " + str(paths)) + ret[lastElement(exp_uri)] = Package(paths, transientPathElement) return ret def penultimateElement( aStr ): |