cosmic-ray icon indicating copy to clipboard operation
cosmic-ray copied to clipboard

duplicate ReplaceAndWithOr and ReplaceOrWithAnd mutants

Open snarfed opened this issue 7 years ago • 0 comments

originally reported in #366: i see a number of duplicate ReplaceAndWithOr and ReplaceOrWithAnd mutants in a current dump from 3.1.2:

job ID c4d61ca2aaf8416791a502cb1b938956:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 16
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -170,7 +170,7 @@
         if loc:
             obj['location']['objectType'] = 'place'
             (lat, lng) = (loc.get('latitude'), loc.get('longitude'))
-            if (lat and lng):
+            if (lat or lng):
                 try:
                     obj['location'].update({'latitude': float(lat), 'longitude': float(lng)})
                 except ValueError:

job ID a8b4c90581bc44d287f79e93a13f93b3:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 17
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -170,7 +170,7 @@
         if loc:
             obj['location']['objectType'] = 'place'
             (lat, lng) = (loc.get('latitude'), loc.get('longitude'))
-            if (lat and lng):
+            if (lat or lng):
                 try:
                     obj['location'].update({'latitude': float(lat), 'longitude': float(lng)})
                 except ValueError:

job ID eb73563d0ebc40eca26a7ad0f11ed268:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 25
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -269,7 +269,7 @@
     start = props.get('start', [])
     end = props.get('end', [])
     event_times += [('  <time class="dt-start">%s</time>' % time) for time in start]
-    if (start and end):
+    if (start or end):
         event_times.append('  to')
     event_times += [('  <time class="dt-end">%s</time>' % time) for time in end]
     return HENTRY.substitute(prop, published=maybe_datetime(prop.get('published'), 'dt-published'), updated=maybe_datetime(prop.get('updated'), 'dt-updated'), types=' '.join((parent_props + types)), author=hcard_to_html(author, ['p-author']), location=hcard_to_html(location, ['p-location']), categories='\n'.join((people + tags)), attachments='\n'.join(attachments), in_reply_tos=in_reply_tos, invitees='\n'.join([hcard_to_html(i, ['p-invitee']) for i in props.get('invitee', [])]), content=content_html, content_classes=' '.join(content_classes), comments=comments_html, children='\n'.join(children), linked_name=maybe_linked_name(props), summary=summary, event_times='\n'.join(event_times))

job ID 6fde419f4bdb4c38a2433e5e2234ed46:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 26
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -269,7 +269,7 @@
     start = props.get('start', [])
     end = props.get('end', [])
     event_times += [('  <time class="dt-start">%s</time>' % time) for time in start]
-    if (start and end):
+    if (start or end):
         event_times.append('  to')
     event_times += [('  <time class="dt-end">%s</time>' % time) for time in end]
     return HENTRY.substitute(prop, published=maybe_datetime(prop.get('published'), 'dt-published'), updated=maybe_datetime(prop.get('updated'), 'dt-updated'), types=' '.join((parent_props + types)), author=hcard_to_html(author, ['p-author']), location=hcard_to_html(location, ['p-location']), categories='\n'.join((people + tags)), attachments='\n'.join(attachments), in_reply_tos=in_reply_tos, invitees='\n'.join([hcard_to_html(i, ['p-invitee']) for i in props.get('invitee', [])]), content=content_html, content_classes=' '.join(content_classes), comments=comments_html, children='\n'.join(children), linked_name=maybe_linked_name(props), summary=summary, event_times='\n'.join(event_times))

job ID e46bdfd547f14ba89324ffe3dd5afca8:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 29
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -297,7 +297,7 @@
         if (id and (id in seen_ids)):
             continue
         seen_ids.add(id)
-        if (('startIndex' in t) and ('length' in t)):
+        if (('startIndex' in t) or ('length' in t)):
             mentions.append(t)
         else:
             tags.setdefault(source.object_type(t), []).append(t)

job ID be1f8761dfde4dceb145500ac49be72a:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceAndWithOr 30
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -297,7 +297,7 @@
         if (id and (id in seen_ids)):
             continue
         seen_ids.add(id)
-        if (('startIndex' in t) and ('length' in t)):
+        if (('startIndex' in t) or ('length' in t)):
             mentions.append(t)
         else:
             tags.setdefault(source.object_type(t), []).append(t)

job ID ad5ebfe80d8940898a6c9bea81d55a96:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 6
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -70,7 +70,7 @@
     obj_type = (source.object_type(obj) or default_object_type)
     if (obj_type == 'post'):
         primary = obj.get('object', {})
-        obj_type = (source.object_type(primary) or default_object_type)
+        obj_type = (source.object_type(primary) and default_object_type)
     else:
         primary = obj
     name = primary.get('displayName', primary.get('title'))

job ID d7556ddf202c43f9abffa600ade13d0c:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 7
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -70,7 +70,7 @@
     obj_type = (source.object_type(obj) or default_object_type)
     if (obj_type == 'post'):
         primary = obj.get('object', {})
