Skip to content

Commit 691cf61

Browse files
committed
fix inconsistent indentation styles
1 parent 8b37a36 commit 691cf61

3 files changed

Lines changed: 42 additions & 35 deletions

File tree

libarchive/read.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
from os import fstat, stat
44

55
from . import ffi
6-
from .ffi import (ARCHIVE_EOF, OPEN_CALLBACK, READ_CALLBACK, CLOSE_CALLBACK,
7-
SEEK_CALLBACK, VOID_CB, page_size)
6+
from .ffi import (
7+
ARCHIVE_EOF, OPEN_CALLBACK, READ_CALLBACK, CLOSE_CALLBACK, SEEK_CALLBACK,
8+
VOID_CB, page_size,
9+
)
810
from .entry import ArchiveEntry, new_archive_entry
911

1012

@@ -54,9 +56,9 @@ def new_archive_read(format_name='all', filter_name='all', passphrase=None):
5456

5557
@contextmanager
5658
def custom_reader(
57-
read_func, format_name='all', filter_name='all',
58-
open_func=VOID_CB, close_func=VOID_CB, block_size=page_size,
59-
archive_read_class=ArchiveRead, passphrase=None,
59+
read_func, format_name='all', filter_name='all',
60+
open_func=VOID_CB, close_func=VOID_CB, block_size=page_size,
61+
archive_read_class=ArchiveRead, passphrase=None,
6062
):
6163
"""Read an archive using a custom function.
6264
"""
@@ -69,8 +71,9 @@ def custom_reader(
6971

7072

7173
@contextmanager
72-
def fd_reader(fd, format_name='all', filter_name='all', block_size=4096,
73-
passphrase=None):
74+
def fd_reader(
75+
fd, format_name='all', filter_name='all', block_size=4096, passphrase=None,
76+
):
7477
"""Read an archive from a file descriptor.
7578
"""
7679
with new_archive_read(format_name, filter_name, passphrase) as archive_p:
@@ -83,8 +86,9 @@ def fd_reader(fd, format_name='all', filter_name='all', block_size=4096,
8386

8487

8588
@contextmanager
86-
def file_reader(path, format_name='all', filter_name='all', block_size=4096,
87-
passphrase=None):
89+
def file_reader(
90+
path, format_name='all', filter_name='all', block_size=4096, passphrase=None,
91+
):
8892
"""Read an archive from a file.
8993
"""
9094
with new_archive_read(format_name, filter_name, passphrase) as archive_p:
@@ -106,8 +110,10 @@ def memory_reader(buf, format_name='all', filter_name='all', passphrase=None):
106110

107111

108112
@contextmanager
109-
def stream_reader(stream, format_name='all', filter_name='all',
110-
block_size=page_size, passphrase=None):
113+
def stream_reader(
114+
stream, format_name='all', filter_name='all', block_size=page_size,
115+
passphrase=None,
116+
):
111117
"""Read an archive from a stream.
112118
113119
The `stream` object must support the standard `readinto` method.
@@ -133,8 +139,10 @@ def read_func(archive_p, context, ptrptr):
133139

134140

135141
@contextmanager
136-
def seekable_stream_reader(stream, format_name='all', filter_name='all',
137-
block_size=page_size, passphrase=None):
142+
def seekable_stream_reader(
143+
stream, format_name='all', filter_name='all', block_size=page_size,
144+
passphrase=None,
145+
):
138146
"""Read an archive from a seekable stream.
139147
140148
The `stream` object must support the standard `readinto`, 'seek' and

libarchive/write.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def add_files(self, *paths, **kw):
7575
entry_clear(entry_p)
7676

7777
def add_file_from_memory(
78-
self, entry_path, entry_size, entry_data,
79-
filetype=REGULAR_FILE, permission=DEFAULT_UNIX_PERMISSION,
80-
atime=None, mtime=None, ctime=None, birthtime=None,
78+
self, entry_path, entry_size, entry_data,
79+
filetype=REGULAR_FILE, permission=DEFAULT_UNIX_PERMISSION,
80+
atime=None, mtime=None, ctime=None, birthtime=None,
8181
):
8282
""""Add file from memory to archive.
8383
@@ -146,10 +146,7 @@ def add_file_from_memory(
146146

147147

148148
@contextmanager
149-
def new_archive_write(format_name,
150-
filter_name=None,
151-
options='',
152-
passphrase=None):
149+
def new_archive_write(format_name, filter_name=None, options='', passphrase=None):
153150
archive_p = ffi.write_new()
154151
try:
155152
ffi.get_write_format_function(format_name)(archive_p)
@@ -189,9 +186,9 @@ def new_archive_write(format_name,
189186

190187
@contextmanager
191188
def custom_writer(
192-
write_func, format_name, filter_name=None,
193-
open_func=VOID_CB, close_func=VOID_CB, block_size=page_size,
194-
archive_write_class=ArchiveWrite, options='', passphrase=None,
189+
write_func, format_name, filter_name=None,
190+
open_func=VOID_CB, close_func=VOID_CB, block_size=page_size,
191+
archive_write_class=ArchiveWrite, options='', passphrase=None,
195192
):
196193

197194
def write_cb_internal(archive_p, context, buffer_, length):
@@ -212,8 +209,8 @@ def write_cb_internal(archive_p, context, buffer_, length):
212209

213210
@contextmanager
214211
def fd_writer(
215-
fd, format_name, filter_name=None,
216-
archive_write_class=ArchiveWrite, options='', passphrase=None,
212+
fd, format_name, filter_name=None,
213+
archive_write_class=ArchiveWrite, options='', passphrase=None,
217214
):
218215
with new_archive_write(format_name, filter_name, options,
219216
passphrase) as archive_p:
@@ -223,8 +220,8 @@ def fd_writer(
223220

224221
@contextmanager
225222
def file_writer(
226-
filepath, format_name, filter_name=None,
227-
archive_write_class=ArchiveWrite, options='', passphrase=None,
223+
filepath, format_name, filter_name=None,
224+
archive_write_class=ArchiveWrite, options='', passphrase=None,
228225
):
229226
with new_archive_write(format_name, filter_name, options,
230227
passphrase) as archive_p:
@@ -234,8 +231,8 @@ def file_writer(
234231

235232
@contextmanager
236233
def memory_writer(
237-
buf, format_name, filter_name=None,
238-
archive_write_class=ArchiveWrite, options='', passphrase=None,
234+
buf, format_name, filter_name=None,
235+
archive_write_class=ArchiveWrite, options='', passphrase=None,
239236
):
240237
with new_archive_write(format_name, filter_name, options,
241238
passphrase) as archive_p:

tests/test_security_flags.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
from libarchive import extract_file
88
from libarchive.ffi import version_number
9-
from libarchive.extract import EXTRACT_SECURE_NOABSOLUTEPATHS, \
10-
EXTRACT_SECURE_NODOTDOT
9+
from libarchive.extract import (
10+
EXTRACT_SECURE_NOABSOLUTEPATHS, EXTRACT_SECURE_NODOTDOT,
11+
)
1112
from libarchive.exception import ArchiveError
1213
from . import data_dir
1314

@@ -24,13 +25,14 @@ def run_test(flag, filename):
2425

2526

2627
def test_no_dot_dot():
27-
run_test(EXTRACT_SECURE_NODOTDOT,
28-
'../python-libarchive-c-test-dot-dot-file')
28+
run_test(EXTRACT_SECURE_NODOTDOT, '../python-libarchive-c-test-dot-dot-file')
2929

3030

3131
def test_absolute():
3232
# EXTRACT_SECURE_NOABSOLUTEPATHS was only added in 3.1.900
3333
# 3.1.900 -> 3001009
3434
if version_number() >= 3001009:
35-
run_test(EXTRACT_SECURE_NOABSOLUTEPATHS,
36-
'/tmp/python-libarchive-c-test-absolute-file')
35+
run_test(
36+
EXTRACT_SECURE_NOABSOLUTEPATHS,
37+
'/tmp/python-libarchive-c-test-absolute-file'
38+
)

0 commit comments

Comments
 (0)