Skip to content

Commit f23ba47

Browse files
committed
Reformat with autopep8.
1 parent 631d8c4 commit f23ba47

11 files changed

+62
-53
lines changed

autopep8.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#/bin/sh
2+
python3 -m autopep8 --in-place --verbose \
3+
--aggressive --aggressive --aggressive \
4+
--ignore E301,E309 \
5+
wpull/*.py \
6+
wpull/http/*.py \
7+
wpull/testing/*.py

wpull/app.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -709,18 +709,20 @@ def _build_file_writer(self):
709709
else:
710710
case = None
711711

712-
path_namer = self._factory.new('PathNamer',
713-
args.directory_prefix,
714-
index=args.default_page,
715-
use_dir=use_dir,
716-
cut=args.cut_dirs,
717-
protocol=args.protocol_directories,
718-
hostname=args.host_directories,
719-
os_type=os_type,
720-
ascii_only=ascii_only,
721-
no_control=no_control,
722-
case=case,
723-
max_filename_length=args.max_filename_length,)
712+
path_namer = self._factory.new(
713+
'PathNamer',
714+
args.directory_prefix,
715+
index=args.default_page,
716+
use_dir=use_dir,
717+
cut=args.cut_dirs,
718+
protocol=args.protocol_directories,
719+
hostname=args.host_directories,
720+
os_type=os_type,
721+
ascii_only=ascii_only,
722+
no_control=no_control,
723+
case=case,
724+
max_filename_length=args.max_filename_length,
725+
)
724726

725727
if args.recursive or args.page_requisites or args.continue_download:
726728
if args.clobber_method == 'disable':
@@ -811,21 +813,20 @@ def _build_http_client(self):
811813
bind_address = None
812814

813815
def connection_factory(*args, **kwargs):
814-
return self._factory.new('Connection',
815-
*args,
816-
resolver=resolver,
817-
params=ConnectionParams(
818-
connect_timeout=connect_timeout,
819-
read_timeout=read_timeout,
820-
keep_alive=(
821-
self._args.http_keep_alive
822-
and not self._args.ignore_length
823-
),
824-
ssl_options=self._build_ssl_options(),
825-
ignore_length=self._args.ignore_length,
826-
bind_address=bind_address,
827-
),
828-
**kwargs)
816+
return self._factory.new(
817+
'Connection',
818+
*args,
819+
resolver=resolver,
820+
params=ConnectionParams(
821+
connect_timeout=connect_timeout,
822+
read_timeout=read_timeout,
823+
keep_alive=(
824+
self._args.http_keep_alive and not self._args.ignore_length),
825+
ssl_options=self._build_ssl_options(),
826+
ignore_length=self._args.ignore_length,
827+
bind_address=bind_address,
828+
),
829+
**kwargs)
829830

830831
def host_connection_pool_factory(*args, **kwargs):
831832
return self._factory.new(

wpull/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __repr__(self):
157157
key=self.key, value=self.value,
158158
ttl=self.time_to_live,
159159
access_time=self.access_time, id=id(self)
160-
)
160+
)
161161

162162
def __hash__(self):
163163
return hash(self.key)

wpull/cookie_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self, headers=None, url=None):
1414
headers: list of RFC822-style 'Key: value' strings
1515
"""
1616
if sys.version_info[0] == 2:
17-
import mimetools, StringIO
17+
import mimetools
18+
import StringIO
1819
f = StringIO.StringIO("\n".join(headers))
1920
self._headers = mimetools.Message(f)
2021
else:

wpull/database.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def get_and_update(self, status, new_status=None, level=None):
262262
.filter(
263263
URL.status == status,
264264
URL.level < level,
265-
).first()
265+
).first()
266266

267267
if not url_record:
268268
raise NotFound()

wpull/iostream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def _update_handler(self, events):
277277
self.close()
278278
raise NetworkError(
279279
'Failed to update handler: {error}'.format(error=error)
280-
) from error
280+
) from error
281281

282282
def _raise_socket_error(self):
283283
'''Get the error from the socket and raise an error.'''

wpull/phantomjs_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import wpull.async
55
from wpull.http.client import Client
66
from wpull.phantomjs import (PhantomJSRemote, PhantomJSClient,
7-
PhantomJSRPCTimedOut)
7+
PhantomJSRPCTimedOut)
88
from wpull.proxy import HTTPProxyServer
99

1010

wpull/processor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _should_fetch_reason(self, url_info, url_record):
342342
and len(test_info['failed']) == 1
343343
and 'SpanHostsFilter' in test_info['map']
344344
and not test_info['map']['SpanHostsFilter']):
345-
return True, 'redirect'
345+
return True, 'redirect'
346346

347347
else:
348348
# _logger.debug(

wpull/scraper_test.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_html_scraper_links(self):
6464
'http://example.com/param_ref_value.php',
6565
'http://example.com/overlay_src.html',
6666
'http://example.com/script_variable.png',
67-
},
67+
},
6868
inline_urls
6969
)
7070
self.assertEqual({
@@ -98,7 +98,7 @@ def test_html_scraper_links(self):
9898
'http://example.com/http_script_json.html?a=b',
9999
'http://example.com/a_javascript_link.html',
100100
'http://example.com/a_onclick_link.html',
101-
},
101+
},
102102
linked_urls
103103
)
104104

@@ -215,12 +215,12 @@ def test_html_scraper_links_base_href(self):
215215
'http://example.com/dir/image2.png',
216216
'http://example.net/image3.png',
217217
'http://example.com/dir/image4.png',
218-
},
218+
},
219219
inline_urls
220220
)
221221
self.assertEqual({
222222
'http://example.com/a/'
223-
},
223+
},
224224
linked_urls
225225
)
226226

@@ -447,7 +447,7 @@ def test_scrape_css_urls(self):
447447
'chrome://communicator/skin/',
448448
'landscape.css',
449449
'cool.css'
450-
},
450+
},
451451
urls
452452
)
453453

@@ -462,7 +462,7 @@ def test_scrape_css_urls(self):
462462
'landscape.css',
463463
'cool.css',
464464
'warm.css',
465-
},
465+
},
466466
urls
467467
)
468468

@@ -484,7 +484,7 @@ def test_css_scraper_links(self):
484484
self.assertEqual({
485485
'http://example.com/mobile.css',
486486
'http://example.com/images/star.gif',
487-
},
487+
},
488488
inline_urls
489489
)
490490
self.assertFalse(linked_urls)
@@ -506,7 +506,7 @@ def test_css_scraper_mojibake(self):
506506

507507
self.assertEqual({
508508
'http://example.com/文字化け.png',
509-
},
509+
},
510510
inline_urls
511511
)
512512
self.assertFalse(linked_urls)
@@ -529,7 +529,7 @@ def test_css_scraper_krokozyabry(self):
529529

530530
self.assertEqual({
531531
'http://example.com/Кракозябры.png',
532-
},
532+
},
533533
inline_urls
534534
)
535535
self.assertFalse(linked_urls)
@@ -550,7 +550,7 @@ def test_sitemap_scraper_robots(self):
550550

551551
self.assertEqual({
552552
'http://example.com/sitemap00.xml',
553-
},
553+
},
554554
linked_urls
555555
)
556556
self.assertFalse(inline_urls)
@@ -596,7 +596,7 @@ def test_sitemap_scraper_xml_index(self):
596596

597597
self.assertEqual({
598598
'http://www.example.com/sitemap1.xml.gz',
599-
},
599+
},
600600
linked_urls
601601
)
602602
self.assertFalse(inline_urls)
@@ -626,7 +626,7 @@ def test_sitemap_scraper_xml(self):
626626

627627
self.assertEqual({
628628
'http://www.example.com/',
629-
},
629+
},
630630
linked_urls
631631
)
632632
self.assertFalse(inline_urls)
@@ -651,7 +651,7 @@ def test_sitemap_scraper_invalid_xml(self):
651651

652652
self.assertEqual({
653653
'http://www.example.com/',
654-
},
654+
},
655655
linked_urls
656656
)
657657
self.assertFalse(inline_urls)
@@ -673,7 +673,7 @@ def test_javascript_scraper(self):
673673

674674
self.assertEqual({
675675
'http://example.com/script_variable.png',
676-
},
676+
},
677677
inline_urls
678678
)
679679
self.assertEqual({
@@ -690,7 +690,7 @@ def test_javascript_scraper(self):
690690
'http://example.com/../relative_dir_script_variable',
691691
'http://example.com/script_json.html',
692692
'http://example.com/http_script_json.html?a=b',
693-
},
693+
},
694694
linked_urls
695695
)
696696

wpull/testing/badapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def utf8_then_binary(self):
549549
'᚛᚛ᚉᚑᚅᚔᚉᚉᚔᚋ ᚔᚈᚔ ᚍᚂᚐᚅᚑ ᚅᚔᚋᚌᚓᚅᚐ᚜'
550550
'Je peux manger du verre, ça ne me fait pas mal.'
551551
"Dw i'n gallu bwyta gwydr, 'dyw e ddim yn gwneud dolur i mi."
552-
).encode('utf8')
552+
).encode('utf8')
553553

554554
for dummy in range(8000):
555555
self.wfile.write(data)

wpull/writer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,10 @@ def __missing__(self, char):
551551
char_num = ord(char)
552552

553553
if ((self.unix and char == b'/')
554-
or (self.control and
555-
(0 <= char_num <= 31 or 128 <= char_num <= 159))
556-
or (self.windows and char in br'\|/:?"*<>')
557-
or (self.ascii and char_num > 127)):
554+
or (self.control and
555+
(0 <= char_num <= 31 or 128 <= char_num <= 159))
556+
or (self.windows and char in br'\|/:?"*<>')
557+
or (self.ascii and char_num > 127)):
558558
value = b'%' + base64.b16encode(char)
559559
else:
560560
value = char

0 commit comments

Comments
 (0)