comparison bitsyblog/bitsyblog.py @ 118:e81b431daf37

py3
author Jeff Hammel <k0scist@gmail.com>
date Tue, 03 Nov 2020 14:39:30 -0800
parents 6cb762107214
children ff44e92fe93f
comparison
equal deleted inserted replaced
117:6cb762107214 118:e81b431daf37
24 from io import StringIO 24 from io import StringIO
25 from paste.fileapp import FileApp 25 from paste.fileapp import FileApp
26 from pkg_resources import iter_entry_points 26 from pkg_resources import iter_entry_points
27 from pkg_resources import resource_filename 27 from pkg_resources import resource_filename
28 from webob import Request, Response, exc 28 from webob import Request, Response, exc
29
30 # python3 (only, for now and probably ever)
31 string = (str,)
29 32
30 try: 33 try:
31 # python2 34 # python2
32 from urlparse import urlparse 35 from urlparse import urlparse
33 except ImportError: 36 except ImportError:
65 for key, value in self.defaults.items(): 68 for key, value in self.defaults.items():
66 kw_value = kw.get(key, value) 69 kw_value = kw.get(key, value)
67 70
68 # convert kw_value to the proper type 71 # convert kw_value to the proper type
69 _type = type(value) 72 _type = type(value)
70 if isinstance(kw_value, basestring) and not issubclass(_type, basestring) and value is not None: 73 if isinstance(kw_value, string) and not issubclass(_type, string) and value is not None:
71 if _type == bool: 74 if _type == bool:
72 kw_value = kw_value.lower() == 'true' 75 kw_value = kw_value.lower() == 'true'
73 else: 76 else:
74 kw_value = _type(kw_value) 77 kw_value = _type(kw_value)
75 setattr(self, key, kw_value) 78 setattr(self, key, kw_value)