diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2021-02-21 15:48:01 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2021-02-21 17:06:18 +0100 |
commit | 4b448758a98670efe259965829e5ce0861392caf (patch) | |
tree | 96dfc517b1384bf5f915dc587e937bcf53f37f47 /wizards | |
parent | 301b09f0c4fef6fca52fa0b28827a657bbbb6b39 (diff) |
ScriptForge - (SF_Platform) new Locale and PythonVersion properties
- 'Locale' returns a la-CO (language-COUNTRY) string
derived from com.sun.star.lang.Locale
- 'PythonVersion' returns Python major.minor.patchlevel
supplied by ScriptForgeHelper.py platform class
Change-Id: I2b8495c03253b17c5e4ba14765b1f359eee67813
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111284
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/scriptforge/SF_Platform.xba | 24 | ||||
-rw-r--r-- | wizards/source/scriptforge/python/ScriptForgeHelper.py | 5 |
2 files changed, 28 insertions, 1 deletions
diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba index 80f3ab97a182..69045404b5ba 100644 --- a/wizards/source/scriptforge/SF_Platform.xba +++ b/wizards/source/scriptforge/SF_Platform.xba @@ -71,6 +71,14 @@ Property Get CurrentUser() As String End Property ' ScriptForge.SF_Platform.CurrentUser (get) REM ----------------------------------------------------------------------------- +Property Get Locale() As String +''' Returns the locale combining language-COUNTRY (la-CO) +''' Example: +''' MsgBox platform.Locale + Locale = _PropertyGet("Locale") +End Property ' ScriptForge.SF_Platform.Locale (get) + +REM ----------------------------------------------------------------------------- Property Get Machine() As String ''' Returns the machine type like 'i386' or 'x86_64' ''' Example: @@ -138,6 +146,14 @@ Property Get Processor() As String Processor = _PropertyGet("Processor") End Property ' ScriptForge.SF_Platform.Processor (get) +REM ----------------------------------------------------------------------------- +Property Get PythonVersion() As String +''' Returns the Python version as string 'Python major.minor.patchlevel' +''' Example: +''' MsgBox platform.PythonVersion ' Python 3.7.7 + PythonVersion = _PropertyGet("PythonVersion") +End Property ' ScriptForge.SF_Platform.PythonVersion (get) + REM ===================================================================== METHODS REM ----------------------------------------------------------------------------- @@ -190,6 +206,7 @@ Public Function Properties() As Variant , "ComputerName" _ , "CPUCount" _ , "CurrentUser" _ + , "Locale" _ , "Machine" _ , "OfficeVersion" _ , "OSName" _ @@ -197,6 +214,7 @@ Public Function Properties() As Variant , "OSRelease" _ , "OSVersion" _ , "Processor" _ + , "PythonVersion" _ ) End Function ' ScriptForge.SF_Platform.Properties @@ -238,6 +256,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant ''' psProperty: the name of the property Dim sOSName As String ' Operating system +Dim oLocale As Object ' com.sun.star.lang.Locale Const cstPyHelper = "$" & "_SF_Platform" Dim cstThisSub As String @@ -248,10 +267,13 @@ Const cstSubArgs = "" Select Case psProperty Case "Architecture", "ComputerName", "CPUCount", "CurrentUser", "Machine" _ - , "OSPlatform", "OSRelease", "OSVersion", "Processor" + , "OSPlatform", "OSRelease", "OSVersion", "Processor", "PythonVersion" With ScriptForge.SF_Session _PropertyGet = .ExecutePythonScript(.SCRIPTISSHARED, _SF_.PythonHelper & cstPyHelper, psProperty) End With + Case "Locale" + Set oLocale = SF_Utils._GetUNOService("Locale") + _PropertyGet = oLocale.Language & "-" & oLocale.Country Case "OfficeVersion" _PropertyGet = _GetProductName() Case "OSName" diff --git a/wizards/source/scriptforge/python/ScriptForgeHelper.py b/wizards/source/scriptforge/python/ScriptForgeHelper.py index ca520434a2a9..aec9311a3f3f 100644 --- a/wizards/source/scriptforge/python/ScriptForgeHelper.py +++ b/wizards/source/scriptforge/python/ScriptForgeHelper.py @@ -171,6 +171,8 @@ def _SF_Platform(propertyname: str): # used by SF_Platform Basic module return pf.OSVersion elif propertyname == 'Processor': return pf.Processor + elif propertyname == 'PythonVersion': + return pf.PythonVersion else: return None @@ -210,6 +212,9 @@ class Platform(object, metaclass = _Singleton): @property # real processor name e.g. 'amdk' def Processor(self): return platform.processor() + @property # Python major.minor.patchlevel + def PythonVersion(self): return 'Python ' + platform.python_version() + # ################################################################# # Session service |