_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q232100 | GridCellContentCairoRenderer._get_translation | train | def _get_translation(self, ims_width, ims_height):
"""Returns x and y for a bitmap translation"""
# Get cell attributes
cell_attributes = self.code_array.cell_attributes[self.key]
justification = cell_attributes["justification"]
vertical_align = cell_attributes["vertical_align"]... | python | {
"resource": ""
} |
q232101 | GridCellContentCairoRenderer.draw_bitmap | train | def draw_bitmap(self, content):
"""Draws bitmap cell content to context"""
if content.HasAlpha():
image = wx.ImageFromBitmap(content)
image.ConvertAlphaToMask()
image.SetMask(False)
content = wx.BitmapFromImage(image)
ims = wx.lib.wxcairo.ImageSu... | python | {
"resource": ""
} |
q232102 | GridCellContentCairoRenderer.draw_svg | train | def draw_svg(self, svg_str):
"""Draws svg string to cell"""
try:
import rsvg
except ImportError:
self.draw_text(svg_str)
return
svg = rsvg.Handle(data=svg_str)
svg_width, svg_height = svg.get_dimension_data()[:2]
transx, transy = se... | python | {
"resource": ""
} |
q232103 | GridCellContentCairoRenderer.draw_matplotlib_figure | train | def draw_matplotlib_figure(self, figure):
"""Draws matplotlib figure to context"""
class CustomRendererCairo(RendererCairo):
"""Workaround for older versins with limited draw path length"""
if sys.byteorder == 'little':
BYTE_FORMAT = 0 # BGRA
else:
... | python | {
"resource": ""
} |
q232104 | GridCellContentCairoRenderer._get_text_color | train | def _get_text_color(self):
"""Returns text color rgb tuple of right line"""
color = self.code_array.cell_attributes[self.key]["textcolor"]
return tuple(c / 255.0 for c in color_pack2rgb(color)) | python | {
"resource": ""
} |
q232105 | GridCellContentCairoRenderer.set_font | train | def set_font(self, pango_layout):
"""Sets the font for draw_text"""
wx2pango_weights = {
wx.FONTWEIGHT_BOLD: pango.WEIGHT_BOLD,
wx.FONTWEIGHT_LIGHT: pango.WEIGHT_LIGHT,
wx.FONTWEIGHT_NORMAL: None, # Do not set a weight by default
}
wx2pango_styles =... | python | {
"resource": ""
} |
q232106 | GridCellContentCairoRenderer._draw_error_underline | train | def _draw_error_underline(self, ptx, pango_layout, start, stop):
"""Draws an error underline"""
self.context.save()
self.context.set_source_rgb(1.0, 0.0, 0.0)
pit = pango_layout.get_iter()
# Skip characters until start
for i in xrange(start):
pit.next_char(... | python | {
"resource": ""
} |
q232107 | GridCellContentCairoRenderer._check_spelling | train | def _check_spelling(self, text, lang="en_US"):
"""Returns a list of start stop tuples that have spelling errors
Parameters
----------
text: Unicode or string
\tThe text that is checked
lang: String, defaults to "en_US"
\tName of spell checking dictionary
... | python | {
"resource": ""
} |
q232108 | GridCellContentCairoRenderer.draw_text | train | def draw_text(self, content):
"""Draws text cell content to context"""
wx2pango_alignment = {
"left": pango.ALIGN_LEFT,
"center": pango.ALIGN_CENTER,
"right": pango.ALIGN_RIGHT,
}
cell_attributes = self.code_array.cell_attributes[self.key]
a... | python | {
"resource": ""
} |
q232109 | GridCellContentCairoRenderer.draw_roundedrect | train | def draw_roundedrect(self, x, y, w, h, r=10):
"""Draws a rounded rectangle"""
# A****BQ
# H C
# * *
# G D
# F****E
context = self.context
context.save
context.move_to(x+r, y) # Move to A
context.line_to(x+w-r, y) # Straight... | python | {
"resource": ""
} |
q232110 | GridCellContentCairoRenderer.draw_button | train | def draw_button(self, x, y, w, h, label):
"""Draws a button"""
context = self.context
self.draw_roundedrect(x, y, w, h)
context.clip()
# Set up the gradients
gradient = cairo.LinearGradient(0, 0, 0, 1)
gradient.add_color_stop_rgba(0, 0.5, 0.5, 0.5, 0.1)
... | python | {
"resource": ""
} |
q232111 | GridCellContentCairoRenderer.draw | train | def draw(self):
"""Draws cell content to context"""
# Content is only rendered within rect
self.context.save()
self.context.rectangle(*self.rect)
self.context.clip()
content = self.get_cell_content()
pos_x, pos_y = self.rect[:2]
self.context.translate(p... | python | {
"resource": ""
} |
q232112 | GridCellBackgroundCairoRenderer._get_background_color | train | def _get_background_color(self):
"""Returns background color rgb tuple of right line"""
color = self.cell_attributes[self.key]["bgcolor"]
return tuple(c / 255.0 for c in color_pack2rgb(color)) | python | {
"resource": ""
} |
q232113 | GridCellBackgroundCairoRenderer._draw_frozen_pattern | train | def _draw_frozen_pattern(self):
"""Draws frozen pattern, i.e. diagonal lines"""
self.context.save()
x, y, w, h = self.rect
self.context.set_source_rgb(0, 0, 1)
self.context.set_line_width(0.25)
self.context.rectangle(*self.rect)
self.context.clip()
for ... | python | {
"resource": ""
} |
q232114 | GridCellBackgroundCairoRenderer.draw | train | def draw(self):
"""Draws cell background to context"""
self.context.set_source_rgb(*self._get_background_color())
self.context.rectangle(*self.rect)
self.context.fill()
# If show frozen is active, show frozen pattern
if self.view_frozen and self.cell_attributes[self.key... | python | {
"resource": ""
} |
q232115 | CellBorder.draw | train | def draw(self, context):
"""Draws self to Cairo context"""
context.set_line_width(self.width)
context.set_source_rgb(*self.color)
context.move_to(*self.start_point)
context.line_to(*self.end_point)
context.stroke() | python | {
"resource": ""
} |
q232116 | Cell.get_above_key_rect | train | def get_above_key_rect(self):
"""Returns tuple key rect of above cell"""
key_above = self.row - 1, self.col, self.tab
border_width_bottom = \
float(self.cell_attributes[key_above]["borderwidth_bottom"]) / 2.0
rect_above = (self.x, self.y-border_width_bottom,
... | python | {
"resource": ""
} |
q232117 | Cell.get_below_key_rect | train | def get_below_key_rect(self):
"""Returns tuple key rect of below cell"""
key_below = self.row + 1, self.col, self.tab
border_width_bottom = \
float(self.cell_attributes[self.key]["borderwidth_bottom"]) / 2.0
rect_below = (self.x, self.y+self.height,
s... | python | {
"resource": ""
} |
q232118 | Cell.get_left_key_rect | train | def get_left_key_rect(self):
"""Returns tuple key rect of left cell"""
key_left = self.row, self.col - 1, self.tab
border_width_right = \
float(self.cell_attributes[key_left]["borderwidth_right"]) / 2.0
rect_left = (self.x-border_width_right, self.y,
b... | python | {
"resource": ""
} |
q232119 | Cell.get_right_key_rect | train | def get_right_key_rect(self):
"""Returns tuple key rect of right cell"""
key_right = self.row, self.col + 1, self.tab
border_width_right = \
float(self.cell_attributes[self.key]["borderwidth_right"]) / 2.0
rect_right = (self.x+self.width, self.y,
bord... | python | {
"resource": ""
} |
q232120 | Cell.get_above_left_key_rect | train | def get_above_left_key_rect(self):
"""Returns tuple key rect of above left cell"""
key_above_left = self.row - 1, self.col - 1, self.tab
border_width_right = \
float(self.cell_attributes[key_above_left]["borderwidth_right"]) \
/ 2.0
border_width_bottom = \
... | python | {
"resource": ""
} |
q232121 | Cell.get_above_right_key_rect | train | def get_above_right_key_rect(self):
"""Returns tuple key rect of above right cell"""
key_above = self.row - 1, self.col, self.tab
key_above_right = self.row - 1, self.col + 1, self.tab
border_width_right = \
float(self.cell_attributes[key_above]["borderwidth_right"]) / 2.0
... | python | {
"resource": ""
} |
q232122 | Cell.get_below_left_key_rect | train | def get_below_left_key_rect(self):
"""Returns tuple key rect of below left cell"""
key_left = self.row, self.col - 1, self.tab
key_below_left = self.row + 1, self.col - 1, self.tab
border_width_right = \
float(self.cell_attributes[key_below_left]["borderwidth_right"]) \
... | python | {
"resource": ""
} |
q232123 | Cell.get_below_right_key_rect | train | def get_below_right_key_rect(self):
"""Returns tuple key rect of below right cell"""
key_below_right = self.row + 1, self.col + 1, self.tab
border_width_right = \
float(self.cell_attributes[self.key]["borderwidth_right"]) / 2.0
border_width_bottom = \
float(self... | python | {
"resource": ""
} |
q232124 | CellBorders._get_bottom_line_coordinates | train | def _get_bottom_line_coordinates(self):
"""Returns start and stop coordinates of bottom line"""
rect_x, rect_y, rect_width, rect_height = self.rect
start_point = rect_x, rect_y + rect_height
end_point = rect_x + rect_width, rect_y + rect_height
return start_point, end_point | python | {
"resource": ""
} |
q232125 | CellBorders._get_bottom_line_color | train | def _get_bottom_line_color(self):
"""Returns color rgb tuple of bottom line"""
color = self.cell_attributes[self.key]["bordercolor_bottom"]
return tuple(c / 255.0 for c in color_pack2rgb(color)) | python | {
"resource": ""
} |
q232126 | CellBorders._get_right_line_color | train | def _get_right_line_color(self):
"""Returns color rgb tuple of right line"""
color = self.cell_attributes[self.key]["bordercolor_right"]
return tuple(c / 255.0 for c in color_pack2rgb(color)) | python | {
"resource": ""
} |
q232127 | CellBorders.get_b | train | def get_b(self):
"""Returns the bottom border of the cell"""
start_point, end_point = self._get_bottom_line_coordinates()
width = self._get_bottom_line_width()
color = self._get_bottom_line_color()
return CellBorder(start_point, end_point, width, color) | python | {
"resource": ""
} |
q232128 | CellBorders.get_r | train | def get_r(self):
"""Returns the right border of the cell"""
start_point, end_point = self._get_right_line_coordinates()
width = self._get_right_line_width()
color = self._get_right_line_color()
return CellBorder(start_point, end_point, width, color) | python | {
"resource": ""
} |
q232129 | CellBorders.get_t | train | def get_t(self):
"""Returns the top border of the cell"""
cell_above = CellBorders(self.cell_attributes,
*self.cell.get_above_key_rect())
return cell_above.get_b() | python | {
"resource": ""
} |
q232130 | CellBorders.get_l | train | def get_l(self):
"""Returns the left border of the cell"""
cell_left = CellBorders(self.cell_attributes,
*self.cell.get_left_key_rect())
return cell_left.get_r() | python | {
"resource": ""
} |
q232131 | CellBorders.get_tl | train | def get_tl(self):
"""Returns the top left border of the cell"""
cell_above_left = CellBorders(self.cell_attributes,
*self.cell.get_above_left_key_rect())
return cell_above_left.get_r() | python | {
"resource": ""
} |
q232132 | CellBorders.get_tr | train | def get_tr(self):
"""Returns the top right border of the cell"""
cell_above = CellBorders(self.cell_attributes,
*self.cell.get_above_key_rect())
return cell_above.get_r() | python | {
"resource": ""
} |
q232133 | CellBorders.get_rt | train | def get_rt(self):
"""Returns the right top border of the cell"""
cell_above_right = CellBorders(self.cell_attributes,
*self.cell.get_above_right_key_rect())
return cell_above_right.get_b() | python | {
"resource": ""
} |
q232134 | CellBorders.get_rb | train | def get_rb(self):
"""Returns the right bottom border of the cell"""
cell_right = CellBorders(self.cell_attributes,
*self.cell.get_right_key_rect())
return cell_right.get_b() | python | {
"resource": ""
} |
q232135 | CellBorders.get_br | train | def get_br(self):
"""Returns the bottom right border of the cell"""
cell_below = CellBorders(self.cell_attributes,
*self.cell.get_below_key_rect())
return cell_below.get_r() | python | {
"resource": ""
} |
q232136 | CellBorders.get_bl | train | def get_bl(self):
"""Returns the bottom left border of the cell"""
cell_below_left = CellBorders(self.cell_attributes,
*self.cell.get_below_left_key_rect())
return cell_below_left.get_r() | python | {
"resource": ""
} |
q232137 | CellBorders.get_lb | train | def get_lb(self):
"""Returns the left bottom border of the cell"""
cell_left = CellBorders(self.cell_attributes,
*self.cell.get_left_key_rect())
return cell_left.get_b() | python | {
"resource": ""
} |
q232138 | CellBorders.get_lt | train | def get_lt(self):
"""Returns the left top border of the cell"""
cell_above_left = CellBorders(self.cell_attributes,
*self.cell.get_above_left_key_rect())
return cell_above_left.get_b() | python | {
"resource": ""
} |
q232139 | CellBorders.gen_all | train | def gen_all(self):
"""Generator of all borders"""
borderfuncs = [
self.get_b, self.get_r, self.get_t, self.get_l,
self.get_tl, self.get_tr, self.get_rt, self.get_rb,
self.get_br, self.get_bl, self.get_lb, self.get_lt,
]
for borderfunc in borderfuncs:... | python | {
"resource": ""
} |
q232140 | GridCellBorderCairoRenderer.draw | train | def draw(self):
"""Draws cell border to context"""
# Lines should have a square cap to avoid ugly edges
self.context.set_line_cap(cairo.LINE_CAP_SQUARE)
self.context.save()
self.context.rectangle(*self.rect)
self.context.clip()
cell_borders = CellBorders(self.c... | python | {
"resource": ""
} |
q232141 | GridRenderer._draw_cursor | train | def _draw_cursor(self, dc, grid, row, col,
pen=None, brush=None):
"""Draws cursor as Rectangle in lower right corner"""
# If in full screen mode draw no cursor
if grid.main_window.IsFullScreen():
return
key = row, col, grid.current_table
rect = ... | python | {
"resource": ""
} |
q232142 | GridRenderer.update_cursor | train | def update_cursor(self, dc, grid, row, col):
"""Whites out the old cursor and draws the new one"""
old_row, old_col = self.old_cursor_row_col
bgcolor = get_color(config["background_color"])
self._draw_cursor(dc, grid, old_row, old_col,
pen=wx.Pen(bgcolor), br... | python | {
"resource": ""
} |
q232143 | GridRenderer.get_merged_rect | train | def get_merged_rect(self, grid, key, rect):
"""Returns cell rect for normal or merged cells and None for merged"""
row, col, tab = key
# Check if cell is merged:
cell_attributes = grid.code_array.cell_attributes
merge_area = cell_attributes[(row, col, tab)]["merge_area"]
... | python | {
"resource": ""
} |
q232144 | GridRenderer._get_drawn_rect | train | def _get_drawn_rect(self, grid, key, rect):
"""Replaces drawn rect if the one provided by wx is incorrect
This handles merged rects including those that are partly off screen.
"""
rect = self.get_merged_rect(grid, key, rect)
if rect is None:
# Merged cell is drawn
... | python | {
"resource": ""
} |
q232145 | GridRenderer._get_draw_cache_key | train | def _get_draw_cache_key(self, grid, key, drawn_rect, is_selected):
"""Returns key for the screen draw cache"""
row, col, tab = key
cell_attributes = grid.code_array.cell_attributes
zoomed_width = drawn_rect.width / self.zoom
zoomed_height = drawn_rect.height / self.zoom
... | python | {
"resource": ""
} |
q232146 | GridRenderer._get_cairo_bmp | train | def _get_cairo_bmp(self, mdc, key, rect, is_selected, view_frozen):
"""Returns a wx.Bitmap of cell key in size rect"""
bmp = wx.EmptyBitmap(rect.width, rect.height)
mdc.SelectObject(bmp)
mdc.SetBackgroundMode(wx.SOLID)
mdc.SetBackground(wx.WHITE_BRUSH)
mdc.Clear()
... | python | {
"resource": ""
} |
q232147 | GridRenderer.Draw | train | def Draw(self, grid, attr, dc, rect, row, col, isSelected):
"""Draws the cell border and content using pycairo"""
key = row, col, grid.current_table
# If cell is merge draw the merging cell if invisibile
if grid.code_array.cell_attributes[key]["merge_area"]:
key = self.get_... | python | {
"resource": ""
} |
q232148 | choose_key | train | def choose_key(gpg_private_keys):
"""Displays gpg key choice and returns key"""
uid_strings_fp = []
uid_string_fp2key = {}
current_key_index = None
for i, key in enumerate(gpg_private_keys):
fingerprint = key['fingerprint']
if fingerprint == config["gpg_key_fingerprint"]:
... | python | {
"resource": ""
} |
q232149 | _register_key | train | def _register_key(fingerprint, gpg):
"""Registers key in config"""
for private_key in gpg.list_keys(True):
try:
if str(fingerprint) == private_key['fingerprint']:
config["gpg_key_fingerprint"] = \
repr(private_key['fingerprint'])
except KeyError:
... | python | {
"resource": ""
} |
q232150 | has_no_password | train | def has_no_password(gpg_secret_keyid):
"""Returns True iif gpg_secret_key has a password"""
if gnupg is None:
return False
gpg = gnupg.GPG()
s = gpg.sign("", keyid=gpg_secret_keyid, passphrase="")
try:
return s.status == "signature created"
except AttributeError:
# Thi... | python | {
"resource": ""
} |
q232151 | genkey | train | def genkey(key_name=None):
"""Creates a new standard GPG key
Parameters
----------
ui: Bool
\tIf True, then a new key is created when required without user interaction
"""
if gnupg is None:
return
gpg_key_param_list = [
('key_type', 'DSA'),
('key_length', '20... | python | {
"resource": ""
} |
q232152 | fingerprint2keyid | train | def fingerprint2keyid(fingerprint):
"""Returns keyid from fingerprint for private keys"""
if gnupg is None:
return
gpg = gnupg.GPG()
private_keys = gpg.list_keys(True)
keyid = None
for private_key in private_keys:
if private_key['fingerprint'] == config["gpg_key_fingerprint"]:... | python | {
"resource": ""
} |
q232153 | sign | train | def sign(filename):
"""Returns detached signature for file"""
if gnupg is None:
return
gpg = gnupg.GPG()
with open(filename, "rb") as signfile:
keyid = fingerprint2keyid(config["gpg_key_fingerprint"])
if keyid is None:
msg = "No private key for GPG fingerprint '{}... | python | {
"resource": ""
} |
q232154 | verify | train | def verify(sigfilename, filefilename=None):
"""Verifies a signature, returns True if successful else False."""
if gnupg is None:
return False
gpg = gnupg.GPG()
with open(sigfilename, "rb") as sigfile:
verified = gpg.verify_file(sigfile, filefilename)
pyspread_keyid = fingerpr... | python | {
"resource": ""
} |
q232155 | CellAttributes._len_table_cache | train | def _len_table_cache(self):
"""Returns the length of the table cache"""
length = 0
for table in self._table_cache:
length += len(self._table_cache[table])
return length | python | {
"resource": ""
} |
q232156 | CellAttributes._update_table_cache | train | def _update_table_cache(self):
"""Clears and updates the table cache to be in sync with self"""
self._table_cache.clear()
for sel, tab, val in self:
try:
self._table_cache[tab].append((sel, val))
except KeyError:
self._table_cache[tab] = [... | python | {
"resource": ""
} |
q232157 | CellAttributes.get_merging_cell | train | def get_merging_cell(self, key):
"""Returns key of cell that merges the cell key
or None if cell key not merged
Parameters
----------
key: 3-tuple of Integer
\tThe key of the cell that is merged
"""
row, col, tab = key
# Is cell merged
... | python | {
"resource": ""
} |
q232158 | DataArray._get_data | train | def _get_data(self):
"""Returns dict of data content.
Keys
----
shape: 3-tuple of Integer
\tGrid shape
grid: Dict of 3-tuples to strings
\tCell content
attributes: List of 3-tuples
\tCell attributes
row_heights: Dict of 2-tuples to float
... | python | {
"resource": ""
} |
q232159 | DataArray._set_data | train | def _set_data(self, **kwargs):
"""Sets data from given parameters
Old values are deleted.
If a paremeter is not given, nothing is changed.
Parameters
----------
shape: 3-tuple of Integer
\tGrid shape
grid: Dict of 3-tuples to strings
\tCell cont... | python | {
"resource": ""
} |
q232160 | DataArray.get_row_height | train | def get_row_height(self, row, tab):
"""Returns row height"""
try:
return self.row_heights[(row, tab)]
except KeyError:
return config["default_row_height"] | python | {
"resource": ""
} |
q232161 | DataArray.get_col_width | train | def get_col_width(self, col, tab):
"""Returns column width"""
try:
return self.col_widths[(col, tab)]
except KeyError:
return config["default_col_width"] | python | {
"resource": ""
} |
q232162 | DataArray._set_shape | train | def _set_shape(self, shape):
"""Deletes all cells beyond new shape and sets dict_grid shape
Parameters
----------
shape: 3-tuple of Integer
\tTarget shape for grid
"""
# Delete each cell that is beyond new borders
old_shape = self.shape
deleted... | python | {
"resource": ""
} |
q232163 | DataArray.get_last_filled_cell | train | def get_last_filled_cell(self, table=None):
"""Returns key for the bottommost rightmost cell with content
Parameters
----------
table: Integer, defaults to None
\tLimit search to this table
"""
maxrow = 0
maxcol = 0
for row, col, tab in self.di... | python | {
"resource": ""
} |
q232164 | DataArray.cell_array_generator | train | def cell_array_generator(self, key):
"""Generator traversing cells specified in key
Parameters
----------
key: Iterable of Integer or slice
\tThe key specifies the cell keys of the generator
"""
for i, key_ele in enumerate(key):
# Get first element... | python | {
"resource": ""
} |
q232165 | DataArray._shift_rowcol | train | def _shift_rowcol(self, insertion_point, no_to_insert):
"""Shifts row and column sizes when a table is inserted or deleted"""
# Shift row heights
new_row_heights = {}
del_row_heights = []
for row, tab in self.row_heights:
if tab > insertion_point:
n... | python | {
"resource": ""
} |
q232166 | DataArray._get_adjusted_merge_area | train | def _get_adjusted_merge_area(self, attrs, insertion_point, no_to_insert,
axis):
"""Returns updated merge area
Parameters
----------
attrs: Dict
\tCell attribute dictionary that shall be adjusted
insertion_point: Integer
\tPont on ... | python | {
"resource": ""
} |
q232167 | DataArray.set_row_height | train | def set_row_height(self, row, tab, height):
"""Sets row height"""
try:
old_height = self.row_heights.pop((row, tab))
except KeyError:
old_height = None
if height is not None:
self.row_heights[(row, tab)] = float(height) | python | {
"resource": ""
} |
q232168 | DataArray.set_col_width | train | def set_col_width(self, col, tab, width):
"""Sets column width"""
try:
old_width = self.col_widths.pop((col, tab))
except KeyError:
old_width = None
if width is not None:
self.col_widths[(col, tab)] = float(width) | python | {
"resource": ""
} |
q232169 | CodeArray._make_nested_list | train | def _make_nested_list(self, gen):
"""Makes nested list from generator for creating numpy.array"""
res = []
for ele in gen:
if ele is None:
res.append(None)
elif not is_string_like(ele) and is_generator_like(ele):
# Nested generator
... | python | {
"resource": ""
} |
q232170 | CodeArray._get_assignment_target_end | train | def _get_assignment_target_end(self, ast_module):
"""Returns position of 1st char after assignment traget.
If there is no assignment, -1 is returned
If there are more than one of any ( expressions or assigments)
then a ValueError is raised.
"""
if len(ast_module.body)... | python | {
"resource": ""
} |
q232171 | CodeArray._get_updated_environment | train | def _get_updated_environment(self, env_dict=None):
"""Returns globals environment with 'magic' variable
Parameters
----------
env_dict: Dict, defaults to {'S': self}
\tDict that maps global variable name to value
"""
if env_dict is None:
env_dict = ... | python | {
"resource": ""
} |
q232172 | CodeArray._eval_cell | train | def _eval_cell(self, key, code):
"""Evaluates one cell and returns its result"""
# Flatten helper function
def nn(val):
"""Returns flat numpy arraz without None values"""
try:
return numpy.array(filter(None, val.flat))
except AttributeError:
... | python | {
"resource": ""
} |
q232173 | CodeArray.pop | train | def pop(self, key):
"""Pops dict_grid with undo and redo support
Parameters
----------
key: 3-tuple of Integer
\tCell key that shall be popped
"""
try:
self.result_cache.pop(repr(key))
except KeyError:
pass
return DataA... | python | {
"resource": ""
} |
q232174 | CodeArray.reload_modules | train | def reload_modules(self):
"""Reloads modules that are available in cells"""
import src.lib.charts as charts
from src.gui.grid_panels import vlcpanel_factory
modules = [charts, bz2, base64, re, ast, sys, wx, numpy, datetime]
for module in modules:
reload(module) | python | {
"resource": ""
} |
q232175 | CodeArray.clear_globals | train | def clear_globals(self):
"""Clears all newly assigned globals"""
base_keys = ['cStringIO', 'IntType', 'KeyValueStore', 'undoable',
'is_generator_like', 'is_string_like', 'bz2', 'base64',
'__package__', 're', 'config', '__doc__', 'SliceType',
... | python | {
"resource": ""
} |
q232176 | CodeArray.execute_macros | train | def execute_macros(self):
"""Executes all macros and returns result string
Executes macros only when not in safe_mode
"""
if self.safe_mode:
return '', "Safe mode activated. Code not executed."
# Windows exec does not like Windows newline
self.macros = sel... | python | {
"resource": ""
} |
q232177 | CodeArray._sorted_keys | train | def _sorted_keys(self, keys, startkey, reverse=False):
"""Generator that yields sorted keys starting with startkey
Parameters
----------
keys: Iterable of tuple/list
\tKey sequence that is sorted
startkey: Tuple/list
\tFirst key to be yielded
reverse: Bo... | python | {
"resource": ""
} |
q232178 | CodeArray.findnextmatch | train | def findnextmatch(self, startkey, find_string, flags, search_result=True):
""" Returns a tuple with the position of the next match of find_string
Returns None if string not found.
Parameters:
-----------
startkey: Start position of search
find_string:String to be sear... | python | {
"resource": ""
} |
q232179 | IntValidator.Validate | train | def Validate(self, win):
"""Returns True if Value in digits, False otherwise"""
val = self.GetWindow().GetValue()
for x in val:
if x not in string.digits:
return False
return True | python | {
"resource": ""
} |
q232180 | IntValidator.OnChar | train | def OnChar(self, event):
"""Eats event if key not in digits"""
key = event.GetKeyCode()
if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255 or \
chr(key) in string.digits:
event.Skip() | python | {
"resource": ""
} |
q232181 | ChoiceRenderer.Draw | train | def Draw(self, grid, attr, dc, rect, row, col, is_selected):
"""Draws the text and the combobox icon"""
render = wx.RendererNative.Get()
# clear the background
dc.SetBackgroundMode(wx.SOLID)
if is_selected:
dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID))
dc.Se... | python | {
"resource": ""
} |
q232182 | CsvParameterWidgets._setup_param_widgets | train | def _setup_param_widgets(self):
"""Creates the parameter entry widgets and binds them to methods"""
for parameter in self.csv_params:
pname, ptype, plabel, phelp = parameter
label = wx.StaticText(self.parent, -1, plabel)
widget = self.type2widget[ptype](self.parent)... | python | {
"resource": ""
} |
q232183 | CsvParameterWidgets._do_layout | train | def _do_layout(self):
"""Sizer hell, returns a sizer that contains all widgets"""
sizer_csvoptions = wx.FlexGridSizer(5, 4, 5, 5)
# Adding parameter widgets to sizer_csvoptions
leftpos = wx.LEFT | wx.ADJUST_MINSIZE
rightpos = wx.RIGHT | wx.EXPAND
current_label_margin =... | python | {
"resource": ""
} |
q232184 | CsvParameterWidgets._update_settings | train | def _update_settings(self, dialect):
"""Sets the widget settings to those of the chosen dialect"""
# the first parameter is the dialect itself --> ignore
for parameter in self.csv_params[2:]:
pname, ptype, plabel, phelp = parameter
widget = self._widget_from_p(pname, pt... | python | {
"resource": ""
} |
q232185 | CsvParameterWidgets._widget_from_p | train | def _widget_from_p(self, pname, ptype):
"""Returns a widget from its ptype and pname"""
widget_name = self.type2widget[ptype].__name__.lower()
widget_name = "_".join([widget_name, pname])
return getattr(self, widget_name) | python | {
"resource": ""
} |
q232186 | CsvParameterWidgets.OnDialectChoice | train | def OnDialectChoice(self, event):
"""Updates all param widgets confirming to the selcted dialect"""
dialect_name = event.GetString()
value = list(self.choices['dialects']).index(dialect_name)
if dialect_name == 'sniffer':
if self.csvfilepath is None:
event.S... | python | {
"resource": ""
} |
q232187 | CsvParameterWidgets.OnWidget | train | def OnWidget(self, event):
"""Update the dialect widget to 'user'"""
self.choice_dialects.SetValue(len(self.choices['dialects']) - 1)
event.Skip() | python | {
"resource": ""
} |
q232188 | CsvParameterWidgets.get_dialect | train | def get_dialect(self):
"""Returns a new dialect that implements the current selection"""
parameters = {}
for parameter in self.csv_params[2:]:
pname, ptype, plabel, phelp = parameter
widget = self._widget_from_p(pname, ptype)
if ptype is types.StringType o... | python | {
"resource": ""
} |
q232189 | CSVPreviewGrid.OnMouse | train | def OnMouse(self, event):
"""Reduces clicks to enter an edit control"""
self.SetGridCursor(event.Row, event.Col)
self.EnableCellEditControl(True)
event.Skip() | python | {
"resource": ""
} |
q232190 | CSVPreviewGrid.OnGridEditorCreated | train | def OnGridEditorCreated(self, event):
"""Used to capture Editor close events"""
editor = event.GetControl()
editor.Bind(wx.EVT_KILL_FOCUS, self.OnGridEditorClosed)
event.Skip() | python | {
"resource": ""
} |
q232191 | CSVPreviewGrid.OnGridEditorClosed | train | def OnGridEditorClosed(self, event):
"""Event handler for end of output type choice"""
try:
dialect, self.has_header = \
self.parent.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.fill_cells(dialect, self.has_he... | python | {
"resource": ""
} |
q232192 | CSVPreviewGrid.get_digest_keys | train | def get_digest_keys(self):
"""Returns a list of the type choices"""
digest_keys = []
for col in xrange(self.GetNumberCols()):
digest_key = self.GetCellValue(self.has_header, col)
if digest_key == "":
digest_key = self.digest_types.keys()[0]
di... | python | {
"resource": ""
} |
q232193 | CsvExportDialog.OnButtonApply | train | def OnButtonApply(self, event):
"""Updates the preview_textctrl"""
try:
dialect, self.has_header = self.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.preview_textctrl.fill(data=self.data, dialect=dialect)
event.Skip() | python | {
"resource": ""
} |
q232194 | MacroPanel._set_properties | train | def _set_properties(self):
"""Setup title, size and tooltips"""
self.codetext_ctrl.SetToolTipString(_("Enter python code here."))
self.apply_button.SetToolTipString(_("Apply changes to current macro"))
self.splitter.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.result_ctrl.SetMinS... | python | {
"resource": ""
} |
q232195 | MacroPanel.OnApply | train | def OnApply(self, event):
"""Event handler for Apply button"""
# See if we have valid python
try:
ast.parse(self.macros)
except:
# Grab the traceback and print it for the user
s = StringIO()
e = exc_info()
# usr_tb will more th... | python | {
"resource": ""
} |
q232196 | MacroPanel.update_result_ctrl | train | def update_result_ctrl(self, event):
"""Update event result following execution by main window"""
# Check to see if macro window still exists
if not self:
return
printLen = 0
self.result_ctrl.SetValue('')
if hasattr(event, 'msg'):
# Output of scr... | python | {
"resource": ""
} |
q232197 | DimensionsEntryDialog._ondim | train | def _ondim(self, dimension, valuestring):
"""Converts valuestring to int and assigns result to self.dim
If there is an error (such as an empty valuestring) or if
the value is < 1, the value 1 is assigned to self.dim
Parameters
----------
dimension: int
\tDimens... | python | {
"resource": ""
} |
q232198 | CellEntryDialog.OnOk | train | def OnOk(self, event):
"""Posts a command event that makes the grid show the entered cell"""
# Get key values from textctrls
key_strings = [self.row_textctrl.GetValue(),
self.col_textctrl.GetValue(),
self.tab_textctrl.GetValue()]
key = []
... | python | {
"resource": ""
} |
q232199 | AboutDialog._set_properties | train | def _set_properties(self):
"""Setup title and label"""
self.SetTitle(_("About pyspread"))
label = _("pyspread {version}\nCopyright Martin Manns")
label = label.format(version=VERSION)
self.about_label.SetLabel(label) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.