srlp/mrmp/local.py

32 lines
807 B
Python
Raw Normal View History

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