#Package configuration information

import json
import os.path
import sys

import QGL.config_location

# Load the configuration from the json file
# and populate the global configuration dictionary

QGLCfgFile = QGL.config_location.get_config_path()
print('Note: using QGLCfgFile [%s]' % QGLCfgFile)

if not os.path.isfile(QGLCfgFile):
    rootFolder = os.path.dirname(os.path.abspath(__file__))
    rootFolder = rootFolder.replace('\\', '/')  # use unix-like convention

    # build a config file from the template
    templateFile = os.path.join(rootFolder, 'config.example.json')
    ifid = open(templateFile, 'r')
    ofid = open(QGLCfgFile, 'w')
    for line in ifid:
        ofid.write(line.replace('/my/path/to', rootFolder))
    ifid.close()
    ofid.close()

    print('Note: created QGLCfgFile using template [%s]' % templateFile)

with open(QGLCfgFile, 'r') as f:
    QGLCfg = json.load(f)

#pull out the variables
#abspath allows the use of relative file names in the config file
AWGDir = os.path.abspath(QGLCfg['AWGDir'])
channelLibFile = os.path.abspath(QGLCfg['ChannelLibraryFile'])

# plotting options
plotBackground = QGLCfg.get('PlotBackground', '#EAEAF2')
gridColor = QGLCfg.get('GridColor', None)

# select pulse library (standard or all90)
pulse_primitives_lib = QGLCfg.get('PulsePrimitivesLibrary', 'standard')

# select a CNOT implementation (a name of a Pulse function that implements
# CNOT in your gate set, e.g. CNOT_simple or CNOT_CR)
cnot_implementation = QGLCfg.get('cnot_implementation', 'CNOT_simple')

@@ -75,20 +75,20 @@
 %0Aimport 
-QGL.
+qgl_
 config_l
@@ -89,21 +89,16 @@
 nfig_loc
-ation
 %0A%0A# Load
@@ -204,12 +204,12 @@
 e = 
-QGL.
+qgl_
 conf
@@ -214,21 +214,16 @@
 nfig_loc
-ation
 .get_con

move QGL.config_location to qgl_config_loc