parameters: (self, names, defaultfmt="f%i", nbfields=None)
return_statement: return tuple(validatednames)
docstring: Validate a list of strings as field names for a structured array.
  
          Parameters
          ----------
          names : sequence of str
              Strings to be validated.
          defaultfmt : str, optional
              Default format string, used if validating a given string
              reduces its length to zero.
          nbfields : integer, optional
              Final number of validated names, used to expand or shrink the
              initial list of names.
  
          Returns
          -------
          validatednames : list of str
              The list of validated field names.
  
          Notes
          -----
          A `NameValidator` instance can be called directly, which is the
          same as calling `validate`. For examples, see `NameValidator`.
docstring_summary: Validate a list of strings as field names for a structured array.
docstring_tokens: Validate a list of strings as field names for a structured array .
function: def validate(self, names, defaultfmt="f%i", nbfields=None):
          """
          Validate a list of strings as field names for a structured array.
  
          Parameters
          ----------
          names : sequence of str
              Strings to be validated.
          defaultfmt : str, optional
              Default format string, used if validating a given string
              reduces its length to zero.
          nbfields : integer, optional
              Final number of validated names, used to expand or shrink the
              initial list of names.
  
          Returns
          -------
          validatednames : list of str
              The list of validated field names.
  
          Notes
          -----
          A `NameValidator` instance can be called directly, which is the
          same as calling `validate`. For examples, see `NameValidator`.
  
          """
          # Initial checks ..............
          if (names is None):
              if (nbfields is None):
                  return None
              names = []
          if isinstance(names, basestring):
              names = [names, ]
          if nbfields is not None:
              nbnames = len(names)
              if (nbnames < nbfields):
                  names = list(names) + [''] * (nbfields - nbnames)
              elif (nbnames > nbfields):
                  names = names[:nbfields]
          # Set some shortcuts ...........
          deletechars = self.deletechars
          excludelist = self.excludelist
          case_converter = self.case_converter
          replace_space = self.replace_space
          # Initializes some variables ...
          validatednames = []
          seen = dict()
          nbempty = 0
          #
          for item in names:
              item = case_converter(item).strip()
              if replace_space:
                  item = item.replace(' ', replace_space)
              item = ''.join([c for c in item if c not in deletechars])
              if item == '':
                  item = defaultfmt % nbempty
                  while item in names:
                      nbempty += 1
                      item = defaultfmt % nbempty
                  nbempty += 1
              elif item in excludelist:
                  item += '_'
              cnt = seen.get(item, 0)
              if cnt > 0:
                  validatednames.append(item + '_%d' % cnt)
              else:
                  validatednames.append(item)
              seen[item] = cnt + 1
          return tuple(validatednames)
function_tokens: def validate ( self , names , defaultfmt = "f%i" , nbfields = None ) : # Initial checks .............. if ( names is None ) : if ( nbfields is None ) : return None names = [ ] if isinstance ( names , basestring ) : names = [ names , ] if nbfields is not None : nbnames = len ( names ) if ( nbnames < nbfields ) : names = list ( names ) + [ '' ] * ( nbfields - nbnames ) elif ( nbnames > nbfields ) : names = names [ : nbfields ] # Set some shortcuts ........... deletechars = self . deletechars excludelist = self . excludelist case_converter = self . case_converter replace_space = self . replace_space # Initializes some variables ... validatednames = [ ] seen = dict ( ) nbempty = 0 # for item in names : item = case_converter ( item ) . strip ( ) if replace_space : item = item . replace ( ' ' , replace_space ) item = '' . join ( [ c for c in item if c not in deletechars ] ) if item == '' : item = defaultfmt % nbempty while item in names : nbempty += 1 item = defaultfmt % nbempty nbempty += 1 elif item in excludelist : item += '_' cnt = seen . get ( item , 0 ) if cnt > 0 : validatednames . append ( item + '_%d' % cnt ) else : validatednames . append ( item ) seen [ item ] = cnt + 1 return tuple ( validatednames )