added ray tracing
This commit is contained in:
20
extensions/fablabchemnitz/raytracing/desc_parser.py
Normal file
20
extensions/fablabchemnitz/raytracing/desc_parser.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import re
|
||||
|
||||
rgx_float = r"[-+]?(\d+([.,]\d*)?|[.,]\d+)([eE][-+]?\d+)?"
|
||||
rgx_name = "[a-z,_]*"
|
||||
optics_pattern = re.compile(
|
||||
f"optics *: *(?P<material>{rgx_name})(: *(?P<num>{rgx_float}))?",
|
||||
re.IGNORECASE | re.MULTILINE,
|
||||
)
|
||||
|
||||
|
||||
def get_optics_fields(string_: str):
|
||||
fields = re.finditer(optics_pattern, string_)
|
||||
return fields
|
||||
|
||||
|
||||
def clear_description(desc: str) -> str:
|
||||
"""Removes text corresponding to an optical property"""
|
||||
|
||||
new_desc = re.sub(optics_pattern, "", desc)
|
||||
return new_desc
|
||||
Reference in New Issue
Block a user