<commit_before>import pathlib
import subprocess
import shlex


class Molt:
    def __init__(self, rev, repo, user):
        self.rev = rev
        self.repo = repo
        self.user = user
        self.repo_url = 'https://github.com/{}/{}.git/'.format(user, repo)
        self.repo_dir = str(pathlib.Path('./repos') / user / repo / rev)

    def molt(self):
        """ gitリポジトリのクローンと、Dockerイメージの立ち上げ """
        for command in (self._git_clone, self._git_checkout):
            for row in command().stdout:
                yield row

    def _git_clone(self):
        command = 'git clone --progress {} {}'.format(
            self.repo_url, self.repo_dir)
        return subprocess.Popen(shlex.split(command),
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)

    def _git_checkout(self):
        command = 'git checkout {}'.format(self.rev)
        return subprocess.Popen(shlex.split(command),
                                cwd=self.repo_dir,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)


if __name__ == '__main__':
    rev = '32b5b45'
    repo = 'molt'
    user = 'swkoubou'

    m = Molt(rev, repo, user)
    for line in m.molt():<commit_msg>:construction: composeコマンド部分の実装<commit_after>import pathlib
import subprocess
import shlex


class Molt:
    def __init__(self, rev, repo, user):
        self.rev = rev
        self.repo = repo
        self.user = user
        self.repo_url = 'https://github.com/{}/{}.git/'.format(user, repo)
        self.repo_dir = str(pathlib.Path('./repos') / user / repo / rev)

    def molt(self):
        """ gitリポジトリのクローンと、Dockerイメージの立ち上げ """
        for command in (self._git_clone, self._git_checkout,
                        self._compose_build, self._compose_up):
            for row in command().stdout:
                yield row

    def _git_clone(self):
        command = 'git clone --progress {} {}'.format(self.repo_url,
                                                      self.repo_dir)
        return subprocess.Popen(shlex.split(command),
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)

    def _git_checkout(self):
        command = 'git checkout {}'.format(self.rev)
        return subprocess.Popen(shlex.split(command),
                                cwd=self.repo_dir,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)

    def _compose_build(self):
        command = 'compose build --no-cache'
        return subprocess.Popen(shlex.split(command),
                                cwd=self.repo_dir,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)

    def _compose_up(self):
        command = 'compose up'
        return subprocess.Popen(shlex.split(command),
                                cwd=self.repo_dir,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)


if __name__ == '__main__':
    rev = '2ea1328'
    repo = 'swkoubou.rms'
    user = 'swkoubou'

    m = Molt(rev, repo, user)
    for line in m.molt():
{'fraction_non_alphanumeric': 0.10754659333944394, 'fraction_numerical': 0.0030553009471432934, 'mean_word_length': 1.5538221528861154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5469508', 'n_tokens_mistral': 1028, 'n_tokens_neox': 968, 'n_words': 186}