<commit_before># =============================================================================
# COPYRIGHT 2013 Brain Corporation.
# License under MIT license (see LICENSE file)
# =============================================================================


import subprocess
import tempfile
import shutil
import os


class GitAccessor(object):
    def access(self, repo_link, tag, path_to_file):
        '''
        Checksout a single file from git repo specified
        by 'repo_link' from branch 'tag' under path 'path_to_file'.
        @return: file content 
        '''
        tmp_dir = tempfile.mkdtemp()
        if tag is not None:
            subprocess.call(['git', 'clone', '-b', tag, repo_link, tmp_dir])
        else:
            subprocess.call(['git', 'clone', repo_link, tmp_dir])
        with open(os.path.join(tmp_dir, path_to_file)) as file:
            lines = file.readlines()
        shutil.rmtree(tmp_dir)
        return lines
<commit_msg>shallow git clone<commit_after># =============================================================================
# COPYRIGHT 2013 Brain Corporation.
# License under MIT license (see LICENSE file)
# =============================================================================


import subprocess
import tempfile
import shutil
import os


class GitAccessor(object):
    def access(self, repo_link, tag, path_to_file):
        '''
        Checksout a single file from git repo specified
        by 'repo_link' from branch 'tag' under path 'path_to_file'.
        @return: file content 
        '''
        tmp_dir = tempfile.mkdtemp()
        if tag is not None:
            subprocess.call(['git', 'clone', '--depth', '1', '-b', tag, repo_link, tmp_dir])
        else:
            subprocess.call(['git', 'clone', '--depth', '1', repo_link, tmp_dir])
        with open(os.path.join(tmp_dir, path_to_file)) as file:
            lines = file.readlines()
        shutil.rmtree(tmp_dir)
        return lines

{'fraction_non_alphanumeric': 0.25025432349949134, 'fraction_numerical': 0.00508646998982706, 'mean_word_length': 3.248380129589633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7463740', 'n_tokens_mistral': 536, 'n_tokens_neox': 503, 'n_words': 154}