def stripped_lines(lines, ignore_comments, ignore_docstrings, ignore_imports):
 strippedlines = []
 docstring = None
 for line in lines:
  line = line.strip()
  if ignore_docstrings:
   if ((not docstring) and (line.startswith('"""') or line.startswith("'''"))):
    docstring = line[:3]
    line = line[3:]
   if docstring:
    if line.endswith(docstring):
     docstring = None
    line = ''
  if ignore_imports:
   if (line.startswith('import ') or line.startswith('from ')):
    line = ''
  if ignore_comments:
   line = line.split('#', 1)[0].strip()
  strippedlines.append(line)
 return strippedlines

def stripped_lines ( lines , ignore_comments , ignore_docstrings , ignore_imports ) : strippedlines = [ ] docstring = None for line in lines : line = line . strip ( ) if ignore_docstrings : if ( ( not docstring ) and ( line . startswith ( '"""' ) or line . startswith ( "'''" ) ) ) : docstring = line [ : 3 ] line = line [ 3 : ] if docstring : if line . endswith ( docstring ) : docstring = None line = '' if ignore_imports : if ( line . startswith ( 'import ' ) or line . startswith ( 'from ' ) ) : line = '' if ignore_comments : line = line . split ( '#' , 1 ) [ 0 ] . strip ( ) strippedlines . append ( line ) return strippedlines
return lines with leading/trailing whitespace and any ignored code features removed .