1
0
mirror of https://github.com/2martens/uni.git synced 2026-05-06 11:26:25 +02:00

[OE-Drucken] Added file.py

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2015-04-30 11:24:14 +02:00
parent 33f46033b2
commit 6b34d9edbf

View File

@ -0,0 +1,33 @@
"""file.py: Provides functionality to manage printable files."""
__author__ = 'Jim Martens'
def get_file_path(year, directory, identifier):
"""
Returns the file path for the given identifier.
:type year: str
:type directory: str
:type identifier: str
:rtype: str
"""
path = directory + '/' + identifier + '/'
version_file = open(path + 'version.txt')
current_version = version_file.readline().strip()
return path + year + '_' + identifier + '_V' + current_version + '.pdf'
def insert_file_paths(year, directory, files):
"""
Manipulates the files list and adds a key named path to each object in the list.
:type year: str
:type directory: str
:type files: list
:rtype: list
"""
file_configs = []
for file_config in files:
file_config['path'] = get_file_path(year, directory, file_config['identifier'])
file_configs.append(file_config)
return file_configs