Fix flake8 errors
This commit is contained in:
parent
2678e666aa
commit
4f31c95aa4
9 changed files with 36 additions and 36 deletions
|
|
@ -100,7 +100,7 @@ class ProjectBreakpoints( object ):
|
||||||
return
|
return
|
||||||
|
|
||||||
found_bp = False
|
found_bp = False
|
||||||
for index, bp in enumerate( self._line_breakpoints[ file_name] ):
|
for index, bp in enumerate( self._line_breakpoints[ file_name ] ):
|
||||||
if bp[ 'line' ] == line:
|
if bp[ 'line' ] == line:
|
||||||
found_bp = True
|
found_bp = True
|
||||||
if bp[ 'state' ] == 'ENABLED':
|
if bp[ 'state' ] == 'ENABLED':
|
||||||
|
|
@ -151,7 +151,7 @@ class ProjectBreakpoints( object ):
|
||||||
def SendBreakpoints( self ):
|
def SendBreakpoints( self ):
|
||||||
if not self._breakpoints_handler:
|
if not self._breakpoints_handler:
|
||||||
def handler( source, msg ):
|
def handler( source, msg ):
|
||||||
return self._ShowBreakpoints()
|
return self._ShowBreakpoints()
|
||||||
else:
|
else:
|
||||||
handler = self._breakpoints_handler
|
handler = self._breakpoints_handler
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from collections import defaultdict
|
||||||
from vimspector import utils
|
from vimspector import utils
|
||||||
|
|
||||||
|
|
||||||
class CodeView( object ):
|
class CodeView( object ):
|
||||||
def __init__( self, window ):
|
def __init__( self, window ):
|
||||||
self._window = window
|
self._window = window
|
||||||
|
|
||||||
|
|
@ -78,9 +78,9 @@ class CodeView( object ):
|
||||||
vim.command( 'sign place {0} group=VimspectorCode priority=20 '
|
vim.command( 'sign place {0} group=VimspectorCode priority=20 '
|
||||||
'line={1} name=vimspectorPC '
|
'line={1} name=vimspectorPC '
|
||||||
'file={2}'.format(
|
'file={2}'.format(
|
||||||
self._signs[ 'vimspectorPC' ],
|
self._signs[ 'vimspectorPC' ],
|
||||||
frame[ 'line' ],
|
frame[ 'line' ],
|
||||||
frame[ 'source' ][ 'path' ] ) )
|
frame[ 'source' ][ 'path' ] ) )
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -166,11 +166,11 @@ class CodeView( object ):
|
||||||
'line={1} '
|
'line={1} '
|
||||||
'name={2} '
|
'name={2} '
|
||||||
'file={3}'.format(
|
'file={3}'.format(
|
||||||
sign_id,
|
sign_id,
|
||||||
breakpoint[ 'line' ],
|
breakpoint[ 'line' ],
|
||||||
'vimspectorBP' if breakpoint[ 'verified' ]
|
'vimspectorBP' if breakpoint[ 'verified' ]
|
||||||
else 'vimspectorBPDisabled',
|
else 'vimspectorBPDisabled',
|
||||||
file_name ) )
|
file_name ) )
|
||||||
|
|
||||||
|
|
||||||
def BreakpointsAsQuickFix( self ):
|
def BreakpointsAsQuickFix( self ):
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ class DebugAdapterConnection( object ):
|
||||||
assert self._state == 'READ_BODY'
|
assert self._state == 'READ_BODY'
|
||||||
return
|
return
|
||||||
|
|
||||||
payload = str( self._buffer[ : content_length ], 'utf-8' )
|
payload = str( self._buffer[ : content_length ], 'utf-8' )
|
||||||
self._buffer = self._buffer[ content_length : ]
|
self._buffer = self._buffer[ content_length : ]
|
||||||
|
|
||||||
# self._logger.debug( 'Message received (raw): %s', payload )
|
# self._logger.debug( 'Message received (raw): %s', payload )
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,9 @@ import logging
|
||||||
import vim
|
import vim
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import functools
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
from vimspector import ( breakpoints,
|
from vimspector import ( breakpoints,
|
||||||
code,
|
code,
|
||||||
debug_adapter_connection,
|
debug_adapter_connection,
|
||||||
|
|
@ -110,11 +107,11 @@ class DebugSession( object ):
|
||||||
# set from an api call like SetLaunchParam( 'var', 'value' ), perhaps also a
|
# set from an api call like SetLaunchParam( 'var', 'value' ), perhaps also a
|
||||||
# way to load .vimspector.local.json which just sets variables
|
# way to load .vimspector.local.json which just sets variables
|
||||||
self._variables = {
|
self._variables = {
|
||||||
'dollar': '$', # HACK
|
'dollar': '$', # HACK. Hote '$$' also works.
|
||||||
'workspaceRoot': self._workspace_root,
|
'workspaceRoot': self._workspace_root,
|
||||||
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() )
|
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() )
|
||||||
}
|
}
|
||||||
self._variables.update(
|
self._variables.update(
|
||||||
utils.ParseVariables( adapter.get( 'variables', {} ) ) )
|
utils.ParseVariables( adapter.get( 'variables', {} ) ) )
|
||||||
self._variables.update(
|
self._variables.update(
|
||||||
utils.ParseVariables( configuration.get( 'variables', {} ) ) )
|
utils.ParseVariables( configuration.get( 'variables', {} ) ) )
|
||||||
|
|
@ -125,7 +122,7 @@ class DebugSession( object ):
|
||||||
|
|
||||||
if not adapter:
|
if not adapter:
|
||||||
utils.UserMessage( 'No adapter configured for {}'.format(
|
utils.UserMessage( 'No adapter configured for {}'.format(
|
||||||
configuration_name ), persist=True )
|
configuration_name ), persist=True )
|
||||||
return
|
return
|
||||||
|
|
||||||
self._StartWithConfiguration( configuration, adapter )
|
self._StartWithConfiguration( configuration, adapter )
|
||||||
|
|
@ -174,7 +171,7 @@ class DebugSession( object ):
|
||||||
# beeps and doesn't display the config selector. One option is to just not
|
# beeps and doesn't display the config selector. One option is to just not
|
||||||
# display the selector and restart with the same opitons.
|
# display the selector and restart with the same opitons.
|
||||||
if not self._configuration or not self._adapter:
|
if not self._configuration or not self._adapter:
|
||||||
return Start()
|
return self.Start()
|
||||||
|
|
||||||
self._StartWithConfiguration( self._configuration, self._adapter )
|
self._StartWithConfiguration( self._configuration, self._adapter )
|
||||||
|
|
||||||
|
|
@ -420,7 +417,7 @@ class DebugSession( object ):
|
||||||
atttach_config = adapter_config.get( 'attach' )
|
atttach_config = adapter_config.get( 'attach' )
|
||||||
|
|
||||||
if not atttach_config:
|
if not atttach_config:
|
||||||
return
|
return
|
||||||
|
|
||||||
if 'remote' in atttach_config:
|
if 'remote' in atttach_config:
|
||||||
# FIXME: We almost want this to feed-back variables to be expanded later,
|
# FIXME: We almost want this to feed-back variables to be expanded later,
|
||||||
|
|
@ -449,7 +446,7 @@ class DebugSession( object ):
|
||||||
commands = self._GetCommands( remote, 'attach' )
|
commands = self._GetCommands( remote, 'attach' )
|
||||||
|
|
||||||
for command in commands:
|
for command in commands:
|
||||||
cmd = ssh + command[:]
|
cmd = ssh + command[ : ]
|
||||||
|
|
||||||
for index, item in enumerate( cmd ):
|
for index, item in enumerate( cmd ):
|
||||||
cmd[ index ] = item.replace( '%PID%', pid )
|
cmd[ index ] = item.replace( '%PID%', pid )
|
||||||
|
|
@ -483,7 +480,7 @@ class DebugSession( object ):
|
||||||
commands = self._GetCommands( remote, 'run' )
|
commands = self._GetCommands( remote, 'run' )
|
||||||
|
|
||||||
for index, command in enumerate( commands ):
|
for index, command in enumerate( commands ):
|
||||||
cmd = ssh + command[:]
|
cmd = ssh + command[ : ]
|
||||||
full_cmd = []
|
full_cmd = []
|
||||||
for item in cmd:
|
for item in cmd:
|
||||||
if isinstance( command_line, list ):
|
if isinstance( command_line, list ):
|
||||||
|
|
@ -560,7 +557,7 @@ class DebugSession( object ):
|
||||||
if request == "attach":
|
if request == "attach":
|
||||||
self._PrepareAttach( adapter_config, launch_config )
|
self._PrepareAttach( adapter_config, launch_config )
|
||||||
elif request == "launch":
|
elif request == "launch":
|
||||||
# FIXME: This cmdLine hack is not fun.
|
# FIXME: This cmdLine hack is not fun.
|
||||||
self._PrepareLaunch( self._configuration.get( 'remote-cmdLine', [] ),
|
self._PrepareLaunch( self._configuration.get( 'remote-cmdLine', [] ),
|
||||||
adapter_config,
|
adapter_config,
|
||||||
launch_config )
|
launch_config )
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
import platform
|
import platform
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def GetOS():
|
def GetOS():
|
||||||
if platform.system() == 'Darwin':
|
if platform.system() == 'Darwin':
|
||||||
return 'macos'
|
return 'macos'
|
||||||
|
|
@ -24,9 +25,11 @@ def GetOS():
|
||||||
else:
|
else:
|
||||||
return 'linux'
|
return 'linux'
|
||||||
|
|
||||||
|
|
||||||
def GetGadgetDir( vimspector_base, OS ):
|
def GetGadgetDir( vimspector_base, OS ):
|
||||||
return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS )
|
return os.path.join( os.path.abspath( vimspector_base ), 'gadgets', OS )
|
||||||
|
|
||||||
|
|
||||||
def GetGadgetConfigFile( vimspector_base ):
|
def GetGadgetConfigFile( vimspector_base ):
|
||||||
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ),
|
return os.path.join( GetGadgetDir( vimspector_base, GetOS() ),
|
||||||
'.gadgets.json' )
|
'.gadgets.json' )
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class OutputView( object ):
|
||||||
self._ShowOutput( category )
|
self._ShowOutput( category )
|
||||||
|
|
||||||
def ConnectionUp( self, connection ):
|
def ConnectionUp( self, connection ):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
||||||
def ConnectionClosed( self ):
|
def ConnectionClosed( self ):
|
||||||
# Don't clear because output is probably still useful
|
# Don't clear because output is probably still useful
|
||||||
|
|
@ -166,7 +166,7 @@ class OutputView( object ):
|
||||||
if cmd is not None:
|
if cmd is not None:
|
||||||
out, err = utils.SetUpCommandBuffer( cmd, category )
|
out, err = utils.SetUpCommandBuffer( cmd, category )
|
||||||
self._buffers[ category + '-out' ] = TabBuffer( out,
|
self._buffers[ category + '-out' ] = TabBuffer( out,
|
||||||
len( self._buffers ) )
|
len( self._buffers ) )
|
||||||
self._buffers[ category + '-out' ].is_job = True
|
self._buffers[ category + '-out' ].is_job = True
|
||||||
self._buffers[ category + '-err' ] = TabBuffer( err,
|
self._buffers[ category + '-err' ] = TabBuffer( err,
|
||||||
len( self._buffers ) )
|
len( self._buffers ) )
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class StackTraceView( object ):
|
||||||
self._line_to_thread = {}
|
self._line_to_thread = {}
|
||||||
|
|
||||||
# TODO: We really need a proper state model
|
# TODO: We really need a proper state model
|
||||||
#
|
#
|
||||||
# AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
|
# AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
|
||||||
# REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
|
# REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
|
||||||
#
|
#
|
||||||
|
|
@ -76,7 +76,7 @@ class StackTraceView( object ):
|
||||||
pending_request = False
|
pending_request = False
|
||||||
if self._requesting_threads:
|
if self._requesting_threads:
|
||||||
pending_request = True
|
pending_request = True
|
||||||
return
|
return
|
||||||
|
|
||||||
def consume_threads( message ):
|
def consume_threads( message ):
|
||||||
self._requesting_threads = False
|
self._requesting_threads = False
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ _log_handler.setFormatter(
|
||||||
def SetUpLogging( logger ):
|
def SetUpLogging( logger ):
|
||||||
logger.setLevel( logging.DEBUG )
|
logger.setLevel( logging.DEBUG )
|
||||||
if _log_handler not in logger.handlers:
|
if _log_handler not in logger.handlers:
|
||||||
logger.addHandler( _log_handler )
|
logger.addHandler( _log_handler )
|
||||||
|
|
||||||
|
|
||||||
def BufferNumberForFile( file_name ):
|
def BufferNumberForFile( file_name ):
|
||||||
|
|
@ -60,12 +60,12 @@ def SetUpCommandBuffer( cmd, name ):
|
||||||
|
|
||||||
if bufs is None:
|
if bufs is None:
|
||||||
raise RuntimeError( "Unable to start job {}: {}".format( cmd, name ) )
|
raise RuntimeError( "Unable to start job {}: {}".format( cmd, name ) )
|
||||||
elif not all( [ b > 0 for b in bufs ] ):
|
elif not all( b > 0 for b in bufs ):
|
||||||
raise RuntimeError( "Unable to get all streams for job {}: {}".format(
|
raise RuntimeError( "Unable to get all streams for job {}: {}".format(
|
||||||
name,
|
name,
|
||||||
cmd ) )
|
cmd ) )
|
||||||
|
|
||||||
UserMessage( 'Bufs: {}'.format( [ int(b) for b in bufs ] ), persist = True )
|
UserMessage( 'Bufs: {}'.format( [ int( b ) for b in bufs ] ), persist = True )
|
||||||
|
|
||||||
return [ vim.buffers[ b ] for b in bufs ]
|
return [ vim.buffers[ b ] for b in bufs ]
|
||||||
|
|
||||||
|
|
@ -257,11 +257,11 @@ def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||||
buf.append( line_or_lines )
|
buf.append( line_or_lines )
|
||||||
elif isinstance( line_or_lines, str ):
|
elif isinstance( line_or_lines, str ):
|
||||||
line = 1
|
line = 1
|
||||||
buf[-1] = line_or_lines
|
buf[ -1 ] = line_or_lines
|
||||||
else:
|
else:
|
||||||
line = 1
|
line = 1
|
||||||
buf[:] = line_or_lines
|
buf[ : ] = line_or_lines
|
||||||
except:
|
except Exception:
|
||||||
# There seem to be a lot of Vim bugs that lead to E315, whose help says that
|
# There seem to be a lot of Vim bugs that lead to E315, whose help says that
|
||||||
# this is an internal error. Ignore the error, but write a trace to the log.
|
# this is an internal error. Ignore the error, but write a trace to the log.
|
||||||
logging.getLogger( __name__ ).exception(
|
logging.getLogger( __name__ ).exception(
|
||||||
|
|
@ -276,7 +276,7 @@ def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||||
|
|
||||||
|
|
||||||
def ClearBuffer( buf ):
|
def ClearBuffer( buf ):
|
||||||
buf[:] = None
|
buf[ : ] = None
|
||||||
|
|
||||||
|
|
||||||
def IsCurrent( window, buf ):
|
def IsCurrent( window, buf ):
|
||||||
|
|
@ -330,7 +330,7 @@ def ExpandReferencesInDict( obj, mapping, **kwargs ):
|
||||||
|
|
||||||
def ParseVariables( variables ):
|
def ParseVariables( variables ):
|
||||||
new_variables = {}
|
new_variables = {}
|
||||||
for n,v in variables.items():
|
for n, v in variables.items():
|
||||||
if isinstance( v, dict ):
|
if isinstance( v, dict ):
|
||||||
if 'shell' in v:
|
if 'shell' in v:
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class VariablesView( object ):
|
||||||
utils.ClearBuffer( self._watch.win.buffer )
|
utils.ClearBuffer( self._watch.win.buffer )
|
||||||
|
|
||||||
def ConnectionUp( self, connection ):
|
def ConnectionUp( self, connection ):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
||||||
def ConnectionClosed( self ):
|
def ConnectionClosed( self ):
|
||||||
self.Clear()
|
self.Clear()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue