code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
'''
:param ContinueRequest request:
'''
arguments = request.arguments # : :type arguments: ContinueArguments
thread_id = arguments.threadId
def on_resumed():
body = {'allThreadsContinued': thread_id == '*'}
response = pydevd_base_schema.build_res... | def on_continue_request(self, py_db, request) | :param ContinueRequest request: | 8.782281 | 8.356419 | 1.050962 |
'''
:param NextRequest request:
'''
arguments = request.arguments # : :type arguments: NextArguments
thread_id = arguments.threadId
if py_db.get_use_libraries_filter():
step_cmd_id = CMD_STEP_OVER_MY_CODE
else:
step_cmd_id = CMD_STEP_OVER... | def on_next_request(self, py_db, request) | :param NextRequest request: | 7.453148 | 6.818706 | 1.093044 |
'''
:param StepInRequest request:
'''
arguments = request.arguments # : :type arguments: StepInArguments
thread_id = arguments.threadId
if py_db.get_use_libraries_filter():
step_cmd_id = CMD_STEP_INTO_MY_CODE
else:
step_cmd_id = CMD_STEP_... | def on_stepin_request(self, py_db, request) | :param StepInRequest request: | 6.250827 | 5.822225 | 1.073615 |
'''
:param StepOutRequest request:
'''
arguments = request.arguments # : :type arguments: StepOutArguments
thread_id = arguments.threadId
if py_db.get_use_libraries_filter():
step_cmd_id = CMD_STEP_RETURN_MY_CODE
else:
step_cmd_id = CMD_S... | def on_stepout_request(self, py_db, request) | :param StepOutRequest request: | 6.324506 | 5.990938 | 1.055679 |
'''Following hit condition values are supported
* x or == x when breakpoint is hit x times
* >= x when breakpoint is hit more than or equal to x times
* % x when breakpoint is hit multiple of x times
Returns '@HIT@ == x' where @HIT@ will be replaced by number of hits
''... | def _get_hit_condition_expression(self, hit_condition) | Following hit condition values are supported
* x or == x when breakpoint is hit x times
* >= x when breakpoint is hit more than or equal to x times
* % x when breakpoint is hit multiple of x times
Returns '@HIT@ == x' where @HIT@ will be replaced by number of hits | 5.315064 | 2.095198 | 2.536784 |
'''
:param DisconnectRequest request:
'''
self.api.set_enable_thread_notifications(py_db, False)
self.api.remove_all_breakpoints(py_db, filename='*')
self.api.remove_all_exception_breakpoints(py_db)
self.api.request_resume_thread(thread_id='*')
response =... | def on_disconnect_request(self, py_db, request) | :param DisconnectRequest request: | 6.954779 | 6.32372 | 1.099792 |
'''
:param SetBreakpointsRequest request:
'''
arguments = request.arguments # : :type arguments: SetBreakpointsArguments
# TODO: Path is optional here it could be source reference.
filename = arguments.source.path
filename = self.api.filename_to_server(filename)
... | def on_setbreakpoints_request(self, py_db, request) | :param SetBreakpointsRequest request: | 4.804055 | 4.738977 | 1.013732 |
'''
:param SetExceptionBreakpointsRequest request:
'''
# : :type arguments: SetExceptionBreakpointsArguments
arguments = request.arguments
filters = arguments.filters
exception_options = arguments.exceptionOptions
self.api.remove_all_exception_breakpoints(... | def on_setexceptionbreakpoints_request(self, py_db, request) | :param SetExceptionBreakpointsRequest request: | 3.289071 | 3.26445 | 1.007542 |
'''
:param StackTraceRequest request:
'''
# : :type stack_trace_arguments: StackTraceArguments
stack_trace_arguments = request.arguments
thread_id = stack_trace_arguments.threadId
start_frame = stack_trace_arguments.startFrame
levels = stack_trace_argument... | def on_stacktrace_request(self, py_db, request) | :param StackTraceRequest request: | 3.398859 | 3.203574 | 1.060959 |
'''
:param ExceptionInfoRequest request:
'''
# : :type exception_into_arguments: ExceptionInfoArguments
exception_into_arguments = request.arguments
thread_id = exception_into_arguments.threadId
max_frames = int(self._debug_options['args'].get('maxExceptionStackFr... | def on_exceptioninfo_request(self, py_db, request) | :param ExceptionInfoRequest request: | 6.394994 | 6.110456 | 1.046566 |
'''
Scopes are the top-level items which appear for a frame (so, we receive the frame id
and provide the scopes it has).
:param ScopesRequest request:
'''
frame_id = request.arguments.frameId
variables_reference = frame_id
scopes = [Scope('Locals', int(v... | def on_scopes_request(self, py_db, request) | Scopes are the top-level items which appear for a frame (so, we receive the frame id
and provide the scopes it has).
:param ScopesRequest request: | 11.135204 | 5.898413 | 1.887831 |
'''
:param EvaluateRequest request:
'''
# : :type arguments: EvaluateArguments
arguments = request.arguments
thread_id = py_db.suspended_frames_manager.get_thread_id_for_variable_reference(
arguments.frameId)
self.api.request_exec_or_evaluate_json(
... | def on_evaluate_request(self, py_db, request) | :param EvaluateRequest request: | 9.05822 | 7.897828 | 1.146926 |
'''
Variables can be asked whenever some place returned a variables reference (so, it
can be a scope gotten from on_scopes_request, the result of some evaluation, etc.).
Note that in the DAP the variables reference requires a unique int... the way this works for
pydevd is that a... | def on_variables_request(self, py_db, request) | Variables can be asked whenever some place returned a variables reference (so, it
can be a scope gotten from on_scopes_request, the result of some evaluation, etc.).
Note that in the DAP the variables reference requires a unique int... the way this works for
pydevd is that an instance is genera... | 12.06747 | 2.492358 | 4.841789 |
'''
:param SourceRequest request:
'''
source_reference = request.arguments.sourceReference
server_filename = None
content = None
if source_reference != 0:
server_filename = pydevd_file_utils.get_server_filename_from_source_reference(source_reference)
... | def on_source_request(self, py_db, request) | :param SourceRequest request: | 4.488697 | 4.403998 | 1.019232 |
try:
app = wx.GetApp() # @UndefinedVariable
if app is not None:
assert wx.Thread_IsMain() # @UndefinedVariable
# Make a temporary event loop and process system events until
# there are no more waiting, then allow idle events (which
# will also ... | def inputhook_wx1() | Run the wx event loop by processing pending events only.
This approach seems to work, but its performance is not great as it
relies on having PyOS_InputHook called regularly. | 6.300139 | 6.481727 | 0.971985 |
try:
app = wx.GetApp() # @UndefinedVariable
if app is not None:
assert wx.Thread_IsMain() # @UndefinedVariable
elr = EventLoopRunner()
# As this time is made shorter, keyboard response improves, but idle
# CPU load goes up. 10 ms seems like a g... | def inputhook_wx2() | Run the wx event loop, polling for stdin.
This version runs the wx eventloop for an undetermined amount of time,
during which it periodically checks to see if anything is ready on
stdin. If anything is ready on stdin, the event loop exits.
The argument to elr.Run controls how often the event loop loo... | 12.381202 | 9.520974 | 1.300413 |
# We need to protect against a user pressing Control-C when IPython is
# idle and this is running. We trap KeyboardInterrupt and pass.
try:
app = wx.GetApp() # @UndefinedVariable
if app is not None:
assert wx.Thread_IsMain() # @UndefinedVariable
# The import o... | def inputhook_wx3() | Run the wx event loop by processing pending events only.
This is like inputhook_wx1, but it keeps processing pending events
until stdin is ready. After processing all pending events, a call to
time.sleep is inserted. This is needed, otherwise, CPU usage is at 100%.
This sleep time should be tuned tho... | 5.378597 | 5.260189 | 1.02251 |
base = os.path.basename(path)
filename, ext = os.path.splitext(base)
return filename | def _modname(path) | Return a plausible module name for the path | 2.949223 | 2.949124 | 1.000034 |
'''
It's possible to show paused frames by adding a custom frame through this API (it's
intended to be used for coroutines, but could potentially be used for generators too).
:param frame:
The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused.
:param n... | def add_custom_frame(frame, name, thread_id) | It's possible to show paused frames by adding a custom frame through this API (it's
intended to be used for coroutines, but could potentially be used for generators too).
:param frame:
The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused.
:param name:
... | 5.331361 | 2.900304 | 1.838208 |
if get_return_control_callback() is None:
raise ValueError("A return_control_callback must be supplied as a reference before a gui can be enabled")
guis = {GUI_NONE: clear_inputhook,
GUI_OSX: enable_mac,
GUI_TK: enable_tk,
GUI_GTK: enable_gtk,
GUI_W... | def enable_gui(gui=None, app=None) | Switch amongst GUI input hooks by name.
This is just a utility wrapper around the methods of the InputHookManager
object.
Parameters
----------
gui : optional, string or None
If None (or 'none'), clears input hook, otherwise it must be one
of the recognized GUI names (see ``GUI_*`` con... | 3.424129 | 3.056702 | 1.120204 |
if gui is None:
self._apps = {}
elif gui in self._apps:
del self._apps[gui] | def clear_app_refs(self, gui=None) | Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themselves. This
method is provided to clear ... | 3.330254 | 4.070891 | 0.818065 |
from pydev_ipython.inputhookgtk import create_inputhook_gtk
self.set_inputhook(create_inputhook_gtk(self._stdin_file))
self._current_gui = GUI_GTK | def enable_gtk(self, app=None) | Enable event loop integration with PyGTK.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
... | 7.759923 | 7.606321 | 1.020194 |
self._current_gui = GUI_TK
if app is None:
try:
import Tkinter as _TK
except:
# Python 3
import tkinter as _TK # @UnresolvedImport
app = _TK.Tk()
app.withdraw()
self._apps[GUI_TK] = app
... | def enable_tk(self, app=None) | Enable event loop integration with Tk.
Parameters
----------
app : toplevel :class:`Tkinter.Tk` widget, optional.
Running toplevel widget to use. If not given, we probe Tk for an
existing one, and create a new one if none is found.
Notes
-----
I... | 4.063087 | 4.821431 | 0.842714 |
import OpenGL.GLUT as glut # @UnresolvedImport
from pydev_ipython.inputhookglut import glut_display_mode, \
glut_close, glut_display, \
glut_idle, inputhook_glut
if GUI_GLUT not in self._apps:... | def enable_glut(self, app=None) | Enable event loop integration with GLUT.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
... | 2.769541 | 2.675308 | 1.035224 |
import OpenGL.GLUT as glut # @UnresolvedImport
from glut_support import glutMainLoopEvent # @UnresolvedImport
glut.glutHideWindow() # This is an event to be processed below
glutMainLoopEvent()
self.clear_inputhook() | def disable_glut(self) | Disable event loop integration with glut.
This sets PyOS_InputHook to NULL and set the display function to a
dummy one and set the timer to a dummy timer that will be triggered
very far in the future. | 6.891568 | 6.608474 | 1.042838 |
from pydev_ipython.inputhookpyglet import inputhook_pyglet
self.set_inputhook(inputhook_pyglet)
self._current_gui = GUI_PYGLET
return app | def enable_pyglet(self, app=None) | Enable event loop integration with pyglet.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
... | 6.42181 | 6.798788 | 0.944552 |
from pydev_ipython.inputhookgtk3 import create_inputhook_gtk3
self.set_inputhook(create_inputhook_gtk3(self._stdin_file))
self._current_gui = GUI_GTK | def enable_gtk3(self, app=None) | Enable event loop integration with Gtk3 (gir bindings).
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
... | 6.861299 | 6.550291 | 1.04748 |
def inputhook_mac(app=None):
if self.pyplot_imported:
pyplot = sys.modules['matplotlib.pyplot']
try:
pyplot.pause(0.01)
except:
pass
else:
if 'matplotlib.pyplot' in sys.module... | def enable_mac(self, app=None) | Enable event loop integration with MacOSX.
We call function pyplot.pause, which updates and displays active
figure during pause. It's not MacOSX-specific, but it enables to
avoid inputhooks in native MacOSX backend.
Also we shouldn't import pyplot, until user does it. Cause it's
... | 4.938467 | 4.004731 | 1.233158 |
name = pydevd_xml.make_valid_xml_value(thread.getName())
cmdText = '<thread name="%s" id="%s" />' % (quote(name), get_thread_id(thread))
return cmdText | def _thread_to_xml(self, thread) | thread information as XML | 6.456087 | 6.394382 | 1.00965 |
try:
threads = get_non_pydevd_threads()
cmd_text = ["<xml>"]
append = cmd_text.append
for thread in threads:
if is_thread_alive(thread):
append(self._thread_to_xml(thread))
append("</xml>")
retur... | def make_list_threads_message(self, py_db, seq) | returns thread listing as XML | 4.528873 | 4.285785 | 1.05672 |
try:
# If frame is None, the return is an empty frame list.
cmd_text = ['<xml><thread id="%s">' % (thread_id,)]
if topmost_frame is not None:
frame_id_to_lineno = {}
try:
# : :type suspended_frames_manager: Suspend... | def make_get_thread_stack_message(self, py_db, seq, thread_id, topmost_frame, fmt, must_be_suspended=False, start_frame=0, levels=0) | Returns thread stack as XML.
:param must_be_suspended: If True and the thread is not suspended, returns None. | 3.88948 | 3.787858 | 1.026828 |
'''
:param frame_id_to_lineno:
If available, the line number for the frame will be gotten from this dict,
otherwise frame.f_lineno will be used (needed for unhandled exceptions as
the place where we report may be different from the place where it's raised).
''... | def make_thread_stack_str(self, frame, frame_id_to_lineno=None) | :param frame_id_to_lineno:
If available, the line number for the frame will be gotten from this dict,
otherwise frame.f_lineno will be used (needed for unhandled exceptions as
the place where we report may be different from the place where it's raised). | 4.958248 | 3.479082 | 1.42516 |
make_valid_xml_value = pydevd_xml.make_valid_xml_value
cmd_text_list = []
append = cmd_text_list.append
cmd_text_list.append('<xml>')
if message:
message = make_valid_xml_value(message)
append('<thread id="%s"' % (thread_id,))
if stop_reason... | def make_thread_suspend_str(
self,
thread_id,
frame,
stop_reason=None,
message=None,
suspend_type="trace",
frame_id_to_lineno=None
) | :return tuple(str,str):
Returns tuple(thread_suspended_str, thread_stack_str).
i.e.:
(
'''
<xml>
<thread id="id" stop_reason="reason">
<frame id="id" name="functionName " file="file" line="line">... | 2.472507 | 2.176734 | 1.135879 |
try:
# If the debugger is not suspended, just return the thread and its id.
cmd_text = ['<xml><thread id="%s" ' % (thread_id,)]
if topmost_frame is not None:
try:
frame = topmost_frame
topmost_frame = None
... | def make_get_exception_details_message(self, seq, thread_id, topmost_frame) | Returns exception details as XML | 3.40138 | 3.367005 | 1.010209 |
if process is None:
self.__process = None
else:
global Process # delayed import
if Process is None:
from winappdbg.process import Process
if not isinstance(process, Process):
msg = "Parent process must be a Pr... | def set_process(self, process = None) | Manually set the parent process. Use with care!
@type process: L{Process}
@param process: (Optional) Process object. Use C{None} for no process. | 3.744799 | 3.781302 | 0.990347 |
"Get the size and entry point of the module using the Win32 API."
process = self.get_process()
if process:
try:
handle = process.get_handle( win32.PROCESS_VM_READ |
win32.PROCESS_QUERY_INFORMATION )
base =... | def __get_size_and_entry_point(self) | Get the size and entry point of the module using the Win32 API. | 3.648397 | 3.22776 | 1.130319 |
filename = PathOperations.pathname_to_filename(pathname)
if filename:
filename = filename.lower()
filepart, extpart = PathOperations.split_extension(filename)
if filepart and extpart:
modName = filepart
else:
modNam... | def __filename_to_modname(self, pathname) | @type pathname: str
@param pathname: Pathname to a module.
@rtype: str
@return: Module name. | 3.699018 | 4.678958 | 0.790564 |
pathname = self.get_filename()
if pathname:
modName = self.__filename_to_modname(pathname)
if isinstance(modName, compat.unicode):
try:
modName = modName.encode('cp1252')
except UnicodeEncodeError:
e... | def get_name(self) | @rtype: str
@return: Module name, as used in labels.
@warning: Names are B{NOT} guaranteed to be unique.
If you need unique identification for a loaded module,
use the base address instead.
@see: L{get_label} | 3.722786 | 3.386311 | 1.099363 |
if not self.get_filename():
msg = "Cannot retrieve filename for module at %s"
msg = msg % HexDump.address( self.get_base() )
raise Exception(msg)
hFile = win32.CreateFile(self.get_filename(),
dwShareMode = win32.FI... | def open_handle(self) | Opens a new handle to the module.
The new handle is stored in the L{hFile} property. | 6.081743 | 5.416753 | 1.122766 |
try:
if hasattr(self.hFile, 'close'):
self.hFile.close()
elif self.hFile not in (None, win32.INVALID_HANDLE_VALUE):
win32.CloseHandle(self.hFile)
finally:
self.hFile = None | def close_handle(self) | Closes the handle to the module.
@note: Normally you don't need to call this method. All handles
created by I{WinAppDbg} are automatically closed when the garbage
collector claims them. So unless you've been tinkering with it,
setting L{hFile} to C{None} should be enough. | 2.592029 | 2.348277 | 1.103801 |
if win32.PROCESS_ALL_ACCESS == win32.PROCESS_ALL_ACCESS_VISTA:
dwAccess = win32.PROCESS_QUERY_LIMITED_INFORMATION
else:
dwAccess = win32.PROCESS_QUERY_INFORMATION
hProcess = self.get_process().get_handle(dwAccess)
hFile = self.hFile
Bas... | def load_symbols(self) | Loads the debugging symbols for a module.
Automatically called by L{get_symbols}. | 3.01022 | 2.957149 | 1.017947 |
if bCaseSensitive:
for (SymbolName, SymbolAddress, SymbolSize) in self.iter_symbols():
if symbol == SymbolName:
return SymbolAddress
for (SymbolName, SymbolAddress, SymbolSize) in self.iter_symbols():
try:
S... | def resolve_symbol(self, symbol, bCaseSensitive = False) | Resolves a debugging symbol's address.
@type symbol: str
@param symbol: Name of the symbol to resolve.
@type bCaseSensitive: bool
@param bCaseSensitive: C{True} for case sensitive matches,
C{False} for case insensitive.
@rtype: int or None
@return: Memor... | 1.776796 | 1.873079 | 0.948596 |
return _ModuleContainer.parse_label(self.get_name(), function, offset) | def get_label(self, function = None, offset = None) | Retrieves the label for the given function of this module or the module
base address if no function name is given.
@type function: str
@param function: (Optional) Exported function name.
@type offset: int
@param offset: (Optional) Offset from the module base address.
... | 20.801996 | 29.324886 | 0.709363 |
# Add the offset to the address.
if offset:
address = address + offset
# Make the label relative to the base address if no match is found.
module = self.get_name()
function = None
offset = address - self.get_base()
# Make the l... | def get_label_at_address(self, address, offset = None) | Creates a label from the given memory address.
If the address belongs to the module, the label is made relative to
it's base address.
@type address: int
@param address: Memory address.
@type offset: None or int
@param offset: (Optional) Offset value.
@rtype:... | 4.767276 | 4.701653 | 1.013957 |
base = self.get_base()
size = self.get_size()
if base and size:
return base <= address < (base + size)
return None | def is_address_here(self, address) | Tries to determine if the given address belongs to this module.
@type address: int
@param address: Memory address.
@rtype: bool or None
@return: C{True} if the address belongs to the module,
C{False} if it doesn't,
and C{None} if it can't be determined. | 4.224517 | 4.538985 | 0.930718 |
# Unknown DLL filename, there's nothing we can do.
filename = self.get_filename()
if not filename:
return None
# If the DLL is already mapped locally, resolve the function.
try:
hlib = win32.GetModuleHandle(filename)
address = win... | def resolve(self, function) | Resolves a function exported by this module.
@type function: str or int
@param function:
str: Name of the function.
int: Ordinal of the function.
@rtype: int
@return: Memory address of the exported function in the process.
Returns None on error. | 4.178204 | 4.146778 | 1.007578 |
# Split the label into it's components.
# Use the fuzzy mode whenever possible.
aProcess = self.get_process()
if aProcess is not None:
(module, procedure, offset) = aProcess.split_label(label)
else:
(module, procedure, offset) = _ModuleContainer.... | def resolve_label(self, label) | Resolves a label for this module only. If the label refers to another
module, an exception is raised.
@type label: str
@param label: Label to resolve.
@rtype: int
@return: Memory address pointed to by the label.
@raise ValueError: The label is malformed or impossible... | 3.800634 | 3.542584 | 1.072843 |
self.__initialize_snapshot()
if lpBaseOfDll not in self.__moduleDict:
msg = "Unknown DLL base address %s"
msg = msg % HexDump.address(lpBaseOfDll)
raise KeyError(msg)
return self.__moduleDict[lpBaseOfDll] | def get_module(self, lpBaseOfDll) | @type lpBaseOfDll: int
@param lpBaseOfDll: Base address of the DLL to look for.
@rtype: L{Module}
@return: Module object with the given base address. | 4.907117 | 4.958404 | 0.989657 |
# Convert modName to lowercase.
# This helps make case insensitive string comparisons.
modName = modName.lower()
# modName is an absolute pathname.
if PathOperations.path_is_absolute(modName):
for lib in self.iter_modules():
if modName == li... | def get_module_by_name(self, modName) | @type modName: int
@param modName:
Name of the module to look for, as returned by L{Module.get_name}.
If two or more modules with the same name are loaded, only one
of the matching modules is returned.
You can also pass a full pathname to the DLL file.
... | 3.838359 | 3.691705 | 1.039725 |
bases = self.get_module_bases()
bases.sort()
bases.append(long(0x10000000000000000)) # max. 64 bit address + 1
if address >= bases[0]:
i = 0
max_i = len(bases) - 1
while i < max_i:
begin, end = bases[i:i+2]
if ... | def get_module_at_address(self, address) | @type address: int
@param address: Memory address to query.
@rtype: L{Module}
@return: C{Module} object that best matches the given address.
Returns C{None} if no C{Module} can be found. | 3.424057 | 3.445581 | 0.993753 |
# The module filenames may be spoofed by malware,
# since this information resides in usermode space.
# See: http://www.ragestorm.net/blogs/?p=163
# Ignore special process IDs.
# PID 0: System Idle Process. Also has a special meaning to the
# toolhelp AP... | def scan_modules(self) | Populates the snapshot with loaded modules. | 6.032227 | 5.828754 | 1.034908 |
for aModule in compat.itervalues(self.__moduleDict):
aModule.clear()
self.__moduleDict = dict() | def clear_modules(self) | Clears the modules snapshot. | 6.927731 | 6.630855 | 1.044772 |
# TODO
# Invalid characters should be escaped or filtered.
# Convert ordinals to strings.
try:
function = "#0x%x" % function
except TypeError:
pass
# Validate the parameters.
if module is not None and ('!' in module or '+' in mo... | def parse_label(module = None, function = None, offset = None) | Creates a label from a module and a function name, plus an offset.
@warning: This method only creates the label, it doesn't make sure the
label actually points to a valid memory location.
@type module: None or str
@param module: (Optional) Module name.
@type function: No... | 2.154289 | 2.070495 | 1.040471 |
module = function = None
offset = 0
# Special case: None
if not label:
label = "0x0"
else:
# Remove all blanks.
label = label.replace(' ', '')
label = label.replace('\t', '')
label = label.replace('\r', '')
... | def split_label_strict(label) | Splits a label created with L{parse_label}.
To parse labels with a less strict syntax, use the L{split_label_fuzzy}
method instead.
@warning: This method only parses the label, it doesn't make sure the
label actually points to a valid memory location.
@type label: str
... | 2.519669 | 2.393732 | 1.052611 |
module = function = None
offset = 0
# Special case: None
if not label:
label = compat.b("0x0")
else:
# Remove all blanks.
label = label.replace(compat.b(' '), compat.b(''))
label = label.replace(compat.b('\t'), compat.b('... | def split_label_fuzzy(self, label) | Splits a label entered as user input.
It's more flexible in it's syntax parsing than the L{split_label_strict}
method, as it allows the exclamation mark (B{C{!}}) to be omitted. The
ambiguity is resolved by searching the modules in the snapshot to guess
if a label refers to a module or ... | 4.514344 | 4.238079 | 1.065186 |
(module, function, offset) = self.split_label_fuzzy(label)
label = self.parse_label(module, function, offset)
return label | def sanitize_label(self, label) | Converts a label taken from user input into a well-formed label.
@type label: str
@param label: Label taken from user input.
@rtype: str
@return: Sanitized label. | 8.677685 | 10.810368 | 0.802719 |
# Split the label into module, function and offset components.
module, function, offset = self.split_label_fuzzy(label)
# Resolve the components into a memory address.
address = self.resolve_label_components(module, function, offset)
# Return the memory address.
... | def resolve_label(self, label) | Resolve the memory address of the given label.
@note:
If multiple modules with the same name are loaded,
the label may be resolved at any of them. For a more precise
way to resolve functions use the base address to get the L{Module}
object (see L{Process.get_modu... | 4.861441 | 4.471062 | 1.087312 |
# Default address if no module or function are given.
# An offset may be added later.
address = 0
# Resolve the module.
# If the module is not found, check for the special symbol "main".
if module:
modobj = self.get_module_by_name(module)
... | def resolve_label_components(self, module = None,
function = None,
offset = None) | Resolve the memory address of the given module, function and/or offset.
@note:
If multiple modules with the same name are loaded,
the label may be resolved at any of them. For a more precise
way to resolve functions use the base address to get the L{Module}
objec... | 2.4558 | 2.457693 | 0.99923 |
if offset:
address = address + offset
modobj = self.get_module_at_address(address)
if modobj:
label = modobj.get_label_at_address(address)
else:
label = self.parse_label(None, None, address)
return label | def get_label_at_address(self, address, offset = None) | Creates a label from the given memory address.
@warning: This method uses the name of the nearest currently loaded
module. If that module is unloaded later, the label becomes
impossible to resolve.
@type address: int
@param address: Memory address.
@type offs... | 2.814213 | 3.434668 | 0.819355 |
if address:
module = self.get_module_at_address(address)
if module:
return module.match_name("ntdll") or \
module.match_name("kernel32")
return False | def is_system_defined_breakpoint(self, address) | @type address: int
@param address: Memory address.
@rtype: bool
@return: C{True} if the given address points to a system defined
breakpoint. System defined breakpoints are hardcoded into
system libraries. | 5.062669 | 5.733245 | 0.883037 |
symbols = list()
for aModule in self.iter_modules():
for symbol in aModule.iter_symbols():
symbols.append(symbol)
return symbols | def get_symbols(self) | Returns the debugging symbols for all modules in this snapshot.
The symbols are automatically loaded when needed.
@rtype: list of tuple( str, int, int )
@return: List of symbols.
Each symbol is represented by a tuple that contains:
- Symbol name
- Sy... | 4.359579 | 4.313178 | 1.010758 |
if bCaseSensitive:
for (SymbolName, SymbolAddress, SymbolSize) in self.iter_symbols():
if symbol == SymbolName:
return SymbolAddress
else:
symbol = symbol.lower()
for (SymbolName, SymbolAddress, SymbolSize) in self.iter_sym... | def resolve_symbol(self, symbol, bCaseSensitive = False) | Resolves a debugging symbol's address.
@type symbol: str
@param symbol: Name of the symbol to resolve.
@type bCaseSensitive: bool
@param bCaseSensitive: C{True} for case sensitive matches,
C{False} for case insensitive.
@rtype: int or None
@return: Memor... | 2.184067 | 2.47875 | 0.881116 |
# Any module may have symbols pointing anywhere in memory, so there's
# no easy way to optimize this. I guess we're stuck with brute force.
found = None
for (SymbolName, SymbolAddress, SymbolSize) in self.iter_symbols():
if SymbolAddress > address:
co... | def get_symbol_at_address(self, address) | Tries to find the closest matching symbol for the given address.
@type address: int
@param address: Memory address to query.
@rtype: None or tuple( str, int, int )
@return: Returns a tuple consisting of:
- Name
- Address
- Size (in bytes)
... | 4.402951 | 4.30148 | 1.02359 |
## if not isinstance(aModule, Module):
## if hasattr(aModule, '__class__'):
## typename = aModule.__class__.__name__
## else:
## typename = str(type(aModule))
## msg = "Expected Module, got %s instead" % typename
## raise TypeErro... | def _add_module(self, aModule) | Private method to add a module object to the snapshot.
@type aModule: L{Module}
@param aModule: Module object. | 2.840707 | 2.888948 | 0.983301 |
try:
aModule = self.__moduleDict[lpBaseOfDll]
del self.__moduleDict[lpBaseOfDll]
except KeyError:
aModule = None
msg = "Unknown base address %d" % HexDump.address(lpBaseOfDll)
warnings.warn(msg, RuntimeWarning)
if aModule:
... | def _del_module(self, lpBaseOfDll) | Private method to remove a module object from the snapshot.
@type lpBaseOfDll: int
@param lpBaseOfDll: Module base address. | 3.724572 | 3.989701 | 0.933547 |
lpBaseOfDll = event.get_module_base()
hFile = event.get_file_handle()
## if not self.has_module(lpBaseOfDll): # XXX this would trigger a scan
if lpBaseOfDll not in self.__moduleDict:
fileName = event.get_filename()
if not fileName:
f... | def __add_loaded_module(self, event) | Private method to automatically add new module objects from debug events.
@type event: L{Event}
@param event: Event object. | 3.17276 | 3.198493 | 0.991955 |
lpBaseOfDll = event.get_module_base()
## if self.has_module(lpBaseOfDll): # XXX this would trigger a scan
if lpBaseOfDll in self.__moduleDict:
self._del_module(lpBaseOfDll)
return True | def _notify_unload_dll(self, event) | Notify the release of a loaded module.
This is done automatically by the L{Debug} class, you shouldn't need
to call it yourself.
@type event: L{UnloadDLLEvent}
@param event: Unload DLL event.
@rtype: bool
@return: C{True} to call the user-defined handle, C{False} oth... | 8.041558 | 9.054236 | 0.888154 |
frame_variables = self.get_namespace()
var_objects = []
vars = scope_attrs.split(NEXT_VALUE_SEPARATOR)
for var_attrs in vars:
if '\t' in var_attrs:
name, attrs = var_attrs.split('\t', 1)
else:
name = var_attrs
... | def loadFullValue(self, seq, scope_attrs) | Evaluate full value for async Console variables in a separate thread and send results to IDE side
:param seq: id of command
:param scope_attrs: a sequence of variables with their attributes separated by NEXT_VALUE_SEPARATOR
(i.e.: obj\tattr1\tattr2NEXT_VALUE_SEPARATORobj2\attr1\tattr2)
:... | 3.546156 | 2.893473 | 1.225571 |
'''
Used to show console with variables connection.
Mainly, monkey-patches things in the debugger structure so that the debugger protocol works.
'''
if debugger_options is None:
debugger_options = {}
env_key = "PYDEVD_EXTRA_ENVS"
if env_key in debugge... | def connectToDebugger(self, debuggerPort, debugger_options=None) | Used to show console with variables connection.
Mainly, monkey-patches things in the debugger structure so that the debugger protocol works. | 5.012624 | 4.260941 | 1.176413 |
''' Enable the GUI specified in guiname (see inputhook for list).
As with IPython, enabling multiple GUIs isn't an error, but
only the last one's main loop runs and it may not work
'''
def do_enable_gui():
from _pydev_bundle.pydev_versioncheck import versionok... | def enableGui(self, guiname) | Enable the GUI specified in guiname (see inputhook for list).
As with IPython, enabling multiple GUIs isn't an error, but
only the last one's main loop runs and it may not work | 7.480061 | 4.501687 | 1.661613 |
'''
Should return 127.0.0.1 in ipv4 and ::1 in ipv6
localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work
properly and takes a lot of time (had this issue on the pyunit server).
Using the IP directly solves the problem.
'''
# TODO: N... | def get_localhost() | Should return 127.0.0.1 in ipv4 and ::1 in ipv6
localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work
properly and takes a lot of time (had this issue on the pyunit server).
Using the IP directly solves the problem. | 5.391475 | 2.517644 | 2.141476 |
# Use the default architecture if none specified.
if not arch:
arch = win32.arch
# Validate the architecture.
if arch not in self.supported:
msg = "The %s engine cannot decode %s code."
msg = msg % (self.name, arch)
raise NotImpl... | def _validate_arch(self, arch = None) | @type arch: str
@param arch: Name of the processor architecture.
If not provided the current processor architecture is assumed.
For more details see L{win32.version._get_arch}.
@rtype: str
@return: Name of the processor architecture.
If not provided the cur... | 4.948049 | 4.468352 | 1.107354 |
if api == QT_API_PYSIDE:
ID.forbid('PyQt4')
ID.forbid('PyQt5')
else:
ID.forbid('PySide') | def commit_api(api) | Commit to a particular API, and trigger ImportErrors on subsequent
dangerous imports | 8.175853 | 7.58045 | 1.078545 |
if 'PyQt4.QtCore' in sys.modules:
if qtapi_version() == 2:
return QT_API_PYQT
else:
return QT_API_PYQTv1
elif 'PySide.QtCore' in sys.modules:
return QT_API_PYSIDE
elif 'PyQt5.QtCore' in sys.modules:
return QT_API_PYQT5
return None | def loaded_api() | Return which API is loaded, if any
If this returns anything besides None,
importing any other Qt binding is unsafe.
Returns
-------
None, 'pyside', 'pyqt', or 'pyqtv1' | 3.085039 | 2.756208 | 1.119306 |
# we can't import an incomplete pyside and pyqt4
# this will cause a crash in sip (#1431)
# check for complete presence before importing
module_name = {QT_API_PYSIDE: 'PySide',
QT_API_PYQT: 'PyQt4',
QT_API_PYQTv1: 'PyQt4',
QT_API_PYQT_DEFAULT... | def has_binding(api) | Safely check for PyQt4 or PySide, without importing
submodules
Parameters
----------
api : str [ 'pyqtv1' | 'pyqt' | 'pyside' | 'pyqtdefault']
Which module to check for
Returns
-------
True if the relevant module appears to be importable | 4.307054 | 4.072058 | 1.057709 |
if not has_binding(api):
return False
current = loaded_api()
if api == QT_API_PYQT_DEFAULT:
return current in [QT_API_PYQT, QT_API_PYQTv1, QT_API_PYQT5, None]
else:
return current in [api, None] | def can_import(api) | Safely query whether an API is importable, without importing it | 5.609641 | 5.750294 | 0.97554 |
# The new-style string API (version=2) automatically
# converts QStrings to Unicode Python strings. Also, automatically unpacks
# QVariants to their underlying objects.
import sip
if version is not None:
sip.setapi('QString', version)
sip.setapi('QVariant', version)
from P... | def import_pyqt4(version=2) | Import PyQt4
Parameters
----------
version : 1, 2, or None
Which QString/QVariant API to use. Set to None to use the system
default
ImportErrors raised within this function are non-recoverable | 4.586782 | 4.720096 | 0.971756 |
from PyQt5 import QtGui, QtCore, QtSvg
# Alias PyQt-specific functions for PySide compatibility.
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
return QtCore, QtGui, QtSvg, QT_API_PYQT5 | def import_pyqt5() | Import PyQt5
ImportErrors raised within this function are non-recoverable | 4.342284 | 5.328689 | 0.814888 |
loaders = {QT_API_PYSIDE: import_pyside,
QT_API_PYQT: import_pyqt4,
QT_API_PYQTv1: partial(import_pyqt4, version=1),
QT_API_PYQT_DEFAULT: partial(import_pyqt4, version=None),
QT_API_PYQT5: import_pyqt5,
}
for api in api_options:
... | def load_qt(api_options) | Attempt to import Qt, given a preference list
of permissible bindings
It is safe to call this function multiple times.
Parameters
----------
api_options: List of strings
The order of APIs to try. Valid items are 'pyside',
'pyqt', and 'pyqtv1'
Returns
-------
A tuple o... | 3.551085 | 3.497682 | 1.015268 |
try:
ind_c = args.index('-c')
except ValueError:
return -1
else:
for i in range(1, ind_c):
if not args[i].startswith('-'):
# there is an arg without "-" before "-c", so it's not an interpreter's option
return -1
return ind_c | def get_c_option_index(args) | Get index of "-c" argument and check if it's interpreter's option
:param args: list of arguments
:return: index of "-c" if it's an interpreter's option and -1 if it doesn't exist or program's option | 4.75304 | 3.332122 | 1.42643 |
def new_execve(path, args, env):
import os
send_process_created_message()
return getattr(os, original_name)(path, patch_args(args), env)
return new_execve | def create_execve(original_name) | os.execve(path, args, env)
os.execvpe(file, args, env) | 6.451482 | 5.819801 | 1.10854 |
def new_spawnve(mode, path, args, env):
import os
send_process_created_message()
return getattr(os, original_name)(mode, path, patch_args(args), env)
return new_spawnve | def create_spawnve(original_name) | os.spawnve(mode, path, args, env)
os.spawnvpe(mode, file, args, env) | 9.170001 | 5.512483 | 1.663497 |
def new_fork_exec(args, *other_args):
import _posixsubprocess # @UnresolvedImport
args = patch_args(args)
send_process_created_message()
return getattr(_posixsubprocess, original_name)(args, *other_args)
return new_fork_exec | def create_fork_exec(original_name) | _posixsubprocess.fork_exec(args, executable_list, close_fds, ... (13 more)) | 5.549675 | 5.73215 | 0.968166 |
def new_warn_fork_exec(*args):
try:
import _posixsubprocess
warn_multiproc()
return getattr(_posixsubprocess, original_name)(*args)
except:
pass
return new_warn_fork_exec | def create_warn_fork_exec(original_name) | _posixsubprocess.fork_exec(args, executable_list, close_fds, ... (13 more)) | 4.762101 | 5.313024 | 0.896307 |
def new_CreateProcess(app_name, cmd_line, *args):
try:
import _subprocess
except ImportError:
import _winapi as _subprocess
send_process_created_message()
return getattr(_subprocess, original_name)(app_name, patch_arg_str_win(cmd_line), *args)
retur... | def create_CreateProcess(original_name) | CreateProcess(*args, **kwargs) | 5.538252 | 5.572635 | 0.99383 |
def new_CreateProcess(*args):
try:
import _subprocess
except ImportError:
import _winapi as _subprocess
warn_multiproc()
return getattr(_subprocess, original_name)(*args)
return new_CreateProcess | def create_CreateProcessWarnMultiproc(original_name) | CreateProcess(*args, **kwargs) | 3.853417 | 3.884682 | 0.991952 |
if not encoding:
encoding = detect_encoding(filename, limit_byte_check=limit_byte_check)
return io.open(filename, mode=mode, encoding=encoding,
newline='') | def open_with_encoding(filename,
encoding=None, mode='r', limit_byte_check=-1) | Return opened file with a specific encoding. | 2.609276 | 2.546822 | 1.024522 |
if previous_logical.startswith('def '):
if blank_lines and pycodestyle.DOCSTRING_REGEX.match(logical_line):
yield (0, 'E303 too many blank lines ({0})'.format(blank_lines))
elif pycodestyle.DOCSTRING_REGEX.match(previous_logical):
# Missing blank line between class docstring and... | def extended_blank_lines(logical_line,
blank_lines,
blank_before,
indent_level,
previous_logical) | Check for missing blank lines after class declaration. | 4.202774 | 3.97787 | 1.056539 |
# Optimization.
return source
ignored_line_numbers = multiline_string_lines(
source,
include_docstrings=True) | set(commented_out_code_lines(source))
fixed_lines = []
sio = io.StringIO(source)
for (line_number, line) in enumerate(sio.readlines(), start=1):
if (
... | def fix_e265(source, aggressive=False): # pylint: disable=unused-argument
if '#' not in source | Format block comments. | 4.524383 | 4.488151 | 1.008073 |
check_lib2to3()
from lib2to3 import pgen2
try:
new_text = refactor_with_2to3(source,
fixer_names=fixer_names,
filename=filename)
except (pgen2.parse.ParseError,
SyntaxError,
UnicodeDecodeErro... | def refactor(source, fixer_names, ignore=None, filename='') | Return refactored code using lib2to3.
Skip if ignore string is produced in the refactored code. | 4.129858 | 3.732856 | 1.106353 |
if not aggressive:
return source
select = select or []
ignore = ignore or []
return refactor(source,
code_to_2to3(select=select,
ignore=ignore),
filename=filename) | def fix_2to3(source,
aggressive=True, select=None, ignore=None, filename='') | Fix various deprecated code (via lib2to3). | 4.999713 | 4.924192 | 1.015337 |
if line.strip():
non_whitespace_index = len(line) - len(line.lstrip())
return line[:non_whitespace_index]
else:
return '' | def _get_indentation(line) | Return leading whitespace. | 3.039258 | 2.461735 | 1.2346 |
priority = [
# Fix multiline colon-based before semicolon based.
'e701',
# Break multiline statements early.
'e702',
# Things that make lines longer.
'e225', 'e231',
# Remove extraneous whitespace before breaking lines.
'e201',
# Shorten w... | def _priority_key(pep8_result) | Key for sorting PEP8 results.
Global fixes should be done first. This is important for things like
indentation. | 7.663774 | 7.517441 | 1.019466 |
if line.startswith('def ') and line.rstrip().endswith(':'):
return line + ' pass'
elif line.startswith('return '):
return 'def _(): ' + line
elif line.startswith('@'):
return line + 'def _(): pass'
elif line.startswith('class '):
return line + ' pass'
elif line.s... | def normalize_multiline(line) | Normalize multiline-related code that will cause syntax error.
This is for purposes of checking syntax. | 3.004452 | 2.876445 | 1.044502 |
# Replace escaped newlines too
left = line[:offset].rstrip('\n\r \t\\')
right = line[offset:].lstrip('\n\r \t\\')
if right.startswith('#'):
return line
else:
return left + replacement + right | def fix_whitespace(line, offset, replacement) | Replace whitespace at offset and return fixed line. | 4.091779 | 4.262425 | 0.959965 |
# Transform everything to line feed. Then change them back to original
# before returning fixed source code.
original_newline = find_newline(source_lines)
tmp_source = ''.join(normalize_line_endings(source_lines, '\n'))
# Keep a history to break out of cycles.
previous_hashes = set()
... | def fix_lines(source_lines, options, filename='') | Return fixed source code. | 5.02878 | 4.853831 | 1.036043 |
if any(code_match(code, select=options.select, ignore=options.ignore)
for code in ['E101', 'E111']):
source = reindent(source,
indent_size=options.indent_size)
for (code, function) in global_fixes():
if code_match(code, select=options.select, ignore=opt... | def apply_global_fixes(source, options, where='global', filename='') | Run global fixes on source code.
These are fixes that only need be done once (unlike those in
FixPEP8, which are dependent on pycodestyle). | 3.794862 | 3.702157 | 1.025041 |
parser = create_parser()
args = parser.parse_args(arguments)
if not args.files and not args.list_fixes:
parser.error('incorrect number of arguments')
args.files = [decode_filename(name) for name in args.files]
if apply_config:
parser = read_config(args, parser)
args =... | def parse_args(arguments, apply_config=False) | Parse command-line options. | 2.407492 | 2.386768 | 1.008683 |
if parameters[1].verbose:
print('[file:{0}]'.format(parameters[0]), file=sys.stderr)
try:
fix_file(*parameters)
except IOError as error:
print(unicode(error), file=sys.stderr) | def _fix_file(parameters) | Helper function for optionally running fix_file() in parallel. | 5.024316 | 4.468358 | 1.124421 |
filenames = find_files(filenames, options.recursive, options.exclude)
if options.jobs > 1:
import multiprocessing
pool = multiprocessing.Pool(options.jobs)
pool.map(_fix_file,
[(name, options) for name in filenames])
else:
for name in filenames:
... | def fix_multiple_files(filenames, options, output=None) | Fix list of files.
Optionally fix files recursively. | 2.661638 | 3.181854 | 0.836505 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.