Skip to content

Commit

Permalink
removed Python 3.6 specific syntax. Cleaned some docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
verybadsoldier committed Aug 24, 2018
1 parent d230eb3 commit a0c69b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
8 changes: 2 additions & 6 deletions sacredboard/app/data/filesdao.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""
Interface for accessing Sacred files.
"""
"""Interface for accessing Sacred files."""


class FilesDAO:
"""
Interface for accessing files.
"""
"""Interface for accessing files."""

def get(self, file_id):
"""
Expand Down
4 changes: 1 addition & 3 deletions sacredboard/app/data/pymongo/filesdao.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Module responsible for accessing the Files data in MongoDB.
"""
"""Module responsible for accessing the Files data in MongoDB."""
from typing import Union

import bson
Expand Down
6 changes: 3 additions & 3 deletions sacredboard/app/webapi/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _get_binary_info(binary: bytes):
hex_data += " "
hex_data += hex(binary[i])
hex_data += " ..."
return f"Binary data\nLength: {len(binary)}\nFirst 10 bytes: {hex_data}"
return "Binary data\nLength: {}\nFirst 10 bytes: {}".format(len(binary), hex_data)


def get_file(file_id: str, download):
Expand Down Expand Up @@ -85,14 +85,14 @@ def get_files_zip(run_id: int, filetype: _FileType):
for f in target_files:
# source and artifact files use a different data structure
file_id = f['file_id'] if 'file_id' in f else f[1]
file: gridfs.GridOut = dao_files.get(file_id)
file = dao_files.get(file_id)
data = zipfile.ZipInfo(file.filename, date_time=file.upload_date.timetuple())
data.compress_type = zipfile.ZIP_DEFLATED
zf.writestr(data, file.read())
memory_file.seek(0)

fn_suffix = _filetype_suffices[filetype]
return send_file(memory_file, attachment_filename=f'run{run_id}_{fn_suffix}.zip', as_attachment=True)
return send_file(memory_file, attachment_filename='run{}_{}.zip'.format(run_id, fn_suffix), as_attachment=True)


@files.route("/api/file/<string:file_id>")
Expand Down

0 comments on commit a0c69b9

Please sign in to comment.