Skip to content

Commit

Permalink
Merge pull request rauc#1406 from jluebbe/ruff-format
Browse files Browse the repository at this point in the history
test/gen_payload_tar.py: format with ruff
  • Loading branch information
ejoerns authored May 7, 2024
2 parents 1ae0377 + cda05c2 commit 1a83fc7
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions test/gen_payload_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,77 @@
from io import BytesIO

# create a tar file with some normal files
with tarfile.open(name='payload-common.tar', mode='w') as t:
f = tarfile.TarInfo(name='file')
with tarfile.open(name="payload-common.tar", mode="w") as t:
f = tarfile.TarInfo(name="file")
t.addfile(f)

c = BytesIO(b'contents')
f = tarfile.TarInfo(name='file-contents')
c = BytesIO(b"contents")
f = tarfile.TarInfo(name="file-contents")
f.size = len(c.getbuffer())
t.addfile(f, c)

f = tarfile.TarInfo(name='file-user')
f = tarfile.TarInfo(name="file-user")
f.uid = 1000
f.gid = 1000
t.addfile(f)

f = tarfile.TarInfo(name='file-mtime')
f = tarfile.TarInfo(name="file-mtime")
f.mtime = 1694006436.1317987
t.addfile(f)

f = tarfile.TarInfo(name='executable')
f = tarfile.TarInfo(name="executable")
f.mode = 0o755
t.addfile(f)

f = tarfile.TarInfo(name='dir')
f = tarfile.TarInfo(name="dir")
f.type = tarfile.DIRTYPE
f.mode = 0o750
t.addfile(f)

f = tarfile.TarInfo(name='dir/file')
f = tarfile.TarInfo(name="dir/file")
t.addfile(f)

f = tarfile.TarInfo(name='symlink')
f = tarfile.TarInfo(name="symlink")
f.type = tarfile.SYMTYPE
f.linkname = './dir/file'
f.linkname = "./dir/file"
t.addfile(f)

f = tarfile.TarInfo(name='hardlink')
f = tarfile.TarInfo(name="hardlink")
f.type = tarfile.LNKTYPE
f.linkname = 'file'
f.linkname = "file"
t.addfile(f)

f = tarfile.TarInfo(name='devchr')
f = tarfile.TarInfo(name="devchr")
f.type = tarfile.CHRTYPE
# /dev/null
f.devmajor = 1
f.devminor = 3
t.addfile(f)

f = tarfile.TarInfo(name='devblk')
f = tarfile.TarInfo(name="devblk")
f.type = tarfile.BLKTYPE
# /dev/dm-0
f.devmajor = 253
f.devminor = 0
t.addfile(f)

f = tarfile.TarInfo(name='fifo')
f = tarfile.TarInfo(name="fifo")
f.type = tarfile.FIFOTYPE
t.addfile(f)

# create a tar file with some special cases
with tarfile.open(name='payload-special.tar', mode='w') as t:
f = tarfile.TarInfo(name='file')
with tarfile.open(name="payload-special.tar", mode="w") as t:
f = tarfile.TarInfo(name="file")
t.addfile(f)

f = tarfile.TarInfo(name='acl')
f.pax_headers['SCHILY.acl.access'] = \
'user::rw-\nuser:root:r--\ngroup::r--\nmask::r--\nother::r--\n'
f = tarfile.TarInfo(name="acl")
f.pax_headers["SCHILY.acl.access"] = "user::rw-\nuser:root:r--\ngroup::r--\nmask::r--\nother::r--\n"
t.addfile(f)

f = tarfile.TarInfo(name='xattr')
f.pax_headers['SCHILY.xattr.user.foo'] = 'bar'
f = tarfile.TarInfo(name="xattr")
f.pax_headers["SCHILY.xattr.user.foo"] = "bar"
t.addfile(f)

f = tarfile.TarInfo(name='selinux')
f.pax_headers['RHT.security.selinux'] = 'system_u:object_r:dummy_t'
f = tarfile.TarInfo(name="selinux")
f.pax_headers["RHT.security.selinux"] = "system_u:object_r:dummy_t"
t.addfile(f)

0 comments on commit 1a83fc7

Please sign in to comment.