Remove pointless calls to GetOS() everywhere

This commit is contained in:
Ben Jackson 2020-05-27 21:22:08 +01:00
commit 6b89df173f
4 changed files with 18 additions and 21 deletions

View file

@ -51,8 +51,7 @@ class DebugSession( object ):
self._logger.info( "API is: {}".format( api_prefix ) ) self._logger.info( "API is: {}".format( api_prefix ) )
self._logger.info( 'VIMSPECTOR_HOME = %s', VIMSPECTOR_HOME ) self._logger.info( 'VIMSPECTOR_HOME = %s', VIMSPECTOR_HOME )
self._logger.info( 'gadgetDir = %s', self._logger.info( 'gadgetDir = %s',
install.GetGadgetDir( VIMSPECTOR_HOME, install.GetGadgetDir( VIMSPECTOR_HOME ) )
install.GetOS() ) )
self._uiTab = None self._uiTab = None
self._stackTraceView = None self._stackTraceView = None
@ -91,7 +90,7 @@ class DebugSession( object ):
configurations = {} configurations = {}
adapters = {} adapters = {}
glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ) ) glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME ) )
for gadget_config_file in PathsToAllGadgetConfigs( VIMSPECTOR_HOME, for gadget_config_file in PathsToAllGadgetConfigs( VIMSPECTOR_HOME,
current_file ): current_file ):
self._logger.debug( f'Reading gadget config: {gadget_config_file}' ) self._logger.debug( f'Reading gadget config: {gadget_config_file}' )
@ -192,7 +191,7 @@ class DebugSession( object ):
'dollar': '$', # HACK. Hote '$$' also works. 'dollar': '$', # HACK. Hote '$$' also works.
'workspaceRoot': self._workspace_root, 'workspaceRoot': self._workspace_root,
'workspaceFolder': self._workspace_root, 'workspaceFolder': self._workspace_root,
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ), 'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME ),
'file': current_file, 'file': current_file,
} }

View file

@ -23,8 +23,7 @@ from vimspector import install, utils
def SetUpDebugpy( wait=False, port=5678 ): def SetUpDebugpy( wait=False, port=5678 ):
sys.path.insert( sys.path.insert(
1, 1,
os.path.join( install.GetGadgetDir( utils.GetVimspectorBase(), os.path.join( install.GetGadgetDir( utils.GetVimspectorBase() ),
install.GetOS() ),
'debugpy', 'debugpy',
'build', 'build',
'lib' ) ) 'lib' ) )

View file

@ -38,18 +38,16 @@ def MakeInstallDirs( vimspector_base ):
mkdirs( GetConfigDirForFiletype( vimspector_base, '_all' ) ) mkdirs( GetConfigDirForFiletype( vimspector_base, '_all' ) )
def GetGadgetDir( vimspector_base, OS ): def GetGadgetDir( vimspector_base ):
return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS ) return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', GetOS() )
def GetGadgetConfigFile( vimspector_base ): def GetGadgetConfigFile( vimspector_base ):
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ), return os.path.join( GetGadgetDir( vimspector_base ), '.gadgets.json' )
'.gadgets.json' )
def GetGadgetConfigDir( vimspector_base ): def GetGadgetConfigDir( vimspector_base ):
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ), return os.path.join( GetGadgetDir( vimspector_base ), '.gadgets.d' )
'.gadgets.d' )
def GetConfigDirForFiletype( vimspector_base, filetype ): def GetConfigDirForFiletype( vimspector_base, filetype ):

View file

@ -163,9 +163,11 @@ def InstallGagdet( name, gadget, failed, all_adapters ):
install.GetOS(), install.GetOS(),
name ) ) name ) )
destination = os.path.join( _GetGadgetDir(), destination = os.path.join(
install.GetGadgetDir( options.vimspector_base ),
'download', 'download',
name, v[ 'version' ] ) name,
v[ 'version' ] )
url = string.Template( gadget[ 'download' ][ 'url' ] ).substitute( v ) 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 ) url = string.Template( gadget[ 'repo' ][ 'url' ] ).substitute( v )
ref = string.Template( gadget[ 'repo' ][ 'ref' ] ).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 ) CloneRepoTo( url, ref, destination )
root = destination root = destination
@ -385,17 +390,13 @@ def ExtractZipTo( file_path, destination, format ):
subprocess.check_call( [ 'tar', 'zxvf', file_path ] ) subprocess.check_call( [ 'tar', 'zxvf', file_path ] )
def _GetGadgetDir():
return install.GetGadgetDir( options.vimspector_base, install.GetOS() )
def MakeExtensionSymlink( name, root ): def MakeExtensionSymlink( name, root ):
MakeSymlink( name, os.path.join( root, 'extension' ) ), MakeSymlink( name, os.path.join( root, 'extension' ) ),
def MakeSymlink( link, pointing_to, in_folder = None ): def MakeSymlink( link, pointing_to, in_folder = None ):
if not in_folder: if not in_folder:
in_folder = _GetGadgetDir() in_folder = install.GetGadgetDir( options.vimspector_base )
RemoveIfExists( os.path.join( in_folder, link ) ) RemoveIfExists( os.path.join( in_folder, link ) )