Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romain
mat2
Commits
bdd55810
Commit
bdd55810
authored
5 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Compress cleaned zip archives by default
parent
47f9cb33
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libmat2/archive.py
+7
-8
7 additions, 8 deletions
libmat2/archive.py
with
7 additions
and
8 deletions
libmat2/archive.py
+
7
−
8
View file @
bdd55810
...
...
@@ -99,9 +99,8 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
def
_get_member_name
(
member
:
ArchiveMember
)
->
str
:
"""
Return the name of the given member.
"""
@staticmethod
@abc.abstractstaticmethod
def
_add_file_to_archive
(
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
@abc.abstractmethod
def
_add_file_to_archive
(
self
,
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
full_path
:
str
):
"""
Add the file at full_path to the archive, via the given member.
"""
...
...
@@ -313,8 +312,7 @@ class TarParser(ArchiveBasedAbstractParser):
metadata
[
'
gname
'
]
=
member
.
gname
return
metadata
@staticmethod
def
_add_file_to_archive
(
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
def
_add_file_to_archive
(
self
,
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
full_path
:
str
):
assert
isinstance
(
member
,
tarfile
.
TarInfo
)
# please mypy
assert
isinstance
(
archive
,
tarfile
.
TarFile
)
# please mypy
...
...
@@ -358,6 +356,7 @@ class ZipParser(ArchiveBasedAbstractParser):
super
().
__init__
(
filename
)
self
.
archive_class
=
zipfile
.
ZipFile
self
.
member_class
=
zipfile
.
ZipInfo
self
.
zip_compression_type
=
zipfile
.
ZIP_DEFLATED
def
is_archive_valid
(
self
):
try
:
...
...
@@ -392,13 +391,13 @@ class ZipParser(ArchiveBasedAbstractParser):
return
metadata
@staticmethod
def
_add_file_to_archive
(
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
def
_add_file_to_archive
(
self
,
archive
:
ArchiveClass
,
member
:
ArchiveMember
,
full_path
:
str
):
assert
isinstance
(
archive
,
zipfile
.
ZipFile
)
# please mypy
assert
isinstance
(
member
,
zipfile
.
ZipInfo
)
# please mypy
with
open
(
full_path
,
'
rb
'
)
as
f
:
archive
.
writestr
(
member
,
f
.
read
())
archive
.
writestr
(
member
,
f
.
read
(),
compress_type
=
self
.
zip_compression_type
)
@staticmethod
def
_get_all_members
(
archive
:
ArchiveClass
)
->
List
[
ArchiveMember
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment