equal
deleted
inserted
replaced
4 |
4 |
5 import time |
5 import time |
6 from calendar import timegm |
6 from calendar import timegm |
7 import base64 |
7 import base64 |
8 import re |
8 import re |
9 |
9 from urllib.parse import urlparse |
10 from six import string_types |
|
11 from six.moves.urllib.parse import urlparse |
|
12 |
10 |
13 |
11 |
14 def dashCapitalize(s): |
12 def dashCapitalize(s): |
15 ''' Capitalize a string, making sure to treat - as a word seperator ''' |
13 ''' Capitalize a string, making sure to treat - as a word seperator ''' |
16 return '-'.join([ x.capitalize() for x in s.split('-')]) |
14 return '-'.join([ x.capitalize() for x in s.split('-')]) |
381 """Return seq[-1]""" |
379 """Return seq[-1]""" |
382 return seq[-1] |
380 return seq[-1] |
383 |
381 |
384 def unique(seq): |
382 def unique(seq): |
385 '''if seq is not a string, check it's a sequence of one element and return it''' |
383 '''if seq is not a string, check it's a sequence of one element and return it''' |
386 if isinstance(seq, string_types): |
384 if isinstance(seq, str): |
387 return seq |
385 return seq |
388 if len(seq) != 1: |
386 if len(seq) != 1: |
389 raise ValueError('single value required, not %s' % seq) |
387 raise ValueError('single value required, not %s' % seq) |
390 return seq[0] |
388 return seq[0] |
391 |
389 |
453 * 'true' values are `True`, `1`, `"true"` |
451 * 'true' values are `True`, `1`, `"true"` |
454 * 'false' values are `False`, `0`, `"false"` |
452 * 'false' values are `False`, `0`, `"false"` |
455 |
453 |
456 """ |
454 """ |
457 if (value in (True, 1) or |
455 if (value in (True, 1) or |
458 isinstance(value, string_types) and value.lower() == 'true'): |
456 isinstance(value, str) and value.lower() == 'true'): |
459 return 'true' |
457 return 'true' |
460 if (value in (False, 0) or |
458 if (value in (False, 0) or |
461 isinstance(value, string_types) and value.lower() == 'false'): |
459 isinstance(value, str) and value.lower() == 'false'): |
462 return 'false' |
460 return 'false' |
463 raise ValueError("Invalid true/false header value: %s" % value) |
461 raise ValueError("Invalid true/false header value: %s" % value) |
464 |
462 |
465 class MimeType(object): |
463 class MimeType(object): |
466 @classmethod |
464 @classmethod |