Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Paste
P349
credentials-repo-replace.py
Active
Public
Actions
Authored by
dereckson
on Jan 28 2024, 19:30.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F2582513: credentials-repo-replace.py
Jan 28 2024, 19:30
2024-01-28 19:30:59 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
sys
# -------------------------------------------------------------
# Migrate : string replacement
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
migrate_all
(
orig_list
,
dest_list
):
for
orig
,
dest
in
zip
(
orig_list
,
dest_list
):
migrate
(
orig
,
dest
)
def
migrate
(
orig
,
dest
):
orig_re
=
orig
.
replace
(
"."
,
"\."
)
print
(
f
"rg -l -F {orig} | xargs gsed -i s@{orig_re}@{dest}@g"
)
# -------------------------------------------------------------
# Application entry point
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
run
(
orig_file
,
dest_file
):
orig_list
=
[
line
.
strip
()
for
line
in
open
(
orig_file
)]
dest_list
=
[
line
.
strip
()
for
line
in
open
(
dest_file
)]
migrate_all
(
orig_list
,
dest_list
)
if
__name__
==
"__main__"
:
run
(
"from"
,
"to"
)
Event Timeline
dereckson
created this paste.
Jan 28 2024, 19:30
2024-01-28 19:30:59 (UTC+0)
dereckson
added a comment.
Jan 28 2024, 19:31
2024-01-28 19:31:46 (UTC+0)
Comment Actions
Used to prepare
D3302
.
Log In to Comment