File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ >>> format_ts('201412261010')
3
+ 'Fri, Dec 26 2014 10:10:59'
4
+
5
+ >>> format_ts('201412261010', '%s')
6
+ 1419617459000
7
+
8
+ >>> is_wb_handler(DebugEchoHandler())
9
+ False
10
+
11
+
12
+ """
13
+
14
+ from pywb .webapp .views import format_ts , is_wb_handler
15
+ from pywb .webapp .handlers import DebugEchoHandler
16
+
17
+
18
+ if __name__ == "__main__" :
19
+ import doctest
20
+ doctest .testmod ()
Original file line number Diff line number Diff line change @@ -23,11 +23,7 @@ class template_filter(object):
23
23
Otherwise, the func name is the filter name
24
24
"""
25
25
def __init__ (self , param = None ):
26
- if hasattr (param , '__call__' ):
27
- self .name = None
28
- self .__call__ (param )
29
- else :
30
- self .name = param
26
+ self .name = param
31
27
32
28
def __call__ (self , func ):
33
29
name = self .name
@@ -40,7 +36,7 @@ def __call__(self, func):
40
36
41
37
#=================================================================
42
38
# Filters
43
- @template_filter
39
+ @template_filter ()
44
40
def format_ts (value , format_ = '%a, %b %d %Y %H:%M:%S' ):
45
41
value = timestamp_to_datetime (value )
46
42
if format_ == '%s' :
@@ -55,17 +51,11 @@ def get_urlsplit(url):
55
51
return split
56
52
57
53
58
- @template_filter ()
59
- def request_hostname (env ):
60
- return env .get ('HTTP_HOST' , 'localhost' )
61
-
62
-
63
54
@template_filter ()
64
55
def is_wb_handler (obj ):
65
56
if not hasattr (obj , 'handler' ):
66
57
return False
67
58
68
- #return isinstance(obj.handler, WBHandler)
69
59
return obj .handler .__class__ .__name__ == "WBHandler"
70
60
71
61
You can’t perform that action at this time.
0 commit comments