<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8 -*-

# Copyright 2011-2014, <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
from subprocess import check_output
from shutil import rmtree

from py2neo.env import NEO4J_DIST
from py2neo.packages.httpstream import NetworkAddressError
from py2neo.packages.httpstream.packages.urimagic import URI
from py2neo.server import download, dist_archive_name, GraphServer


__all__ = ["Warehouse", "Box"]


class Warehouse(object):
    """ Container for Neo4j :class:`.Box` installations.

    :arg home: Home directory for this warehouse (defaults to the path
               held in ``$NEOBOX_HOME`` if specified, otherwise ``$HOME/.neobox``)

    """

    __instances = {}

    def __new__(cls, home=None):
        if not home:
            home = os.getenv("NEOBOX_HOME") or os.path.expanduser("~/.neobox")
        key = home
        try:
            inst = cls.__instances[key]
        except KeyError:
            inst = super(Warehouse, cls).__new__(cls)
            inst.home = home
            cls.__instances[key] = inst
        return inst

    home = None

    def __repr__(self):
        return "<Warehouse home=%r>" % self.home<commit_msg>FileExistsError workaround for Python 2<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8 -*-

# Copyright 2011-2014, <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
from subprocess import check_output
from shutil import rmtree

from py2neo.env import NEO4J_DIST
from py2neo.packages.httpstream import NetworkAddressError
from py2neo.packages.httpstream.packages.urimagic import URI
from py2neo.server import download, dist_archive_name, GraphServer


__all__ = ["Warehouse", "Box"]


# Workaround for Python 2
try:
    FileExistsError
except NameError:
    FileExistsError = OSError


class Warehouse(object):
    """ Container for Neo4j :class:`.Box` installations.

    :arg home: Home directory for this warehouse (defaults to the path
               held in ``$NEOBOX_HOME`` if specified, otherwise ``$HOME/.neobox``)

    """

    __instances = {}

    def __new__(cls, home=None):
        if not home:
            home = os.getenv("NEOBOX_HOME") or os.path.expanduser("~/.neobox")
        key = home
        try:
            inst = cls.__instances[key]
        except KeyError:
            inst = super(Warehouse, cls).__new__(cls)
            inst.home = home
            cls.__instances[key] = inst
        return inst

    home = None

    def __repr__(self):
        return "<Warehouse home=%r>" % self.home
{'fraction_non_alphanumeric': 0.09333708181051448, 'fraction_numerical': 0.011245431543435479, 'mean_word_length': 3.142025611175786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4300853', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1000, 'n_words': 365}