Revised several custom sky130 scripts to accept the option "-ef_format"
and handle the syntax of the filesystem under libs.ref/ accordingly.
Change only affects installations using EF_STYLE=1.
diff --git a/sky130/custom/scripts/add_bipolar_ids.py b/sky130/custom/scripts/add_bipolar_ids.py
index 1668ef4..247d522 100755
--- a/sky130/custom/scripts/add_bipolar_ids.py
+++ b/sky130/custom/scripts/add_bipolar_ids.py
@@ -11,10 +11,20 @@
 import re
 import sys
 
-magpath = 'sky130A/libs.ref/sky130_fd_pr/mag'
+options = []
+arguments = []
+for item in sys.argv[1:]:
+    if item.find('-', 0) == 0:
+        options.append(item[1:])
+    else:
+        arguments.append(item)
 
-if len(sys.argv) > 1:
-    magpath = sys.argv[1]
+magpath = 'sky130A/libs.ref/sky130_fd_pr/mag'
+if len(options) > 0:
+    if options[0] == 'ef_format':
+        magpath = 'sky130A/libs.ref/mag/sky130_fd_pr'
+elif len(arguments) > 0:
+    magpath = arguments[0]
 
 baserex = re.compile('<< [np]base >>')
 
diff --git a/sky130/custom/scripts/fix_spice_includes.py b/sky130/custom/scripts/fix_spice_includes.py
index 7465786..1aaa0b5 100755
--- a/sky130/custom/scripts/fix_spice_includes.py
+++ b/sky130/custom/scripts/fix_spice_includes.py
@@ -15,12 +15,25 @@
 newdevs = []
 newdevs.append('sky130_fd_pr__pnp_05v5_W3p40L3p40')
 
-if len(sys.argv) <= 1:
-    print('Usage: fix_spice_includes.py <path_to_file>')
+options = []
+arguments = []
+for item in sys.argv[1:]:
+    if item.find('-', 0) == 0:
+        options.append(item[1:])
+    else:
+        arguments.append(item)
+
+if len(arguments) < 1:
+    print('Usage: fix_spice_includes.py <path_to_file> [-ef_format]')
     sys.exit(1)
 
 else:
-    infile_name = sys.argv[1]
+    infile_name = arguments[0]
+
+    libpath = 'sky130_fd_pr/spice/'
+    if len(options) > 0:
+        if options[0] == 'ef_format':
+            libpath = 'spi/sky130_fd_pr/'
 
     filepath = os.path.split(infile_name)[0]
     outfile_name = os.path.join(filepath, 'temp')
@@ -36,7 +49,7 @@
         if 'pnp_05v5' in line:
             # Insert these additional lines
             for newdev in newdevs:
-                newline = '.include "../../libs.ref/sky130_fd_pr/spice/' + newdev + '.model.spice"\n'
+                newline = '.include "../../libs.ref/' + libpath + newdev + '.model.spice"\n'
                 outfile.write(newline)
             replaced_something = True
 
diff --git a/sky130/custom/scripts/mismatch_params.py b/sky130/custom/scripts/mismatch_params.py
index b6616d7..c370c56 100755
--- a/sky130/custom/scripts/mismatch_params.py
+++ b/sky130/custom/scripts/mismatch_params.py
@@ -12,10 +12,21 @@
 
 mm_switch_param = 'MC_MM_SWITCH'
 
+options = []
+arguments = []
+for item in sys.argv[1:]:
+    if item.find('-', 0) == 0:
+        options.append(item[1:])
+    else:
+        arguments.append(item)
+
 walkpath = 'sky130A/libs.ref/sky130_fd_pr/spice'
 
-if len(sys.argv) > 1:
-    walkpath = sys.argv[1]
+if len(options) > 0:
+    if options[0] == 'ef_format':
+        walkpath = 'sky130A/libs.ref/spi/sky130_fd_pr'
+elif len(arguments) > 0:
+    walkpath = arguments[0]
 
 mismatch_params = []
 
diff --git a/sky130/custom/scripts/rename_models.py b/sky130/custom/scripts/rename_models.py
index 80e153c..b883be8 100755
--- a/sky130/custom/scripts/rename_models.py
+++ b/sky130/custom/scripts/rename_models.py
@@ -14,7 +14,12 @@
 import os
 import sys
 
-def filter(inname, outname):
+def filter(inname, outname, ef_format = True):
+
+    if ef_format:
+        libpath = 'spi/sky130_fd_pr/'
+    else:
+        libpath = 'sky130_fd_pr/spice/'
 
     # Read input
     try:
@@ -33,7 +38,7 @@
     for line in spilines:
 
         # Fix: Replace "../cells/<name>/" with "../../libs.ref/sky130_fd_pr/spice/"
-        fixedline = re.sub('\.\./cells/[^/]+/', '../../libs.ref/sky130_fd_pr/spice/', line)
+        fixedline = re.sub('\.\./cells/[^/]+/', '../../libs.ref/' + libpath, line)
 
         # This subsitution makes SPICE files compatible with Xyce without
         # breaking ngspice compatibility ('$' comments changed to ';')
@@ -82,11 +87,19 @@
 
     if len(arguments) > 0:
         infilename = arguments[0]
+    else:
+        print('Usage: rename_models.py <filename> [<outfilename>] [-ef_format]')
+        sys.exit(1)
 
     if len(arguments) > 1:
         outfilename = arguments[1]
     else:
         outfilename = None
 
-    result = filter(infilename, outfilename)
+    ef_format = False
+    if len(options) > 0:
+        if options[0] == 'ef_format':
+            ef_format = True
+
+    result = filter(infilename, outfilename, ef_format)
     sys.exit(result)