class_docstr: Defines a trait whose value must be a file path.
  
  >>> from nipype.interfaces.base import File, TraitedSpec, TraitError
  >>> class A(TraitedSpec):
  ...     foo = File()
  >>> a = A()
  >>> a.foo
  <undefined>
  
  >>> a.foo = '/some/made/out/path/to/file'
  >>> a.foo
  '/some/made/out/path/to/file'
  
  >>> class A(TraitedSpec):
  ...     foo = File(exists=False, resolve=True)
  >>> a = A(foo='idontexist.txt')
  >>> a.foo  # doctest: +ELLIPSIS
  '.../idontexist.txt'
  
  >>> class A(TraitedSpec):
  ...     foo = File(exists=True, resolve=True)
  >>> a = A()
  >>> a.foo = 'idontexist.txt'  # doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
  TraitError:
  
  >>> open('idoexist.txt', 'w').close()
  >>> a.foo = 'idoexist.txt'
  >>> a.foo  # doctest: +ELLIPSIS
  '.../idoexist.txt'
  
  >>> class A(TraitedSpec):
  ...     foo = File('idoexist.txt')
  >>> a = A()
  >>> a.foo
  <undefined>
  
  >>> class A(TraitedSpec):
  ...     foo = File('idoexist.txt', usedefault=True)
  >>> a = A()
  >>> a.foo
  'idoexist.txt'
  
  >>> class A(TraitedSpec):
  ...     foo = File(exists=True, resolve=True, extensions=['.txt', 'txt.gz'])
  >>> a = A()
  >>> a.foo = 'idoexist.badtxt'  # doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
  TraitError:
  
  >>> a.foo = 'idoexist.txt'
  >>> a.foo  # doctest: +ELLIPSIS
  '.../idoexist.txt'
  
  >>> class A(TraitedSpec):
  ...     foo = File(extensions=['.nii', '.nii.gz'])
  >>> a = A()
  >>> a.foo = 'badext.txt'  # doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
  TraitError:
  
  >>> class A(TraitedSpec):
  ...     foo = File(extensions=['.nii', '.nii.gz'])
  >>> a = A()
  >>> a.foo = 'goodext.nii'
  >>> a.foo
  'goodext.nii'
  
  >>> a = A()
  >>> a.foo = 'idontexist.000.nii'
  >>> a.foo  # doctest: +ELLIPSIS
  'idontexist.000.nii'
  
  >>> a = A()
  >>> a.foo = 'idontexist.000.nii.gz'
  >>> a.foo  # doctest: +ELLIPSIS
  'idontexist.000.nii.gz'
class_docstr_tok: ["Defines","a","trait","whose","value","must","be","a","file","path",".",">",">",">","from","nipype.interfaces.base","import","File",",","TraitedSpec",",","TraitError",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","<","undefined",">",">",">",">","a.foo","=","'\/some\/made\/out\/path\/to\/file'",">",">",">","a.foo","'\/some\/made\/out\/path\/to\/file'",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","exists=False",",","resolve=True",")",">",">",">","a","=","A","(","foo='idontexist.txt","'",")",">",">",">","a.foo","#","doctest",":","+ELLIPSIS","'","...","\/idontexist.txt'",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","exists=True",",","resolve=True",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'idontexist.txt","'","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","TraitError",":",">",">",">","open","(","'idoexist.txt","'",",","'","w","'",")",".close","(",")",">",">",">","a.foo","=","'idoexist.txt'",">",">",">","a.foo","#","doctest",":","+ELLIPSIS","'","...","\/idoexist.txt'",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","'idoexist.txt","'",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","<","undefined",">",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","'idoexist.txt","'",",","usedefault=True",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","'idoexist.txt'",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","exists=True",",","resolve=True",",","extensions=","[","'.txt","'",",","'txt.gz","'","]",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'idoexist.badtxt","'","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","TraitError",":",">",">",">","a.foo","=","'idoexist.txt'",">",">",">","a.foo","#","doctest",":","+ELLIPSIS","'","...","\/idoexist.txt'",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","extensions=","[","'.nii","'",",","'.nii.gz","'","]",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'badext.txt","'","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","TraitError",":",">",">",">","class","A","(","TraitedSpec",")",":","...","foo","=","File","(","extensions=","[","'.nii","'",",","'.nii.gz","'","]",")",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'goodext.nii'",">",">",">","a.foo","'goodext.nii'",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'idontexist.000.nii'",">",">",">","a.foo","#","doctest",":","+ELLIPSIS","'idontexist.000.nii'",">",">",">","a","=","A","(",")",">",">",">","a.foo","=","'idontexist.000.nii.gz'",">",">",">","a.foo","#","doctest",":","+ELLIPSIS","'idontexist.000.nii.gz","'"]
docstr: Create a File trait.
docstr_tok: ["Create","a","File","trait","."]
code: def __init__(
      self,
      value=NoDefaultSpecified,
      exists=False,
      resolve=False,
      allow_compressed=True,
      extensions=None,
      **metadata,
  ):
      """Create a File trait."""
      if extensions is not None:
          if isinstance(extensions, (bytes, str)):
              extensions = [extensions]
  
          if allow_compressed is False:
              extensions = list(set(extensions) - IMG_ZIP_FMT)
  
          self._exts = sorted(
              {
                  f".{ext}" if not ext.startswith(".") else ext
                  for ext in extensions
              }
          )
  
      super().__init__(
          value=value,
          exists=exists,
          resolve=resolve,
          extensions=self._exts,
          **metadata,
      )
  
imports: from collections.abc import Sequence
  from traits import __version__
  import traits.api
  from traits.api import TraitType, Unicode
  from traits.trait_base import _Undefined
  from pathlib import Path
  from ...utils.filemanip import path_resolve
label_desc: Use image node_id 1 to create a new File object from inherited base classes: BasePath with example: obj = File(value, exists, resolve, allow_compressed, extensions)