'loop through the signatures, looking for a match for both
the signature directory and the version file'

def scan_signatures(self):

    sigdata = self.api.get_signatures()
    for breed in sigdata['breeds'].keys():
        if (self.breed and (self.breed != breed)):
            continue
        for version in sigdata['breeds'][breed].keys():
            if (self.os_version and (self.os_version != version)):
                continue
            for sig in sigdata['breeds'][breed][version]['signatures']:
                pkgdir = os.path.join(self.path, sig)
                if os.path.exists(pkgdir):
                    self.logger.debug(('Found    a    candidate    signature:    breed=%s,    version=%s' % (breed, version)))
                    f_re = re.compile(sigdata['breeds'][breed][version]['version_file'])
                    for (root, subdir, fnames) in os.walk(self.path):
                        for fname in (fnames + subdir):
                            if f_re.match(fname):
                                if sigdata['breeds'][breed][version]['version_file_regex']:
                                    vf_re = re.compile(sigdata['breeds'][breed][version]['version_file_regex'])
                                    vf_lines = self.get_file_lines(os.path.join(root, fname))
                                    for line in vf_lines:
                                        if vf_re.match(line):
                                            break
                                    else:
                                        continue
                                self.logger.debug(('Found    a    matching    signature:    breed=%s,    version=%s' % (breed, version)))
                                if (not self.breed):
                                    self.breed = breed
                                if (not self.os_version):
                                    self.os_version = version
                                if (not self.autoinstall_file):
                                    self.autoinstall_file = sigdata['breeds'][breed][version]['default_autoinstall']
                                self.pkgdir = pkgdir
                                return sigdata['breeds'][breed][version]
    return None
