mirror of https://github.com/fmartingr/porg.git
filename/extension properties
This commit is contained in:
parent
295db2a5d2
commit
07f3d00c6e
12
porg.py
12
porg.py
|
@ -109,11 +109,11 @@ class File:
|
|||
# Tag not found, try to guess datetime from filename
|
||||
# Format: YYYY-MM-DD HH.MM.SS.ext
|
||||
try:
|
||||
name, _ = os.path.basename(self.path).rsplit('.', maxsplit=1)
|
||||
name, _ = self.filename.rsplit('.', maxsplit=1)
|
||||
date, time = name.split(' ')
|
||||
return datetime(*(int(x) for x in date.split('-') + time.split('.')))
|
||||
except ValueError:
|
||||
raise
|
||||
pass
|
||||
|
||||
# Last resort, use file creation/modification date
|
||||
stat = os.stat(self.path)
|
||||
|
@ -124,6 +124,14 @@ class File:
|
|||
# so we'll settle for when its content was last modified.
|
||||
return datetime.fromtimestamp(stat.st_mtime)
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
return os.path.splitext(self.path)[0]
|
||||
|
||||
@property
|
||||
def extension(self):
|
||||
return os.path.splitext(self.path)[1][1:].lower()
|
||||
|
||||
@property
|
||||
def checksum(self) -> Text:
|
||||
if not getattr(self, '_checksum', False):
|
||||
|
|
Loading…
Reference in New Issue