Uploaded image for project: 'Instrument control development'
  1. Instrument control development
  2. INSTRM-1466

use safe_load() to read a yaml file

    XMLWordPrintable

    Details

      Description

      I needed to edit a file in ics_cobraCharmer as follows to load a yaml file with PyYAML.

       
      — ics_cobraCharmer/python/ics/cobraCharmer/utils/orig.butler.py 2021-11-19 17:01:27.507710048 -1000
      +++ ics_cobraCharmer/python/ics/cobraCharmer/utils/butler.py 2021-11-19 17:03:45.186142846 -1000
      @@ -230,7 +230,7 @@
      """
      yamlPath = configPathForPfi(version=version, rootDir=rootDir)
      with open(yamlPath, mode='rt') as yamlFile:

      • config = yaml.load(yamlFile)
        + config = yaml.safe_load(yamlFile)

      return [c.strip() for c in config['modules']]
       

      I think this is due to an additional requirement for PyYAML 5.1+.  The above modification is the easist one, but there are various ways to specify a loader explicitly in their web site.

       

      https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

        Attachments

          Activity

            People

            • Assignee:
              cloomis cloomis
              Reporter:
              monodera monodera
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: