Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9342869
file.py
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
879 B
Subscribers
None
file.py
View Options
# Copyright (C) 2015 Stefano Zacchiroli <zack@upsilon.cc>,
# Antoine R. Dumont <antoine.romain.dumont@gmail.com>
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
os
import
gzip
def
folder_path
(
prefix_dir
,
hexhash
,
depth
=
4
):
"""Compute the folder prefix from a hexhash key.
The depth determines the number of subfolder from prefix_dir.
Default to 4.
"""
hexhashes
=
[
hexhash
[
x
:
x
+
2
]
for
x
in
range
(
0
,
2
*
depth
,
2
)]
return
os
.
path
.
join
(
prefix_dir
,
*
hexhashes
)
def
write_data
(
data
,
path
,
comp_flag
=
None
):
"""Write data to path.
If compress_path is not None, gzip the data.
"""
with
(
gzip
.
open
(
path
,
'wb'
)
if
comp_flag
else
open
(
path
,
'wb'
))
as
f
:
f
.
write
(
data
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 4, 1:04 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3373906
Attached To
rDLDG Git loader
Event Timeline
Log In to Comment