From f04ea1d600e0cbc4281c9d9792db04a235359ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 24 Mar 2019 20:19:55 +0200 Subject: [PATCH] Refractive index database into C incomplete draft. Former-commit-id: fbfce8297f16400954fa3a1a1d24b980b67d0453 --- riinfo2c.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 riinfo2c.py diff --git a/riinfo2c.py b/riinfo2c.py new file mode 100644 index 0000000..e6a0010 --- /dev/null +++ b/riinfo2c.py @@ -0,0 +1,31 @@ +'''INCOMPLETE! This will read read the refractiveindex.info yaml files +and transforms the database into a C source.''' + +import re +import os +try: + from yaml import CLoader as Loader, CDumper as Dumper +except ImportError: + from yaml import Loader, Dumper + +# Right now, we can process only the 'tabulated nk' data +searchfor = '- type: tabulated nk' +searchfor = re.compile(searchfor) + +ridatadir = "/u/46/necadam1/unix/repo/refractiveindex.info-database/database/data" + +nktables = dict() + +def find_files_by_pattern (pattern, dir): + r = re.compile(pattern) + for parent, dnames, fnames in os.walk(ridatadir): + for fname in fnames: + filename = os.path.join(parent, fname) + if os.path.isfile(filename): + with open(filename) as f: + text = f.read() + if r.search(text): + yield ( + + +