Skip to content

Commit

Permalink
Merge pull request #112 from sciris/default-filename
Browse files Browse the repository at this point in the history
Default filename
  • Loading branch information
cliffckerr committed Jul 8, 2020
2 parents ccf5709 + 044f3a1 commit 7fa0d41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

By import convention, components of the Sciris library are listed beginning with `sc.`, e.g. `sc.odict()`.

## Version 0.17.1 (2020-07-07)
1. `sc.Blobject` has been modified to allow more flexibility with saving (e.g., `Path` objects).

## Version 0.17.0 (2020-04-27)
1. `sc.mprofile()` has been added, which does memory profiling just like `sc.profile()`.
1. `sc.progressbar()` has been added, which prints a progress bar.
Expand Down
18 changes: 4 additions & 14 deletions sciris/sc_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,21 +582,11 @@ def read_file(filename):

def save(self, filename=None):
''' This function writes the spreadsheet to a file on disk. '''
if filename is None:
if self.filename is not None:
filename = self.filename
elif self.name is not None:
if self.name.endswith('.xlsx'):
filename = self.name
else:
filename = self.name + '.xlsx'
else:
filename = 'spreadsheet.xlsx' # Come up with a terrible default name
filepath = makefilepath(filename=filename)
with open(filepath, mode='wb') as f:
f.write(self.blob)
self.filename = filename
print('Spreadsheet saved to %s.' % filepath)
print('Object saved to %s.' % filepath)
return filepath

def tofile(self, output=True):
Expand Down Expand Up @@ -774,9 +764,9 @@ def writecells(self, cells=None, startrow=None, startcol=None, vals=None, sheetn

return None


pass

def save(self, filename='spreadsheet.xlsx'):
filepath = makefilepath(filename=filename, ext='xlsx')
super().save(filepath)

def loadspreadsheet(filename=None, folder=None, fileobj=None, sheetname=None, sheetnum=None, asdataframe=None, header=True, cells=None):
'''
Expand Down
6 changes: 3 additions & 3 deletions sciris/sc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ def print_date(date, includeyear=True, shortmonths=True):
elif elapsed_time < datetime.timedelta(seconds=60 * 60):

# We know that seconds > 60, so we can safely round down
minutes = elapsed_time.seconds / 60
minutes = int(elapsed_time.seconds / 60)
if minutes == 1:
time_str = "a minute ago"
else:
Expand All @@ -1365,9 +1365,9 @@ def print_date(date, includeyear=True, shortmonths=True):
elif elapsed_time < datetime.timedelta(seconds=60 * 60 * 24 - 1):

# We know that it's at least an hour, so we can safely round down
hours = elapsed_time.seconds / (60 * 60)
hours = int(elapsed_time.seconds / (60 * 60))
if hours == 1:
time_str = "an hour ago"
time_str = "1 hour ago"
else:
time_str = "%d hours ago" % hours

Expand Down
4 changes: 2 additions & 2 deletions sciris/sc_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ['__version__', '__versiondate__', '__license__']

__version__ = '0.17.0'
__versiondate__ = '2020-04-27'
__version__ = '0.17.1'
__versiondate__ = '2020-07-07'
__license__ = 'Sciris %s (%s) -- (c) Sciris.org' % (__version__, __versiondate__)

0 comments on commit 7fa0d41

Please sign in to comment.