MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / write

Method write

Web/scripts/CPWeb/SphinxTools.py:563–623  ·  view source on GitHub ↗
(self, path)

Source from the content-addressed store, hash-verified

561 self.fluid = fluid
562
563 def write(self, path):
564
565 # Write CSV table data for fluid information
566 ITG = FluidInfoTableGenerator(self.fluid)
567 ITG.write(path)
568
569 del_old = CP.get_config_string(CP.LIST_STRING_DELIMITER)
570
571 CP.set_config_string(CP.LIST_STRING_DELIMITER, '|')
572 try:
573 aliases = ', '.join(['``' + a.strip() + '``' for a in CoolProp.CoolProp.get_fluid_param_string(self.fluid, 'aliases').strip().split('|') if a])
574 finally:
575 CP.set_config_string(CP.LIST_STRING_DELIMITER, del_old)
576
577 if aliases:
578 aliases = 'Aliases\n=======\n\n' + aliases + '\n'
579
580 references = generate_bibtex_string(self.fluid)
581 if references:
582 references = 'References\n==========\n' + references + '\n'
583
584 # Generate interactive 3-D molecule viewer (py3Dmol via PubChem SDF)
585 molecule_viewer_rst = ''
586 inchikey = CoolProp.CoolProp.get_fluid_param_string(self.fluid, "INCHIKEY")
587 if inchikey and _INCHIKEY_RE.match(inchikey):
588 sdf_cache = os.path.join(path, 'molecule_sdf')
589 sdf_data, is_3d = fetch_pubchem_sdf(inchikey, sdf_cache)
590 if sdf_data:
591 molecule_viewer_rst = generate_3dmol_rst(self.fluid, sdf_data, is_3d)
592 bucket = 'has_3d' if is_3d else 'has_2d_only'
593 GEOMETRY_STATUS[bucket].append(self.fluid)
594 else:
595 GEOMETRY_STATUS['pubchem_missing'].append((self.fluid, inchikey))
596 else:
597 GEOMETRY_STATUS['no_inchikey'].append(self.fluid)
598
599 # The REFPROP consistency section is opt-in: it only appears in the fluid
600 # page when COOLPROP_CONSISTENCY_INCLUDE_REFPROP is set, so a default
601 # (HEOS-only) build does not carry an empty "not generated" stub section.
602 include_refprop = os.environ.get('COOLPROP_CONSISTENCY_INCLUDE_REFPROP', '').lower() in ('1', 'true', 'yes')
603 if include_refprop:
604 refprop_consistency_rst = (
605 'REFPROP Consistency Plots\n'
606 '=========================\n\n'
607 '.. include:: Consistencyplots_REFPROP/{fluid:s}-report.rst\n\n'
608 ).format(fluid=self.fluid)
609 else:
610 refprop_consistency_rst = ''
611
612 # Write RST file for fluid
613 out = fluid_template.format(aliases=aliases,
614 fluid=self.fluid,
615 fluid_stars='*' * len(self.fluid),
616 references=references,
617 molecule_viewer_rst=molecule_viewer_rst,
618 refprop_consistency_rst=refprop_consistency_rst
619 )
620

Calls 8

writeMethod · 0.95
generate_bibtex_stringFunction · 0.85
fetch_pubchem_sdfFunction · 0.85
generate_3dmol_rstFunction · 0.85
matchMethod · 0.80
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected