docs: def upgrade_nrml(directory, dry_run, multipoint):
      """
      Upgrade all the NRML files contained in the given directory to the latest
      NRML version. Works by walking all subdirectories.
      WARNING: there is no downgrade!
      """
      for cwd, dirs, files in os.walk(directory):
          for f in files:
              path = os.path.join(cwd, f)
              if f.endswith('.xml'):
                  ip = iterparse(path, events=('start',))
                  next(ip)  # read node zero
                  try:
                      fulltag = next(ip)[1].tag  # tag of the first node
                      xmlns, tag = fulltag.split('}')
                  except Exception:  # not a NRML file
                      xmlns, tag = '', ''
                  if xmlns[1:] == NRML05:  # already upgraded
                      if 'sourceModel' in tag and multipoint:
                          print('upgrading to multiPointSources', path)
                          node0 = nrml.read(path)[0]
                          sourceconverter.update_source_model(node0, path)
                          with open(path, 'wb') as f:
                              nrml.write([node0], f, gml=True)
                  elif 'nrml/0.4' in xmlns and (
                          'vulnerability' in tag or 'fragility' in tag or
                          'sourceModel' in tag):
                      if not dry_run:
                          print('Upgrading', path)
                          try:
                              upgrade_file(path, multipoint)
                          except Exception as exc:
                              raise
                              print(exc)
                      else:
                          print('Not upgrading', path)