Ejemplo n.º 1
0
 def __init__(self, atom_number, prop_name, value_string, units_string, interval, notes):
     self.atom_number = atom_number
     self.property_name = strip_quotes(prop_name)
     #----------------------------------------#
     self.value = self._get_missing_status(value_string)
     if self.value is None:
         self.value = self._parse_value_string(value_string)
     #----------------------------------------#
     self.units = self._get_missing_status(units_string)
     if self.units is None:
         self.units = strip_quotes(units_string)
     #----------------------------------------#
     self.interval = self._get_missing_status(interval)
     if self.interval is None:
         self.interval = self._parse_interval(interval)
     #----------------------------------------#
     self.notes = self._get_missing_status(notes)
     if self.notes is None:
         self.notes = strip_quotes(notes)
Ejemplo n.º 2
0
 def __init__(self, atom_number, prop_name, value_string, units_string,
              interval, notes):
     self.atom_number = atom_number
     self.property_name = strip_quotes(prop_name)
     #----------------------------------------#
     self.value = self._get_missing_status(value_string)
     if self.value is None:
         self.value = self._parse_value_string(value_string)
     #----------------------------------------#
     self.units = self._get_missing_status(units_string)
     if self.units is None:
         self.units = strip_quotes(units_string)
     #----------------------------------------#
     self.interval = self._get_missing_status(interval)
     if self.interval is None:
         self.interval = self._parse_interval(interval)
     #----------------------------------------#
     self.notes = self._get_missing_status(notes)
     if self.notes is None:
         self.notes = strip_quotes(notes)
Ejemplo n.º 3
0
 def _parse_value_string(value_string):
     m = re.match(r'(-?\d+\.?\d*)(?:`(-?\d+?\.?\d*))?(?:\*^(-?\d+\.?\d*))?', value_string)
     if m:
         num = m.group(1)
         if m.groups()[2] is not None:
             float_expon = float(m.group(3))
             expon = int(round(float_expon))
             value_string = num + "e{}".format(expon)
         else:
             value_string = num
         return value_string
     elif value_string[0] == "{" and value_string[-1] == "}":
         if len(value_string) == 2:
             return []
         else:
             return [MathematicaElementDatum._parse_value_string(v) for v in re.split("\s*,\s*", value_string[1:-1])]
     else:
         return strip_quotes(value_string)
Ejemplo n.º 4
0
 def _parse_value_string(value_string):
     m = re.match(r'(-?\d+\.?\d*)(?:`(-?\d+?\.?\d*))?(?:\*^(-?\d+\.?\d*))?',
                  value_string)
     if m:
         num = m.group(1)
         if m.groups()[2] is not None:
             float_expon = float(m.group(3))
             expon = int(round(float_expon))
             value_string = num + "e{}".format(expon)
         else:
             value_string = num
         return value_string
     elif value_string[0] == "{" and value_string[-1] == "}":
         if len(value_string) == 2:
             return []
         else:
             return [
                 MathematicaElementDatum._parse_value_string(v)
                 for v in re.split("\s*,\s*", value_string[1:-1])
             ]
     else:
         return strip_quotes(value_string)