code: def metadata(f):
      
  
      if not isinstance(f, segyio.SegyFile):
          with segyio.open(f) as fl:
              return metadata(fl)
  
      spec = segyio.spec()
  
      spec.iline = f._il
      spec.xline = f._xl
      spec.samples = f.samples
      spec.format = f.format
  
      spec.ilines = f.ilines
      spec.xlines = f.xlines
      spec.offsets = f.offsets
      spec.sorting = f.sorting
  
      spec.tracecount = f.tracecount
  
      spec.ext_headers = f.ext_headers
      spec.endian = f.endian
  
      return spec
docs: Get survey structural properties and metadata
  
      Create a description object that, when passed to ``segyio.create()``, would
      create a new file with the same structure, dimensions, and metadata as
      ``f``.
  
      Takes an open segy file (created with segyio.open) or a file name.
  
      Parameters
      ----------
  
      f : str or segyio.SegyFile
  
      Returns
      -------
      spec : segyio.spec
  
      Notes
      -----
  
      .. versionadded:: 1.4