Skip to content

Commit

Permalink
Fix annotation profile projections in csv
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens committed May 25, 2020
1 parent 171dc2f commit 922a6b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cytomine/models/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ def profile(self):
data = Cytomine.get_instance().get("{}/{}/profile.json".format(self.callback_identifier, self.id))
return data['collection'] if "collection" in data else data

def profile_projections(self, csv=False, csv_destination="projections-annotation-{id}.csv"):
def profile_projections(self, csv=False, csv_dest_pattern="projections-annotation-{id}.csv"):
if self.id is None:
raise ValueError("Cannot review an annotation with no ID.")

uri = "{}/{}/profile/projections.json".format(self.callback_identifier, self.id)
uri = "{}/{}/profile/projections.{}".format(self.callback_identifier, self.id, "csv" if csv else "json")
if csv:
pattern = re.compile("{(.*?)}")
destination = re.sub(pattern, lambda m: str(getattr(self, str(m.group(0))[1:-1], "_")), csv_destination)
destination = re.sub(pattern, lambda m: str(getattr(self, str(m.group(0))[1:-1], "_")), csv_dest_pattern)

return Cytomine.get_instance().download_file(uri, destination, {"format": "csv"})

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name='Cytomine-Python-Client',
version='2.7.0',
version='2.7.1',
description='Python client to interact with Cytomine.',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 922a6b8

Please sign in to comment.