# Path: dgitcore/plugins/metadata.py
# class MetadataBase(object):
#     """
#     This is the base class for all backends including
#     """
#     def __init__(self, name, version, description, supported=[]):
#         """
#         Parameters:
#         -----------
#         name: Name of the backend service e.g., s3
#         version: Version of this implementation
#         description: Text description of this service
#         supported: supported services with including name
# 
#         For example, there may be multiple s3 implementations that
#         support different kinds of services.
# 
#         """
#         self.enable = 'y'
#         self.name = name
#         self.version = version
#         self.description = description
#         self.support = supported + [name]
#         self.initialize()
# 
#     def __str__(self): 
#         return self.name 
# 
#     def initialize(self):
#         """
#         Called to initialize sessions, internal objects etc.
#         """
#         return
# 
#     def post(self, repo):
#         """
#         Post to server
#         """
#         pass
# 
# Path: dgitcore/config.py
# def get_config():
#     if config is None:
#         init()
#     return config
# 
# class ChoiceValidator(object):
#     def __init__(self, choices):
#         self.choices = choices        
#         message = "Supported options include: {}"
#         self.message = message.format(",".join(self.choices))
# 
#     def is_valid(self, value):
#         if value in self.choices:
#             return True
#         return False
# 
# class URLValidator(object):
#     def __init__(self):
#         self.message = "Value should be a valid URL"
# 
#     def is_valid(self, value):
#         o = urlparse(value)
#         return o.scheme in ['http', 'https']
# 
# class NonEmptyValidator(object):
#     def __init__(self):
#         self.message = "Value cannot be an empty string"
# 
#     def is_valid(self, value):
#         if value is None or len(value) == 0:
#             return False
#         return True


import os, sys, requests, json
import traceback 
from dgitcore.plugins.metadata import MetadataBase
from dgitcore.exceptions import *
from dgitcore.config import get_config, ChoiceValidator, URLValidator, NonEmptyValidator

"""

class BasicMetadata(MetadataBase):
    """
    Metadata backend for the datasets.

    Parameters
    ----------
    Configuration (token)
    """
    def __init__(self):
        self.enable = False
        self.token = None
        self.url = None
        super(BasicMetadata, self).__init__('basic-metadata',
                                              'v0',
                                              "Basic metadata server")

    def config(self, what='get', params=None):

        if what == 'get':
            return {
                'name': 'basic-metadata',
                'nature': 'metadata',
                'variables': ['enable', 'token', 'url'],
                'defaults': {
                    'enable': {
                        'value': "n",
                        "description": "Enable a generic Metadata server? (see documentation)",

# Path: dgitcore/plugins/metadata.py
# class MetadataBase(object):
#     """
#     This is the base class for all backends including
#     """
#     def __init__(self, name, version, description, supported=[]):
#         """
#         Parameters:
#         -----------
#         name: Name of the backend service e.g., s3
#         version: Version of this implementation
#         description: Text description of this service
#         supported: supported services with including name
# 
#         For example, there may be multiple s3 implementations that
#         support different kinds of services.
# 
#         """
#         self.enable = 'y'
#         self.name = name
#         self.version = version
#         self.description = description
#         self.support = supported + [name]
#         self.initialize()
# 
#     def __str__(self): 
#         return self.name 
# 
#     def initialize(self):
#         """
#         Called to initialize sessions, internal objects etc.
#         """
#         return
# 
#     def post(self, repo):
#         """
#         Post to server
#         """
#         pass
# 
# Path: dgitcore/config.py
# def get_config():
#     if config is None:
#         init()
#     return config
# 
# class ChoiceValidator(object):
#     def __init__(self, choices):
#         self.choices = choices        
#         message = "Supported options include: {}"
#         self.message = message.format(",".join(self.choices))
# 
#     def is_valid(self, value):
#         if value in self.choices:
#             return True
#         return False
# 
# class URLValidator(object):
#     def __init__(self):
#         self.message = "Value should be a valid URL"
# 
#     def is_valid(self, value):
#         o = urlparse(value)
#         return o.scheme in ['http', 'https']
# 
# class NonEmptyValidator(object):
#     def __init__(self):
#         self.message = "Value cannot be an empty string"
# 
#     def is_valid(self, value):
#         if value is None or len(value) == 0:
#             return False
#         return True


# Path: dgitcore/contrib/metadata/default.py
import os, sys, requests, json
import traceback 
from dgitcore.plugins.metadata import MetadataBase
from dgitcore.exceptions import *
from dgitcore.config import get_config, ChoiceValidator, URLValidator, NonEmptyValidator


"""

class BasicMetadata(MetadataBase):
    """
    Metadata backend for the datasets.

    Parameters
    ----------
    Configuration (token)
    """
    def __init__(self):
        self.enable = False
        self.token = None
        self.url = None
        super(BasicMetadata, self).__init__('basic-metadata',
                                              'v0',
                                              "Basic metadata server")

    def config(self, what='get', params=None):

        if what == 'get':
            return {
                'name': 'basic-metadata',
                'nature': 'metadata',
                'variables': ['enable', 'token', 'url'],
                'defaults': {
                    'enable': {
                        'value': "n",
                        "description": "Enable a generic Metadata server? (see documentation)",

                        'validator': ChoiceValidator(['y','n'])