Skip to content

Commit

Permalink
use re substitution for params
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo authored and sethfowler committed Apr 10, 2017
1 parent 99335a3 commit 1d9a575
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker/scripts/mininet/multi_switch_mininet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import argparse
import json
import importlib
import re
from time import sleep

from mininet.net import Mininet
Expand Down Expand Up @@ -85,7 +86,7 @@ def main():

def formatParams(s):
for param in params:
s = s.replace('$'+param, str(params[param]))
s = re.sub('\$'+param+'(\W|$)', str(params[param]) + r'\1', s)
s = s.replace('${'+param+'}', str(params[param]))
return s

Expand Down Expand Up @@ -162,7 +163,6 @@ def formatParams(s):


def formatCmd(cmd):
cmd = formatParams(cmd)
for h in net.hosts:
cmd = cmd.replace(h.name, h.defaultIntf().updateIP())
return cmd
Expand Down

0 comments on commit 1d9a575

Please sign in to comment.