mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-05 11:00:10 +01:00
Add directory for ezfio_interface, first apparition of ezfio_generate_ocaml
This commit is contained in:
parent
04514b5b4f
commit
7db2751cdb
@ -83,7 +83,7 @@ def get_type_dict():
|
|||||||
|
|
||||||
qpackage_root = os.environ['QPACKAGE_ROOT']
|
qpackage_root = os.environ['QPACKAGE_ROOT']
|
||||||
|
|
||||||
fancy_type_pickle = qpackage_root + "/scripts/fancy_type.p"
|
fancy_type_pickle = qpackage_root + "/scripts/ezfio_interface/fancy_type.p"
|
||||||
|
|
||||||
if fancy_type_pickle in listdir(os.getcwd()):
|
if fancy_type_pickle in listdir(os.getcwd()):
|
||||||
fancy_type = pickle.load(open(fancy_type_pickle, "rb"))
|
fancy_type = pickle.load(open(fancy_type_pickle, "rb"))
|
||||||
@ -416,36 +416,14 @@ def save_ezfio_config(module_lower, str_ezfio_config):
|
|||||||
|
|
||||||
def create_ocaml_check(dict_ezfio_cfg):
|
def create_ocaml_check(dict_ezfio_cfg):
|
||||||
|
|
||||||
# ~#~#~#~#~#~#~#~# #
|
|
||||||
# F u n c t i o n #
|
|
||||||
# ~#~#~#~#~#~#~#~# #
|
|
||||||
|
|
||||||
def create_read(d_format):
|
|
||||||
|
|
||||||
template = """
|
|
||||||
(* Read snippet for {ezfio_name} *)
|
|
||||||
let read_{ezfio_name} () =
|
|
||||||
if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then
|
|
||||||
get_default "{ezfio_name}"
|
|
||||||
|> {Ocaml_type}.of_string
|
|
||||||
|> Ezfio.set_{ezfio_dir}_{ezfio_name}
|
|
||||||
;
|
|
||||||
Ezfio.get_{ezfio_dir}_{ezfio_name} ()
|
|
||||||
"""
|
|
||||||
fancy_type = d_format["type"]
|
|
||||||
if d_format["type"].fancy:
|
|
||||||
template += " |> {0}.of_{1}".format(fancy_type.fancy,
|
|
||||||
fancy_type.ocaml)
|
|
||||||
|
|
||||||
template += """
|
|
||||||
;;
|
|
||||||
"""
|
|
||||||
return template.strip().format(**d_format)
|
|
||||||
|
|
||||||
# ~#~#~#~#~#~#~#~# #
|
# ~#~#~#~#~#~#~#~# #
|
||||||
# C r e a t i o n #
|
# C r e a t i o n #
|
||||||
# ~#~#~#~#~#~#~#~# #
|
# ~#~#~#~#~#~#~#~# #
|
||||||
|
|
||||||
|
from ezfio_generate_ocaml import EZFIO_ocaml
|
||||||
|
|
||||||
|
e = EZFIO_ocaml()
|
||||||
|
|
||||||
for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()):
|
for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()):
|
||||||
|
|
||||||
ocaml_type = d_val["type"].ocaml.capitalize()
|
ocaml_type = d_val["type"].ocaml.capitalize()
|
||||||
@ -454,10 +432,9 @@ def create_ocaml_check(dict_ezfio_cfg):
|
|||||||
|
|
||||||
d = {"ezfio_dir": ezfio_dir,
|
d = {"ezfio_dir": ezfio_dir,
|
||||||
"ezfio_name": ezfio_name,
|
"ezfio_name": ezfio_name,
|
||||||
"type": d_val["type"],
|
"type": d_val["type"]}
|
||||||
"Ocaml_type": ocaml_type}
|
|
||||||
|
|
||||||
template = create_read(d)
|
template = e.create_read(**d)
|
||||||
|
|
||||||
print template
|
print template
|
||||||
|
|
59
scripts/ezfio_interface/ezfio_generate_ocaml.py
Executable file
59
scripts/ezfio_interface/ezfio_generate_ocaml.py
Executable file
@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class EZFIO_ocaml(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def create_read(self, **param):
|
||||||
|
'''
|
||||||
|
Take an imput a list of keyword argument
|
||||||
|
ezfio_dir = str
|
||||||
|
ezfio_name = str
|
||||||
|
type = Named_tuple(fancy_type, ocaml_type, fortrant_type)
|
||||||
|
|
||||||
|
Return the read template
|
||||||
|
'''
|
||||||
|
|
||||||
|
l_name_need = "ezfio_dir ezfio_name type".split()
|
||||||
|
|
||||||
|
for key in l_name_need:
|
||||||
|
if key not in param:
|
||||||
|
print "You need to provide {0} at keyword argument".format(key)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
|
||||||
|
# C r e a t e _ t e m pl a t e #
|
||||||
|
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
|
||||||
|
|
||||||
|
l_template = ['(* Read snippet for {ezfio_name} *)',
|
||||||
|
'let read_{ezfio_name} () =',
|
||||||
|
' if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then',
|
||||||
|
' get_default "{ezfio_name}"',
|
||||||
|
' |> {Ocaml_type}.of_string',
|
||||||
|
' |> Ezfio.set_{ezfio_dir}_{ezfio_name}',
|
||||||
|
' ;',
|
||||||
|
' Ezfio.get_{ezfio_dir}_{ezfio_name} ()']
|
||||||
|
|
||||||
|
if param["type"].fancy:
|
||||||
|
l_template += [" |> {fancy_type}.of_{Ocaml_type}"]
|
||||||
|
|
||||||
|
l_template += [";;;"]
|
||||||
|
|
||||||
|
template = "\n ".join(l_template)
|
||||||
|
|
||||||
|
# ~#~#~#~#~#~ #
|
||||||
|
# R e n d e r #
|
||||||
|
# ~#~#~#~#~#~ #
|
||||||
|
|
||||||
|
param["Ocaml_type"] = param["type"].ocaml.capitalize()
|
||||||
|
param["fancy_type"] = param["type"].fancy
|
||||||
|
template_rendered = template.format(**param)
|
||||||
|
|
||||||
|
# ~#~#~#~#~#~ #
|
||||||
|
# R e t u r n #
|
||||||
|
# ~#~#~#~#~#~ #
|
||||||
|
return template_rendered
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__author__ = "Anthony Scemama and Applencourt for the amazing PEP8"
|
__author__ = "Applencourt PEP8"
|
||||||
__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)"
|
__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)"
|
||||||
|
|
||||||
"""
|
"""
|
@ -9,7 +9,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-"
|
|||||||
for dir in ${QPACKAGE_ROOT}/src/*/
|
for dir in ${QPACKAGE_ROOT}/src/*/
|
||||||
do
|
do
|
||||||
cd $dir || exit -1
|
cd $dir || exit -1
|
||||||
${QPACKAGE_ROOT}/scripts/ezfio_interface.py
|
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py
|
||||||
done
|
done
|
||||||
|
|
||||||
# For old-style directories. Will be removed some day...
|
# For old-style directories. Will be removed some day...
|
||||||
|
@ -65,5 +65,4 @@ fi
|
|||||||
${QPACKAGE_ROOT}/scripts/create_Makefile_depend.sh
|
${QPACKAGE_ROOT}/scripts/create_Makefile_depend.sh
|
||||||
|
|
||||||
# Update EZFIO interface
|
# Update EZFIO interface
|
||||||
${QPACKAGE_ROOT}/scripts/ezfio_interface.py
|
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ export QPACKAGE_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P )
|
|||||||
export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH}
|
export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH}
|
||||||
export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH}
|
export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH}
|
||||||
export C_INCLUDE_PATH="\${QPACKAGE_ROOT}"/include:\${C_INCLUDE_PATH}
|
export C_INCLUDE_PATH="\${QPACKAGE_ROOT}"/include:\${C_INCLUDE_PATH}
|
||||||
export PYTHONPATH=\${PYTHONPATH}:"\${QPACKAGE_ROOT}"/scripts
|
export PYTHONPATH=\${PYTHONPATH}:"\${QPACKAGE_ROOT}"/scripts:"\${QPACKAGE_ROOT}"/scripts/ezfio_interface
|
||||||
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/scripts
|
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/scripts:"\${QPACKAGE_ROOT}"/scripts/ezfio_interface
|
||||||
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/bin
|
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/bin
|
||||||
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ocaml
|
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ocaml
|
||||||
source "\${QPACKAGE_ROOT}"/bin/irpman &> /dev/null
|
source "\${QPACKAGE_ROOT}"/bin/irpman &> /dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user