110 return responses.get(code, ('Error', 'Unknown error'))[0] |
110 return responses.get(code, ('Error', 'Unknown error'))[0] |
111 |
111 |
112 def statusmessage(code, message=None): |
112 def statusmessage(code, message=None): |
113 return '%d %s' % (code, message or _statusmessage(code)) |
113 return '%d %s' % (code, message or _statusmessage(code)) |
114 |
114 |
115 def get_stat(spath, fn="00changelog.i"): |
115 def get_stat(spath, fn): |
116 """stat fn (00changelog.i by default) if it exists, spath otherwise""" |
116 """stat fn if it exists, spath otherwise""" |
117 cl_path = os.path.join(spath, fn) |
117 cl_path = os.path.join(spath, fn) |
118 if os.path.exists(cl_path): |
118 if os.path.exists(cl_path): |
119 return os.stat(cl_path) |
119 return os.stat(cl_path) |
120 else: |
120 else: |
121 return os.stat(spath) |
121 return os.stat(spath) |
122 |
122 |
123 def get_mtime(spath): |
123 def get_mtime(spath): |
124 return get_stat(spath).st_mtime |
124 return get_stat(spath, "00changelog.i").st_mtime |
125 |
125 |
126 def staticfile(directory, fname, req): |
126 def staticfile(directory, fname, req): |
127 """return a file inside directory with guessed Content-Type header |
127 """return a file inside directory with guessed Content-Type header |
128 |
128 |
129 fname always uses '/' as directory separator and isn't allowed to |
129 fname always uses '/' as directory separator and isn't allowed to |