mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Misc fixes for previous py3 PR
This commit is contained in:
		
							parent
							
								
									68afcf4598
								
							
						
					
					
						commit
						f0ab48d1a9
					
				@ -14,7 +14,7 @@ from calibre.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS
 | 
			
		||||
from calibre.customize.conversion import DummyReporter
 | 
			
		||||
from calibre.constants import preferred_encoding
 | 
			
		||||
from calibre.ebooks.metadata import format_isbn
 | 
			
		||||
from polyglot.builtins import string_or_bytes, unicode_type
 | 
			
		||||
from polyglot.builtins import string_or_bytes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BIBTEX(CatalogPlugin):
 | 
			
		||||
@ -350,7 +350,7 @@ class BIBTEX(CatalogPlugin):
 | 
			
		||||
            bibtexc.ascii_bibtex = True
 | 
			
		||||
 | 
			
		||||
        # Check citation choice and go to default in case of bad CLI
 | 
			
		||||
        if isinstance(opts.impcit, (str, unicode_type)) :
 | 
			
		||||
        if isinstance(opts.impcit, string_or_bytes) :
 | 
			
		||||
            if opts.impcit == 'False' :
 | 
			
		||||
                citation_bibtex= False
 | 
			
		||||
            elif opts.impcit == 'True' :
 | 
			
		||||
@ -362,7 +362,7 @@ class BIBTEX(CatalogPlugin):
 | 
			
		||||
            citation_bibtex= opts.impcit
 | 
			
		||||
 | 
			
		||||
        # Check add file entry and go to default in case of bad CLI
 | 
			
		||||
        if isinstance(opts.addfiles, (StringType, UnicodeType)) :
 | 
			
		||||
        if isinstance(opts.addfiles, string_or_bytes) :
 | 
			
		||||
            if opts.addfiles == 'False' :
 | 
			
		||||
                addfiles_bibtex = False
 | 
			
		||||
            elif opts.addfiles == 'True' :
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,8 @@ from polyglot import http_client, reprlib
 | 
			
		||||
 | 
			
		||||
Range = namedtuple('Range', 'start stop size')
 | 
			
		||||
MULTIPART_SEPARATOR = uuid.uuid4().hex
 | 
			
		||||
if isinstance(MULTIPART_SEPARATOR, bytes):
 | 
			
		||||
    MULTIPART_SEPARATOR = MULTIPART_SEPARATOR.decode('ascii')
 | 
			
		||||
COMPRESSIBLE_TYPES = {'application/json', 'application/javascript', 'application/xml', 'application/oebps-package+xml'}
 | 
			
		||||
if is_py3:
 | 
			
		||||
    import zlib
 | 
			
		||||
@ -450,7 +452,10 @@ class HTTPConnection(HTTPRequest):
 | 
			
		||||
 | 
			
		||||
    def send_range_not_satisfiable(self, content_length):
 | 
			
		||||
        buf = [
 | 
			
		||||
            '%s %d %s' % (self.response_protocol, http_client.REQUESTED_RANGE_NOT_SATISFIABLE, http_client.responses[http_client.REQUESTED_RANGE_NOT_SATISFIABLE]),
 | 
			
		||||
            '%s %d %s' % (
 | 
			
		||||
                self.response_protocol,
 | 
			
		||||
                http_client.REQUESTED_RANGE_NOT_SATISFIABLE,
 | 
			
		||||
                http_client.responses[http_client.REQUESTED_RANGE_NOT_SATISFIABLE]),
 | 
			
		||||
            "Date: " + http_date(),
 | 
			
		||||
            "Content-Range: bytes */%d" % content_length,
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
@ -127,8 +127,9 @@ def test_basic():
 | 
			
		||||
 | 
			
		||||
    def do_test(stream):
 | 
			
		||||
        c = comment(stream)
 | 
			
		||||
        if c != 'some comment\n':
 | 
			
		||||
            raise ValueError('Comment not read: %r != %r' % (c, b'some comment\n'))
 | 
			
		||||
        expected = 'some comment\n'
 | 
			
		||||
        if c != expected:
 | 
			
		||||
            raise ValueError('Comment not read: %r != %r' % (c, expected))
 | 
			
		||||
        if set(names(stream)) != {
 | 
			
		||||
            '1/sub-one', 'one.txt', '2/sub-two.txt', '诶比屁.txt', 'Füße.txt',
 | 
			
		||||
            'uncompressed', 'max-compressed'}:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user