The output is not the expected. I would like it to print all diffs regarding 'system' under the 'system' directory and all diffs related to 'interfaces' under the 'interface' directory. "{ ... }" is also not printing even though I have a statement to catch it. The code is below:
import re
template_list = ['system','interfaces']
directory = '/templates/juniper/junos/vfirewall/'
diff = """[edit system name-server]
    8.8.8.8 { ... }
+   4.4.4.4;
[edit interfaces ge-0/0/0 unit 0 family inet]
+       address 10.20.30.10/24;
-       address 10.50.30.10/24;
[edit interfaces]
+   ge-0/0/1 {
+       unit 2 {
+           family inet {
+               address 10.50.80.10/24;
+           }
+       }
+   }""".splitlines()
for template in template_list:
 print("{}{}".format(directory,template))
 for line in diff:
   if(re.match('\[edit\s({})'.format(template),line)):
     print('{}'.format(line))
   elif(re.match('\{ ... \}',line)):
     print('{}'.format(line))
   elif(re.match('^\-',line)):
     print('{}'.format(line))
   elif(re.match('^\+',line)):
     print('{}'.format(line))
   elif(re.match('\[edit\s\w.+',line)):
     break
Output gives:
/templates/juniper/junos/vfirewall/system
[edit system name-server]
+   4.4.4.4;
/templates/juniper/junos/vfirewall/interfaces
>>> 
Expected output:
/templates/juniper/junos/vfirewall/system
[edit system name-server]
    8.8.8.8 { ... }
+   4.4.4.4;
/templates/juniper/junos/vfirewall/interfaces
[edit interfaces ge-0/0/0 unit 0 family inet]
+       address 10.20.30.10/24;
-       address 10.50.30.10/24;
[edit interfaces]
+   ge-0/0/1 {
+       unit 2 {
+           family inet {
+               address 10.50.80.10/24;
+           }
+       }
+   }
 
    