Return a list of namedtuple `Line` for each line of code found in the
        source file with the given `filename`.
335771
def file_source(self, filename):
        
        lines = []
        try:
            with self.filesystem.open(filename) as f:
                line_statuses = dict(self.line_statuses(filename))
                for lineno, source in enumerate(f, start=1):
                    line_status = line_statuses.get(lineno)
                    line = Line(lineno, source, line_status, None)
                    lines.append(line)

        except self.filesystem.FileNotFound as file_not_found:
            lines.append(
                Line(0, '%s not found' % file_not_found.path, None, None)
            )

        return lines
254524
def lines(input):
    """"""
    for raw_line in input:
        line = raw_line.strip()
        if line and not line.startswith('#'):
            yield strip_comments(line)
408390
public static List<String> readLines(String filename) {
    List<String> lines = Lists.newArrayList();
    try {
      BufferedReader in = new BufferedReader(new FileReader(filename));
      String line;
      while ((line = in.readLine()) != null) {
        // Ignore blank lines.
        if (line.trim().length() > 0) {
          lines.add(line);
        }
      }
      in.close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return lines;
  }
1098267
def lines(self, code):
        """"""
        if isinstance(code, str):
            fix_indentation = self.fix_indentation
            if fix_indentation:
                code = fix_indentation(code)
            return self.append(code)
        else:
            return self.append(code)
1218404
def get_stripped_file_lines(filename):
    
    try:
        lines = open(filename).readlines()
    except FileNotFoundError:
        fatal("Could not open file: {!r}".format(filename))

    return [line.strip() for line in lines]
1241776
def find_lines_with(cls, lines, what):
        
        result = []
        for line in lines:
            if what in line:
                result = result + [line]
        return result
1298035
def iter_lines(file_like: Iterable[str]) -> Generator[str, None, None]:
    
    for line in file_like:
        line = line.rstrip('\r\n')
        if line:
            yield line
761336
def get_all_lines(self):
        """"""
        output = []
        line = []
        lineno = 1
        for char in self.string:
            line.append(char)
            if char == '\n':
                output.append(SourceLine(''.join(line), lineno))
                line = []
                lineno += 1
        if line:
            output.append(SourceLine(''.join(line), lineno))

        return output
1115244
def get_lines_from_file(filepath, encoding="UTF-8"):
    """"""
    try:
        fd = codecs.open(filepath, 'r', encoding)
        lines = fd.readlines()
    except UnicodeDecodeError:
        # Fall back to 'ISO-8859-1'
        fd = codecs.open(filepath, 'r', 'ISO-8859-1')
        lines = fd.readlines()
    finally:
        fd.close()
    return lines
745100
def read_file(filename):
        
        lines = []
        with open(filename) as f:
            for line in f:
                if len(line.strip()) != 0:
                    lines.append(line.strip())
        return lines
921603
def identify_names(filename):
    """"""
    node, _ = parse_source_file(filename)
    if node is None:
        return {}

    # Get matches from the code (AST)
    finder = NameFinder()
    finder.visit(node)
    names = list(finder.get_mapping())
    names += extract_object_names_from_docs(filename)

    example_code_obj = collections.OrderedDict()
    for name, full_name in names:
        if name in example_code_obj:
            continue  # if someone puts it in the docstring and code
        # name is as written in file (e.g. np.asarray)
        # full_name includes resolved import path (e.g. numpy.asarray)
        splitted = full_name.rsplit('.', 1)
        if len(splitted) == 1:
            # module without attribute. This is not useful for
            # backreferences
            continue

        module, attribute = splitted
        # get shortened module name
        module_short = get_short_module_name(module, attribute)
        cobj = {'name': attribute, 'module': module,
                'module_short': module_short}
        example_code_obj[name] = cobj
    return example_code_obj
827234
def scan_for_line_warnings(line, filename)
      warnings = scan_for_warnings(using & LineWarning.all_warnings, line, filename)
      filtered_warnings_from_line(line, warnings)
    end
913592
public static List<String> linesFromFile(String filename,String encoding) {
    try {
      List<String> lines = new ArrayList<String>();
      BufferedReader in = new BufferedReader(new EncodingFileReader(filename,encoding));
      String line;
      while ((line = in.readLine()) != null) {
        lines.add(line);
      }
      in.close();
      return lines;
    }
    catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
93232
def sourcelines(self):
        """"""
        # get sourcecode from loader or file
        source = None
        if self.loader is not None:
            try:
                if hasattr(self.loader, 'get_source'):
                    source = self.loader.get_source(self.module)
                elif hasattr(self.loader, 'get_source_by_code'):
                    source = self.loader.get_source_by_code(self.code)
            except Exception:
                # we munch the exception so that we don't cause troubles
                # if the loader is broken.
                pass

        if source is None:
            try:
                f = codecs.open(self.filename, 'r', 'utf-8')
            except IOError:
                return []
            try:
                source = f.read()
            finally:
                f.close()

        return source.splitlines()
662064
def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
        
        source = None
        if loader is not None and hasattr(loader, "get_source"):
            try:
                source = loader.get_source(module_name)
            except ImportError:
                pass
            if source is not None:
                source = source.splitlines()
        if source is None:
            try:
                with open(filename, 'rb') as fp:
                    source = fp.read().splitlines()
            except (OSError, IOError):
                pass
        if source is None:
            return None, [], None, []

        # If we just read the source from a file, or if the loader did not
        # apply tokenize.detect_encoding to decode the source into a Unicode
        # string, then we should do that ourselves.
        if isinstance(source[0], six.binary_type):
            encoding = 'ascii'
            for line in source[:2]:
                # File coding may be specified. Match pattern from PEP-263
                # (http://www.python.org/dev/peps/pep-0263/)
                match = re.search(br'coding[:=]\s*([-\w.]+)', line)
                if match:
                    encoding = match.group(1).decode('ascii')
                    break
            source = [six.text_type(sline, encoding, 'replace') for sline in source]

        lower_bound = max(0, lineno - context_lines)
        upper_bound = lineno + context_lines

        pre_context = source[lower_bound:lineno]
        context_line = source[lineno]
        post_context = source[lineno + 1:upper_bound]

        return lower_bound, pre_context, context_line, post_context
155165
def do_list(self, line):
        '''
        
        '''
        repo_names = self.network.repo_names
        print('Known repos:')
        print('    ' + '\n    '.join(repo_names))
992519
def parse_comments_for_file(filename):
    
    return [parse_comment(strip_stars(comment), next_line)
            for comment, next_line in get_doc_comments(read_file(filename))]