-        obj_type = (source.object_type(primary) or default_object_type)
+        obj_type = (source.object_type(primary) and default_object_type)
     else:
         primary = obj
     name = primary.get('displayName', primary.get('title'))

job ID 88966186096c4c6aad0d1f39bfef775c:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 16
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -85,7 +85,7 @@
     for prop in ('attachments', 'tags'):
         for elem in get_list(primary, prop):
             attachments[elem.get('objectType')].append(elem)
-    ret = {'type': ((AS_TO_MF2_TYPE.get(obj_type) or [entry_class]) if isinstance(entry_class, basestring) else list(entry_class)), 'properties': {'uid': [(obj.get('id') or '')], 'numeric-id': [(obj.get('numeric_id') or '')], 'name': [name], 'nickname': [(obj.get('username') or '')], 'summary': [summary], 'url': (list((object_urls(obj) or object_urls(primary))) + obj.get('upstreamDuplicates', [])), 'photo': dedupe_urls((get_urls(attachments, 'image', 'image') + get_urls(primary, 'image'))), 'video': dedupe_urls((get_urls(attachments, 'video', 'stream') + get_urls(primary, 'stream'))), 'audio': get_urls(attachments, 'audio', 'stream'), 'published': [obj.get('published', primary.get('published', ''))], 'updated': [obj.get('updated', primary.get('updated', ''))], 'content': [{'value': xml.sax.saxutils.unescape(primary.get('content', '')), 'html': render_content(primary, include_location=False, synthesize_content=synthesize_content)}], 'in-reply-to': util.trim_nulls([o.get('url') for o in in_reply_tos]), 'author': [object_to_json(author, trim_nulls=False, default_object_type='person')], 'location': [object_to_json(primary.get('location', {}), trim_nulls=False, default_object_type='place')], 'comment': [object_to_json(c, trim_nulls=False, entry_class='h-cite') for c in obj.get('replies', {}).get('items', [])], 'start': [primary.get('startTime')], 'end': [primary.get('endTime')]}, 'children': [object_to_json(a, trim_nulls=False, entry_class=['u-quotation-of', 'h-cite']) for a in (attachments['note'] + attachments['article'])]}
+    ret = {'type': ((AS_TO_MF2_TYPE.get(obj_type) or [entry_class]) if isinstance(entry_class, basestring) else list(entry_class)), 'properties': {'uid': [(obj.get('id') or '')], 'numeric-id': [(obj.get('numeric_id') or '')], 'name': [name], 'nickname': [(obj.get('username') or '')], 'summary': [summary], 'url': (list((object_urls(obj) and object_urls(primary))) + obj.get('upstreamDuplicates', [])), 'photo': dedupe_urls((get_urls(attachments, 'image', 'image') + get_urls(primary, 'image'))), 'video': dedupe_urls((get_urls(attachments, 'video', 'stream') + get_urls(primary, 'stream'))), 'audio': get_urls(attachments, 'audio', 'stream'), 'published': [obj.get('published', primary.get('published', ''))], 'updated': [obj.get('updated', primary.get('updated', ''))], 'content': [{'value': xml.sax.saxutils.unescape(primary.get('content', '')), 'html': render_content(primary, include_location=False, synthesize_content=synthesize_content)}], 'in-reply-to': util.trim_nulls([o.get('url') for o in in_reply_tos]), 'author': [object_to_json(author, trim_nulls=False, default_object_type='person')], 'location': [object_to_json(primary.get('location', {}), trim_nulls=False, default_object_type='place')], 'comment': [object_to_json(c, trim_nulls=False, entry_class='h-cite') for c in obj.get('replies', {}).get('items', [])], 'start': [primary.get('startTime')], 'end': [primary.get('endTime')]}, 'children': [object_to_json(a, trim_nulls=False, entry_class=['u-quotation-of', 'h-cite']) for a in (attachments['note'] + attachments['article'])]}
     tags = (obj.get('tags', []) or get_first(obj, 'object', {}).get('tags', []))
     ret['properties']['category'] = []
     for tag in tags:

job ID e9f99780983f49ee824b68821814506b:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 17
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -85,7 +85,7 @@
     for prop in ('attachments', 'tags'):
         for elem in get_list(primary, prop):
             attachments[elem.get('objectType')].append(elem)
