nodes: 0, module; 1, function_definition; 2, function_name:list_images; 3, parameters; 4, block; 5, identifier:img_dpath_; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, comment:#if not QUIET:; 13, comment:#    print(ignore_list); 14, if_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, comment:# Get all the files in a directory recursively; 21, expression_statement; 22, for_statement; 23, if_statement; 24, return_statement; 25, identifier:ignore_list; 26, list; 27, identifier:recursive; 28, False; 29, identifier:fullpath; 30, False; 31, identifier:full; 32, None; 33, identifier:sort; 34, True; 35, comment:r"""
      Returns a list of images in a directory. By default returns relative paths.
  
      TODO: rename to ls_images
      TODO: Change all instances of fullpath to full
  
      Args:
          img_dpath_ (str):
          ignore_list (list): (default = [])
          recursive (bool): (default = False)
          fullpath (bool): (default = False)
          full (None): (default = None)
          sort (bool): (default = True)
  
      Returns:
          list: gname_list
  
      CommandLine:
          python -m utool.util_path --exec-list_images
  
      Example:
          >>> # DISABLE_DOCTEST
          >>> from utool.util_path import *  # NOQA
          >>> img_dpath_ = '?'
          >>> ignore_list = []
          >>> recursive = False
          >>> fullpath = False
          >>> full = None
          >>> sort = True
          >>> gname_list = list_images(img_dpath_, ignore_list, recursive,
          >>>                          fullpath, full, sort)
          >>> result = ('gname_list = %s' % (str(gname_list),))
          >>> print(result)
      """; 36, comparison_operator:full is not None; 37, block; 38, assignment; 39, assignment; 40, assignment; 41, assignment; 42, call; 43, assignment; 44, pattern_list; 45, call; 46, block; 47, identifier:sort; 48, block; 49, identifier:gname_list; 50, identifier:full; 51, None; 52, expression_statement; 53, identifier:img_dpath_; 54, call; 55, identifier:img_dpath; 56, call; 57, identifier:ignore_set; 58, call; 59, identifier:gname_list_; 60, list; 61, identifier:assertpath; 62, argument_list; 63, identifier:true_imgpath; 64, call; 65, identifier:root; 66, identifier:dlist; 67, identifier:flist; 68, attribute; 69, argument_list; 70, expression_statement; 71, expression_statement; 72, comment:# Ignore directories; 73, if_statement; 74, for_statement; 75, if_statement; 76, expression_statement; 77, assignment; 78, attribute; 79, argument_list; 80, identifier:realpath; 81, argument_list; 82, identifier:set; 83, argument_list; 84, identifier:img_dpath; 85, identifier:truepath; 86, argument_list; 87, identifier:os; 88, identifier:walk; 89, identifier:true_imgpath; 90, assignment; 91, assignment; 92, call; 93, block; 94, identifier:fname; 95, call; 96, block; 97, not_operator; 98, block; 99, assignment; 100, identifier:fullpath; 101, boolean_operator; 102, identifier:util_str; 103, identifier:ensure_unicode; 104, identifier:img_dpath_; 105, identifier:img_dpath_; 106, identifier:ignore_list; 107, identifier:img_dpath; 108, identifier:root; 109, call; 110, identifier:rel_dpath; 111, call; 112, identifier:any; 113, argument_list; 114, continue_statement; 115, identifier:iter; 116, argument_list; 117, expression_statement; 118, expression_statement; 119, if_statement; 120, if_statement; 121, identifier:recursive; 122, break_statement; 123, identifier:gname_list; 124, call; 125, identifier:fullpath; 126, identifier:full; 127, attribute; 128, argument_list; 129, identifier:relpath; 130, argument_list; 131, list_comprehension; 132, identifier:flist; 133, assignment; 134, assignment; 135, call; 136, block; 137, call; 138, comment:# Ignore Files; 139, block; 140, identifier:sorted; 141, argument_list; 142, identifier:util_str; 143, identifier:ensure_unicode; 144, identifier:root; 145, identifier:root; 146, identifier:img_dpath; 147, comparison_operator:dname in ignore_set; 148, for_in_clause; 149, identifier:fname; 150, call; 151, identifier:gname; 152, call; 153, attribute; 154, argument_list; 155, expression_statement; 156, identifier:fpath_has_imgext; 157, argument_list; 158, if_statement; 159, if_statement; 160, identifier:gname_list_; 161, identifier:dname; 162, identifier:ignore_set; 163, identifier:dname; 164, call; 165, attribute; 166, argument_list; 167, attribute; 168, argument_list; 169, identifier:gname; 170, identifier:startswith; 171, string; 172, assignment; 173, identifier:gname; 174, comparison_operator:gname in ignore_set; 175, block; 176, identifier:fullpath; 177, block; 178, else_clause; 179, identifier:dirsplit; 180, argument_list; 181, identifier:util_str; 182, identifier:ensure_unicode; 183, identifier:fname; 184, call; 185, identifier:replace; 186, string; 187, string; 188, string_content:./; 189, identifier:gname; 190, subscript; 191, identifier:gname; 192, identifier:ignore_set; 193, continue_statement; 194, expression_statement; 195, expression_statement; 196, block; 197, identifier:rel_dpath; 198, identifier:join; 199, argument_list; 200, string_content; 201, string_content:/; 202, identifier:gname; 203, slice; 204, assignment; 205, call; 206, expression_statement; 207, identifier:rel_dpath; 208, identifier:fname; 209, escape_sequence:\\; 210, integer:2; 211, identifier:gpath; 212, call; 213, attribute; 214, argument_list; 215, call; 216, identifier:join; 217, argument_list; 218, identifier:gname_list_; 219, identifier:append; 220, identifier:gpath; 221, attribute; 222, argument_list; 223, identifier:img_dpath; 224, identifier:gname; 225, identifier:gname_list_; 226, identifier:append; 227, identifier:gname
code: def list_images(img_dpath_, ignore_list=[], recursive=False, fullpath=False,
                  full=None, sort=True):
      r"""
      Returns a list of images in a directory. By default returns relative paths.
  
      TODO: rename to ls_images
      TODO: Change all instances of fullpath to full
  
      Args:
          img_dpath_ (str):
          ignore_list (list): (default = [])
          recursive (bool): (default = False)
          fullpath (bool): (default = False)
          full (None): (default = None)
          sort (bool): (default = True)
  
      Returns:
          list: gname_list
  
      CommandLine:
          python -m utool.util_path --exec-list_images
  
      Example:
          >>> # DISABLE_DOCTEST
          >>> from utool.util_path import *  # NOQA
          >>> img_dpath_ = '?'
          >>> ignore_list = []
          >>> recursive = False
          >>> fullpath = False
          >>> full = None
          >>> sort = True
          >>> gname_list = list_images(img_dpath_, ignore_list, recursive,
          >>>                          fullpath, full, sort)
          >>> result = ('gname_list = %s' % (str(gname_list),))
          >>> print(result)
      """
      #if not QUIET:
      #    print(ignore_list)
      if full is not None:
          fullpath = fullpath or full
      img_dpath_ = util_str.ensure_unicode(img_dpath_)
      img_dpath = realpath(img_dpath_)
      ignore_set = set(ignore_list)
      gname_list_ = []
      assertpath(img_dpath)
      # Get all the files in a directory recursively
      true_imgpath = truepath(img_dpath)
      for root, dlist, flist in os.walk(true_imgpath):
          root = util_str.ensure_unicode(root)
          rel_dpath = relpath(root, img_dpath)
          # Ignore directories
          if any([dname in ignore_set for dname in dirsplit(rel_dpath)]):
              continue
          for fname in iter(flist):
              fname = util_str.ensure_unicode(fname)
              gname = join(rel_dpath, fname).replace('\\', '/')
              if gname.startswith('./'):
                  gname = gname[2:]
              if fpath_has_imgext(gname):
                  # Ignore Files
                  if gname in ignore_set:
                      continue
                  if fullpath:
                      gpath = join(img_dpath, gname)
                      gname_list_.append(gpath)
                  else:
                      gname_list_.append(gname)
          if not recursive:
              break
      if sort:
          gname_list = sorted(gname_list_)
      return gname_list