rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
ws = Workspace.objects.get(pk = workspace_id) | ws = DAMWorkspace.objects.get(pk = workspace_id) | def test_remove_from_collection(self): workspace_id = 1 ws = Workspace.objects.get(pk = workspace_id) collection_node = Node.objects.get(label = 'test1', type = 'collection') item = Item.objects.all()[0] params = self.get_final_parameters({ 'collection_id': collection_node.pk}) response = self.client.post('/api/item/... |
workspace = Workspace.objects.create(name = 'test_ws', creator = self.user) | workspace = DAMWorkspace.objects.create(name = 'test', creator = self.user) | def test_add_to_ws(self): workspace = Workspace.objects.create(name = 'test_ws', creator = self.user) workspace_id = workspace.pk item = Item.objects.all()[0] params = self.get_final_parameters({ 'workspace_id': workspace_id}) response = self.client.post('/api/item/%s/add_to_workspace/'%item.pk, params, ) self.asser... |
workspace = Workspace.objects.all()[0] | workspace = DAMWorkspace.objects.all()[0] | def test_upload(self): from django.test import client from batch_processor.models import Action workspace = Workspace.objects.all()[0] image = Type.objects.get(name = 'image') item = Item.objects.create(type = image) item.workspaces.add(workspace) file = open('files/images/logo_blue.jpg') params = self.get_final_param... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_get_state(self): workspace = Workspace.objects.get(pk = 1) item = Item.objects.all()[0] state = State.objects.create(name = 'test', workspace = workspace) state_association = StateItemAssociation.objects.create(state = state, item = item, ) params = self.get_final_parameters({ 'workspace_id': workspace.pk, ... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_set_state(self): workspace = Workspace.objects.get(pk = 1) item = Item.objects.all()[0] state = State.objects.create(name = 'test', workspace = workspace) state_association = StateItemAssociation.objects.create(state = state, item = item) params = self.get_final_parameters({ 'workspace_id': workspace.pk, 'sta... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_get_single(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) params = self.get_final_parameters({}) node = Node.objects.get(label = 'test_remove_1', workspace = ws) response = self.client.get('/api/keyword/%s/get/'%node.pk, params) resp_dict = json.loads(response.content) print '-----------------------... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_get_single_category(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) params = self.get_final_parameters({}) node = Node.objects.get(label = 'People', workspace = ws) response = self.client.get('/api/keyword/%s/get/'%node.pk, params) resp_dict = json.loads(response.content) print resp_dict self.assertT... |
ws = Workspace.objects.get(pk = 1) | ws = DAMWorkspace.objects.get(pk = 1) | def test_create_category(self): ws = Workspace.objects.get(pk = 1) label = 'test_category' parent_node = Node.objects.get(pk = 3) params = self.get_final_parameters({ 'parent_id':parent_node.pk, 'label':label, 'type': 'category' }) response = self.client.post('/api/keyword/new/', params, ) resp_dict = json.loads(res... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_edit(self): |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_edit_1(self): |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_edit_metadata(self): |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_move(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) node_id = Node.objects.get(label = 'test').pk new_parent_node_pk = parent_node = Node.objects.get(workspace = ws, label = 'Places', depth = 1).pk params = self.get_final_parameters({ 'parent_id':new_parent_node_pk, }) self.client.post('/api/keywor... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_delete(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) node_id = Node.objects.get(label = 'test').pk params = self.get_final_parameters({}) response = self.client.get('/api/keyword/%s/delete/'%node_id, params, ) self.assertTrue(response.content == '') self.assertRaises(Node.DoesNotExist, Node.objec... |
ws = Workspace.objects.get(pk = workspace_id) | ws = DAMWorkspace.objects.get(pk = workspace_id) | def test_add_items(self): workspace_id = 1 ws = Workspace.objects.get(pk = workspace_id) node_parent = Node.objects.get(label = 'People', workspace = ws) item = Item.objects.all()[0] item_id = item.pk new_node = Node.objects.get(label = 'test') params = self.get_final_parameters({ 'items':item.pk}) response = self.cl... |
ws = Workspace.objects.get(pk = workspace_id) | ws = DAMWorkspace.objects.get(pk = workspace_id) | def test_remove_items(self): workspace_id = 1 ws = Workspace.objects.get(pk = workspace_id) node_parent = Node.objects.get(label = 'People', workspace = ws) item = Item.objects.create(uploader = User.objects.get(pk = 1), type = Type.objects.get(name = 'image'),) node_parent = Node.objects.get(label = 'People', work... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_get_single(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) params = self.get_final_parameters() label ='test1' node = Node.objects.get(label = label, workspace = ws) response = self.client.get('/api/collection/%s/get/'%node.pk, params) resp_dict = json.loads(response.content) self.assertTrue(resp_di... |
ws = Workspace.objects.get(pk = 1) | ws = DAMWorkspace.objects.get(pk = 1) | def test_create(self): ws = Workspace.objects.get(pk = 1) label = 'collection_test' params = self.get_final_parameters({ 'workspace_id':ws.pk, 'label':label}) response = self.client.post('/api/collection/new/', params, ) resp_dict = json.loads(response.content) self.assertTrue(resp_dict.has_key('id')) self.assertT... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_move(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) node_id = Node.objects.get(label = 'test1', depth = 1).pk dest_id= Node.objects.get(label = 'test2', depth = 1).pk params = self.get_final_parameters({ 'parent_id':dest_id, }) resp = self.client.get('/api/collection/%s/move/'%node_id, params) self... |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_move_to_the_top(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) node_id = Node.objects.get(label = 'test1_child', ).pk root_pk = Node.objects.get(workspace = ws, type ="collection",depth = 0).id params = self.get_final_parameters({ }) resp = self.client.get('/api/collection/%s/move/'%node_id, params) ... |
ws = Workspace.objects.get(pk = workspace_id) | ws = DAMWorkspace.objects.get(pk = workspace_id) | def test_add_items(self): workspace_id = 1 ws = Workspace.objects.get(pk = workspace_id) coll= Node.objects.get(label = 'test1', workspace = ws, type = 'collection') item = Item.objects.all()[0] params = self.get_final_parameters({ 'items':[item.pk, item.pk]}) response = self.client.post('/api/collection/%s/add_ite... |
ws = Workspace.objects.get(pk = workspace_id) | ws = DAMWorkspace.objects.get(pk = workspace_id) | def test_remove_items(self): workspace_id = 1 ws = Workspace.objects.get(pk = workspace_id) coll = Node.objects.get(label = 'test_with_item', workspace = ws) item = Item.objects.all()[0] items = coll.items.all() self.assertTrue(items.count() == 1) params = self.get_final_parameters({ 'items':item.pk}) response = self.... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_get_single(self): variant_pk = 1 variant = Variant.objects.get(pk = variant_pk) workspace = Workspace.objects.get(pk = 1) params = self.get_final_parameters({'workspace_id': workspace.pk}) response = self.client.get('/api/variant/%s/get/'%variant.pk, params) resp_dict = json.loads(response.content) self.ass... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_get_single_preset(self): variant = Variant.objects.get(name = 'preview', media_type__name = 'video') workspace = Workspace.objects.get(pk = 1) prefs = VariantAssociation.objects.get(workspace = workspace, variant = variant).preferences params = self.get_final_parameters({'workspace_id': workspace.pk}) re... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_edit(self): variant = Variant.objects.get(name = 'preview', media_type__name = 'image') workspace = Workspace.objects.get(pk = 1) params = { 'codec': 'gif', 'max_dim': 400, |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_edit_wm(self): variant = Variant.objects.get(name = 'preview', media_type__name = 'image') workspace = Workspace.objects.get(pk = 1) params = { 'codec': 'gif', 'max_dim': 400, |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_edit_preset(self): variant = Variant.objects.get(name = 'preview', media_type__name = 'video') workspace = Workspace.objects.get(pk = 1) params = { 'audio_bitrate_kb':256, 'audio_rate':44100, 'preset': 'flv', 'sources': [11, 10], 'video_bitrate_b': 640000, 'video_framerate': 25/1, 'workspace_id': workspace... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_create_auto_generated_no_preset(self): workspace = Workspace.objects.get(pk = 1) name = 'test' auto_generated = True media_type = 'image' caption = 'test' params = { 'workspace_id': workspace.pk, 'name': name, 'auto_generated': auto_generated, 'media_type': media_type, 'caption': caption, 'codec': 'gif', 'max... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_create_source(self): workspace = Workspace.objects.get(pk = 1) name = 'test' auto_generated = False media_type = 'image' caption = 'test' params = { 'workspace_id': workspace.pk, 'name': name, |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_create_auto_generated_preset(self): workspace = Workspace.objects.get(pk = 1) name = 'test' auto_generated = True media_type = 'video' caption = 'test' preset_name = 'flv' params = { 'workspace_id': workspace.pk, 'name': name, 'auto_generated': auto_generated, 'media_type': media_type, 'caption': caption, 'pr... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_delete(self): workspace = Workspace.objects.get(pk = 1) name = 'test' auto_generated = True media_type = Type.objects.get(name = 'image') caption = 'test' variant = Variant.objects.create(name = name, caption = caption, auto_generated = auto_generated, media_type = media_type) va = VariantAssociation.object... |
workspace = Workspace.objects.get(pk = 1) | workspace = DAMWorkspace.objects.get(pk = 1) | def test_delete_exception(self): workspace = Workspace.objects.get(pk = 1) name = 'test' auto_generated = True media_type = Type.objects.get(name = 'image') caption = 'test' |
ws = Workspace.objects.get(pk = ws_pk) | ws = DAMWorkspace.objects.get(pk = ws_pk) | def test_get_single(self): ws_pk = 1 ws = Workspace.objects.get(pk = ws_pk) params = self.get_final_parameters({}) sm = SmartFolder.objects.get(label = 'test', workspace = ws) response = self.client.get('/api/smartfolder/%s/get/'%sm.pk, params) resp_dict = json.loads(response.content) print resp_dict self.assertTrue(r... |
item_in_basket = 0 if item.pk in basket_items: item_in_basket = 1 | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') logger.debug('workspace_id %s'%workspace_id) if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) ... | |
'inbasket': item.pk in basket_items, | 'inbasket': item_in_basket, | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') logger.debug('workspace_id %s'%workspace_id) if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) ... |
inprogress = 0 if item.pk in tasks_pending: inprogress = 1 | inprogress = int( (not thumb_ready) or (item.pk in tasks_pending)) | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) else: workspace = request.session['workspace... |
thumb_url,thumb_ready = _get_thumb_url(item, workspace) logger.debug('thumb_url,thumb_ready %s, %s'%(thumb_url,thumb_ready)) | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) else: workspace = request.session['workspace... | |
"inprogress":0, | "inprogress": int(not thumb_ready), | def get_status(request): """ Returns information for the given items, including name, size, url of thumbnail and preview Called every 10 seconds by the GUI for refreshing information on pending items """ try: items = simplejson.loads(request.POST.get('items')) #logger.debug('######## items: %s' % items) #logger.debug('... |
def get_adapt_params(self): if self.media_type == 'image': return self.parameters else: tmp = dict(self.parameters) tmp['pos_y_percent'] = tmp.pop('watermark_top_percent') tmp['pos_x_percent'] = tmp.pop('watermark_left_percent') return tmp | def _get_params(self): return { 'type': self.verbose_name, 'parameters': { 'watermark_filename': self.parameters['watermark_filename'], 'pos_y_percent': self.parameters['watermark_top_percent'], 'pos_x_percent': self.parameters['watermark_left_percent'], }} | def __init__(self, media_type, source_variant, workspace, script, watermark_filename, pos_x = None, pos_y = None, pos_x_percent = None, pos_y_percent = None, alpha = None): super(Watermark, self).__init__(media_type, source_variant, workspace, script) self.parameters['watermark_filename'] = watermark_filename if ... |
only_basket = simplejson.loads(request.POST.get('only_basket', 'false')) | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') logger.debug('workspace_id %s'%workspace_id) if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) ... | |
if only_basket: items = items.filter(pk__in=basket_items) | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') logger.debug('workspace_id %s'%workspace_id) if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) ... | |
def get_permissions(self, user): return WorkSpacePermission.objects.filter(Q(workspacepermissionassociation__in = WorkSpacePermissionAssociation.objects.filter(Q(users=user, workspace = self)) ) | Q(workspacepermissionsgroup__in= WorkspacePermissionsGroup.objects.filter(users = user, workspace = self) )).distinct() ... | def get_variants(self): from dam.variants.models import Variant return Variant.objects.filter(Q(workspace = self) | Q(workspace__isnull = True, )).distinct() | |
raise WorkspaceDoesNotExist | raise Workspace.DoesNotExist | def get_keywords(self, request, item_id): """ """ if not request.GET.has_key('workspace_id'): raise MissingArgs, "workspace id and item id are both mandatory parameters" workspace_id = request.GET['workspace_id'] try: ws = Workspace.objects.get(id=workspace_id) except: raise WorkspaceDoesNotExist item = Item.object... |
raise WorkspaceDoesNotExist | raise Workspace.DoesNotExist | def get_state(self, request, item_id): """ Allows to get the state of an item in a given workspace - method: POST - parameters: - workspace_id - returns: empty string if no state has been found, otherwise a json string similar to: {'name': 'test'} """ item = Item.objects.get(pk = item_id) if not request.POST.has_key(... |
user_id = request.POST.get('user_id') | def set_state(self, request, item_id): """ Allows to set a state to an item in a workspace - method: POST - parameters: - workspace_id - state: name of the state - returns: empty string """ items = Item.objects.filter(pk = item_id) state_name = request.POST.get('state') if not state_name: raise MissingArgs({'args': [... | |
def get_adapt_params(self): if self.media_type == 'image': return self.parameters else: tmp = dict(self.parameters) tmp['pos_y_percent'] = tmp.pop('watermark_top_percent') tmp['pos_x_percent'] = tmp.pop('watermark_left_percent') return tmp | def __init__(self, media_type, source_variant, workspace, script, watermark_filename, pos_x = None, pos_y = None, pos_x_percent = None, pos_y_percent = None, alpha = None): super(Watermark, self).__init__(media_type, source_variant, workspace, script) self.parameters['watermark_filename'] = watermark_filename if ... | |
media_types_settings = DAMComponentSetting.objects.get(name='ws_media_types') media_types_selected = get_user_setting_by_level(media_types_settings, ws) media_types_selected = media_types_selected.split(',') logger.debug('media_types_selected %s'%media_types_selected) | def get_workspaces(request): try: user = User.objects.get(pk=request.session['_auth_user_id']) wss = Workspace.objects.filter(members = user).order_by('name').distinct() | |
'media_type': media_types_selected, | def get_workspaces(request): try: user = User.objects.get(pk=request.session['_auth_user_id']) wss = Workspace.objects.filter(members = user).order_by('name').distinct() | |
tmp[media_type.name] = [variant. name for variant in Variant.objects.filter(Q(workspace = workspace) | Q(workspace__isnull = True), hidden = False, media_type = media_type)] | tmp[media_type.name] = [variant. name for variant in Variant.objects.filter(Q(workspace = workspace) | Q(workspace__isnull = True), hidden = False, media_type = media_type, auto_generated = True)] | def required_parameters(workspace): params = SaveAction.required_parameters(workspace) tmp = {} for media_type in Type.objects.all(): tmp[media_type.name] = [variant. name for variant in Variant.objects.filter(Q(workspace = workspace) | Q(workspace__isnull = True), hidden = False, media_type = media_type)] params.appe... |
if x_ratio > y_ratio: final_height = y_ratio*orig_width/x_ratio final_width = orig_width elif x_ratio < y_ratio: final_height = orig_height final_width = x_ratio*orig_height/y_ratio else: if orig_height > orig_width: final_width = orig_width final_height = orig_width else: final_width = orig_height final_height = orig... | final_width = min(orig_width, orig_height*x_ratio/y_ratio) final_height = final_width*y_ratio/x_ratio | def save_and_extract_features(result, component, machine): if result: dir, name = os.path.split(result) component._id = name component.save() |
if media_type == 'video': self.parameters['video_height'] = max_height self.parameters['video_width'] = max_width else: self.parameters['max_height'] = max_height self.parameters['max_width'] = max_width | self.parameters['max_height'] = max_height self.parameters['max_width'] = max_width | def __init__(self, media_type, source_variant, workspace, script, max_height, max_width): super(Resize, self).__init__(media_type, source_variant, workspace, script) if media_type == 'video': self.parameters['video_height'] = max_height self.parameters['video_width'] = max_width else: self.parameters['max_height'] = m... |
my_caption = _get_thumb_caption(item, thumb_caption, default_language) | try: my_caption = _get_thumb_caption(item, thumb_caption, default_language) except: continue | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) else: workspace = request.session['workspace... |
if p.pk in perm_list: | if admin_user == u: all_true = True break for p in available_permissions: if p.pk in perm_list or all_true == True: | def get_ws_members(request): """ Returns the list of members for the current workspace (for workspace admins only) Called by the GUI for workspace/members configuration """ ws_id = request.POST.get('ws_id', request.session.get('workspace').pk) admin_user = User.objects.get(pk=request.session['_auth_user_id']) ws = Wo... |
logger.debug('component.get_parameters() %s'%component.get_parameters()) | def send_mail(component, machine): logger.debug("[SendMail.execute] component %s" % component.ID) mail = component.get_parameters()['mail'] email = EmailMessage('OpenDam Rendition', 'Hi, an OpenDam rendition has been attached. ', EMAIL_SENDER, [mail]) storage = Storage() email.attach_file(storage.abspath(component.... | |
email.attach_file(storage.abspath(component.source.ID)) | email.attach_file(storage.abspath(component.ID)) | def send_mail(component, machine): logger.debug("[SendMail.execute] component %s" % component.ID) mail = component.get_parameters()['mail'] email = EmailMessage('OpenDam Rendition', 'Hi, an OpenDam rendition has been attached. ', EMAIL_SENDER, [mail]) storage = Storage() email.attach_file(storage.abspath(component.... |
lang = settings.METADATA_DEFAULT_LANGUAGE | i = c.item user = i.uploaded_by() metadata_default_language = get_metadata_default_language(user) | def _save_features(c, features): xmp_metadata_commons = {'size':[('notreDAM','FileSize')]} xmp_metadata_audio = {'channels':[('xmpDM', 'audioChannelType')], 'sample_rate':[('xmpDM', 'audioSampleRate')], 'duration':[('notreDAM', 'Duration')]} xmp_metadata_video = {'height':[('xmpDM', 'videoFrameSize','stDim','h')] , '... |
x = MetadataValue(schema=ms, object_id=c.pk, content_type=ctype, value=features[feature], language=lang, xpath=property_xpath) | x = MetadataValue(schema=ms, object_id=c.pk, content_type=ctype, value=features[feature], language=metadata_default_language, xpath=property_xpath) | def _save_features(c, features): xmp_metadata_commons = {'size':[('notreDAM','FileSize')]} xmp_metadata_audio = {'channels':[('xmpDM', 'audioChannelType')], 'sample_rate':[('xmpDM', 'audioSampleRate')], 'duration':[('notreDAM', 'Duration')]} xmp_metadata_video = {'height':[('xmpDM', 'videoFrameSize','stDim','h')] , '... |
file_name = upload_file.name | if not isinstance(upload_file.name, unicode): file_name = unicode(upload_file.name, 'utf-8') else: file_name = upload_file.name | def _get_uploaded_info(upload_file): file_name = upload_file.name type = guess_media_type(file_name) upload_file.rename() res_id = upload_file.get_res_id() return (file_name, type, res_id) |
if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) else: workspace = request.session['workspace'] | workspace = request.session['workspace'] | def load_items(request, view_type=None, unlimited=False, ): from datetime import datetime try: user = User.objects.get(pk=request.session['_auth_user_id']) workspace_id = request.POST.get('workspace_id') if workspace_id: workspace = Workspace.objects.get(pk = workspace_id) else: workspace = request.session['workspace... |
items = items.extra(select=SortedDict([(order_by, 'select value from metadata_metadatavalue where object_id = item.id and schema_id = %s and language=%s or language=null')]), select_params = (str(property.id), language_selected)) | logger.debug('------------- items.query %s'%items.query) items = items.extra(select=SortedDict([(order_by, 'select distinct value from metadata_metadatavalue where object_id = item.id and schema_id = %s and language=%s')]), select_params = (str(property.id), language_selected)) logger.debug('------------- items.quer... | def search_smart_folder(smart_folder_node, items): complex_query = smart_folder_node.get_complex_query() items = _search_complex_query(complex_query, items) return items |
tmp['rate'] = tmp.pop('audio_erate') | tmp['rate'] = tmp.pop('audio_rate') | def get_adapt_params(self): tmp = dict(self.parameters) tmp['bitrate'] = tmp.pop('audio_bitrate') tmp['rate'] = tmp.pop('audio_erate') return tmp |
call_capture_output(cmdline, working_dir) | retcode, stdout, stderr = call_capture_output( cmdline, working_dir) if stderr and "error" in stderr.lower(): msg = "gmsh execution failed with message:\n\n" if stdout: msg += stdout+"\n" msg += stderr+"\n" raise GmshError(msg) if stderr: from warnings import warn msg = "gmsh issued the following messages:\n\n" if s... | def __enter__(self): self.temp_dir_mgr = None temp_dir_mgr = _TempDirManager() try: working_dir = temp_dir_mgr.path from os.path import join source_file_name = join(working_dir, "temp."+self.extension) source_file = open(source_file_name, "w") try: source_file.write(self.source) finally: source_file.close() |
x = numpy.cos(phi) + cx y = numpy.sin(phi) + cy | x = r*numpy.cos(phi) + cx y = r*numpy.sin(phi) + cy | def round_trip_connect(seq): result = [] for i in range(len(seq)): result.append((i, (i+1)%len(seq))) return result |
'Programming Language :: Python 3', | 'Programming Language :: Python :: 3', | def main(): import glob from aksetup_helper import hack_distutils, \ get_config, setup, Extension hack_distutils() conf = get_config(get_config_schema()) triangle_macros = [ ( "EXTERNAL_TEST", 1 ), ( "ANSI_DECLARATORS", 1 ), ( "TRILIBRARY", 1 ) , ] tetgen_macros = [ ("TETLIBRARY", 1), ("SELF_CHECK", 1) , ] INCLUDE_... |
def __init__(self, config, dir, scheme=None): | def __init__(self, base, scheme=None): | def __init__(self, config, dir, scheme=None): """Protocol-specific initializations""" if scheme is None: scheme = COLOR_SCHEME super(IPythonHandler, self).__init__(config, dir, scheme) |
super(IPythonHandler, self).__init__(config, dir, scheme) | super(IPythonHandler, self).__init__(base, scheme) | def __init__(self, config, dir, scheme=None): """Protocol-specific initializations""" if scheme is None: scheme = COLOR_SCHEME super(IPythonHandler, self).__init__(config, dir, scheme) |
settings.GATEWAY_SAVE_IMAGES = settings.GATEWAY_IMAGE_URL and settings.GATEWAY_IMAGE_PATH | settings.GATEWAY_SAVE_IMAGES = bool(settings.GATEWAY_IMAGE_URL and settings.GATEWAY_IMAGE_PATH) | def migrate(fromdir, todir): os.makedirs(todir) dbdir = os.path.join(todir, 'db') if not os.path.exists(dbdir): os.makedirs(dbdir) data = None config = ConfigParser() config.read(os.path.join(fromdir, 'include', 'defaults.ini')) for filename in os.listdir(fromdir): src = os.path.join(fromdir, filename) if filename == '... |
lang = self.lookup.get(res['responseData']['detectedSourceLanguage'], 'unknown').capitalize() | try: lang = self.lookup.get(res['responseData']['detectedSourceLanguage'], 'unknown') except KeyError: lang = dst lang = lang.capitalize() | def translate(self, text, src, dst): """Perform the translation""" opts = {'langpair': '%s|%s' % (self.langs[src], self.langs[dst]), 'v': '1.0', 'q': text} res = simplejson.loads(geturl(self.url, opts)) lang = self.lookup.get(res['responseData']['detectedSourceLanguage'], 'unknown').capitalize() return stripHTML('[%s] ... |
self.periodics = Modules(self, 'tasks', settings.TASKS) | def __init__(self, base, scheme=None): """Initialize bot""" self.base = base self.log = get_logger('madcow', unique=False, stream=sys.stdout) self.colorlib = ColorLib(scheme) self.cached_nick = None self.running = False | |
signal.signal(signalSIGHUP, self.signal_handler) | signal.signal(signal.SIGHUP, self.signal_handler) | def __init__(self, base, scheme=None): """Initialize bot""" self.base = base self.log = get_logger('madcow', unique=False, stream=sys.stdout) self.colorlib = ColorLib(scheme) self.cached_nick = None self.running = False |
except Empty: | except queue.Empty: | def check_response_queue(self): """Check if there's any message in response queue and process""" try: self.handle_response(*self.response_queue.get_nowait()) except Empty: pass except Exception, error: self.log.exception(error) |
now = unix_time() | now = time.time() | def run(self): """While bot is alive, process periodic event queue""" delay = 5 now = unix_time() for mod_name, mod in self.bot.periodics.modules.iteritems(): self.last_run[mod_name] = now - mod[u'obj'].frequency + delay |
sleep(self._process_frequency) | time.sleep(self._process_frequency) | def run(self): """While bot is alive, process periodic event queue""" delay = 5 now = unix_time() for mod_name, mod in self.bot.periodics.modules.iteritems(): self.last_run[mod_name] = now - mod[u'obj'].frequency + delay |
now = unix_time() | now = time.time() | def process_queue(self): """Process queue""" now = unix_time() for mod_name, mod in self.bot.periodics.modules.iteritems(): obj = mod[u'obj'] if (now - self.last_run[mod_name]) < obj.frequency: continue self.last_run[mod_name] = now req = Request() req.sendto = obj.output request = (obj, None, None, {u'req': req}) self... |
print 'yes...' | def _cbGetChatInfoForInvite(self, info, user, message): print 'yes...' apply(self.receiveChatInvite, (user,message)+info) | |
message = stripHTML(message) | message = message.replace('&', '&') message = message.replace('<', '<') message = message.replace('>', '>') message = newline_re.sub('<br>', message) | def protocol_output(self, message, req=None): """This is how we send shit to AOL""" try: # so, utf16 doubles the size of the FLAP packets, which # really limits our max message size. if none of the ordinals # are outside the 7bit ascii range, convert to ascii bytes if not [ch for ch in message if ord(ch) > 127]: messa... |
clock_re = re.compile(r'/chart\?.*?chc=localtime') | clock_re = re.compile(r'/images/icons/onebox/clock') | def http_error_default(self, req, fp, code, msg, headers): return Response(data=dict(headers.items())[u'location']) |
self.frequency = settings.UPDATER_FREQ self.output = None | def init(self): self.frequency = settings.UPDATER_FREQ self.output = None if settings.PROTOCOL != 'irc': raise ValueError('ircops only relevant for irc protocol') | |
wanted = (None, 'plone-developers@lists.sourceforge.net') | wanted = (None, 'aclark@aclark.net') | def test_pypi_certified_owner(self): # testing the real server # XXX this is not optimal try: contacts = _pypi_certified_owner('Products.PloneSoftwareCenter') except gaierror: pass else: wanted = (None, 'plone-developers@lists.sourceforge.net') self.assertEquals(contacts, wanted) |
step=None, total=None): | namespaces=[0,], step=None, total=None): """ Iterate Page objects for all new titles in a single namespace. """ | def NewpagesPageGenerator(get_redirect=False, repeat=False, site=None, step=None, total=None): # API does not (yet) have a newpages function, so this tries to duplicate # it by filtering the recentchanges output # defaults to namespace 0 because that's how Special:Newpages defaults if site is None: site = pywikibot.Sit... |
changetype="new", namespaces=0, step=step, total=total): | changetype="new", namespaces=namespaces, step=step, total=total): | def NewpagesPageGenerator(get_redirect=False, repeat=False, site=None, step=None, total=None): # API does not (yet) have a newpages function, so this tries to duplicate # it by filtering the recentchanges output # defaults to namespace 0 because that's how Special:Newpages defaults if site is None: site = pywikibot.Sit... |
_page = u"%s:%s:%s" % (page.site.family.name, page.site.code, page.title()) seenPages[_page] = True | seenPages[page] = True | def DuplicateFilterPageGenerator(generator): """Yield all unique pages from another generator, omitting duplicates.""" seenPages = {} for page in generator: if page not in seenPages: _page = u"%s:%s:%s" % (page.site.family.name, page.site.code, page.title()) seenPages[_page] = True yield page |
botListPageTitle = botList[self.site.family.name][self.site.code] | botListPageTitle, botTemplate = botList[self.site.family.name][self.site.code] | def botAllowed(self): """ Checks whether the bot is listed on a specific page to comply with the policy on the respective wiki. """ if self.site.family.name in botList \ and self.site.code in botList[self.site.family.name]: botListPageTitle = botList[self.site.family.name][self.site.code] botListPage = pywikibot.Page(s... |
for linkedPage in botListPage.linkedPages(): if linkedPage.title(withNamespace=False) == self.username: return True | if botTemplate: for template in botListPage.templatesWithParams(): if template[0] == botTemplate \ and template[1][0] == self.username: return True else: for linkedPage in botListPage.linkedPages(): if linkedPage.title(withNamespace=False) == self.username: return True | def botAllowed(self): """ Checks whether the bot is listed on a specific page to comply with the policy on the respective wiki. """ if self.site.family.name in botList \ and self.site.code in botList[self.site.family.name]: botListPageTitle = botList[self.site.family.name][self.site.code] botListPage = pywikibot.Page(s... |
'\n'.join(os.listdir(os.path.join(base_dir, "families")))) | '\n'.join(os.listdir( os.path.join( pywikibot_dir, "pywikibot", "families")))) | def create_user_config(): _fnc = os.path.join(base_dir, "user-config.py") if not file_exists(_fnc): known_families = re.findall(r'(.+)_family.py\b', '\n'.join(os.listdir(os.path.join(base_dir, "families")))) fam = listchoice(known_families, "Select family of sites we are working on", default='wikipedia') mylang = raw_i... |
usprop="blockinfo|groups|editcount|registration") | usprop="blockinfo|groups|editcount|registration|emailable") | def users(self, usernames): """Iterate info about a list of users by name or IP. |
default = set(self.site.family.disambig('_default')) | try: default = set(self.site.family.disambig('_default')) except KeyError: default = set(u'Disambig') | def isDisambig(self, get_Index=True): """Return True if this is a disambiguation page, False otherwise. |
'interwiki': re.compile(r'(?i)\[\[(%s)\s?:[^\]]*\]\][\s]*' | 'interwiki': re.compile(r'(?i)\[\[:?(%s)\s?:[^\]]*\]\][\s]*' | def replaceExcept(text, old, new, exceptions, caseInsensitive=False, allowoverlap=False, marker = '', site = None): """ Return text with 'old' replaced by 'new', ignoring specified types of text. Skips occurences of 'old' within exceptions; e.g., within nowiki tags or HTML comments. If caseInsensitive is true, then us... |
if ok in ["Yy"]: | if ok in ["Y", "y"]: | def change_base_dir(): """Create a new user directory.""" global base_dir while True: new_base = raw_input("New user directory? ") new_base = os.path.abspath(new_base) if os.path.exists(new_base): if os.path.isfile(new_base): print("ERROR: there is an existing file with that name.") continue # make sure user can read a... |
'template': re.compile(r'(?s){{(({{.*?}})?.*?)*}}'), | 'template': re.compile(r'(?s){{(({{.*?}})|.)*}}'), | def replaceExcept(text, old, new, exceptions, caseInsensitive=False, allowoverlap=False, marker = '', site = None): """ Return text with 'old' replaced by 'new', ignoring specified types of text. Skips occurences of 'old' within exceptions; e.g., within nowiki tags or HTML comments. If caseInsensitive is true, then us... |
print " %(was)s: %(new)s" % {'now': "Now", 'new': nt} | print " %(now)s: %(new)s" % {'now': "Now", 'new': nt} | def _get_base_dir(): """Return the directory in which user-specific information is stored. This is determined in the following order - 1. If the script was called with a -dir: argument, use the directory provided in this argument 2. If the user has a PYWIKIBOT2_DIR environment variable, use the value of it 3. Use (... |
"""All parameters are the same as for Page() constructor. | """Initializer for a User object. All parameters are the same as for Page() constructor. | def __init__(self, source, title=u''): """All parameters are the same as for Page() constructor. """ if len(title) > 1 and title[0] == u'#': self.is_autoblock = True title = title[1:] else: self.is_autoblock = False Page.__init__(self, source, title, ns=2) if self.namespace() != 2: raise ValueError(u"'%s' is not in the... |
self.is_autoblock = True | self._isAutoblock = True | def __init__(self, source, title=u''): """All parameters are the same as for Page() constructor. """ if len(title) > 1 and title[0] == u'#': self.is_autoblock = True title = title[1:] else: self.is_autoblock = False Page.__init__(self, source, title, ns=2) if self.namespace() != 2: raise ValueError(u"'%s' is not in the... |
self.is_autoblock = False | self._isAutoblock = False | def __init__(self, source, title=u''): """All parameters are the same as for Page() constructor. """ if len(title) > 1 and title[0] == u'#': self.is_autoblock = True title = title[1:] else: self.is_autoblock = False Page.__init__(self, source, title, ns=2) if self.namespace() != 2: raise ValueError(u"'%s' is not in the... |
if self.is_autoblock: | if self._isAutoblock: | def __init__(self, source, title=u''): """All parameters are the same as for Page() constructor. """ if len(title) > 1 and title[0] == u'#': self.is_autoblock = True title = title[1:] else: self.is_autoblock = False Page.__init__(self, source, title, ns=2) if self.namespace() != 2: raise ValueError(u"'%s' is not in the... |
pywikibot.output("This is an autoblock ID, " "you can only use to unblock it.") | pywikibot.output( "This is an autoblock ID, you can only use to unblock it.") def name(self): return self.username | def __init__(self, source, title=u''): """All parameters are the same as for Page() constructor. """ if len(title) > 1 and title[0] == u'#': self.is_autoblock = True title = title[1:] else: self.is_autoblock = False Page.__init__(self, source, title, ns=2) if self.namespace() != 2: raise ValueError(u"'%s' is not in the... |
if self.is_autoblock: | if self._isAutoblock: | def username(self): """ Convenience method that returns the title of the page with namespace prefix omitted, aka the username, as a Unicode string. """ if self.is_autoblock: return u'#' + self.title(withNamespace=False) else: return self.title(withNamespace=False) |
usrequest = pywikibot.data.api.Request( site=self.site, action='query', list='users', usprop='blockinfo|groups|editcount|registration|emailable', ususers=self.username, ) usdata = usrequest.submit() assert 'query' in usdata, \ "API users response lacks 'query' key" assert 'users' in usdata['query'], \ "API users respon... | self._userprops = list(self.site.users([self.username,]))[0] if self.isAnonymous(): r = list(self.site.blocks(users=self.username)) if r: self._userprops['blockedby'] = r[0]['by'] self._userprops['blockreason'] = r[0]['reason'] | def getprops(self, force=False): """ Return a Dictionnary that contains user's properties. Use cached values if already called before, otherwise fetch data from the API. |
""" Return registration time for this user, as a Unicode string in ISO8601 format, or None if the date is unknown. | """ Return registration date for this user, as a long in Mediawiki's internal timestamp format, or 0 if the date is unknown. | def registrationTime(self, force=False): """ Return registration time for this user, as a Unicode string in ISO8601 format, or None if the date is unknown. |
if 'registration' in self.getprops(force): return self.getprops()['registration'] | if self.registration(): return long(self.registration().strftime('%Y%m%d%H%M%S')) else: return 0 def registration(self, force=False): """ Return registration date for this user as a pywikibot.Timestamp object, or None if the date is unknown. @param force: if True, forces reloading the data from API @type force: bool ... | def registrationTime(self, force=False): """ Return registration time for this user, as a Unicode string in ISO8601 format, or None if the date is unknown. |
""" Return edit count for this user as int. | """ Return edit count for this user as int. This is always 0 for 'anonymous' users. | def editCount(self, force=False): """ Return edit count for this user as int. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.