_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q36800 | base_argparser | train | def base_argparser(argv=()):
"""Initial parser that can set values for the rest of the parsing process.
"""
global verbose
verbose = _not_verbose
_p = argparse.ArgumentParser(add_help=False)
_p.add_argument('--debug', action='store_true', help="turn on all the show and verbose options (mainly f... | python | {
"resource": ""
} |
q36801 | dep2req | train | def dep2req(name, imported_by):
"""Convert dependency to requirement.
"""
lst = [item for item in sorted(imported_by) if not item.startswith(name)]
res = '%-15s # from: ' % name
imps = ', '.join(lst)
if len(imps) < WIDTH - 24:
return res + imps
return res + imps[:WIDTH - 24 -... | python | {
"resource": ""
} |
q36802 | pydeps2reqs | train | def pydeps2reqs(deps):
"""Convert a deps instance into requirements.
"""
reqs = defaultdict(set)
for k, v in list(deps.items()):
# not a built-in
p = v['path']
if p and not p.startswith(sys.real_prefix):
if p.startswith(sys.prefix) and 'site-packages' in p:
... | python | {
"resource": ""
} |
q36803 | main | train | def main():
"""Cli entrypoint.
"""
if len(sys.argv) == 2:
fname = sys.argv[1]
data = json.load(open(fname, 'rb'))
else:
data = json.loads(sys.stdin.read())
print(pydeps2reqs(data)) | python | {
"resource": ""
} |
q36804 | pydeps | train | def pydeps(**args):
"""Entry point for the ``pydeps`` command.
This function should do all the initial parameter and environment
munging before calling ``_pydeps`` (so that function has a clean
execution path).
"""
_args = args if args else cli.parse_args(sys.argv[1:])
inp = target... | python | {
"resource": ""
} |
q36805 | Target._path_parts | train | def _path_parts(self, pth):
"""Return a list of all directories in the path ``pth``.
"""
res = re.split(r"[\\/]", pth)
if res and os.path.splitdrive(res[0]) == (res[0], ''):
res[0] += os.path.sep
return res | python | {
"resource": ""
} |
q36806 | Connection.cursor | train | def cursor(self):
"""
Create a new ``Cursor`` instance associated with this ``Connection``
:return: A new ``Cursor`` instance
"""
self._assert_valid()
c = Cursor(self.impl.cursor())
self.cursors.add(c)
return c | python | {
"resource": ""
} |
q36807 | Connection.close | train | def close(self):
"""
Close the connection and all associated cursors. This will implicitly
roll back any uncommitted operations.
"""
for c in self.cursors:
c.close()
self.cursors = []
self.impl = None | python | {
"resource": ""
} |
q36808 | make_options | train | def make_options(read_buffer_size=None,
parameter_sets_to_buffer=None,
varchar_max_character_limit=None,
prefer_unicode=None,
use_async_io=None,
autocommit=None,
large_decimals_as_64_bit_types=None,
li... | python | {
"resource": ""
} |
q36809 | _get_distutils_build_directory | train | def _get_distutils_build_directory():
"""
Returns the directory distutils uses to build its files.
We need this directory since we build extensions which have to link
other ones.
"""
pattern = "lib.{platform}-{major}.{minor}"
return os.path.join('build', pattern.format(platform=sysconfig.get... | python | {
"resource": ""
} |
q36810 | get_extension_modules | train | def get_extension_modules():
extension_modules = []
"""
Extension module which is actually a plain C++ library without Python bindings
"""
turbodbc_sources = _get_source_files('cpp_odbc') + _get_source_files('turbodbc')
turbodbc_library = Extension('libturbodbc',
... | python | {
"resource": ""
} |
q36811 | connect | train | def connect(dsn=None, turbodbc_options=None, connection_string=None, **kwargs):
"""
Create a connection with the database identified by the ``dsn`` or the ``connection_string``.
:param dsn: Data source name as given in the (unix) odbc.ini file
or (Windows) ODBC Data Source Administrator tool.
... | python | {
"resource": ""
} |
q36812 | Cursor.description | train | def description(self):
"""
Retrieve a description of the columns in the current result set
:return: A tuple of seven elements. Only some elements are meaningful:\n
* Element #0 is the name of the column
* Element #1 is the type code of the column
... | python | {
"resource": ""
} |
q36813 | Cursor.execute | train | def execute(self, sql, parameters=None):
"""
Execute an SQL command or query
:param sql: A (unicode) string that contains the SQL command or query. If you would like to
use parameters, please use a question mark ``?`` at the location where the
parameter shall be in... | python | {
"resource": ""
} |
q36814 | Cursor.close | train | def close(self):
"""
Close the cursor.
"""
self.result_set = None
if self.impl is not None:
self.impl._reset()
self.impl = None | python | {
"resource": ""
} |
q36815 | connect_to_pipe | train | def connect_to_pipe(pipe_name):
"""
Connect to a new pipe in message mode.
"""
pipe_handle = windll.kernel32.CreateFileW(
pipe_name,
DWORD(GENERIC_READ | GENERIC_WRITE | FILE_WRITE_ATTRIBUTES),
DWORD(0), # No sharing.
None, # Default security attributes.
DWORD(O... | python | {
"resource": ""
} |
q36816 | create_event | train | def create_event():
"""
Create Win32 event.
"""
event = windll.kernel32.CreateEventA(
None, # Default security attributes.
BOOL(True), # Manual reset event.
BOOL(True), # Initial state = signaled.
None # Unnamed event object.
)
if not event:
raise Exce... | python | {
"resource": ""
} |
q36817 | wait_for_event | train | def wait_for_event(event):
"""
Wraps a win32 event into a `Future` and wait for it.
"""
f = Future()
def ready():
get_event_loop().remove_win32_handle(event)
f.set_result(None)
get_event_loop().add_win32_handle(event, ready)
return f | python | {
"resource": ""
} |
q36818 | WindowsClient._start_reader | train | def _start_reader(self):
"""
Read messages from the Win32 pipe server and handle them.
"""
while True:
message = yield From(self.pipe.read_message())
self._process(message) | python | {
"resource": ""
} |
q36819 | _draw_number | train | def _draw_number(screen, x_offset, y_offset, number, style='class:clock',
transparent=False):
" Write number at position. "
fg = Char(' ', 'class:clock')
bg = Char(' ', '')
for y, row in enumerate(_numbers[number]):
screen_row = screen.data_buffer[y + y_offset]
for x, n... | python | {
"resource": ""
} |
q36820 | _create_split | train | def _create_split(pymux, window, split):
"""
Create a prompt_toolkit `Container` instance for the given pymux split.
"""
assert isinstance(split, (arrangement.HSplit, arrangement.VSplit))
is_vsplit = isinstance(split, arrangement.VSplit)
def get_average_weight():
""" Calculate average w... | python | {
"resource": ""
} |
q36821 | _create_container_for_process | train | def _create_container_for_process(pymux, window, arrangement_pane, zoom=False):
"""
Create a `Container` with a titlebar for a process.
"""
@Condition
def clock_is_visible():
return arrangement_pane.clock_mode
@Condition
def pane_numbers_are_visible():
return pymux.display_p... | python | {
"resource": ""
} |
q36822 | focus_left | train | def focus_left(pymux):
" Move focus to the left. "
_move_focus(pymux,
lambda wp: wp.xpos - 2, # 2 in order to skip over the border.
lambda wp: wp.ypos) | python | {
"resource": ""
} |
q36823 | focus_right | train | def focus_right(pymux):
" Move focus to the right. "
_move_focus(pymux,
lambda wp: wp.xpos + wp.width + 1,
lambda wp: wp.ypos) | python | {
"resource": ""
} |
q36824 | focus_down | train | def focus_down(pymux):
" Move focus down. "
_move_focus(pymux,
lambda wp: wp.xpos,
lambda wp: wp.ypos + wp.height + 2) | python | {
"resource": ""
} |
q36825 | focus_up | train | def focus_up(pymux):
" Move focus up. "
_move_focus(pymux,
lambda wp: wp.xpos,
lambda wp: wp.ypos - 2) | python | {
"resource": ""
} |
q36826 | _move_focus | train | def _move_focus(pymux, get_x, get_y):
" Move focus of the active window. "
window = pymux.arrangement.get_active_window()
try:
write_pos = pymux.get_client_state().layout_manager.pane_write_positions[window.active_pane]
except KeyError:
pass
else:
x = get_x(write_pos)
... | python | {
"resource": ""
} |
q36827 | Background.write_to_screen | train | def write_to_screen(self, screen, mouse_handlers, write_position,
parent_style, erase_bg, z_index):
" Fill the whole area of write_position with dots. "
default_char = Char(' ', 'class:background')
dot = Char('.', 'class:background')
ypos = write_position.ypos
... | python | {
"resource": ""
} |
q36828 | BigClock._mouse_handler | train | def _mouse_handler(self, cli, mouse_event):
" Click callback. "
if mouse_event.event_type == MouseEventType.MOUSE_UP:
self.on_click(cli)
else:
return NotImplemented | python | {
"resource": ""
} |
q36829 | LayoutManager.display_popup | train | def display_popup(self, title, content):
"""
Display a pop-up dialog.
"""
assert isinstance(title, six.text_type)
assert isinstance(content, six.text_type)
self.popup_dialog.title = title
self._popup_textarea.text = content
self.client_state.display_popup... | python | {
"resource": ""
} |
q36830 | LayoutManager._create_select_window_handler | train | def _create_select_window_handler(self, window):
" Return a mouse handler that selects the given window when clicking. "
def handler(mouse_event):
if mouse_event.event_type == MouseEventType.MOUSE_DOWN:
self.pymux.arrangement.set_active_window(window)
self.pym... | python | {
"resource": ""
} |
q36831 | LayoutManager._get_status_tokens | train | def _get_status_tokens(self):
" The tokens for the status bar. "
result = []
# Display panes.
for i, w in enumerate(self.pymux.arrangement.windows):
if i > 0:
result.append(('', ' '))
if w == self.pymux.arrangement.get_active_window():
... | python | {
"resource": ""
} |
q36832 | DynamicBody._get_body | train | def _get_body(self):
" Return the Container object for the current CLI. "
new_hash = self.pymux.arrangement.invalidation_hash()
# Return existing layout if nothing has changed to the arrangement.
app = get_app()
if app in self._bodies_for_app:
existing_hash, contain... | python | {
"resource": ""
} |
q36833 | DynamicBody._build_layout | train | def _build_layout(self):
" Rebuild a new Container object and return that. "
logger.info('Rebuilding layout.')
if not self.pymux.arrangement.windows:
# No Pymux windows in the arrangement.
return Window()
active_window = self.pymux.arrangement.get_active_window(... | python | {
"resource": ""
} |
q36834 | bind_and_listen_on_socket | train | def bind_and_listen_on_socket(socket_name, accept_callback):
"""
Return socket name.
:param accept_callback: Callback is called with a `PipeConnection` as
argument.
"""
if is_windows():
from .win32_server import bind_and_listen_on_win32_socket
return bind_and_listen_on_win32... | python | {
"resource": ""
} |
q36835 | list_clients | train | def list_clients():
"""
List all the servers that are running.
"""
p = '%s/pymux.sock.%s.*' % (tempfile.gettempdir(), getpass.getuser())
for path in glob.glob(p):
try:
yield PosixClient(path)
except socket.error:
pass | python | {
"resource": ""
} |
q36836 | PosixClient.attach | train | def attach(self, detach_other_clients=False, color_depth=ColorDepth.DEPTH_8_BIT):
"""
Attach client user interface.
"""
assert isinstance(detach_other_clients, bool)
self._send_size()
self._send_packet({
'cmd': 'start-gui',
'detach-others': detach... | python | {
"resource": ""
} |
q36837 | PosixClient._process_stdin | train | def _process_stdin(self):
"""
Received data on stdin. Read and send to server.
"""
with nonblocking(sys.stdin.fileno()):
data = self._stdin_reader.read()
# Send input in chunks of 4k.
step = 4056
for i in range(0, len(data), step):
self._s... | python | {
"resource": ""
} |
q36838 | ClientState._handle_command | train | def _handle_command(self, buffer):
" When text is accepted in the command line. "
text = buffer.text
# First leave command mode. We want to make sure that the working
# pane is focused again before executing the command handers.
self.pymux.leave_command_mode(append_to_history=Tr... | python | {
"resource": ""
} |
q36839 | ClientState._handle_prompt_command | train | def _handle_prompt_command(self, buffer):
" When a command-prompt command is accepted. "
text = buffer.text
prompt_command = self.prompt_command
# Leave command mode and handle command.
self.pymux.leave_command_mode(append_to_history=True)
self.pymux.handle_command(promp... | python | {
"resource": ""
} |
q36840 | ClientState._create_app | train | def _create_app(self):
"""
Create `Application` instance for this .
"""
pymux = self.pymux
def on_focus_changed():
""" When the focus changes to a read/write buffer, make sure to go
to insert mode. This happens when the ViState was set to NAVIGATION
... | python | {
"resource": ""
} |
q36841 | ClientState.sync_focus | train | def sync_focus(self, *_):
"""
Focus the focused window from the pymux arrangement.
"""
# Pop-up displayed?
if self.display_popup:
self.app.layout.focus(self.layout_manager.popup_dialog)
return
# Confirm.
if self.confirm_text:
r... | python | {
"resource": ""
} |
q36842 | Pymux._start_auto_refresh_thread | train | def _start_auto_refresh_thread(self):
"""
Start the background thread that auto refreshes all clients according to
`self.status_interval`.
"""
def run():
while True:
time.sleep(self.status_interval)
self.invalidate()
t = thread... | python | {
"resource": ""
} |
q36843 | Pymux.get_client_state | train | def get_client_state(self):
" Return the active ClientState instance. "
app = get_app()
for client_state in self._client_states.values():
if client_state.app == app:
return client_state
raise ValueError('Client state for app %r not found' % (app, )) | python | {
"resource": ""
} |
q36844 | Pymux.get_connection | train | def get_connection(self):
" Return the active Connection instance. "
app = get_app()
for connection, client_state in self._client_states.items():
if client_state.app == app:
return connection
raise ValueError('Connection for app %r not found' % (app, )) | python | {
"resource": ""
} |
q36845 | Pymux.get_title | train | def get_title(self):
"""
The title to be displayed in the titlebar of the terminal.
"""
w = self.arrangement.get_active_window()
if w and w.active_process:
title = w.active_process.screen.title
else:
title = ''
if title:
retur... | python | {
"resource": ""
} |
q36846 | Pymux.get_window_size | train | def get_window_size(self):
"""
Get the size to be used for the DynamicBody.
This will be the smallest size of all clients.
"""
def active_window_for_app(app):
with set_app(app):
return self.arrangement.get_active_window()
active_window = self.... | python | {
"resource": ""
} |
q36847 | Pymux.invalidate | train | def invalidate(self):
" Invalidate the UI for all clients. "
logger.info('Invalidating %s applications', len(self.apps))
for app in self.apps:
app.invalidate() | python | {
"resource": ""
} |
q36848 | Pymux.kill_pane | train | def kill_pane(self, pane):
"""
Kill the given pane, and remove it from the arrangement.
"""
assert isinstance(pane, Pane)
# Send kill signal.
if not pane.process.is_terminated:
pane.process.kill()
# Remove from layout.
self.arrangement.remove... | python | {
"resource": ""
} |
q36849 | Pymux.detach_client | train | def detach_client(self, app):
"""
Detach the client that belongs to this CLI.
"""
connection = self.get_connection()
if connection:
connection.detach_and_close()
# Redraw all clients -> Maybe their size has to change.
self.invalidate() | python | {
"resource": ""
} |
q36850 | Pymux.listen_on_socket | train | def listen_on_socket(self, socket_name=None):
"""
Listen for clients on a Unix socket.
Returns the socket name.
"""
def connection_cb(pipe_connection):
# We have to create a new `context`, because this will be the scope for
# a new prompt_toolkit.Applicati... | python | {
"resource": ""
} |
q36851 | _bind_posix_socket | train | def _bind_posix_socket(socket_name=None):
"""
Find a socket to listen on and return it.
Returns (socket_name, sock_obj)
"""
assert socket_name is None or isinstance(socket_name, six.text_type)
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
if socket_name:
s.bind(socket_name... | python | {
"resource": ""
} |
q36852 | PosixSocketConnection.write | train | def write(self, message):
"""
Coroutine that writes the next packet.
"""
try:
self.socket.send(message.encode('utf-8') + b'\0')
except socket.error:
if not self._closed:
raise BrokenPipeError
return Future.succeed(None) | python | {
"resource": ""
} |
q36853 | PymuxKeyBindings._load_prefix_binding | train | def _load_prefix_binding(self):
"""
Load the prefix key binding.
"""
pymux = self.pymux
# Remove previous binding.
if self._prefix_binding:
self.custom_key_bindings.remove_binding(self._prefix_binding)
# Create new Python binding.
@self.custo... | python | {
"resource": ""
} |
q36854 | PymuxKeyBindings.prefix | train | def prefix(self, keys):
"""
Set a new prefix key.
"""
assert isinstance(keys, tuple)
self._prefix = keys
self._load_prefix_binding() | python | {
"resource": ""
} |
q36855 | PymuxKeyBindings.remove_custom_binding | train | def remove_custom_binding(self, key_name, needs_prefix=False):
"""
Remove custom key binding for a key.
:param key_name: Pymux key name, for instance "C-A".
"""
k = (needs_prefix, key_name)
if k in self.custom_bindings:
self.custom_key_bindings.remove(self.c... | python | {
"resource": ""
} |
q36856 | PipeInstance._handle_client | train | def _handle_client(self):
"""
Coroutine that connects to a single client and handles that.
"""
while True:
try:
# Wait for connection.
logger.info('Waiting for connection in pipe instance.')
yield From(self._connect_client())
... | python | {
"resource": ""
} |
q36857 | PipeInstance._connect_client | train | def _connect_client(self):
"""
Wait for a client to connect to this pipe.
"""
overlapped = OVERLAPPED()
overlapped.hEvent = create_event()
while True:
success = windll.kernel32.ConnectNamedPipe(
self.pipe_handle,
byref(overlapp... | python | {
"resource": ""
} |
q36858 | pymux_key_to_prompt_toolkit_key_sequence | train | def pymux_key_to_prompt_toolkit_key_sequence(key):
"""
Turn a pymux description of a key. E.g. "C-a" or "M-x" into a
prompt-toolkit key sequence.
Raises `ValueError` if the key is not known.
"""
# Make the c- and m- prefixes case insensitive.
if key.lower().startswith('m-c-'):
key ... | python | {
"resource": ""
} |
q36859 | PositiveIntOption.set_value | train | def set_value(self, pymux, value):
"""
Take a string, and return an integer. Raise SetOptionError when the
given text does not parse to a positive integer.
"""
try:
value = int(value)
if value < 0:
raise ValueError
except ValueError... | python | {
"resource": ""
} |
q36860 | handle_command | train | def handle_command(pymux, input_string):
"""
Handle command.
"""
assert isinstance(input_string, six.text_type)
input_string = input_string.strip()
logger.info('handle command: %s %s.', input_string, type(input_string))
if input_string and not input_string.startswith('#'): # Ignore commen... | python | {
"resource": ""
} |
q36861 | cmd | train | def cmd(name, options=''):
"""
Decorator for all commands.
Commands will receive (pymux, variables) as input.
Commands can raise CommandException.
"""
# Validate options.
if options:
try:
docopt.docopt('Usage:\n %s %s' % (name, options, ), [])
except SystemExi... | python | {
"resource": ""
} |
q36862 | kill_window | train | def kill_window(pymux, variables):
" Kill all panes in the current window. "
for pane in pymux.arrangement.get_active_window().panes:
pymux.kill_pane(pane) | python | {
"resource": ""
} |
q36863 | next_layout | train | def next_layout(pymux, variables):
" Select next layout. "
pane = pymux.arrangement.get_active_window()
if pane:
pane.select_next_layout() | python | {
"resource": ""
} |
q36864 | previous_layout | train | def previous_layout(pymux, variables):
" Select previous layout. "
pane = pymux.arrangement.get_active_window()
if pane:
pane.select_previous_layout() | python | {
"resource": ""
} |
q36865 | _ | train | def _(pymux, variables):
" Go to previous active window. "
w = pymux.arrangement.get_previous_active_window()
if w:
pymux.arrangement.set_active_window(w) | python | {
"resource": ""
} |
q36866 | split_window | train | def split_window(pymux, variables):
"""
Split horizontally or vertically.
"""
executable = variables['<executable>']
start_directory = variables['<start-directory>']
# The tmux definition of horizontal is the opposite of prompt_toolkit.
pymux.add_process(executable, vsplit=variables['-h'],
... | python | {
"resource": ""
} |
q36867 | command_prompt | train | def command_prompt(pymux, variables):
"""
Enter command prompt.
"""
client_state = pymux.get_client_state()
if variables['<command>']:
# When a 'command' has been given.
client_state.prompt_text = variables['<message>'] or '(%s)' % variables['<command>'].split()[0]
client_st... | python | {
"resource": ""
} |
q36868 | send_prefix | train | def send_prefix(pymux, variables):
"""
Send prefix to active pane.
"""
process = pymux.arrangement.get_active_pane().process
for k in pymux.key_bindings_manager.prefix:
vt100_data = prompt_toolkit_key_to_vt100_key(k)
process.write_input(vt100_data) | python | {
"resource": ""
} |
q36869 | unbind_key | train | def unbind_key(pymux, variables):
"""
Remove key binding.
"""
key = variables['<key>']
needs_prefix = not variables['-n']
pymux.key_bindings_manager.remove_custom_binding(
key, needs_prefix=needs_prefix) | python | {
"resource": ""
} |
q36870 | send_keys | train | def send_keys(pymux, variables):
"""
Send key strokes to the active process.
"""
pane = pymux.arrangement.get_active_pane()
if pane.display_scroll_buffer:
raise CommandException('Cannot send keys. Pane is in copy mode.')
for key in variables['<keys>']:
# Translate key from pymu... | python | {
"resource": ""
} |
q36871 | copy_mode | train | def copy_mode(pymux, variables):
"""
Enter copy mode.
"""
go_up = variables['-u'] # Go in copy mode and page-up directly.
# TODO: handle '-u'
pane = pymux.arrangement.get_active_pane()
pane.enter_copy_mode() | python | {
"resource": ""
} |
q36872 | paste_buffer | train | def paste_buffer(pymux, variables):
"""
Paste clipboard content into buffer.
"""
pane = pymux.arrangement.get_active_pane()
pane.process.write_input(get_app().clipboard.get_data().text, paste=True) | python | {
"resource": ""
} |
q36873 | source_file | train | def source_file(pymux, variables):
"""
Source configuration file.
"""
filename = os.path.expanduser(variables['<filename>'])
try:
with open(filename, 'rb') as f:
for line in f:
line = line.decode('utf-8')
handle_command(pymux, line)
except IOEr... | python | {
"resource": ""
} |
q36874 | display_message | train | def display_message(pymux, variables):
" Display a message. "
message = variables['<message>']
client_state = pymux.get_client_state()
client_state.message = message | python | {
"resource": ""
} |
q36875 | clear_history | train | def clear_history(pymux, variables):
" Clear scrollback buffer. "
pane = pymux.arrangement.get_active_pane()
if pane.display_scroll_buffer:
raise CommandException('Not available in copy mode')
else:
pane.process.screen.clear_history() | python | {
"resource": ""
} |
q36876 | list_keys | train | def list_keys(pymux, variables):
"""
Display all configured key bindings.
"""
# Create help string.
result = []
for k, custom_binding in pymux.key_bindings_manager.custom_bindings.items():
needs_prefix, key = k
result.append('bind-key %3s %-10s %s %s' % (
('-n' if n... | python | {
"resource": ""
} |
q36877 | list_panes | train | def list_panes(pymux, variables):
"""
Display a list of all the panes.
"""
w = pymux.arrangement.get_active_window()
active_pane = w.active_pane
result = []
for i, p in enumerate(w.panes):
process = p.process
result.append('%i: [%sx%s] [history %s/%s] %s' % (
i... | python | {
"resource": ""
} |
q36878 | show_buffer | train | def show_buffer(pymux, variables):
"""
Display the clipboard content.
"""
text = get_app().clipboard.get_data().text
pymux.get_client_state().layout_manager.display_popup('show-buffer', text) | python | {
"resource": ""
} |
q36879 | Pane.name | train | def name(self):
"""
The name for the window as displayed in the title bar and status bar.
"""
# Name, explicitely set for the pane.
if self.chosen_name:
return self.chosen_name
else:
# Name from the process running inside the pane.
name... | python | {
"resource": ""
} |
q36880 | Window.name | train | def name(self):
"""
The name for this window as it should be displayed in the status bar.
"""
# Name, explicitely set for the window.
if self.chosen_name:
return self.chosen_name
else:
pane = self.active_pane
if pane:
re... | python | {
"resource": ""
} |
q36881 | Window.add_pane | train | def add_pane(self, pane, vsplit=False):
"""
Add another pane to this Window.
"""
assert isinstance(pane, Pane)
assert isinstance(vsplit, bool)
split_cls = VSplit if vsplit else HSplit
if self.active_pane is None:
self.root.append(pane)
else:
... | python | {
"resource": ""
} |
q36882 | Window.remove_pane | train | def remove_pane(self, pane):
"""
Remove pane from this Window.
"""
assert isinstance(pane, Pane)
if pane in self.panes:
# When this pane was focused, switch to previous active or next in order.
if pane == self.active_pane:
if self.previous... | python | {
"resource": ""
} |
q36883 | Window.panes | train | def panes(self):
" List with all panes from this Window. "
result = []
for s in self.splits:
for item in s:
if isinstance(item, Pane):
result.append(item)
return result | python | {
"resource": ""
} |
q36884 | Window.focus_next | train | def focus_next(self, count=1):
" Focus the next pane. "
panes = self.panes
if panes:
self.active_pane = panes[(panes.index(self.active_pane) + count) % len(panes)]
else:
self.active_pane = None | python | {
"resource": ""
} |
q36885 | Window.select_layout | train | def select_layout(self, layout_type):
"""
Select one of the predefined layouts.
"""
assert layout_type in LayoutTypes._ALL
# When there is only one pane, always choose EVEN_HORIZONTAL,
# Otherwise, we create VSplit/HSplit instances with an empty list of
# childre... | python | {
"resource": ""
} |
q36886 | Window.change_size_for_active_pane | train | def change_size_for_active_pane(self, up=0, right=0, down=0, left=0):
"""
Increase the size of the current pane in any of the four directions.
"""
child = self.active_pane
self.change_size_for_pane(child, up=up, right=right, down=down, left=left) | python | {
"resource": ""
} |
q36887 | Window.change_size_for_pane | train | def change_size_for_pane(self, pane, up=0, right=0, down=0, left=0):
"""
Increase the size of the current pane in any of the four directions.
Positive values indicate an increase, negative values a decrease.
"""
assert isinstance(pane, Pane)
def find_split_and_child(spli... | python | {
"resource": ""
} |
q36888 | Window.get_pane_index | train | def get_pane_index(self, pane):
" Return the index of the given pane. ValueError if not found. "
assert isinstance(pane, Pane)
return self.panes.index(pane) | python | {
"resource": ""
} |
q36889 | Arrangement.set_active_window_from_pane_id | train | def set_active_window_from_pane_id(self, pane_id):
"""
Make the window with this pane ID the active Window.
"""
assert isinstance(pane_id, int)
for w in self.windows:
for p in w.panes:
if p.pane_id == pane_id:
self.set_active_windo... | python | {
"resource": ""
} |
q36890 | Arrangement.get_window_by_index | train | def get_window_by_index(self, index):
" Return the Window with this index or None if not found. "
for w in self.windows:
if w.index == index:
return w | python | {
"resource": ""
} |
q36891 | Arrangement.create_window | train | def create_window(self, pane, name=None, set_active=True):
"""
Create a new window that contains just this pane.
:param pane: The :class:`.Pane` instance to put in the new window.
:param name: If given, name for the new window.
:param set_active: When True, focus the new window.... | python | {
"resource": ""
} |
q36892 | Arrangement.break_pane | train | def break_pane(self, set_active=True):
"""
When the current window has multiple panes, remove the pane from this
window and put it in a new window.
:param set_active: When True, focus the new window.
"""
w = self.get_active_window()
if len(w.panes) > 1:
... | python | {
"resource": ""
} |
q36893 | Arrangement.rotate_window | train | def rotate_window(self, count=1):
" Rotate the panes in the active window. "
w = self.get_active_window()
w.rotate(count=count) | python | {
"resource": ""
} |
q36894 | ServerConnection._process | train | def _process(self, data):
"""
Process packet received from client.
"""
try:
packet = json.loads(data)
except ValueError:
# So far, this never happened. But it would be good to have some
# protection.
logger.warning('Received invalid... | python | {
"resource": ""
} |
q36895 | ServerConnection._send_packet | train | def _send_packet(self, data):
"""
Send packet to client.
"""
if self._closed:
return
data = json.dumps(data)
def send():
try:
yield From(self.pipe_connection.write(data))
except BrokenPipeError:
self.de... | python | {
"resource": ""
} |
q36896 | ServerConnection._run_command | train | def _run_command(self, packet):
"""
Execute a run command from the client.
"""
create_temp_cli = self.client_states is None
if create_temp_cli:
# If this client doesn't have a CLI. Create a Fake CLI where the
# window containing this pane, is the active o... | python | {
"resource": ""
} |
q36897 | ServerConnection._create_app | train | def _create_app(self, color_depth, term='xterm'):
"""
Create CommandLineInterface for this client.
Called when the client wants to attach the UI to the server.
"""
output = Vt100_Output(_SocketStdout(self._send_packet),
lambda: self.size,
... | python | {
"resource": ""
} |
q36898 | _ClientInput._create_context_manager | train | def _create_context_manager(self, mode):
" Create a context manager that sends 'mode' commands to the client. "
class mode_context_manager(object):
def __enter__(*a):
self.send_packet({'cmd': 'mode', 'data': mode})
def __exit__(*a):
self.send_pack... | python | {
"resource": ""
} |
q36899 | wrap_argument | train | def wrap_argument(text):
"""
Wrap command argument in quotes and escape when this contains special characters.
"""
if not any(x in text for x in [' ', '"', "'", '\\']):
return text
else:
return '"%s"' % (text.replace('\\', r'\\').replace('"', r'\"'), ) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.