From 6b34d9edbf6996c00d2e057be8c97c510aecc271 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 30 Apr 2015 11:24:14 +0200 Subject: [PATCH] [OE-Drucken] Added file.py Signed-off-by: Jim Martens --- oe/Drucken/oeprint/file.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 oe/Drucken/oeprint/file.py diff --git a/oe/Drucken/oeprint/file.py b/oe/Drucken/oeprint/file.py new file mode 100644 index 0000000..9b27d7a --- /dev/null +++ b/oe/Drucken/oeprint/file.py @@ -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