<commit_before># -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# 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.
#

from helpers import unittest
import luigi
from luigi.contrib.simulate import RunAnywayTarget

from multiprocessing import Process
import os
import tempfile


def temp_dir():
    if os.getenv('TRAVIS') == 'true':
        return os.path.abspath(os.path.join(os.path.dirname(__file__), 'simulate-tmp'))
    return os.path.join(tempfile.gettempdir(), 'luigi-simulate')


def is_writable():
    d = temp_dir()
    fn = os.path.join(d, 'luigi-simulate-write-test')
    exists = True
    try:
        os.makedirs(d, exist_ok=True)
        open(fn, 'w').close()
        os.remove(fn)
    except:
        exists = False

    return unittest.skipIf(not exists, 'Can\'t write to temporary directory')


class PathRunAnywayTarget(RunAnywayTarget):
    temp_dir = temp_dir()


class TaskA(luigi.Task):
    i = luigi.IntParameter(default=0)

    def output(self):
        return PathRunAnywayTarget(self)

    def run(self):<commit_msg>Cleaned up temp_dir function in test/simulate<commit_after># -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# 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.
#

from helpers import unittest
import luigi
from luigi.contrib.simulate import RunAnywayTarget

from multiprocessing import Process
import os
import tempfile


def temp_dir():
    return os.path.join(tempfile.gettempdir(), 'luigi-simulate')


def is_writable():
    d = temp_dir()
    fn = os.path.join(d, 'luigi-simulate-write-test')
    exists = True
    try:
        os.makedirs(d, exist_ok=True)
        open(fn, 'w').close()
        os.remove(fn)
    except:
        exists = False

    return unittest.skipIf(not exists, 'Can\'t write to temporary directory')


class TaskA(luigi.Task):
    i = luigi.IntParameter(default=0)

    def output(self):
        return RunAnywayTarget(self)

    def run(self):
{'fraction_non_alphanumeric': 0.10061813186813187, 'fraction_numerical': 0.009615384615384616, 'mean_word_length': 3.631160572337043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1319599', 'n_tokens_mistral': 900, 'n_tokens_neox': 864, 'n_words': 302}