comparison mercurial/url.py @ 45957:89a2afe31e82

formating: upgrade to black 20.8b1 This required a couple of small tweaks to un-confuse black, but now it works. Big formatting changes come from: * Dramatically improved collection-splitting logic upstream * Black having a strong (correct IMO) opinion that """ is better than ''' Differential Revision: https://phab.mercurial-scm.org/D9430
author Augie Fackler <raf@durin42.com>
date Fri, 27 Nov 2020 17:03:29 -0500
parents ff48eea4a926
children d4ba4d51f85f
comparison
equal deleted inserted replaced
45956:346af7687c6f 45957:89a2afe31e82
33 urlerr = util.urlerr 33 urlerr = util.urlerr
34 urlreq = util.urlreq 34 urlreq = util.urlreq
35 35
36 36
37 def escape(s, quote=None): 37 def escape(s, quote=None):
38 '''Replace special characters "&", "<" and ">" to HTML-safe sequences. 38 """Replace special characters "&", "<" and ">" to HTML-safe sequences.
39 If the optional flag quote is true, the quotation mark character (") 39 If the optional flag quote is true, the quotation mark character (")
40 is also translated. 40 is also translated.
41 41
42 This is the same as cgi.escape in Python, but always operates on 42 This is the same as cgi.escape in Python, but always operates on
43 bytes, whereas cgi.escape in Python 3 only works on unicodes. 43 bytes, whereas cgi.escape in Python 3 only works on unicodes.
44 ''' 44 """
45 s = s.replace(b"&", b"&amp;") 45 s = s.replace(b"&", b"&amp;")
46 s = s.replace(b"<", b"&lt;") 46 s = s.replace(b"<", b"&lt;")
47 s = s.replace(b">", b"&gt;") 47 s = s.replace(b">", b"&gt;")
48 if quote: 48 if quote:
49 s = s.replace(b'"', b"&quot;") 49 s = s.replace(b'"', b"&quot;")
584 loggingfh=None, 584 loggingfh=None,
585 loggingname=b's', 585 loggingname=b's',
586 loggingopts=None, 586 loggingopts=None,
587 sendaccept=True, 587 sendaccept=True,
588 ): 588 ):
589 ''' 589 """
590 construct an opener suitable for urllib2 590 construct an opener suitable for urllib2
591 authinfo will be added to the password manager 591 authinfo will be added to the password manager
592 592
593 The opener can be configured to log socket events if the various 593 The opener can be configured to log socket events if the various
594 ``logging*`` arguments are specified. 594 ``logging*`` arguments are specified.
598 ``loggingopts`` is a dict of keyword arguments to pass to the constructed 598 ``loggingopts`` is a dict of keyword arguments to pass to the constructed
599 ``util.socketobserver`` instance. 599 ``util.socketobserver`` instance.
600 600
601 ``sendaccept`` allows controlling whether the ``Accept`` request header 601 ``sendaccept`` allows controlling whether the ``Accept`` request header
602 is sent. The header is sent by default. 602 is sent. The header is sent by default.
603 ''' 603 """
604 timeout = ui.configwith(float, b'http', b'timeout') 604 timeout = ui.configwith(float, b'http', b'timeout')
605 handlers = [] 605 handlers = []
606 606
607 if loggingfh: 607 if loggingfh:
608 handlers.append( 608 handlers.append(