-    ret = {'type': ((AS_TO_MF2_TYPE.get(obj_type) or [entry_class]) if isinstance(entry_class, basestring) else list(entry_class)), 'properties': {'uid': [(obj.get('id') or '')], 'numeric-id': [(obj.get('numeric_id') or '')], 'name': [name], 'nickname': [(obj.get('username') or '')], 'summary': [summary], 'url': (list((object_urls(obj) or object_urls(primary))) + obj.get('upstreamDuplicates', [])), 'photo': dedupe_urls((get_urls(attachments, 'image', 'image') + get_urls(primary, 'image'))), 'video': dedupe_urls((get_urls(attachments, 'video', 'stream') + get_urls(primary, 'stream'))), 'audio': get_urls(attachments, 'audio', 'stream'), 'published': [obj.get('published', primary.get('published', ''))], 'updated': [obj.get('updated', primary.get('updated', ''))], 'content': [{'value': xml.sax.saxutils.unescape(primary.get('content', '')), 'html': render_content(primary, include_location=False, synthesize_content=synthesize_content)}], 'in-reply-to': util.trim_nulls([o.get('url') for o in in_reply_tos]), 'author': [object_to_json(author, trim_nulls=False, default_object_type='person')], 'location': [object_to_json(primary.get('location', {}), trim_nulls=False, default_object_type='place')], 'comment': [object_to_json(c, trim_nulls=False, entry_class='h-cite') for c in obj.get('replies', {}).get('items', [])], 'start': [primary.get('startTime')], 'end': [primary.get('endTime')]}, 'children': [object_to_json(a, trim_nulls=False, entry_class=['u-quotation-of', 'h-cite']) for a in (attachments['note'] + attachments['article'])]}
+    ret = {'type': ((AS_TO_MF2_TYPE.get(obj_type) or [entry_class]) if isinstance(entry_class, basestring) else list(entry_class)), 'properties': {'uid': [(obj.get('id') or '')], 'numeric-id': [(obj.get('numeric_id') or '')], 'name': [name], 'nickname': [(obj.get('username') or '')], 'summary': [summary], 'url': (list((object_urls(obj) and object_urls(primary))) + obj.get('upstreamDuplicates', [])), 'photo': dedupe_urls((get_urls(attachments, 'image', 'image') + get_urls(primary, 'image'))), 'video': dedupe_urls((get_urls(attachments, 'video', 'stream') + get_urls(primary, 'stream'))), 'audio': get_urls(attachments, 'audio', 'stream'), 'published': [obj.get('published', primary.get('published', ''))], 'updated': [obj.get('updated', primary.get('updated', ''))], 'content': [{'value': xml.sax.saxutils.unescape(primary.get('content', '')), 'html': render_content(primary, include_location=False, synthesize_content=synthesize_content)}], 'in-reply-to': util.trim_nulls([o.get('url') for o in in_reply_tos]), 'author': [object_to_json(author, trim_nulls=False, default_object_type='person')], 'location': [object_to_json(primary.get('location', {}), trim_nulls=False, default_object_type='place')], 'comment': [object_to_json(c, trim_nulls=False, entry_class='h-cite') for c in obj.get('replies', {}).get('items', [])], 'start': [primary.get('startTime')], 'end': [primary.get('endTime')]}, 'children': [object_to_json(a, trim_nulls=False, entry_class=['u-quotation-of', 'h-cite']) for a in (attachments['note'] + attachments['article'])]}
     tags = (obj.get('tags', []) or get_first(obj, 'object', {}).get('tags', []))
     ret['properties']['category'] = []
     for tag in tags:

job ID d544bbd5f4414b21bc6ea862c3a78956:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 22
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -124,7 +124,7 @@
 
 def json_to_object(mf2, actor=None, fetch_mf2=False):
     'Converts microformats2 JSON to an ActivityStreams object.\n\n  Args:\n    mf2: dict, decoded JSON microformats2 object\n    actor: optional author AS actor object. usually comes from a rel="author"\n      link. if mf2 has its own author, that will override this.\n    fetch_mf2: boolean, whether to fetch additional pages via HTTP if necessary,\n      e.g. to determine authorship: https://indieweb.org/authorship\n\n  Returns:\n    dict, ActivityStreams object\n  '
-    if ((not mf2) or (not isinstance(mf2, dict))):
+    if ((not mf2) and (not isinstance(mf2, dict))):
         return {}
     mf2 = copy.copy(mf2)
     props = mf2.setdefault('properties', {})

job ID 3db7d4456a9d4941b26e5abc0830d322:survived:granary.microformats2
command: cosmic-ray worker granary.microformats2 core/ReplaceOrWithAnd 23
--- mutation diff ---
--- a/Users/ryan/src/granary/granary/microformats2.py
+++ b/Users/ryan/src/granary/granary/microformats2.py
@@ -124,7 +124,7 @@
 
 def json_to_object(mf2, actor=None, fetch_mf2=False):
     'Converts microformats2 JSON to an ActivityStreams object.\n\n  Args:\n    mf2: dict, decoded JSON microformats2 object\n    actor: optional author AS actor object. usually comes from a rel="author"\n      link. if mf2 has its own author, that will override this.\n    fetch_mf2: boolean, whether to fetch additional pages via HTTP if necessary,\n      e.g. to determine authorship: https://indieweb.org/authorship\n\n  Returns:\n    dict, ActivityStreams object\n  '
-    if ((not mf2) or (not isinstance(mf2, dict))):
+    if ((not mf2) and (not isinstance(mf2, dict))):
         return {}
     mf2 = copy.copy(mf2)
     props = mf2.setdefault('properties', {})

snarfed avatar Apr 02 '18 17:04 snarfed