# Path: mdk/config.py
# class Conf(Config):
#     """MDK config class"""
# 
#     userFile = None
#     _instance = None
# 
#     def __new__(cls, *args, **kwargs):
#         if not cls._instance:
#             cls._instance = super(Conf, cls).__new__(cls, *args, **kwargs)
#         return cls._instance
# 
#     def __init__(self, userfile=None):
#         if userfile == None:
#             userfile = os.path.expanduser('~/.moodle-sdk/config.json')
#         self.userFile = userfile
#         files = [
#             os.path.join(os.path.dirname(__file__), 'config-dist.json'),
#             os.path.join(os.path.dirname(__file__), 'config.json'),
#             '/etc/moodle-sdk/config.json',
#             self.userFile,
#         ]
#         Config.__init__(self, files)
#         self.load(allowMissing=True)
# 
#     def add(self, name, value):
#         """Set a new setting"""
#         super(Conf, self).add(name, value)
#         self.save()
# 
#     def remove(self, name):
#         """Remove a setting"""
#         # We need to remove from the object we use as a reference in save().
#         self.objects[self.userFile].remove(name)
#         super(Conf, self).remove(name)
#         self.save()
# 
#     def save(self, to=None, confObj=None):
#         """Save only the difference to the user config file"""
# 
#         # The base file to use is the user file
#         to = self.userFile
#         diffData = self.objects[self.userFile]
# 
#         files = list(self.files)
#         files.reverse()
# 
#         # Each of the know settings will be checked
#         data = self.data.getFlat()
#         for k in sorted(data.keys()):
#             v = data[k]
#             different = False
#             found = False
# 
#             # Respect the files order when reading the settings
#             for f in files:
#                 o = self.objects[f]
#                 ov = o.get(k)
#                 present = k in o
# 
#                 # The value hasn't been found and is different
#                 if not found and present and ov is not v:
#                     different = True
#                     break
#                 # The value is set
#                 elif present and ov is v:
#                     found = True
# 
#             # The value differs, or none of the file define it
#             if different or not found:
#                 diffData.set(k, v)
# 
#         confObj = diffData
#         super(Conf, self).save(to, confObj)
# 
#     def set(self, name, value):
#         """Set a new setting"""
#         super(Conf, self).set(name, value)
#         self.save()


import logging
from jenkinsapi import jenkins
from jenkinsapi.custom_exceptions import JenkinsAPIException, TimeOut
from jenkinsapi.utils.crumb_requester import CrumbRequester
from .config import Conf
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Moodle Development Kit

Copyright (c) 2014 Frédéric Massart - FMCorz.net

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""



# Path: mdk/config.py
# class Conf(Config):
#     """MDK config class"""
# 
#     userFile = None
#     _instance = None
# 
#     def __new__(cls, *args, **kwargs):
#         if not cls._instance:
#             cls._instance = super(Conf, cls).__new__(cls, *args, **kwargs)
#         return cls._instance
# 
#     def __init__(self, userfile=None):
#         if userfile == None:
#             userfile = os.path.expanduser('~/.moodle-sdk/config.json')
#         self.userFile = userfile
#         files = [
#             os.path.join(os.path.dirname(__file__), 'config-dist.json'),
#             os.path.join(os.path.dirname(__file__), 'config.json'),
#             '/etc/moodle-sdk/config.json',
#             self.userFile,
#         ]
#         Config.__init__(self, files)
#         self.load(allowMissing=True)
# 
#     def add(self, name, value):
#         """Set a new setting"""
#         super(Conf, self).add(name, value)
#         self.save()
# 
#     def remove(self, name):
#         """Remove a setting"""
#         # We need to remove from the object we use as a reference in save().
#         self.objects[self.userFile].remove(name)
#         super(Conf, self).remove(name)
#         self.save()
# 
#     def save(self, to=None, confObj=None):
#         """Save only the difference to the user config file"""
# 
#         # The base file to use is the user file
#         to = self.userFile
#         diffData = self.objects[self.userFile]
# 
#         files = list(self.files)
#         files.reverse()
# 
#         # Each of the know settings will be checked
#         data = self.data.getFlat()
#         for k in sorted(data.keys()):
#             v = data[k]
#             different = False
#             found = False
# 
#             # Respect the files order when reading the settings
#             for f in files:
#                 o = self.objects[f]
#                 ov = o.get(k)
#                 present = k in o
# 
#                 # The value hasn't been found and is different
#                 if not found and present and ov is not v:
#                     different = True
#                     break
#                 # The value is set
#                 elif present and ov is v:
#                     found = True
# 
#             # The value differs, or none of the file define it
#             if different or not found:
#                 diffData.set(k, v)
# 
#         confObj = diffData
#         super(Conf, self).save(to, confObj)
# 
#     def set(self, name, value):
#         """Set a new setting"""
#         super(Conf, self).set(name, value)
#         self.save()


# Path: mdk/ci.py
import logging
from jenkinsapi import jenkins
from jenkinsapi.custom_exceptions import JenkinsAPIException, TimeOut
from jenkinsapi.utils.crumb_requester import CrumbRequester
from .config import Conf

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Moodle Development Kit

Copyright (c) 2014 Frédéric Massart - FMCorz.net

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""



C = Conf()