From 6b89df173fe84c6f8a6663ebb57c7f124aa32c59 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Wed, 27 May 2020 21:22:08 +0100 Subject: [PATCH] Remove pointless calls to GetOS() everywhere --- python3/vimspector/debug_session.py | 7 +++---- python3/vimspector/developer.py | 3 +-- python3/vimspector/install.py | 10 ++++------ python3/vimspector/installer.py | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 9ff680a..bd32cf1 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -51,8 +51,7 @@ class DebugSession( object ): self._logger.info( "API is: {}".format( api_prefix ) ) self._logger.info( 'VIMSPECTOR_HOME = %s', VIMSPECTOR_HOME ) self._logger.info( 'gadgetDir = %s', - install.GetGadgetDir( VIMSPECTOR_HOME, - install.GetOS() ) ) + install.GetGadgetDir( VIMSPECTOR_HOME ) ) self._uiTab = None self._stackTraceView = None @@ -91,7 +90,7 @@ class DebugSession( object ): configurations = {} adapters = {} - glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ) ) + glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME ) ) for gadget_config_file in PathsToAllGadgetConfigs( VIMSPECTOR_HOME, current_file ): self._logger.debug( f'Reading gadget config: {gadget_config_file}' ) @@ -192,7 +191,7 @@ class DebugSession( object ): 'dollar': '$', # HACK. Hote '$$' also works. 'workspaceRoot': self._workspace_root, 'workspaceFolder': self._workspace_root, - 'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ), + 'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME ), 'file': current_file, } diff --git a/python3/vimspector/developer.py b/python3/vimspector/developer.py index 4945e6a..49e96c3 100644 --- a/python3/vimspector/developer.py +++ b/python3/vimspector/developer.py @@ -23,8 +23,7 @@ from vimspector import install, utils def SetUpDebugpy( wait=False, port=5678 ): sys.path.insert( 1, - os.path.join( install.GetGadgetDir( utils.GetVimspectorBase(), - install.GetOS() ), + os.path.join( install.GetGadgetDir( utils.GetVimspectorBase() ), 'debugpy', 'build', 'lib' ) ) diff --git a/python3/vimspector/install.py b/python3/vimspector/install.py index 4726a5b..7dc0897 100644 --- a/python3/vimspector/install.py +++ b/python3/vimspector/install.py @@ -38,18 +38,16 @@ def MakeInstallDirs( vimspector_base ): mkdirs( GetConfigDirForFiletype( vimspector_base, '_all' ) ) -def GetGadgetDir( vimspector_base, OS ): - return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS ) +def GetGadgetDir( vimspector_base ): + return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', GetOS() ) def GetGadgetConfigFile( vimspector_base ): - return os.path.join( GetGadgetDir( vimspector_base, GetOS() ), - '.gadgets.json' ) + return os.path.join( GetGadgetDir( vimspector_base ), '.gadgets.json' ) def GetGadgetConfigDir( vimspector_base ): - return os.path.join( GetGadgetDir( vimspector_base, GetOS() ), - '.gadgets.d' ) + return os.path.join( GetGadgetDir( vimspector_base ), '.gadgets.d' ) def GetConfigDirForFiletype( vimspector_base, filetype ): diff --git a/python3/vimspector/installer.py b/python3/vimspector/installer.py index c767aa5..9e42fee 100644 --- a/python3/vimspector/installer.py +++ b/python3/vimspector/installer.py @@ -163,9 +163,11 @@ def InstallGagdet( name, gadget, failed, all_adapters ): install.GetOS(), name ) ) - destination = os.path.join( _GetGadgetDir(), - 'download', - name, v[ 'version' ] ) + destination = os.path.join( + install.GetGadgetDir( options.vimspector_base ), + 'download', + name, + v[ 'version' ] ) url = string.Template( gadget[ 'download' ][ 'url' ] ).substitute( v ) @@ -185,7 +187,10 @@ def InstallGagdet( name, gadget, failed, all_adapters ): url = string.Template( gadget[ 'repo' ][ 'url' ] ).substitute( v ) ref = string.Template( gadget[ 'repo' ][ 'ref' ] ).substitute( v ) - destination = os.path.join( _GetGadgetDir(), 'download', name ) + destination = os.path.join( + install.GetGadgetDir( options.vimspector_base ), + 'download', + name ) CloneRepoTo( url, ref, destination ) root = destination @@ -385,17 +390,13 @@ def ExtractZipTo( file_path, destination, format ): subprocess.check_call( [ 'tar', 'zxvf', file_path ] ) -def _GetGadgetDir(): - return install.GetGadgetDir( options.vimspector_base, install.GetOS() ) - - def MakeExtensionSymlink( name, root ): MakeSymlink( name, os.path.join( root, 'extension' ) ), def MakeSymlink( link, pointing_to, in_folder = None ): if not in_folder: - in_folder = _GetGadgetDir() + in_folder = install.GetGadgetDir( options.vimspector_base ) RemoveIfExists( os.path.join( in_folder, link ) )