]> gitweb.michael.orlitzky.com - dead/pictar.git/blob - Configuration/__init__.py
Initial commit.
[dead/pictar.git] / Configuration / __init__.py
1 import os
2 import sys
3 import time
4 import md5
5 import tempfile
6 import Defaults
7
8
9 def GetPictarDir():
10 rel_script_path = sys.argv[0]
11 abs_script_path = os.path.abspath(rel_script_path)
12 abs_script_dir = os.path.dirname(abs_script_path)
13
14 return abs_script_dir
15
16
17 def GetBrowserCommand():
18 # Get the command used to execute the user's browser.
19 return Defaults.BROWSER_COMMAND
20
21
22 def GetAbsTargetDir():
23 rel_target_dir = os.getcwd()
24 argc = len(sys.argv)
25
26 if (argc > 1):
27 # If no directory was passed to the program,
28 # use the current working directory as the target.
29 # Otherwise, use the passed directory.
30 rel_target_dir = sys.argv[1]
31
32 # Convert a relative path into an absolute one.
33 # It will be important to have an absolute path
34 # later when we are constructing URLs.
35 __abs_target_dir = os.path.abspath(rel_target_dir)
36
37 return __abs_target_dir
38
39
40
41
42 def GetPageTemplatePath():
43 script_dir = GetPictarDir()
44 page_template_path = os.path.join(script_dir, Defaults.PAGE_TEMPLATE_FILE_NAME)
45
46 return page_template_path
47
48
49
50 def GetRecursive():
51 __recursive = False
52 return __recursive
53
54
55
56 def GetOutfilePath():
57 unique_string = str(time.time())
58 md5hash = md5.new(unique_string)
59 outfile_name = md5hash.hexdigest()
60 outfile_path = os.path.join(tempfile.gettempdir(), outfile_name)
61
62 return outfile_path
63
64
65
66
67
68
69 def GetItemTemplatePath():
70 script_dir = GetPictarDir()
71 item_template_path = os.path.join(script_dir, Defaults.ITEM_TEMPLATE_FILE_NAME)
72
73 return item_template_path
74
75
76
77 def GetStyleSheetPath():
78 script_dir = GetPictarDir()
79 stylesheet_path = os.path.join(script_dir, Defaults.STYLESHEET_FILE_NAME)
80
81 return stylesheet_path
82
83
84
85 def GetVerbose():
86 return True
87
88
89 def GetMimetypesFilePath():
90 script_dir = GetPictarDir()
91 mimetypes_file_path = os.path.join(script_dir, Defaults.MIMETYPES_FILE_NAME)
92
93 return mimetypes_file_path
94