# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/options.py
# class BottomSpacedOpt(OptionsBase):
#     OPTIONS = ['space_bottom']
# 
#     def __init__(self, space_bottom=True, **kwargs):
#         super(BottomSpacedOpt, self).__init__(space_bottom=space_bottom, **kwargs)
# 
# class ColorSchema(object):
#     INFO = 'green'
#     PROMPT = 'cyan'
#     WARNING = 'yellow'
#     ERROR = 'red'
# 
# class PromptOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.PROMPT, **kwargs):
#         super(PromptOpt, self).__init__(color=color, **kwargs)
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class TopSpacedOpt(OptionsBase):
#     OPTIONS = ['space_top']
# 
#     def __init__(self, space_top=True, **kwargs):
#         super(TopSpacedOpt, self).__init__(space_top=space_top, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)
# 
# Path: syncano_cli/hosting/exceptions.py
# class NoHostingFoundException(CLIBaseException):
#     default_message = u'Hosting with domain `{}` - not found. Exit.'
# 
# class PathNotFoundException(CLIBaseException):
#     default_message = u'File `{}` not found.'
# 
# class UnicodeInPathException(CLIBaseException):
#     default_message = u'Unicode characters in path are not supported. Check the files names.'


import os
import re
import sys
import click
from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.options import BottomSpacedOpt, ColorSchema, PromptOpt, SpacedOpt, TopSpacedOpt, WarningOpt
from syncano_cli.hosting.exceptions import NoHostingFoundException, PathNotFoundException, UnicodeInPathException
# -*- coding: utf-8 -*-



class HostingCommands(BaseInstanceCommand):

    VALID_PATH_REGEX = re.compile(r'^(?!/)([a-zA-Z0-9\-\._]+/{0,1})+(?<!/)\Z')

    def list_hostings(self):
        return [
            (hosting.label, hosting.domains) for hosting in self.instance.hostings.all()
        ]

    def print_hostings(self, hostings):
        if not hostings:
            self.formatter.write('No Hosting defined for instance `{}`.'.format(
                self.instance.name

# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/options.py
# class BottomSpacedOpt(OptionsBase):
#     OPTIONS = ['space_bottom']
# 
#     def __init__(self, space_bottom=True, **kwargs):
#         super(BottomSpacedOpt, self).__init__(space_bottom=space_bottom, **kwargs)
# 
# class ColorSchema(object):
#     INFO = 'green'
#     PROMPT = 'cyan'
#     WARNING = 'yellow'
#     ERROR = 'red'
# 
# class PromptOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.PROMPT, **kwargs):
#         super(PromptOpt, self).__init__(color=color, **kwargs)
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class TopSpacedOpt(OptionsBase):
#     OPTIONS = ['space_top']
# 
#     def __init__(self, space_top=True, **kwargs):
#         super(TopSpacedOpt, self).__init__(space_top=space_top, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)
# 
# Path: syncano_cli/hosting/exceptions.py
# class NoHostingFoundException(CLIBaseException):
#     default_message = u'Hosting with domain `{}` - not found. Exit.'
# 
# class PathNotFoundException(CLIBaseException):
#     default_message = u'File `{}` not found.'
# 
# class UnicodeInPathException(CLIBaseException):
#     default_message = u'Unicode characters in path are not supported. Check the files names.'


# Path: syncano_cli/hosting/command.py
import os
import re
import sys
import click
from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.options import BottomSpacedOpt, ColorSchema, PromptOpt, SpacedOpt, TopSpacedOpt, WarningOpt
from syncano_cli.hosting.exceptions import NoHostingFoundException, PathNotFoundException, UnicodeInPathException

# -*- coding: utf-8 -*-



class HostingCommands(BaseInstanceCommand):

    VALID_PATH_REGEX = re.compile(r'^(?!/)([a-zA-Z0-9\-\._]+/{0,1})+(?<!/)\Z')

    def list_hostings(self):
        return [
            (hosting.label, hosting.domains) for hosting in self.instance.hostings.all()
        ]

    def print_hostings(self, hostings):
        if not hostings:
            self.formatter.write('No Hosting defined for instance `{}`.'.format(
                self.instance.name

            ), SpacedOpt())