<commit_before>import ectl
import ectl.rundeck

import re
import sys
import os
import string
import tempfile
import filecmp
import shutil
from ectl import pathutil
import ectl.config

# TODO: Be careful not to leave around zero-length files when downloading

# --------------------------------------
class FollowLinks(object):
    """Reads links from an existing run directory.  If the links don't
    exist, or if the entire directory doesn't exist, sets to None."""

    def __init__(self, run):
        self.run = run
        self.rundeck = pathutil.follow_link(
            os.path.join(run, 'upstream.R'), must_exist=True)
        self.src = pathutil.follow_link(
            os.path.join(run, 'src'), must_exist=True)
        self.build = pathutil.follow_link(
            os.path.join(run, 'build'))
        self.pkg = pathutil.follow_link(
            os.path.join(run, 'pkg'))

        # Determine if pkgbuild was set before
        self.pkgbuild = \
            (self.pkg is not None) and \
            (os.path.split(self.pkg)[1].find('-') >= 0)


def write_I(preamble, sections, fname):
    with open(fname, 'w') as out:
        out.write(preamble[0].raw)    # First line of preamble
        out.write('\n')

        out.write('&&PARAMETERS\n')
        out.write('\n'.join(sections.parameters))
        out.write('\n')
        out.write('\n'.join(sections.data_lines))
        out.write('\n&&END_PARAMETERS\n')
<commit_msg>Bug fix: make sure rundir's path is absolute.<commit_after>import ectl
import ectl.rundeck

import re
import sys
import os
import string
import tempfile
import filecmp
import shutil
from ectl import pathutil
import ectl.config

# TODO: Be careful not to leave around zero-length files when downloading

# --------------------------------------
class FollowLinks(object):
    """Reads links from an existing run directory.  If the links don't
    exist, or if the entire directory doesn't exist, sets to None."""

    def __init__(self, run):
        self.run = os.path.abspath(run)
        self.rundeck = pathutil.follow_link(
            os.path.join(run, 'upstream.R'), must_exist=True)
        self.src = pathutil.follow_link(
            os.path.join(run, 'src'), must_exist=True)
        self.build = pathutil.follow_link(
            os.path.join(run, 'build'))
        self.pkg = pathutil.follow_link(
            os.path.join(run, 'pkg'))

        # Determine if pkgbuild was set before
        self.pkgbuild = \
            (self.pkg is not None) and \
            (os.path.split(self.pkg)[1].find('-') >= 0)


def write_I(preamble, sections, fname):
    with open(fname, 'w') as out:
        out.write(preamble[0].raw)    # First line of preamble
        out.write('\n')

        out.write('&&PARAMETERS\n')
        out.write('\n'.join(sections.parameters))
        out.write('\n')
        out.write('\n'.join(sections.data_lines))
        out.write('\n&&END_PARAMETERS\n')

{'fraction_non_alphanumeric': 0.14833847207947928, 'fraction_numerical': 0.0020554984583761563, 'mean_word_length': 2.3447880870561284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3261011', 'n_tokens_mistral': 914, 'n_tokens_neox': 899, 'n_words': 239}