import os import sys import time import md5 import tempfile import Defaults def GetPictarDir(): rel_script_path = sys.argv[0] abs_script_path = os.path.abspath(rel_script_path) abs_script_dir = os.path.dirname(abs_script_path) return abs_script_dir def GetBrowserCommand(): # Get the command used to execute the user's browser. return Defaults.BROWSER_COMMAND def GetAbsTargetDir(): rel_target_dir = os.getcwd() argc = len(sys.argv) if (argc > 1): # If no directory was passed to the program, # use the current working directory as the target. # Otherwise, use the passed directory. rel_target_dir = sys.argv[1] # Convert a relative path into an absolute one. # It will be important to have an absolute path # later when we are constructing URLs. __abs_target_dir = os.path.abspath(rel_target_dir) return __abs_target_dir def GetPageTemplatePath(): script_dir = GetPictarDir() page_template_path = os.path.join(script_dir, Defaults.PAGE_TEMPLATE_FILE_NAME) return page_template_path def GetRecursive(): __recursive = False return __recursive def GetOutfilePath(): unique_string = str(time.time()) md5hash = md5.new(unique_string) outfile_name = md5hash.hexdigest() outfile_path = os.path.join(tempfile.gettempdir(), outfile_name) return outfile_path def GetItemTemplatePath(): script_dir = GetPictarDir() item_template_path = os.path.join(script_dir, Defaults.ITEM_TEMPLATE_FILE_NAME) return item_template_path def GetStyleSheetPath(): script_dir = GetPictarDir() stylesheet_path = os.path.join(script_dir, Defaults.STYLESHEET_FILE_NAME) return stylesheet_path def GetVerbose(): return True def GetMimetypesFilePath(): script_dir = GetPictarDir() mimetypes_file_path = os.path.join(script_dir, Defaults.MIMETYPES_FILE_NAME) return mimetypes_file_path