Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/407 2to3 impact #411

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ This is an overview of major changes. Refer to the git repository for a full log

Version 0.1.35
-------------
- #407 Performance impact of 2to3
- #406 Show Boxes view on creating new document
- #405 Remove qtpy
- #401 Support new pyzbar and pylibdmtx
Expand Down
4 changes: 2 additions & 2 deletions inselect/gui/views/boxes/boxes_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def pixmap_item(self):
"""The single QGraphicsPixmapItem within this scene, or None if there is
no open document
"""
items = list(self.items())
items = self.items()
if not items:
return None
else:
Expand Down Expand Up @@ -80,7 +80,7 @@ def set_pixmap(self, pixmap):

def box_items(self):
"Iterable containin just BoxItems"
return filter(lambda i: isinstance(i, BoxItem), list(self.items()))
return filter(lambda i: isinstance(i, BoxItem), self.items())

def add_box(self, rect, isvalid):
"""Notification from source that a box has been added.
Expand Down
2 changes: 1 addition & 1 deletion inselect/lib/cookie_cutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def save(self, path):
'boxes': self._boxes,
}
with Path(path).open('w', encoding='utf8') as outfile:
outfile.write(str(json.dumps(doc, indent=4)))
outfile.write(json.dumps(doc, indent=4))

@property
def document_items(self):
Expand Down
10 changes: 5 additions & 5 deletions inselect/lib/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def load(cls, path):
properties = doc.get('properties', {})

# Parse datetimes
for dt in {'Saved on', 'Created on'}.intersection(list(properties.keys())):
for dt in {'Saved on', 'Created on'}.intersection(properties.keys()):
properties[dt] = cls._parse_datetime(properties[dt])

msg = 'Loaded [{0}] items from [{1}]'
Expand All @@ -274,7 +274,7 @@ def save(self):
properties = deepcopy(self.properties)

# Format datetimes
for dt in {'Saved on', 'Created on'}.intersection(list(properties.keys())):
for dt in {'Saved on', 'Created on'}.intersection(properties.keys()):
properties[dt] = self._format_datetime(properties[dt])

doc = {
Expand All @@ -290,8 +290,8 @@ def save(self):
# http://stackoverflow.com/a/20776329/1773758
# Specify separators to prevent trailing whitespace
with path.open("w", newline='\n', encoding='utf8') as f:
f.write(str(json.dumps(doc, ensure_ascii=False, indent=4,
separators=(',', ': '), sort_keys=True)))
f.write(json.dumps(doc, ensure_ascii=False, indent=4,
separators=(',', ': '), sort_keys=True))

debug_print('Saved [{0}] items to [{1}]'.format(len(items), path))

Expand Down Expand Up @@ -336,4 +336,4 @@ def metadata_fields(self):
"""An iterable of metadata field names
"""
# The union of fields among all items
return set(chain(*(list(i['fields'].keys()) for i in self._items)))
return set(chain(*(i['fields'].keys() for i in self._items)))
5 changes: 0 additions & 5 deletions inselect/lib/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ def swallow(*args, **kwargs):
new_rects.append(new_rect)
rects = new_rects

# Reverse order so that boxes at the top left are towards the start
# and boxes at the bottom right are towards the end
# TODO LH This is crummy - need a way to order rects
rects = list(reversed(rects))

return rects, display


Expand Down
2 changes: 1 addition & 1 deletion inselect/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def duplicated(v):
"""Returns a generator expression of values within v that appear more than
once
"""
return (x for x, y in list(Counter(v).items()) if y > 1)
return (x for x, y in Counter(v).items() if y > 1)


class FormatDefault(string.Formatter):
Expand Down
5 changes: 4 additions & 1 deletion inselect/tests/gui/test_export_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def _test_csv(self):
'ItemNumber': '{0}'.format(1 + index),
'Cropped_image_name': '{0:04}.jpg'.format(1 + index),
})
actual = {k: v for k, v in list(row.items()) if v and k not in BOUNDING_BOX_FIELD_NAMES}
actual = {
k: v for k, v in row.items()
if v and k not in BOUNDING_BOX_FIELD_NAMES
}
self.assertEqual(expected, actual)

# Expect 4 rows
Expand Down
5 changes: 4 additions & 1 deletion inselect/tests/scripts/test_export_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def test_export_csv(self):
'ItemNumber': str(1+index),
'Cropped_image_name': '{0:04}.jpg'.format(1+index)
})
actual = {k: v for k, v in list(row.items()) if v and k not in BOUNDING_BOX_FIELD_NAMES}
actual = {
k: v for k, v in row.items()
if v and k not in BOUNDING_BOX_FIELD_NAMES
}
self.assertEqual(expected, actual)

def test_export_csv_with_template(self):
Expand Down