To make life simpler, we've developed a helper function, make_path(), defined on line 78. Helper functions allow us to reuse code that we might normally write out many times throughout our script in one function call. With this code, we take an input string representing a file nameĀ and return the absolute path of where the file should exist within the operating system based on the output_directory value supplied by the user. On line 85, two operations take place; first, we join the file_name to the output_directory value with the correct path delimiters using the os.path.join() method.
Next, this value is processed by the os.path.abspath() method, which provides the full file path within the operating system environment. We then return this value to the function that originally called it. As we saw in the flow diagram, many functions will make calls to the make_path() function:
078 def make_path(file_name):
079 """
080 The make_path function provides an absolute path between the
081 output_directory and a file
082 :param file_name: A string representing a file name
083 :return: A string representing the path to a specified file
084 """
085 return os.path.abspath(os.path.join(output_directory,
086 file_name))