# Path: lib/repository.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# MAIN_REMOTE_NAME = "origin"
#         REPO_REMOTE_NAME = "push-remote"
# class PushError(Exception):
# class GitRepository(git.Repo):
# class SvnRepository():
#     def __init__(self, push_info):
# def get_git_repository(remote_repo_url, parent_dir_path, name=None):
# def get_svn_repository(remote_repo_url, repo_path):
#     def clone_from(cls, remote_repo_url, repo_path, proxy=None, *args, **kwargs):
#     def __init__(self, repo_path, *args, **kwargs):
#     def name(self):
#     def checkout(self, ref_name, refspecs=None):
#     def _get_reference(self, ref_name):
#     def _update_submodules(self):
#     def archive(self, archive_name, build_dir):
#     def commit_changes(self, commit_message, committer_name, committer_email):
#     def push_head_commits(self, remote_repo_url, remote_repo_branch):
#     def force_create_remote(self, name, url):
#     def checkout_from(cls, remote_repo_url, repo_path):
#     def __init__(self, remote_repo_url, local_repo_path):
#     def name(self):
#     def checkout(self, revision):
# 
# Path: lib/constants.py
# BUILD_INFO_FILE_NAME = "build.json"
# 
# Path: lib/constants.py
# PACKAGES_INFO_FILE_NAME = "packages.json"


import config
import json
import logging
import os
import pprint
from lib import repository
from lib.constants import BUILD_INFO_FILE_NAME
from lib.constants import PACKAGES_INFO_FILE_NAME
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.



CONF = config.get_config().CONF
LOG = logging.getLogger(__name__)


class PackageInfo(object):
    def __init__(self, pkg):
        self.pkg = pkg

    def __getattr__(self, attr):
        if hasattr(self.pkg, attr):
            return getattr(self.pkg, attr)
        raise AttributeError("%r object has no attribute %r" %
                             (self.pkg.__class__, attr))

    @property
    def sources(self):
        sources = []
        for source in self.pkg.sources:
        # Dereference dict with repository type as key
            source = source.values()[0]
            sources.append({
                "src": source.get("src", ""),
                "branch": source.get("branch", ""),
                "commit_id": source.get("commit_id", ""),
            })

# Path: lib/repository.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# MAIN_REMOTE_NAME = "origin"
#         REPO_REMOTE_NAME = "push-remote"
# class PushError(Exception):
# class GitRepository(git.Repo):
# class SvnRepository():
#     def __init__(self, push_info):
# def get_git_repository(remote_repo_url, parent_dir_path, name=None):
# def get_svn_repository(remote_repo_url, repo_path):
#     def clone_from(cls, remote_repo_url, repo_path, proxy=None, *args, **kwargs):
#     def __init__(self, repo_path, *args, **kwargs):
#     def name(self):
#     def checkout(self, ref_name, refspecs=None):
#     def _get_reference(self, ref_name):
#     def _update_submodules(self):
#     def archive(self, archive_name, build_dir):
#     def commit_changes(self, commit_message, committer_name, committer_email):
#     def push_head_commits(self, remote_repo_url, remote_repo_branch):
#     def force_create_remote(self, name, url):
#     def checkout_from(cls, remote_repo_url, repo_path):
#     def __init__(self, remote_repo_url, local_repo_path):
#     def name(self):
#     def checkout(self, revision):
# 
# Path: lib/constants.py
# BUILD_INFO_FILE_NAME = "build.json"
# 
# Path: lib/constants.py
# PACKAGES_INFO_FILE_NAME = "packages.json"


# Path: lib/build_info.py
import config
import json
import logging
import os
import pprint
from lib import repository
from lib.constants import BUILD_INFO_FILE_NAME
from lib.constants import PACKAGES_INFO_FILE_NAME

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



CONF = config.get_config().CONF
LOG = logging.getLogger(__name__)


class PackageInfo(object):
    def __init__(self, pkg):
        self.pkg = pkg

    def __getattr__(self, attr):
        if hasattr(self.pkg, attr):
            return getattr(self.pkg, attr)
        raise AttributeError("%r object has no attribute %r" %
                             (self.pkg.__class__, attr))

    @property
    def sources(self):
        sources = []
        for source in self.pkg.sources:
        # Dereference dict with repository type as key
            source = source.values()[0]
            sources.append({
                "src": source.get("src", ""),
                "branch": source.get("branch", ""),
                "commit_id": source.get("commit_id", ""),
            })

        return sources