Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33103407
helpers.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
helpers.py
View Options
import
json
import
shlex
def
normalize_path_for_rsync
(
path
):
n
=
path
if
n
.
startswith
(
'./'
):
n
=
n
[
2
:]
if
n
.
endswith
(
'/'
):
n
=
n
[:
-
1
]
return
'/'
+
n
def
rsync_rules_from_artifacts
(
artifacts
):
paths
=
artifacts
.
get
(
'paths'
,
[])
# Include all dirs
rules
=
[
'--include'
,
'*/'
]
for
p
in
paths
:
normalized_path
=
normalize_path_for_rsync
(
p
)
rules
+=
[
# If path already has /** at the end, the second will actually do nothing,
# but it's fine to add it anyway. The directory itself will still
# be visited because of the --include */ option we add at the beginning.
'--include'
,
normalized_path
,
'--include'
,
normalized_path
+
'/**'
,
]
# Exclude everything else
rules
+=
[
'--exclude'
,
'*'
]
return
rules
def
normalize_base_url
(
base_url
):
return
base_url
.
rstrip
(
'/'
)
if
base_url
else
None
def
phorge_token_to_arcrc
(
normalized_base_url
,
token
):
return
json
.
dumps
({
'hosts'
:
{
normalized_base_url
+
'/api/'
:
{
'token'
:
token
,
},
},
})
def
ci_vars_to_cmds
(
v
):
res
=
[]
for
name
in
v
:
value
=
shlex
.
quote
(
'{}'
.
format
(
v
[
name
]))
res
.
append
(
f
'export {name}={value}'
)
return
'
\n
'
.
join
(
res
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Tue, Jan 20, 1:47 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
973596
Default Alt Text
helpers.py (1 KB)
Attached To
Mode
rB lilybuild
Attached
Detach File
Event Timeline
Log In to Comment