# Path: vmcatcher/__version__.py

# 
# Path: vmcatcher/listutils.py
# def pairsNnot(list_a,list_b):
#     len_generate_list = len(list_a)
#     len_image_list = len(list_b)
#     ocupies_generate_list = set(range(len_generate_list))
#     ocupies_image_list = set(range(len_image_list))
#     ocupies_pairs = ocupies_image_list.intersection(ocupies_generate_list)
#     diff_a = ocupies_generate_list.difference(ocupies_image_list)
#     diff_b = ocupies_image_list.difference(ocupies_generate_list)
#     arepairs = []
#     for i in ocupies_pairs:
#         arepairs.append([list_a[i],list_b[i]])
#     notpairs_a = []
#     for i in diff_a:
#         notpairs_a.append(list_a[i])
#     notpairs_b = []
#     for i in diff_b:
#         notpairs_b.append(list_b[i])
# 
#     return arepairs,notpairs_a,notpairs_b


from sqlalchemy import create_engine
from smimeX509validation import TrustStore, LoadDirChainOfTrust,smimeX509validation, smimeX509ValidationError
from vmcatcher.__version__ import version
from sqlalchemy.orm import sessionmaker
from sqlalchemy.exc import IntegrityError, DatabaseError, ProgrammingError
from hepixvmitrust.vmitrustlib import VMimageListDecoder as VMimageListDecoder
from hepixvmitrust.vmitrustlib import time_format_definition as time_format_definition
from vmcatcher.listutils import pairsNnot
import vmcatcher.databaseDefinition as model
import os
import logging
import optparse
import sys
import vmcatcher
import urllib2
import urllib
import hashlib
import datetime
    import json
    import simplejson
import vmcatcher.outputfacard
import vmcatcher.queryby
    def __init__(self,dboptions,dblog = False):
        self.log = logging.getLogger("db_controler")
        self.engine = create_engine(dboptions, echo=dblog)
        model.init(self.engine)
        self.SessionFactory = sessionmaker(bind=self.engine)
        self.anchor = None
        self.factory_selector = None
        self.selectors_available = ["endorser_uuid"]
        self.selector_curent = None
        self._outputter = vmcatcher.outputfacard.outputFacade()
    def set_selector(self,selector_string):
        self.selector_curent = None
        if not selector_string in self.selectors_available:
            self.log.warning("Invalid selector string set:%s" % (selector_string))
            return False
        if selector_string == 'endorser_uuid':
            self.selector_curent = vmcatcher.queryby.query_endorser_by_identifier
        elif selector_string == 'sub_uri':
            self.selector_curent = vmcatcher.queryby.query_subscriptions_by_uri
        return True
    def setup_trust_anchor(self,directory):
        self.anchor = LoadDirChainOfTrust(directory)

    def setup_view_format(self,format):
        self._outputter.format = format

    def endosers_list(self):
        Session = self.SessionFactory()
        self._outputter.fpOutput = sys.stdout
        self._outputter.saSession = Session

# Path: vmcatcher/__version__.py

# 
# Path: vmcatcher/listutils.py
# def pairsNnot(list_a,list_b):
#     len_generate_list = len(list_a)
#     len_image_list = len(list_b)
#     ocupies_generate_list = set(range(len_generate_list))
#     ocupies_image_list = set(range(len_image_list))
#     ocupies_pairs = ocupies_image_list.intersection(ocupies_generate_list)
#     diff_a = ocupies_generate_list.difference(ocupies_image_list)
#     diff_b = ocupies_image_list.difference(ocupies_generate_list)
#     arepairs = []
#     for i in ocupies_pairs:
#         arepairs.append([list_a[i],list_b[i]])
#     notpairs_a = []
#     for i in diff_a:
#         notpairs_a.append(list_a[i])
#     notpairs_b = []
#     for i in diff_b:
#         notpairs_b.append(list_b[i])
# 
#     return arepairs,notpairs_a,notpairs_b


# Path: vmcatcher/vmcatcher_endorser/controler.py
from sqlalchemy import create_engine
from smimeX509validation import TrustStore, LoadDirChainOfTrust,smimeX509validation, smimeX509ValidationError
from vmcatcher.__version__ import version
from sqlalchemy.orm import sessionmaker
from sqlalchemy.exc import IntegrityError, DatabaseError, ProgrammingError
from hepixvmitrust.vmitrustlib import VMimageListDecoder as VMimageListDecoder
from hepixvmitrust.vmitrustlib import time_format_definition as time_format_definition
from vmcatcher.listutils import pairsNnot
import vmcatcher.databaseDefinition as model
import os
import logging
import optparse
import sys
import vmcatcher
import urllib2
import urllib
import hashlib
import datetime
    import json
    import simplejson
import vmcatcher.outputfacard
import vmcatcher.queryby

    def __init__(self,dboptions,dblog = False):
        self.log = logging.getLogger("db_controler")
        self.engine = create_engine(dboptions, echo=dblog)
        model.init(self.engine)
        self.SessionFactory = sessionmaker(bind=self.engine)
        self.anchor = None
        self.factory_selector = None
        self.selectors_available = ["endorser_uuid"]
        self.selector_curent = None
        self._outputter = vmcatcher.outputfacard.outputFacade()
    def set_selector(self,selector_string):
        self.selector_curent = None
        if not selector_string in self.selectors_available:
            self.log.warning("Invalid selector string set:%s" % (selector_string))
            return False
        if selector_string == 'endorser_uuid':
            self.selector_curent = vmcatcher.queryby.query_endorser_by_identifier
        elif selector_string == 'sub_uri':
            self.selector_curent = vmcatcher.queryby.query_subscriptions_by_uri
        return True
    def setup_trust_anchor(self,directory):
        self.anchor = LoadDirChainOfTrust(directory)

    def setup_view_format(self,format):
        self._outputter.format = format

    def endosers_list(self):
        Session = self.SessionFactory()
        self._outputter.fpOutput = sys.stdout
        self._outputter.saSession = Session

        self._outputter.x509anchor = self.anchor