<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-
"""
    linescan.py - Effortlessly read single lines from a text file
    Created 2013 Triangle717
    <http://triangle717.wordpress.com/>

    linescan.py is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    linescan.py is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with linescan.py. If not, see <http://www.gnu.org/licenses/>.
"""

import locale
import sys

# Get open() function if this is not Python 3.0 or higher
if sys.version_info < (3,0):
    from io import open
# Block running on Python 2.5 or lower
if sys.version_info <= (2,5):
    sys.stdout.write('''\n\nYou are running Python {0}.
You must have Python 2.6 or newer to use linescan.py'''.format(sys.version[0:5]))
    exit()

def scanline(file, lineno, encode=None):
    '''Reads a single line from a file using a specified encoding.
    Falls back to default system encoding if None is specified.'''

    try:
        # Because Python starts line numbers at 0.
        lineno = lineno - 1

        if encode == None:
            # If no encoding is specified, use encoding returned by
            # locale.getpreferredencoding(False)
            encode = locale.getpreferredencoding(False)<commit_msg>Removed Python 2.5 block [ci skip]<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-
"""
    linescan.py - Effortlessly read single lines from a text file
    Created 2013 Triangle717
    <http://triangle717.wordpress.com/>

    linescan.py is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    linescan.py is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with linescan.py. If not, see <http://www.gnu.org/licenses/>.
"""

import locale
import sys

# Get open() function if this is not Python 3.0 or higher
if sys.version_info < (3,0):
    from io import open

def scanline(file, lineno, encode=None):
    '''Reads a single line from a file using a specified encoding.
    Falls back to default system encoding if None is specified.'''

    try:
        # Because Python starts line numbers at 0.
        lineno = lineno - 1

        if encode == None:
            # If no encoding is specified, use encoding returned by
            # locale.getpreferredencoding(False)
            encode = locale.getpreferredencoding(False)
{'fraction_non_alphanumeric': 0.07573366992742189, 'fraction_numerical': 0.014831177027453455, 'mean_word_length': 2.942786069651741, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '854569', 'n_tokens_mistral': 879, 'n_tokens_neox': 832, 'n_words': 402}