mrmp/local.py

32 lines
807 B
Python
Raw Normal View History

2021-10-09 10:26:53 +00:00
import datetime
import os
2021-10-10 18:04:45 +00:00
import arguments
2021-10-10 12:48:12 +00:00
import repository
2021-10-09 13:58:44 +00:00
2021-10-09 10:26:53 +00:00
2021-10-10 12:48:12 +00:00
class Local(repository.Repository):
2021-10-10 17:02:34 +00:00
def __init__(self):
super().__init__(arguments.directory)
self.temporary = arguments.temporary
2021-10-09 10:26:53 +00:00
2021-10-10 19:30:40 +00:00
def get_file(self, path):
with open(os.path.join(self.location, path), 'br') as f:
return f.read()
2021-10-10 18:27:48 +00:00
def get_files(self, path):
*_, files = next(os.walk(os.path.join(self.location, path)))
return files
2021-10-09 17:46:11 +00:00
def get_temporary(self):
2021-10-09 16:19:58 +00:00
return os.path.join(self.temporary,
datetime.datetime.now()
.strftime('%Y%m%d%H%M%S'))
2021-10-09 10:26:53 +00:00
def __str__(self):
2021-10-09 12:54:50 +00:00
lines = [
2021-10-10 13:01:24 +00:00
super().__str__(),
2021-10-10 18:40:14 +00:00
f'Temporary: {self.temporary}',
2021-10-09 12:54:50 +00:00
]
return os.linesep.join(lines)