Commit ba224692 authored by Remi Perenon's avatar Remi Perenon
Browse files

Implementing error messages reading

parent 1139a575
Pipeline #8890 failed with stages
in 29 minutes and 33 seconds
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
import CFML_api
while True:
CFML_api.ErrorMessages.ERR_Symm
CFML_api.ErrorMessages.ERR_Symm_Mess
CFML_api.ErrorMessages.ERR_Crys
CFML_api.ErrorMessages.ERR_Crys_Mess
CFML_api.ErrorMessages.ERR_Atmd
CFML_api.ErrorMessages.ERR_Atmd_Mess
CFML_api.ErrorMessages.ERR_String
CFML_api.ErrorMessages.ERR_String_Mess
CFML_api.ErrorMessages.ERR_DiffPatt
CFML_api.ErrorMessages.ERR_DiffPatt_Mess
CFML_api.ErrorMessages.ERR_Form
CFML_api.ErrorMessages.ERR_Form_Mess
CFML_api.ErrorMessages.ERR_Refl
CFML_api.ErrorMessages.ERR_Refl_Mess
CFML_api.ErrorMessages.ERR_MagSym
CFML_api.ErrorMessages.ERR_MagSym_Mess
CFML_api.ErrorMessages.ERR_SFac
CFML_api.ErrorMessages.ERR_SFac_Mess
CFML_api.ErrorMessages.ERR_MSFac
CFML_api.ErrorMessages.ERR_MSFac_Mess
\ No newline at end of file
class classproperty(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, owner):
return self.f(owner)
import CFML_api.crysfml_api
class ErrorMessages():
@classproperty
def ERR_Symm(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Symm"]
@classproperty
def ERR_Symm_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Symm_Mess"]
@classproperty
def ERR_Crys(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Crys"]
@classproperty
def ERR_Crys_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Crys_Mess"]
@classproperty
def ERR_Atmd(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Atmd"]
@classproperty
def ERR_Atmd_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Atmd_Mess"]
@classproperty
def ERR_String(cls):
return CFML_api.crysfml_api.error_messages()["ERR_String"]
@classproperty
def ERR_String_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_String_Mess"]
@classproperty
def ERR_DiffPatt(cls):
return CFML_api.crysfml_api.error_messages()["ERR_DiffPatt"]
@classproperty
def ERR_DiffPatt_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_DiffPatt_Mess"]
@classproperty
def ERR_Form(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Form"]
@classproperty
def ERR_Form_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Form_Mess"]
@classproperty
def ERR_Refl(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Refl"]
@classproperty
def ERR_Refl_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_Refl_Mess"]
@classproperty
def ERR_MagSym(cls):
return CFML_api.crysfml_api.error_messages()["ERR_MagSym"]
@classproperty
def ERR_MagSym_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_MagSym_Mess"]
@classproperty
def ERR_SFac(cls):
return CFML_api.crysfml_api.error_messages()["ERR_SFac"]
@classproperty
def ERR_SFac_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_SFac_Mess"]
@classproperty
def ERR_MSFac(cls):
return CFML_api.crysfml_api.error_messages()["ERR_MSFac"]
@classproperty
def ERR_MSFac_Mess(cls):
return CFML_api.crysfml_api.error_messages()["ERR_MSFac_Mess"]
......@@ -15,6 +15,7 @@ add_library(${LIBRARY_NAME} SHARED
Extensions/API_Crystallographic_Symmetry.f90
Extensions/API_Crystal_Metrics.f90
Extensions/API_Diffraction_Patterns.f90
Extensions/API_Error_Messages.f90
Extensions/API_IO_Formats.f90
Extensions/API_Reflections_Utilities.f90
Extensions/API_Structure_Factors.f90
......
module API_Error_Messages
use forpy_mod
use, intrinsic :: iso_c_binding
use, intrinsic :: iso_fortran_env
use CFML_Crystallographic_Symmetry, only: ERR_Symm, ERR_Symm_Mess
use CFML_Crystal_Metrics, only: ERR_Crys, ERR_Crys_Mess
use CFML_Atom_TypeDef, only: ERR_Atmd, ERR_Atmd_Mess
use CFML_String_Utilities, only: ERR_String, ERR_String_Mess
use CFML_Diffraction_Patterns, only: ERR_DiffPatt, ERR_DiffPatt_Mess
use CFML_IO_Formats, only: ERR_Form, ERR_Form_Mess
use CFML_Reflections_Utilities, only: ERR_Refl, ERR_Refl_Mess
use CFML_Magnetic_Symmetry, only: ERR_MagSym, ERR_MagSym_Mess
use CFML_Structure_Factors, only: ERR_SFac, ERR_SFac_Mess
use CFML_Magnetic_Structure_Factors, only: ERR_MSFac, ERR_MSFac_Mess
implicit none
contains
function error_messages(self_ptr, args_ptr) result(r) bind(c)
type(c_ptr), value :: self_ptr
type(c_ptr), value :: args_ptr
type(c_ptr) :: r
type(tuple) :: args
type(dict) :: retval
integer :: num_args
integer :: ierror
r = C_NULL_PTR
call unsafe_cast_from_c_ptr(args, args_ptr)
ierror = args%len(num_args)
if (num_args /= 0) then
call raise_exception(TypeError, "get_item expects exactly 0 arguments")
call args%destroy
return
endif
ierror = dict_create(retval)
ierror = retval%setitem("ERR_Symm", ERR_Symm)
ierror = retval%setitem("ERR_Symm_Mess", ERR_Symm_Mess)
ierror = retval%setitem("ERR_Crys", ERR_Crys)
ierror = retval%setitem("ERR_Crys_Mess", ERR_Crys_Mess)
ierror = retval%setitem("ERR_Atmd", ERR_Atmd)
ierror = retval%setitem("ERR_Atmd_Mess", ERR_Atmd_Mess)
ierror = retval%setitem("ERR_String", ERR_String)
ierror = retval%setitem("ERR_String_Mess", ERR_String_Mess)
ierror = retval%setitem("ERR_DiffPatt", ERR_DiffPatt)
ierror = retval%setitem("ERR_DiffPatt_Mess", ERR_DiffPatt_Mess)
ierror = retval%setitem("ERR_Form", ERR_Form)
ierror = retval%setitem("ERR_Form_Mess", ERR_Form_Mess)
ierror = retval%setitem("ERR_Refl", ERR_Refl)
ierror = retval%setitem("ERR_Refl_Mess", ERR_Refl_Mess)
ierror = retval%setitem("ERR_MagSym", ERR_MagSym)
ierror = retval%setitem("ERR_MagSym_Mess", ERR_MagSym_Mess)
ierror = retval%setitem("ERR_SFac", ERR_SFac)
ierror = retval%setitem("ERR_SFac_Mess", ERR_SFac_Mess)
ierror = retval%setitem("ERR_MSFac", ERR_MSFac)
ierror = retval%setitem("ERR_MSFac_Mess", ERR_MSFac_Mess)
r = retval%get_c_ptr()
call args%destroy
end function error_messages
end module API_Error_Messages
......@@ -17,6 +17,8 @@ module API_init
use, intrinsic :: iso_c_binding
use, intrinsic :: iso_fortran_env
use API_Error_Messages, only: error_messages
use API_Crystallographic_Symmetry,only: &
crystallographic_symmetry_set_spacegroup, &
crystallographic_symmetry_del_spacegroup, &
......@@ -168,7 +170,16 @@ CONTAINS
integer :: ierror
ierror = forpy_initialize()
call method_table%init(111)
call method_table%init(112)
!--------------------------
! Error Messages (1)
!--------------------------
call method_table%add_method("error_messages", & ! method name
"gets CrysFML error messages", & !doc-string
METH_VARARGS, & ! this method takes arguments but no keyword arguments
c_funloc(error_messages)) ! address of Fortran function to add
!--------------------------
! Diffraction Patterns (3)
!--------------------------
......
......@@ -28,5 +28,6 @@ from CFML_api.API_IO_Formats import CIFFile
from CFML_api.API_Reflections_Utilities import ReflectionList
from CFML_api.PowderPatternSimulation import PowderPatternSimulationConditions
from CFML_api.PowderPatternSimulation import PowderPatternSimulationSource
from CFML_api.API_Error_Messages import ErrorMessages
API_version = 0.2
API_version = 0.2
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment