input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def on_random_range_max_changed(self): self.ui.spinBoxRandomMinimum.setMaximum(self.ui.spinBoxRandomMaximum.value() - 1)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def on_btn_add_fuzzing_values_clicked(self): if self.ui.comboBoxStrategy.currentIndex() == 0: self.__add_fuzzing_range() elif self.ui.comboBoxStrategy.currentIndex() == 1: self.__add_fuzzing_boundaries() elif self.ui.comboBoxStrategy.currentIndex() == 2: self.__add_random_fuzzing_values()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __add_fuzzing_range(self): start = self.ui.sBAddRangeStart.value() end = self.ui.sBAddRangeEnd.value() step = self.ui.sBAddRangeStep.value() self.fuzz_table_model.add_range(start, end + 1, step)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __add_fuzzing_boundaries(self): lower_bound = -1 if self.ui.spinBoxLowerBound.isEnabled(): lower_bound = self.ui.spinBoxLowerBound.value() upper_bound = -1 if self.ui.spinBoxUpperBound.isEnabled(): upper_bound = self.ui.spinBoxUpperBound.value() num_vals = self.ui.spinBoxBoundaryNumber.value() self.fuzz_table_model.add_boundaries(lower_bound, upper_bound, num_vals)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __add_random_fuzzing_values(self): n = self.ui.spinBoxNumberRandom.value() minimum = self.ui.spinBoxRandomMinimum.value() maximum = self.ui.spinBoxRandomMaximum.value() self.fuzz_table_model.add_random(n, minimum, maximum)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def remove_duplicates(self): if self.ui.chkBRemoveDuplicates.isChecked(): for lbl in self.message.message_type: seq = lbl.fuzz_values[:] seen = set() add_seen = seen.add lbl.fuzz_values = [l for l in seq if not (l in seen or add_seen(l))]
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def set_current_label_name(self): self.current_label.name = self.ui.comboBoxFuzzingLabel.currentText() self.ui.comboBoxFuzzingLabel.setItemText(self.ui.comboBoxFuzzingLabel.currentIndex(), self.current_label.name)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def on_fuzz_msg_changed(self, index: int): self.ui.comboBoxFuzzingLabel.setDisabled(False) sel_label_ind = self.ui.comboBoxFuzzingLabel.currentIndex() self.ui.comboBoxFuzzingLabel.blockSignals(True) self.ui.comboBoxFuzzingLabel.clear() if len(self.message.message_type) == 0: self.ui.comboBoxFuzzingLabel.setDisabled(True) return self.ui.comboBoxFuzzingLabel.addItems([lbl.name for lbl in self.message.message_type]) self.ui.comboBoxFuzzingLabel.blockSignals(False) if sel_label_ind < self.ui.comboBoxFuzzingLabel.count(): self.ui.comboBoxFuzzingLabel.setCurrentIndex(sel_label_ind) else: self.ui.comboBoxFuzzingLabel.setCurrentIndex(0) self.fuzz_table_model.fuzzing_label = self.current_label self.fuzz_table_model.update() self.update_message_data_string()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def echo_server(loop, address, unix): if unix: sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) else: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(address) sock.listen(5) sock.setblocking(False) if PRINT: print('Server listening at', address) with sock: while True: client, addr = await loop.sock_accept(sock) if PRINT: print('Connection from', addr) loop.create_task(echo_client(loop, client))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def echo_client(loop, client): try: client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) except (OSError, NameError): pass with client: while True: data = await loop.sock_recv(client, 1000000) if not data: break await loop.sock_sendall(client, data) if PRINT: print('Connection closed')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def echo_client_streams(reader, writer): sock = writer.get_extra_info('socket') try: sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) except (OSError, NameError): pass if PRINT: print('Connection from', sock.getpeername()) while True: data = await reader.read(1000000) if not data: break writer.write(data) if PRINT: print('Connection closed') writer.close()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def connection_made(self, transport): self.transport = transport
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def connection_lost(self, exc): self.transport = None
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def data_received(self, data): self.transport.write(data)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def connection_made(self, transport): self.transport = transport # Here the buffer is intended to be copied, so that the outgoing buffer # won't be wrongly updated by next read self.buffer = bytearray(256 * 1024)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_buffer(self, sizehint): return self.buffer
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def buffer_updated(self, nbytes): self.transport.write(self.buffer[:nbytes])
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def print_debug(loop): while True: print(chr(27) + "[2J") # clear screen loop.print_debug_info() await asyncio.sleep(0.5)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_error_on_wrong_value_for_consumed_capacity(): resource = boto3.resource("dynamodb", region_name="ap-northeast-3") client = boto3.client("dynamodb", region_name="ap-northeast-3") client.create_table( TableName="jobs", KeySchema=[{"AttributeName": "job_id", "KeyType": "HASH"}], AttributeDefinitions=[{"AttributeName": "job_id", "AttributeType": "S"}], ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5}, ) table = resource.Table("jobs") item = {"job_id": "asdasdasd", "expires_at": "1"} # PUT_ITEM with pytest.raises(ClientError) as ex: table.put_item(Item=item, ReturnConsumedCapacity="Garbage") err = ex.value.response["Error"] err["Code"].should.equal("ValidationException") err["Message"].should.equal( "1 validation error detected: Value 'Garbage' at 'returnConsumedCapacity' failed to satisfy constraint: Member must satisfy enum value set: [INDEXES, TOTAL, NONE]" )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def index(self, request): queryset = Condition.objects.select_related('source', 'target_option') serializer = ConditionIndexSerializer(queryset, many=True) return Response(serializer.data)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_consumed_capacity_get_unknown_item(): conn = boto3.client("dynamodb", region_name="us-east-1") conn.create_table( TableName="test_table", KeySchema=[{"AttributeName": "u", "KeyType": "HASH"}], AttributeDefinitions=[{"AttributeName": "u", "AttributeType": "S"}], BillingMode="PAY_PER_REQUEST", ) response = conn.get_item( TableName="test_table", Key={"u": {"S": "does_not_exist"}}, ReturnConsumedCapacity="TOTAL", ) # Should still return ConsumedCapacity, even if it does not return an item response.should.have.key("ConsumedCapacity") response["ConsumedCapacity"].should.equal( {"TableName": "test_table", "CapacityUnits": 0.5} )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def export(self, request): serializer = ConditionExportSerializer(self.get_queryset(), many=True) xml = ConditionRenderer().render(serializer.data) return XMLResponse(xml, name='conditions')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_only_return_consumed_capacity_when_required( capacity, should_have_capacity, should_have_table ): resource = boto3.resource("dynamodb", region_name="ap-northeast-3") client = boto3.client("dynamodb", region_name="ap-northeast-3") client.create_table( TableName="jobs", KeySchema=[{"AttributeName": "job_id", "KeyType": "HASH"}], LocalSecondaryIndexes=[ { "IndexName": "job_name-index", "KeySchema": [{"AttributeName": "job_name", "KeyType": "HASH"}], "Projection": {"ProjectionType": "ALL"}, } ], AttributeDefinitions=[ {"AttributeName": "job_id", "AttributeType": "S"}, {"AttributeName": "job_name", "AttributeType": "S"}, ], ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5}, ) table = resource.Table("jobs") item = {"job_id": "asdasdasd", "expires_at": "1"} # PUT_ITEM args = {"Item": item} if capacity: args["ReturnConsumedCapacity"] = capacity response = table.put_item(**args) validate_response(response, should_have_capacity, should_have_table) # GET_ITEM args = {"Key": item} if capacity: args["ReturnConsumedCapacity"] = capacity response = table.get_item(**args) validate_response(response, should_have_capacity, should_have_table, value=0.5) # SCAN args = {"TableName": "jobs"} if capacity: args["ReturnConsumedCapacity"] = capacity response = client.scan(**args) validate_response(response, should_have_capacity, should_have_table) # SCAN_INDEX args["IndexName"] = "job_name-index" response = client.scan(**args) validate_response(response, should_have_capacity, should_have_table, is_index=True) # QUERY args = { "TableName": "jobs", "KeyConditionExpression": "job_id = :id", "ExpressionAttributeValues": {":id": {"S": "asdasdasd"}}, } if capacity: args["ReturnConsumedCapacity"] = capacity response = client.query(**args) validate_response(response, should_have_capacity, should_have_table) # QUERY_INDEX args["IndexName"] = "job_name-index" response = client.query(**args) validate_response(response, should_have_capacity, should_have_table, is_index=True)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def detail_export(self, request, pk=None): serializer = ConditionExportSerializer(self.get_object()) xml = ConditionRenderer().render([serializer.data]) return XMLResponse(xml, name=self.get_object().key)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, translations_path, domain_name: str): super().__init__() self.update_types = self.process_update_types() self.path = translations_path self.domain = domain_name self.translations = self.find_translations()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def opengl_lamp_buttons(column, lamp): split = column.row() split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA') col = split.column() col.active = lamp.use row = col.row() row.label(text="Diffuse:") row.prop(lamp, "diffuse_color", text="") row = col.row() row.label(text="Specular:") row.prop(lamp, "specular_color", text="") col = split.column() col.active = lamp.use col.prop(lamp, "direction", text="")
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def available_translations(self): return list(self.translations)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout layout.template_header() userpref = context.user_preferences layout.operator_context = 'EXEC_AREA' layout.operator("wm.save_userpref") layout.operator_context = 'INVOKE_DEFAULT' if userpref.active_section == 'INPUT': layout.operator("wm.keyconfig_import") layout.operator("wm.keyconfig_export") elif userpref.active_section == 'ADDONS': layout.operator("wm.addon_install", icon='FILESEL') layout.operator("wm.addon_refresh", icon='FILE_REFRESH') layout.menu("USERPREF_MT_addons_online_resources") elif userpref.active_section == 'THEMES': layout.operator("ui.reset_default_theme") layout.operator("wm.theme_install")
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def gettext(self, text: str, lang: str = None): """ Singular translations """ if lang is None: lang = self.context_lang.get() if lang not in self.translations: return text translator = self.translations[lang] return translator.gettext(text)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout userpref = context.user_preferences layout.prop(userpref, "active_section", expand=True)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def ngettext(self, singular: str, plural: str, lang: str = None, n=1): """ Plural translations """ if lang is None: lang = self.context_lang.get() if lang not in self.translations: if n == 1: return singular return plural translator = self.translations[lang] return translator.ngettext(singular, plural, n)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): self.layout.operator("wm.appconfig_default", text="Blender (default)") # now draw the presets Menu.draw_preset(self, context)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def lazy_gettext(self, text: str, lang: str = None): if not babel_imported: raise RuntimeError('babel module is not imported. Check that you installed it.') return LazyProxy(self.gettext, text, lang, enable_cache=False)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout split = layout.split() row = split.row() row.label("") row = split.row() row.label("Interaction:") text = bpy.path.display_name(context.window_manager.keyconfigs.active.name) if not text: text = "Blender (default)" row.menu("USERPREF_MT_appconfigs", text=text)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def lazy_ngettext(self, singular: str, plural: str, lang: str = None, n=1): if not babel_imported: raise RuntimeError('babel module is not imported. Check that you installed it.') return LazyProxy(self.ngettext, singular, plural, lang, n, enable_cache=False)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def get_user_language(self, obj): """ You need to override this method and return user language """ raise NotImplementedError
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'INTERFACE')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def process_update_types(self) -> list: """ You need to override this method and return any update types which you want to be processed """ raise NotImplementedError
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): import sys layout = self.layout userpref = context.user_preferences view = userpref.view row = layout.row() col = row.column() col.label(text="Display:") col.prop(view, "show_tooltips") col.prop(view, "show_tooltips_python") col.prop(view, "show_object_info", text="Object Info") col.prop(view, "show_large_cursors") col.prop(view, "show_view_name", text="View Name") col.prop(view, "show_playback_fps", text="Playback FPS") col.prop(view, "use_global_scene") col.prop(view, "object_origin_size") col.separator() col.separator() col.separator() col.prop(view, "show_mini_axis", text="Display Mini Axis") sub = col.column() sub.active = view.show_mini_axis sub.prop(view, "mini_axis_size", text="Size") sub.prop(view, "mini_axis_brightness", text="Brightness") col.separator() if sys.platform[:3] == "win": col.label("Warnings") col.prop(view, "use_quit_dialog") row.separator() row.separator() col = row.column() col.label(text="View Manipulation:") col.prop(view, "use_mouse_depth_cursor") col.prop(view, "use_mouse_depth_navigate") col.prop(view, "use_zoom_to_mouse") col.prop(view, "use_rotate_around_active") col.prop(view, "use_global_pivot") col.prop(view, "use_camera_lock_parent") col.separator() col.prop(view, "use_auto_perspective") col.prop(view, "smooth_view") col.prop(view, "rotation_angle") col.separator() col.separator() col.label(text="2D Viewports:") col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing") col.prop(view, "timecode_style") col.prop(view, "view_frame_type") if (view.view_frame_type == 'SECONDS'): col.prop(view, "view_frame_seconds") elif (view.view_frame_type == 'KEYFRAMES'): col.prop(view, "view_frame_keyframes") row.separator() row.separator() col = row.column() #Toolbox doesn't exist yet #col.label(text="Toolbox:") #col.prop(view, "show_column_layout") #col.label(text="Open Toolbox Delay:") #col.prop(view, "open_left_mouse_delay", text="Hold LMB") #col.prop(view, "open_right_mouse_delay", text="Hold RMB") col.prop(view, "show_manipulator") sub = col.column() sub.active = view.show_manipulator sub.prop(view, "manipulator_size", text="Size") sub.prop(view, "manipulator_handle_size", text="Handle Size") sub.prop(view, "manipulator_hotspot", text="Hotspot") col.separator() col.separator() col.separator() col.label(text="Menus:") col.prop(view, "use_mouse_over_open") sub = col.column() sub.active = view.use_mouse_over_open sub.prop(view, "open_toplevel_delay", text="Top Level") sub.prop(view, "open_sublevel_delay", text="Sub Level") col.separator() col.label(text="Pie Menus:") sub = col.column(align=True) sub.prop(view, "pie_animation_timeout") sub.prop(view, "pie_initial_timeout") sub.prop(view, "pie_menu_radius") sub.prop(view, "pie_menu_threshold") sub.prop(view, "pie_menu_confirm") col.separator() col.separator() col.separator() col.prop(view, "show_splash")
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def pre_process(self, message, data): """ context language variable will be set each time when update from 'process_update_types' comes value is the result of 'get_user_language' method """ self.context_lang.set(await self.get_user_language(obj=message))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'EDITING')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
async def post_process(self, message, data, exception): pass
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout userpref = context.user_preferences edit = userpref.edit row = layout.row() col = row.column() col.label(text="Link Materials To:") col.prop(edit, "material_link", text="") col.separator() col.separator() col.separator() col.label(text="New Objects:") col.prop(edit, "use_enter_edit_mode") col.label(text="Align To:") col.prop(edit, "object_align", text="") col.separator() col.separator() col.separator() col.label(text="Undo:") col.prop(edit, "use_global_undo") col.prop(edit, "undo_steps", text="Steps") col.prop(edit, "undo_memory_limit", text="Memory Limit") row.separator() row.separator() col = row.column() col.label(text="Grease Pencil:") col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius") col.separator() col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance") col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance") col.separator() col.prop(edit, "grease_pencil_default_color", text="Default Color") col.separator() col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke") col.separator() col.separator() col.separator() col.separator() col.label(text="Playback:") col.prop(edit, "use_negative_frames") col.separator() col.separator() col.separator() col.label(text="Node Editor:") col.prop(edit, "node_margin") col.label(text="Animation Editors:") col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility") row.separator() row.separator() col = row.column() col.label(text="Keyframing:") col.prop(edit, "use_visual_keying") col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed") col.separator() col.prop(edit, "use_auto_keying", text="Auto Keyframing:") col.prop(edit, "use_auto_keying_warning") sub = col.column() #~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available") col.separator() col.label(text="New F-Curve Defaults:") col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation") col.prop(edit, "keyframe_new_handle_type", text="Handles") col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB") col.separator() col.separator() col.separator() col.label(text="Transform:") col.prop(edit, "use_drag_immediately") row.separator() row.separator() col = row.column() col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color") col.separator() col.separator() col.separator() col.label(text="Duplicate Data:") col.prop(edit, "use_duplicate_mesh", text="Mesh") col.prop(edit, "use_duplicate_surface", text="Surface") col.prop(edit, "use_duplicate_curve", text="Curve") col.prop(edit, "use_duplicate_text", text="Text") col.prop(edit, "use_duplicate_metaball", text="Metaball") col.prop(edit, "use_duplicate_armature", text="Armature") col.prop(edit, "use_duplicate_lamp", text="Lamp") col.prop(edit, "use_duplicate_material", text="Material") col.prop(edit, "use_duplicate_texture", text="Texture") #col.prop(edit, "use_duplicate_fcurve", text="F-Curve") col.prop(edit, "use_duplicate_action", text="Action") col.prop(edit, "use_duplicate_particle", text="Particle")
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'SYSTEM')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): import sys layout = self.layout userpref = context.user_preferences system = userpref.system split = layout.split() # 1. Column column = split.column() colsplit = column.split(percentage=0.85) col = colsplit.column() col.label(text="General:") col.prop(system, "dpi") col.label("Virtual Pixel Mode:") col.prop(system, "virtual_pixel_mode", text="") col.separator() col.prop(system, "frame_server_port") col.prop(system, "scrollback", text="Console Scrollback") col.separator() col.label(text="Sound:") col.row().prop(system, "audio_device", expand=False) sub = col.column() sub.active = system.audio_device != 'NONE' and system.audio_device != 'Null' #sub.prop(system, "use_preview_images") sub.prop(system, "audio_channels", text="Channels") sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer") sub.prop(system, "audio_sample_rate", text="Sample Rate") sub.prop(system, "audio_sample_format", text="Sample Format") col.separator() col.label(text="Screencast:") col.prop(system, "screencast_fps") col.prop(system, "screencast_wait_time") col.separator() if userpref.addons.find('cycles') != -1: userpref.addons['cycles'].preferences.draw_impl(col, context) if hasattr(system, "opensubdiv_compute_type"): col.label(text="OpenSubdiv compute:") col.row().prop(system, "opensubdiv_compute_type", text="") # 2. Column column = split.column() colsplit = column.split(percentage=0.85) col = colsplit.column() col.label(text="OpenGL:") col.prop(system, "gl_clip_alpha", slider=True) col.prop(system, "use_mipmaps") col.prop(system, "use_gpu_mipmap") col.prop(system, "use_16bit_textures") col.separator() col.label(text="Selection") col.prop(system, "select_method", text="") col.separator() col.label(text="Anisotropic Filtering") col.prop(system, "anisotropic_filter", text="") col.separator() col.label(text="Window Draw Method:") col.prop(system, "window_draw_method", text="") col.prop(system, "multi_sample", text="") if sys.platform == "linux" and system.multi_sample != 'NONE': col.label(text="Might fail for Mesh editing selection!") col.separator() col.prop(system, "use_region_overlap") col.separator() col.label(text="Text Draw Options:") col.prop(system, "use_text_antialiasing") col.separator() col.label(text="Textures:") col.prop(system, "gl_texture_limit", text="Limit Size") col.prop(system, "texture_time_out", text="Time Out") col.prop(system, "texture_collection_rate", text="Collection Rate") col.separator() col.label(text="Images Draw Method:") col.prop(system, "image_draw_method", text="") col.separator() col.label(text="Sequencer/Clip Editor:") # currently disabled in the code # col.prop(system, "prefetch_frames") col.prop(system, "memory_cache_limit") # 3. Column column = split.column() column.label(text="Solid OpenGL lights:") split = column.split(percentage=0.1) split.label() split.label(text="Colors:") split.label(text="Direction:") lamp = system.solid_lights[0] opengl_lamp_buttons(column, lamp) lamp = system.solid_lights[1] opengl_lamp_buttons(column, lamp) lamp = system.solid_lights[2] opengl_lamp_buttons(column, lamp) column.separator() column.label(text="Color Picker Type:") column.row().prop(system, "color_picker_type", text="") column.separator() column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range") sub = column.column() sub.active = system.use_weight_color_range sub.template_color_ramp(system, "weight_color_range", expand=True) column.separator() column.prop(system, "font_path_ui") column.prop(system, "font_path_ui_mono") if bpy.app.build_options.international: column.prop(system, "use_international_fonts") if system.use_international_fonts: column.prop(system, "language") row = column.row() row.label(text="Translate:", text_ctxt=i18n_contexts.id_windowmanager) row = column.row(align=True) row.prop(system, "use_translate_interface", text="Interface", toggle=True) row.prop(system, "use_translate_tooltips", text="Tooltips", toggle=True) row.prop(system, "use_translate_new_dataname", text="New Data", toggle=True)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def theme_generic_recurse(data): col.label(data.rna_type.name) row = col.row() subsplit = row.split(percentage=0.95) padding1 = subsplit.split(percentage=0.15) padding1.column() subsplit = row.split(percentage=0.85) padding2 = subsplit.split(percentage=0.15) padding2.column() colsub_pair = padding1.column(), padding2.column() props_type = {} for i, prop in enumerate(data.rna_type.properties): if prop.identifier == "rna_type": continue props_type.setdefault((prop.type, prop.subtype), []).append(prop) th_delimiters = USERPREF_PT_theme.ui_delimiters.get(theme_area) for props_type, props_ls in sorted(props_type.items()): if props_type[0] == 'POINTER': for i, prop in enumerate(props_ls): theme_generic_recurse(getattr(data, prop.identifier)) else: if th_delimiters is None: # simple, no delimiters for i, prop in enumerate(props_ls): colsub_pair[i % 2].row().prop(data, prop.identifier) else: # add hard coded delimiters i = 0 for prop in props_ls: colsub = colsub_pair[i] colsub.row().prop(data, prop.identifier) i = (i + 1) % 2 if prop.identifier in th_delimiters: if i: colsub = colsub_pair[1] colsub.row().label("") colsub_pair[0].row().label("") colsub_pair[1].row().label("") i = 0
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _theme_widget_style(layout, widget_style): row = layout.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(widget_style, "outline") colsub.row().prop(widget_style, "item", slider=True) colsub.row().prop(widget_style, "inner", slider=True) colsub.row().prop(widget_style, "inner_sel", slider=True) subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(widget_style, "text") colsub.row().prop(widget_style, "text_sel") colsub.prop(widget_style, "show_shaded") subsub = colsub.column(align=True) subsub.active = widget_style.show_shaded subsub.prop(widget_style, "shadetop") subsub.prop(widget_style, "shadedown") layout.separator()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _ui_font_style(layout, font_style): split = layout.split() col = split.column() col.label(text="Kerning Style:") col.row().prop(font_style, "font_kerning_style", expand=True) col.prop(font_style, "points") col = split.column() col.label(text="Shadow Offset:") col.prop(font_style, "shadow_offset_x", text="X") col.prop(font_style, "shadow_offset_y", text="Y") col = split.column() col.prop(font_style, "shadow") col.prop(font_style, "shadow_alpha") col.prop(font_style, "shadow_value") layout.separator()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'THEMES')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout theme = context.user_preferences.themes[0] split_themes = layout.split(percentage=0.2) sub = split_themes.column() sub.label(text="Presets:") subrow = sub.row(align=True) subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label) subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN') subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True sub.separator() sub.prop(theme, "theme_area", expand=True) split = layout.split(percentage=0.4) layout.separator() layout.separator() split = split_themes.split() if theme.theme_area == 'USER_INTERFACE': col = split.column() ui = theme.user_interface col.label(text="Regular:") self._theme_widget_style(col, ui.wcol_regular) col.label(text="Tool:") self._theme_widget_style(col, ui.wcol_tool) col.label(text="Radio Buttons:") self._theme_widget_style(col, ui.wcol_radio) col.label(text="Text:") self._theme_widget_style(col, ui.wcol_text) col.label(text="Option:") self._theme_widget_style(col, ui.wcol_option) col.label(text="Toggle:") self._theme_widget_style(col, ui.wcol_toggle) col.label(text="Number Field:") self._theme_widget_style(col, ui.wcol_num) col.label(text="Value Slider:") self._theme_widget_style(col, ui.wcol_numslider) col.label(text="Box:") self._theme_widget_style(col, ui.wcol_box) col.label(text="Menu:") self._theme_widget_style(col, ui.wcol_menu) col.label(text="Pie Menu:") self._theme_widget_style(col, ui.wcol_pie_menu) col.label(text="Pulldown:") self._theme_widget_style(col, ui.wcol_pulldown) col.label(text="Menu Back:") self._theme_widget_style(col, ui.wcol_menu_back) col.label(text="Tooltip:") self._theme_widget_style(col, ui.wcol_tooltip) col.label(text="Menu Item:") self._theme_widget_style(col, ui.wcol_menu_item) col.label(text="Scroll Bar:") self._theme_widget_style(col, ui.wcol_scroll) col.label(text="Progress Bar:") self._theme_widget_style(col, ui.wcol_progress) col.label(text="List Item:") self._theme_widget_style(col, ui.wcol_list_item) ui_state = theme.user_interface.wcol_state col.label(text="State:") row = col.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui_state, "inner_anim") colsub.row().prop(ui_state, "inner_anim_sel") colsub.row().prop(ui_state, "inner_driven") colsub.row().prop(ui_state, "inner_driven_sel") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui_state, "inner_key") colsub.row().prop(ui_state, "inner_key_sel") colsub.row().prop(ui_state, "blend") col.separator() col.separator() col.label("Styles:") row = col.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "menu_shadow_fac") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "menu_shadow_width") row = col.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "icon_alpha") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "widget_emboss") col.separator() col.separator() col.label("Axis Colors:") row = col.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "axis_x") colsub.row().prop(ui, "axis_y") colsub.row().prop(ui, "axis_z") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() layout.separator() layout.separator() elif theme.theme_area == 'BONE_COLOR_SETS': col = split.column() for i, ui in enumerate(theme.bone_color_sets): col.label(text=iface_("Color Set %d:") % (i + 1), translate=False) # i starts from 0 row = col.row() subsplit = row.split(percentage=0.95) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "normal") colsub.row().prop(ui, "select") colsub.row().prop(ui, "active") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "show_colored_constraints") elif theme.theme_area == 'STYLE': col = split.column() style = context.user_preferences.ui_styles[0] col.label(text="Panel Title:") self._ui_font_style(col, style.panel_title) col.separator() col.label(text="Widget:") self._ui_font_style(col, style.widget) col.separator() col.label(text="Widget Label:") self._ui_font_style(col, style.widget_label) else: self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'FILES')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout userpref = context.user_preferences paths = userpref.filepaths system = userpref.system split = layout.split(percentage=0.7) col = split.column() col.label(text="File Paths:") colsplit = col.split(percentage=0.95) col1 = colsplit.split(percentage=0.3) sub = col1.column() sub.label(text="Fonts:") sub.label(text="Textures:") sub.label(text="Render Output:") sub.label(text="Scripts:") sub.label(text="Sounds:") sub.label(text="Temp:") sub.label(text="Render Cache:") sub.label(text="I18n Branches:") sub.label(text="Image Editor:") sub.label(text="Animation Player:") sub = col1.column() sub.prop(paths, "font_directory", text="") sub.prop(paths, "texture_directory", text="") sub.prop(paths, "render_output_directory", text="") sub.prop(paths, "script_directory", text="") sub.prop(paths, "sound_directory", text="") sub.prop(paths, "temporary_directory", text="") sub.prop(paths, "render_cache_directory", text="") sub.prop(paths, "i18n_branches_directory", text="") sub.prop(paths, "image_editor", text="") subsplit = sub.split(percentage=0.3) subsplit.prop(paths, "animation_player_preset", text="") subsplit.prop(paths, "animation_player", text="") col.separator() col.separator() colsplit = col.split(percentage=0.95) sub = colsplit.column() row = sub.split(percentage=0.3) row.label(text="Auto Execution:") row.prop(system, "use_scripts_auto_execute") if system.use_scripts_auto_execute: box = sub.box() row = box.row() row.label(text="Excluded Paths:") row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False) for i, path_cmp in enumerate(userpref.autoexec_paths): row = box.row() row.prop(path_cmp, "path", text="") row.prop(path_cmp, "use_glob", text="", icon='FILTER') row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i col = split.column() col.label(text="Save & Load:") col.prop(paths, "use_relative_paths") col.prop(paths, "use_file_compression") col.prop(paths, "use_load_ui") col.prop(paths, "use_filter_files") col.prop(paths, "show_hidden_files_datablocks") col.prop(paths, "hide_recent_locations") col.prop(paths, "hide_system_bookmarks") col.prop(paths, "show_thumbnails") col.separator() col.prop(paths, "save_version") col.prop(paths, "recent_files") col.prop(paths, "use_save_preview_images") col.separator() col.label(text="Auto Save:") col.prop(paths, "use_keep_session") col.prop(paths, "use_auto_save_temporary_files") sub = col.column() sub.active = paths.use_auto_save_temporary_files sub.prop(paths, "auto_save_time", text="Timer (mins)") col.separator() col.label(text="Text Editor:") col.prop(system, "use_tabs_as_spaces") colsplit = col.split(percentage=0.95) col1 = colsplit.split(percentage=0.3) sub = col1.column() sub.label(text="Author:") sub = col1.column() sub.prop(system, "author", text="")
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout input_prefs = context.user_preferences.inputs is_view3d = context.space_data.type == 'VIEW_3D' layout.prop(input_prefs, "ndof_sensitivity") layout.prop(input_prefs, "ndof_orbit_sensitivity") layout.prop(input_prefs, "ndof_deadzone") if is_view3d: layout.separator() layout.prop(input_prefs, "ndof_show_guide") layout.separator() layout.label(text="Orbit style") layout.row().prop(input_prefs, "ndof_view_navigate_method", text="") layout.row().prop(input_prefs, "ndof_view_rotate_method", text="") layout.separator() layout.label(text="Orbit options") layout.prop(input_prefs, "ndof_rotx_invert_axis") layout.prop(input_prefs, "ndof_roty_invert_axis") layout.prop(input_prefs, "ndof_rotz_invert_axis") # view2d use pan/zoom layout.separator() layout.label(text="Pan options") layout.prop(input_prefs, "ndof_panx_invert_axis") layout.prop(input_prefs, "ndof_pany_invert_axis") layout.prop(input_prefs, "ndof_panz_invert_axis") layout.prop(input_prefs, "ndof_pan_yz_swap_axis") layout.label(text="Zoom options") layout.prop(input_prefs, "ndof_zoom_invert") if is_view3d: layout.separator() layout.label(text="Fly/Walk options") layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY') layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): props = self.layout.operator("wm.context_set_value", text="Blender (default)") props.data_path = "window_manager.keyconfigs.active" props.value = "context.window_manager.keyconfigs.default" # now draw the presets Menu.draw_preset(self, context)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'INPUT')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw_input_prefs(inputs, layout): import sys # General settings row = layout.row() col = row.column() sub = col.column() sub.label(text="Presets:") subrow = sub.row(align=True) subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label) subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN') subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True sub.separator() sub.label(text="Mouse:") sub1 = sub.column() sub1.active = (inputs.select_mouse == 'RIGHT') sub1.prop(inputs, "use_mouse_emulate_3_button") sub.prop(inputs, "use_mouse_continuous") sub.prop(inputs, "drag_threshold") sub.prop(inputs, "tweak_threshold") sub.label(text="Select With:") sub.row().prop(inputs, "select_mouse", expand=True) sub = col.column() sub.label(text="Double Click:") sub.prop(inputs, "mouse_double_click_time", text="Speed") sub.separator() sub.prop(inputs, "use_emulate_numpad") sub.separator() sub.label(text="Orbit Style:") sub.row().prop(inputs, "view_rotate_method", expand=True) sub.separator() sub.label(text="Zoom Style:") sub.row().prop(inputs, "view_zoom_method", text="") if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}: sub.row().prop(inputs, "view_zoom_axis", expand=True) sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction") #sub.prop(inputs, "use_mouse_mmb_paste") #col.separator() sub = col.column() sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction") #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines") if sys.platform == "darwin": sub = col.column() sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction") col.separator() sub = col.column() sub.label(text="View Navigation:") sub.row().prop(inputs, "navigation_mode", expand=True) if inputs.navigation_mode == 'WALK': walk = inputs.walk_navigation sub.prop(walk, "use_mouse_reverse") sub.prop(walk, "mouse_speed") sub.prop(walk, "teleport_time") sub = col.column(align=True) sub.prop(walk, "walk_speed") sub.prop(walk, "walk_speed_factor") sub.separator() sub.prop(walk, "use_gravity") sub = col.column(align=True) sub.active = walk.use_gravity sub.prop(walk, "view_height") sub.prop(walk, "jump_height") if inputs.use_ndof: col.separator() col.label(text="NDOF Device:") sub = col.column(align=True) sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity") sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity") sub.prop(inputs, "ndof_deadzone", text="NDOF Deadzone") sub = col.column(align=True) sub.row().prop(inputs, "ndof_view_navigate_method", expand=True) sub.row().prop(inputs, "ndof_view_rotate_method", expand=True) row.separator()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): from rna_keymap_ui import draw_keymaps layout = self.layout #import time #start = time.time() userpref = context.user_preferences inputs = userpref.inputs split = layout.split(percentage=0.25) # Input settings self.draw_input_prefs(inputs, split) # Keymap Settings draw_keymaps(context, split) #print("runtime", time.time() - start)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): layout = self.layout layout.operator( "wm.url_open", text="Add-ons Catalog", icon='URL', ).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts" layout.separator() layout.operator( "wm.url_open", text="How to share your add-on", icon='URL', ).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing" layout.operator( "wm.url_open", text="Add-on Guidelines", icon='URL', ).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons" layout.operator( "wm.url_open", text="API Concepts", icon='URL', ).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html" layout.operator("wm.url_open", text="Add-on Tutorial", icon='URL', ).url = "http://www.blender.org/api/blender_python_api_current/info_tutorial_addon.html"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def poll(cls, context): userpref = context.user_preferences return (userpref.active_section == 'ADDONS')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def is_user_addon(mod, user_addon_paths): import os if not user_addon_paths: for path in (bpy.utils.script_path_user(), bpy.utils.script_path_pref()): if path is not None: user_addon_paths.append(os.path.join(path, "addons")) for path in user_addon_paths: if bpy.path.is_subdir(mod.__file__, path): return True return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw_error(layout, message): lines = message.split("\n") box = layout.box() sub = box.row() sub.label(lines[0]) sub.label(icon='ERROR') for l in lines[1:]: box.label(l)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def draw(self, context): import os import addon_utils layout = self.layout userpref = context.user_preferences used_ext = {ext.module for ext in userpref.addons} userpref_addons_folder = os.path.join(userpref.filepaths.script_directory, "addons") scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "addons") # collect the categories that can be filtered on addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(refresh=False)] split = layout.split(percentage=0.2) col = split.column() col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM') col.label(text="Supported Level") col.prop(context.window_manager, "addon_support", expand=True) col.label(text="Categories") col.prop(context.window_manager, "addon_filter", expand=True) col = split.column() # set in addon_utils.modules_refresh() if addon_utils.error_duplicates: self.draw_error(col, "Multiple addons using the same name found!\n" "likely a problem with the script search path.\n" "(see console for details)", ) if addon_utils.error_encoding: self.draw_error(col, "One or more addons do not have UTF-8 encoding\n" "(see console for details)", ) filter = context.window_manager.addon_filter search = context.window_manager.addon_search.lower() support = context.window_manager.addon_support # initialized on demand user_addon_paths = [] for mod, info in addons: module_name = mod.__name__ is_enabled = module_name in used_ext if info["support"] not in support: continue # check if addon should be visible with current filters if ((filter == "All") or (filter == info["category"]) or (filter == "Enabled" and is_enabled) or (filter == "Disabled" and not is_enabled) or (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder)))) ): if search and search not in info["name"].lower(): if info["author"]: if search not in info["author"].lower(): continue else: continue # Addon UI Code col_box = col.column() box = col_box.box() colsub = box.column() row = colsub.row(align=True) row.operator( "wm.addon_expand", icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT', emboss=False, ).module = module_name row.operator( "wm.addon_disable" if is_enabled else "wm.addon_enable", icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="", emboss=False, ).module = module_name sub = row.row() sub.active = is_enabled sub.label(text='%s: %s' % (info["category"], info["name"])) if info["warning"]: sub.label(icon='ERROR') # icon showing support level. sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION')) # Expanded UI (only if additional info is available) if info["show_expanded"]: if info["description"]: split = colsub.row().split(percentage=0.15) split.label(text="Description:") split.label(text=info["description"]) if info["location"]: split = colsub.row().split(percentage=0.15) split.label(text="Location:") split.label(text=info["location"]) if mod: split = colsub.row().split(percentage=0.15) split.label(text="File:") split.label(text=mod.__file__, translate=False) if info["author"]: split = colsub.row().split(percentage=0.15) split.label(text="Author:") split.label(text=info["author"], translate=False) if info["version"]: split = colsub.row().split(percentage=0.15) split.label(text="Version:") split.label(text='.'.join(str(x) for x in info["version"]), translate=False) if info["warning"]: split = colsub.row().split(percentage=0.15) split.label(text="Warning:") split.label(text=' ' + info["warning"], icon='ERROR') user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths) tot_row = bool(info["wiki_url"]) + bool(user_addon) if tot_row: split = colsub.row().split(percentage=0.15) split.label(text="Internet:") if info["wiki_url"]: split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"] split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info.get( "tracker_url", "https://developer.blender.org/maniphest/task/edit/form/2") if user_addon: split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__ for i in range(4 - tot_row): split.separator() # Show addon user preferences if is_enabled: addon_preferences = userpref.addons[module_name].preferences if addon_preferences is not None: draw = getattr(addon_preferences, "draw", None) if draw is not None: addon_preferences_class = type(addon_preferences) box_prefs = col_box.box() box_prefs.label("Preferences:") addon_preferences_class.layout = box_prefs try: draw(context) except: import traceback traceback.print_exc() box_prefs.label(text="Error (see console)", icon='ERROR') del addon_preferences_class.layout # Append missing scripts # First collect scripts that are used but have no script file. module_names = {mod.__name__ for mod, info in addons} missing_modules = {ext for ext in used_ext if ext not in module_names} if missing_modules and filter in {"All", "Enabled"}: col.column().separator() col.column().label(text="Missing script files") module_names = {mod.__name__ for mod, info in addons} for module_name in sorted(missing_modules): is_enabled = module_name in used_ext # Addon UI Code box = col.column().box() colsub = box.column() row = colsub.row(align=True) row.label(text="", icon='ERROR') if is_enabled: row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name row.label(text=module_name, translate=False)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def define_tables(cls, metadata): Table( "table1", metadata, Column( "id", Integer, primary_key=True, test_needs_autoincrement=True ), Column("data", String(30)), ) Table( "table2", metadata, Column( "id", Integer, primary_key=True, test_needs_autoincrement=True ), Column("someid", None, ForeignKey("table1.id")), )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def memoized(*args): try: return stored_results[args] except KeyError: result = stored_results[args] = fn(*args) return result
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_basic(self): table2, table1 = self.tables.table2, self.tables.table1 Session = scoped_session(sa.orm.sessionmaker(testing.db)) class CustomQuery(query.Query): pass class SomeObject(fixtures.ComparableEntity): query = Session.query_property() class SomeOtherObject(fixtures.ComparableEntity): query = Session.query_property() custom_query = Session.query_property(query_cls=CustomQuery) self.mapper_registry.map_imperatively( SomeObject, table1, properties={"options": relationship(SomeOtherObject)}, ) self.mapper_registry.map_imperatively(SomeOtherObject, table2) s = SomeObject(id=1, data="hello") sso = SomeOtherObject() s.options.append(sso) Session.add(s) Session.commit() Session.refresh(sso) Session.remove() eq_( SomeObject( id=1, data="hello", options=[SomeOtherObject(someid=1)] ), Session.query(SomeObject).one(), ) eq_( SomeObject( id=1, data="hello", options=[SomeOtherObject(someid=1)] ), SomeObject.query.one(), ) eq_( SomeOtherObject(someid=1), SomeOtherObject.query.filter( SomeOtherObject.someid == sso.someid ).one(), ) assert isinstance(SomeOtherObject.query, query.Query) assert not isinstance(SomeOtherObject.query, CustomQuery) assert isinstance(SomeOtherObject.custom_query, query.Query)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_folder_size(folder): total_size = os.path.getsize(folder) for item in os.listdir(folder): itempath = os.path.join(folder, item) if os.path.isfile(itempath): total_size += os.path.getsize(itempath) elif os.path.isdir(itempath): total_size += get_folder_size(itempath) return total_size
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_config_errors(self): Session = scoped_session(sa.orm.sessionmaker()) s = Session() # noqa assert_raises_message( sa.exc.InvalidRequestError, "Scoped session is already present", Session, bind=testing.db, ) assert_warns_message( sa.exc.SAWarning, "At least one scoped session is already present. ", Session.configure, bind=testing.db, )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def usage_iter(root): root = os.path.abspath(root) root_size = get_folder_size(root) root_string = "{0}\n{1}".format(root, root_size) yield [root_string, None, root_size]
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_call_with_kwargs(self): mock_scope_func = Mock() SessionMaker = sa.orm.sessionmaker() Session = scoped_session(sa.orm.sessionmaker(), mock_scope_func) s0 = SessionMaker() assert s0.autoflush == True mock_scope_func.return_value = 0 s1 = Session() assert s1.autoflush == True assert_raises_message( sa.exc.InvalidRequestError, "Scoped session is already present", Session, autoflush=False, ) mock_scope_func.return_value = 1 s2 = Session(autoflush=False) assert s2.autoflush == False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def json_usage(root): root = os.path.abspath(root) result = [['Path', 'Parent', 'Usage']] result.extend(entry for entry in usage_iter(root)) return json.dumps(result)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_methods_etc(self): mock_session = Mock() mock_session.bind = "the bind" sess = scoped_session(lambda: mock_session) sess.add("add") sess.delete("delete") sess.get("Cls", 5) eq_(sess.bind, "the bind") eq_( mock_session.mock_calls, [ mock.call.add("add", _warn=True), mock.call.delete("delete"), mock.call.get( "Cls", 5, options=None, populate_existing=False, with_for_update=None, identity_token=None, execution_options=None, ), ], ) with mock.patch( "sqlalchemy.orm.session.object_session" ) as mock_object_session: sess.object_session("foo") eq_(mock_object_session.mock_calls, [mock.call("foo")])
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def main(args): '''Populates an html template using JSON-formatted output from the Linux 'du' utility and prints the result''' html = '''
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_bind(self, mapper=None, **kwargs): return super().get_bind(mapper=mapper, **kwargs)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_bind(self, mapper=None, *args, **kwargs): return super().get_bind(mapper, *args, **kwargs)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_bind(self, mapper=None, *args, **kwargs): return super(MySession, self).get_bind( mapper, *args, **kwargs )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def get_bind(self, mapper=None, **kwargs): return super(MySession, self).get_bind( mapper=mapper, **kwargs )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_reverse_rfc822_datetime(): dates = [ ("Sat, 01 Jan 2011 00:00:00 -0000", datetime(2011, 1, 1, tzinfo=pytz.utc)), ("Sat, 01 Jan 2011 23:59:59 -0000", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc)), ("Sat, 01 Jan 2011 21:59:59 -0200", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc)), ] for date_string, expected in dates: yield assert_equal, inputs.datetime_from_rfc822(date_string), expected
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_reverse_iso8601_datetime(): dates = [ ("2011-01-01T00:00:00+00:00", datetime(2011, 1, 1, tzinfo=pytz.utc)), ("2011-01-01T23:59:59+00:00", datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc)), ("2011-01-01T23:59:59.001000+00:00", datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=pytz.utc)), ("2011-01-01T23:59:59+02:00", datetime(2011, 1, 1, 21, 59, 59, tzinfo=pytz.utc)) ] for date_string, expected in dates: yield assert_equal, inputs.datetime_from_iso8601(date_string), expected
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_urls(): urls = [ 'http://www.djangoproject.com/', 'http://localhost/', 'http://example.com/', 'http://www.example.com/', 'http://www.example.com:8000/test', 'http://valid-with-hyphens.com/', 'http://subdomain.example.com/', 'http://200.8.9.10/', 'http://200.8.9.10:8000/test', 'http://valid-----hyphens.com/', 'http://example.com?something=value', 'http://example.com/index.php?something=value&another=value2', 'http://foo:bar@example.com', 'http://foo:@example.com', 'http://foo:@2001:db8:85a3::8a2e:370:7334', 'http://foo2:qd1%r@example.com', ] for value in urls: yield assert_equal, inputs.url(value), value
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def check_bad_url_raises(value): try: inputs.url(value) assert False, "shouldn't get here" except ValueError as e: assert_equal(six.text_type(e), u"{0} is not a valid URL".format(value))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_bad_urls(): values = [ 'foo', 'http://', 'http://example', 'http://example.', 'http://.com', 'http://invalid-.com', 'http://-invalid.com', 'http://inv-.alid-.com', 'http://inv-.-alid.com', 'foo bar baz', u'foo \u2713', 'http://@foo:bar@example.com', 'http://:bar@example.com', 'http://bar:bar:bar@example.com', ] for value in values: yield check_bad_url_raises, value
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_bad_url_error_message(): values = [ 'google.com', 'domain.google.com', 'kevin:pass@google.com/path?query', u'google.com/path?\u2713', ] for value in values: yield check_url_error_message, value
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def check_url_error_message(value): try: inputs.url(value) assert False, u"inputs.url({0}) should raise an exception".format(value) except ValueError as e: assert_equal(six.text_type(e), (u"{0} is not a valid URL. Did you mean: http://{0}".format(value)))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_regex_bad_input(): cases = ( 'abc', '123abc', 'abc123', '', ) num_only = inputs.regex(r'^[0-9]+$') for value in cases: yield assert_raises, ValueError, lambda: num_only(value)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_regex_good_input(): cases = ( '123', '1234567890', '00000', ) num_only = inputs.regex(r'^[0-9]+$') for value in cases: yield assert_equal, num_only(value), value
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_regex_bad_pattern(): """Regex error raised immediately when regex input parser is created.""" assert_raises(re.error, inputs.regex, '[')
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_regex_flags_good_input(): cases = ( 'abcd', 'ABCabc', 'ABC', ) case_insensitive = inputs.regex(r'^[A-Z]+$', re.IGNORECASE) for value in cases: yield assert_equal, case_insensitive(value), value
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_regex_flags_bad_input(): cases = ( 'abcd', 'ABCabc' ) case_sensitive = inputs.regex(r'^[A-Z]+$') for value in cases: yield assert_raises, ValueError, lambda: case_sensitive(value)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_boolean_with_python_bool(self): """Input that is already a native python `bool` should be passed through without extra processing.""" assert_equal(inputs.boolean(True), True) assert_equal(inputs.boolean(False), False)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_bad_boolean(self): assert_raises(ValueError, lambda: inputs.boolean("blah"))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_date_later_than_1900(self): assert_equal(inputs.date("1900-01-01"), datetime(1900, 1, 1))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_date_input_error(self): assert_raises(ValueError, lambda: inputs.date("2008-13-13"))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_date_input(self): assert_equal(inputs.date("2008-08-01"), datetime(2008, 8, 1))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_natual_negative(self): assert_raises(ValueError, lambda: inputs.natural(-1))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_natural(self): assert_equal(3, inputs.natural(3))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_natual_string(self): assert_raises(ValueError, lambda: inputs.natural('foo'))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_positive(self): assert_equal(1, inputs.positive(1)) assert_equal(10000, inputs.positive(10000))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_positive_zero(self): assert_raises(ValueError, lambda: inputs.positive(0))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_positive_negative_input(self): assert_raises(ValueError, lambda: inputs.positive(-1))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def test_int_range_good(self): int_range = inputs.int_range(1, 5) assert_equal(3, int_range(3))