Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F2582513
credentials-repo-replace.py
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
dereckson
Jan 28 2024, 19:30
2024-01-28 19:30:59 (UTC+0)
Size
856 B
Referenced Files
None
Subscribers
None
credentials-repo-replace.py
View Options
#!/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"
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1639360
Default Alt Text
credentials-repo-replace.py (856 B)
Attached To
Mode
P349 credentials-repo-replace.py
Attached
Detach File
Event Timeline
Log In to Comment