Skip to content

Commit

Permalink
Merge pull request #24 from sat-utils/develop
Browse files Browse the repository at this point in the history
fix year,month,day patterns
  • Loading branch information
matthewhanson authored Dec 20, 2018
2 parents 51bf3b2 + 0b6b72a commit b1cca98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
19 changes: 4 additions & 15 deletions satstac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ def __getitem__(self, key):
def date(self):
return self.datetime.date()

@property
def year(self):
return self.datetime.year()

@property
def month(self):
return self.datetime.month()

@property
def day(self):
return self.datetime.day()

@property
def datetime(self):
return dateparse(self['datetime'])
Expand Down Expand Up @@ -122,14 +110,15 @@ def get_filename(self, path='', filename='${id}'):
)

def substitute(self, string):
""" Substitude envvars in string with Item values """
""" Substitute envvars in string with Item values """
string = string.replace(':', '_colon_')
subs = {}
for key in [i[1] for i in Formatter().parse(string.rstrip('/')) if i[1] is not None]:
if key == 'id':
subs[key] = self.id
elif key == 'date':
subs[key] = self.date
elif key in ['date', 'year', 'month', 'day']:
vals = {'date': self.date, 'year': self.date.year, 'month': self.date.month, 'day': self.date.day}
subs[key] = vals[key]
else:
subs[key] = self[key.replace('_colon_', ':')]
return Template(string).substitute(**subs)
Expand Down
2 changes: 1 addition & 1 deletion satstac/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0rc4'
__version__ = '0.1.0rc5'

0 comments on commit b1cca98

Please sign in to comment.