# Path: django_node/settings.py
# PATH_TO_NODE = setting_overrides.get(
#     'PATH_TO_NODE',
#     'node'
# )
# 
# PATH_TO_NPM = setting_overrides.get(
#     'PATH_TO_NPM',
#     'npm'
# )
# 
# NODE_VERSION_COMMAND = setting_overrides.get(
#     'NODE_VERSION_COMMAND',
#     '--version',
# )
# 
# NODE_VERSION_FILTER = setting_overrides.get(
#     'NODE_VERSION_FILTER',
#     lambda version: tuple(map(int, (version[1:] if version[0] == 'v' else version).split('.'))),
# )
# 
# NPM_VERSION_COMMAND = setting_overrides.get(
#     'NPM_VERSION_COMMAND',
#     '--version',
# )
# 
# NPM_VERSION_FILTER = setting_overrides.get(
#     'NPM_VERSION_FILTER',
#     lambda version: tuple(map(int, version.split('.'))),
# )
# 
# Path: django_node/exceptions.py
# class DynamicImportError(Exception):
#     pass
# 
# class ErrorInterrogatingEnvironment(Exception):
#     pass
# 
# class MalformedVersionInput(Exception):
#     pass
# 
# class MissingDependency(Exception):
#     pass
# 
# class OutdatedDependency(Exception):
#     pass
# 
# class ModuleDoesNotContainAnyServices(Exception):
#     pass


import sys
import subprocess
import tempfile
import importlib
import re
import inspect
from django.utils import six
from .settings import (
    PATH_TO_NODE, PATH_TO_NPM, NODE_VERSION_COMMAND, NODE_VERSION_FILTER, NPM_VERSION_COMMAND, NPM_VERSION_FILTER,
)
from .exceptions import (
    DynamicImportError, ErrorInterrogatingEnvironment, MalformedVersionInput, MissingDependency, OutdatedDependency,
    ModuleDoesNotContainAnyServices
)
    from . import node, npm  # Avoid a circular import
    from .base_service import BaseService  # Avoid a circular import
            'Versions must be tuples. Received {0}'.format(version)
        )
    if len(version) < 3:
        raise MalformedVersionInput(
            'Versions must have three numbers defined. Received {0}'.format(version)
        )
    for number in version:
        if not isinstance(number, six.integer_types):
            raise MalformedVersionInput(
                'Versions can only contain number. Received {0}'.format(version)
            )


def _check_if_version_is_outdated(current_version, required_version):
    _validate_version_iterable(required_version)
    for i, number_required in enumerate(required_version):
        if number_required > current_version[i]:
            return True
        elif number_required < current_version[i]:
            return False
    return current_version != required_version


def _format_version(version):
    return '.'.join(map(six.text_type, version))


def raise_if_dependency_missing(application, required_version=None):
    if application == NPM_NAME:
        is_installed = npm_installed

# Path: django_node/settings.py
# PATH_TO_NODE = setting_overrides.get(
#     'PATH_TO_NODE',
#     'node'
# )
# 
# PATH_TO_NPM = setting_overrides.get(
#     'PATH_TO_NPM',
#     'npm'
# )
# 
# NODE_VERSION_COMMAND = setting_overrides.get(
#     'NODE_VERSION_COMMAND',
#     '--version',
# )
# 
# NODE_VERSION_FILTER = setting_overrides.get(
#     'NODE_VERSION_FILTER',
#     lambda version: tuple(map(int, (version[1:] if version[0] == 'v' else version).split('.'))),
# )
# 
# NPM_VERSION_COMMAND = setting_overrides.get(
#     'NPM_VERSION_COMMAND',
#     '--version',
# )
# 
# NPM_VERSION_FILTER = setting_overrides.get(
#     'NPM_VERSION_FILTER',
#     lambda version: tuple(map(int, version.split('.'))),
# )
# 
# Path: django_node/exceptions.py
# class DynamicImportError(Exception):
#     pass
# 
# class ErrorInterrogatingEnvironment(Exception):
#     pass
# 
# class MalformedVersionInput(Exception):
#     pass
# 
# class MissingDependency(Exception):
#     pass
# 
# class OutdatedDependency(Exception):
#     pass
# 
# class ModuleDoesNotContainAnyServices(Exception):
#     pass


# Path: django_node/utils.py
import sys
import subprocess
import tempfile
import importlib
import re
import inspect
from django.utils import six
from .settings import (
    PATH_TO_NODE, PATH_TO_NPM, NODE_VERSION_COMMAND, NODE_VERSION_FILTER, NPM_VERSION_COMMAND, NPM_VERSION_FILTER,
)
from .exceptions import (
    DynamicImportError, ErrorInterrogatingEnvironment, MalformedVersionInput, MissingDependency, OutdatedDependency,
    ModuleDoesNotContainAnyServices
)
    from . import node, npm  # Avoid a circular import
    from .base_service import BaseService  # Avoid a circular import

            'Versions must be tuples. Received {0}'.format(version)
        )
    if len(version) < 3:
        raise MalformedVersionInput(
            'Versions must have three numbers defined. Received {0}'.format(version)
        )
    for number in version:
        if not isinstance(number, six.integer_types):
            raise MalformedVersionInput(
                'Versions can only contain number. Received {0}'.format(version)
            )


def _check_if_version_is_outdated(current_version, required_version):
    _validate_version_iterable(required_version)
    for i, number_required in enumerate(required_version):
        if number_required > current_version[i]:
            return True
        elif number_required < current_version[i]:
            return False
    return current_version != required_version


def _format_version(version):
    return '.'.join(map(six.text_type, version))


def raise_if_dependency_missing(application, required_version=None):
    if application == NPM_NAME:
        is_installed = npm_installed

        path = PATH_TO_NPM