Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pugixml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
SCALE
Code
external
pugixml
Commits
7a9da11d
Commit
7a9da11d
authored
4 years ago
by
Arseny Kapoulkine
Browse files
Options
Downloads
Patches
Plain Diff
scripts: Convert archive.py to Python 3
The changes are mostly mechanically converting str to bytes.
parent
a3ae05cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
scripts/archive.py
+6
-6
6 additions, 6 deletions
scripts/archive.py
with
7 additions
and
7 deletions
Makefile
+
1
−
1
View file @
7a9da11d
...
@@ -77,7 +77,7 @@ docs: docs/quickstart.html docs/manual.html
...
@@ -77,7 +77,7 @@ docs: docs/quickstart.html docs/manual.html
build/pugixml-%
:
.FORCE | $(RELEASE)
build/pugixml-%
:
.FORCE | $(RELEASE)
@
mkdir
-p
$(
BUILD
)
@
mkdir
-p
$(
BUILD
)
TIMESTAMP
=
`
git show v
$(
VERSION
)
-s
--format
=
%ct
`
&&
python scripts/archive.py
$@
pugixml-
$(
VERSION
)
$$
TIMESTAMP
$|
TIMESTAMP
=
`
git show v
$(
VERSION
)
-s
--format
=
%ct
`
&&
python
3
scripts/archive.py
$@
pugixml-
$(
VERSION
)
$$
TIMESTAMP
$|
$(EXECUTABLE)
:
$(OBJECTS)
$(EXECUTABLE)
:
$(OBJECTS)
$(
CXX
)
$(
OBJECTS
)
$(
LDFLAGS
)
-o
$@
$(
CXX
)
$(
OBJECTS
)
$(
LDFLAGS
)
-o
$@
...
...
This diff is collapsed.
Click to expand it.
scripts/archive.py
+
6
−
6
View file @
7a9da11d
import
io
import
os.path
import
os.path
import
sys
import
sys
import
tarfile
import
tarfile
import
time
import
time
import
zipfile
import
zipfile
import
StringIO
def
read_file
(
path
,
use_crlf
):
def
read_file
(
path
,
use_crlf
):
with
open
(
path
,
'
rb
'
)
as
file
:
with
open
(
path
,
'
rb
'
)
as
file
:
data
=
file
.
read
()
data
=
file
.
read
()
if
'
\0
'
not
in
data
:
if
b
'
\0
'
not
in
data
:
data
=
data
.
replace
(
'
\r
'
,
''
)
data
=
data
.
replace
(
b
'
\r
'
,
b
''
)
if
use_crlf
:
if
use_crlf
:
data
=
data
.
replace
(
'
\n
'
,
'
\r\n
'
)
data
=
data
.
replace
(
b
'
\n
'
,
b
'
\r\n
'
)
return
data
return
data
...
@@ -24,7 +24,7 @@ def write_zip(target, arcprefix, timestamp, sources):
...
@@ -24,7 +24,7 @@ def write_zip(target, arcprefix, timestamp, sources):
info
=
zipfile
.
ZipInfo
(
path
)
info
=
zipfile
.
ZipInfo
(
path
)
info
.
date_time
=
time
.
localtime
(
timestamp
)
info
.
date_time
=
time
.
localtime
(
timestamp
)
info
.
compress_type
=
zipfile
.
ZIP_DEFLATED
info
.
compress_type
=
zipfile
.
ZIP_DEFLATED
info
.
external_attr
=
0644
<<
16
L
info
.
external_attr
=
0
o
644
<<
16
archive
.
writestr
(
info
,
data
)
archive
.
writestr
(
info
,
data
)
def
write_tar
(
target
,
arcprefix
,
timestamp
,
sources
,
compression
):
def
write_tar
(
target
,
arcprefix
,
timestamp
,
sources
,
compression
):
...
@@ -35,7 +35,7 @@ def write_tar(target, arcprefix, timestamp, sources, compression):
...
@@ -35,7 +35,7 @@ def write_tar(target, arcprefix, timestamp, sources, compression):
info
=
tarfile
.
TarInfo
(
path
)
info
=
tarfile
.
TarInfo
(
path
)
info
.
size
=
len
(
data
)
info
.
size
=
len
(
data
)
info
.
mtime
=
timestamp
info
.
mtime
=
timestamp
archive
.
addfile
(
info
,
StringIO
.
String
IO
(
data
))
archive
.
addfile
(
info
,
io
.
Bytes
IO
(
data
))
if
len
(
sys
.
argv
)
<
5
:
if
len
(
sys
.
argv
)
<
5
:
raise
RuntimeError
(
'
Usage: python archive.py <target> <archive prefix> <timestamp> <source files>
'
)
raise
RuntimeError
(
'
Usage: python archive.py <target> <archive prefix> <timestamp> <source files>
'
)
...
...
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