<commit_before>"""
Copyright 2016 <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import subprocess

from .virtual_dirs import TemplateDir, TemplateRoot
from .virtual_files import TemplateFile

templates_dir = os.path.expanduser(
    os.path.join("~", ".fossil")
)


class FileSystemReader(object):
    def __init__(self, directory, skip=[]):
        self.path = os.path.abspath(directory)
        self.skip = skip

    def get_template(self):
        templates = self._get_children(self.path)
        return TemplateRoot(templates)

    def _get_children(self, path):
        templates = []
        for item in os.listdir(path):
            if item in self.skip:
                continue
            full_path = os.path.join(path, item)
            if os.path.isfile(full_path):
                content = open(full_path).read()
                template = TemplateFile(item, content)
                templates.append(template)
            else:
                children = self._get_children(full_path)
                template = TemplateDir(item, children)
                templates.append(template)
        return templates


class GitRepoReader(FileSystemReader):
    def __init__(self, repo_url):
        self.repo_url = repo_url
        self.repo_name = repo_url.split("/")[-1].replace(".git", "")
        path = os.path.join(templates_dir, self.repo_name)
        super(GitRepoReader, self).__init__(path, skip=[".git"])

    def get_template(self):
        
        if not os.path.isdir(self.path):
            exit_code = subprocess.check_call(['git', 'clone', self.repo_url],
                                              cwd=templates_dir)
        else:
            exit_code = 0
        if exit_code == 0:
            return super(GitRepoReader, self).get_template()
        else:
            raise Exception("git clone command failed")<commit_msg>pass flake8<commit_after>"""
Copyright 2016 <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import subprocess

from .virtual_dirs import TemplateDir, TemplateRoot
from .virtual_files import TemplateFile

templates_dir = os.path.expanduser(
    os.path.join("~", ".fossil")
)


class FileSystemReader(object):
    def __init__(self, directory, skip=[]):
        self.path = os.path.abspath(directory)
        self.skip = skip

    def get_template(self):
        templates = self._get_children(self.path)
        return TemplateRoot(templates)

    def _get_children(self, path):
        templates = []
        for item in os.listdir(path):
            if item in self.skip:
                continue
            full_path = os.path.join(path, item)
            if os.path.isfile(full_path):
                content = open(full_path).read()
                template = TemplateFile(item, content)
                templates.append(template)
            else:
                children = self._get_children(full_path)
                template = TemplateDir(item, children)
                templates.append(template)
        return templates


class GitRepoReader(FileSystemReader):
    def __init__(self, repo_url):
        self.repo_url = repo_url
        self.repo_name = repo_url.split("/")[-1].replace(".git", "")
        path = os.path.join(templates_dir, self.repo_name)
        super(GitRepoReader, self).__init__(path, skip=[".git"])

    def get_template(self):
        if not os.path.isdir(self.path):
            exit_code = subprocess.check_call(['git', 'clone', self.repo_url],
                                              cwd=templates_dir)
        else:
            exit_code = 0
        if exit_code == 0:
            return super(GitRepoReader, self).get_template()
        else:
            raise Exception("git clone command failed")
{'fraction_non_alphanumeric': 0.09402254839395874, 'fraction_numerical': 0.0048925760476494365, 'mean_word_length': 2.459896983075791, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '760223', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1251, 'n_words': 376}