Page MenuHomePhorge

helpers.py
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

helpers.py

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

Mime Type
text/x-python
Expires
Tue, Jan 20, 1:47 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
973596
Default Alt Text
helpers.py (1 KB)

Event Timeline