# Path: validator/decorator.py
# TEST_TIERS = {}
# CLEANUP_FUNCTIONS = []
# def register_test(tier=1, expected_type=None, simple=False, versions=None):
#     def wrap(function):
# def register_cleanup(cleanup):
# def cleanup():
# def get_tiers():
# def get_tests(tier, type_=None):
# def version_range(guid, version, before=None, app_versions=None):
# 
# Path: validator/submain.py
# def prepare_package(err, path, expectation=0, for_appversions=None,
#                     timeout=-1):
#         def timeout_handler(signum, frame):
# def test_search(err, package, expectation=0):
# def test_package(err, file_, name, expectation=PACKAGE_ANY,
#                  for_appversions=None):
# def _load_install_rdf(err, package, expectation):
# def _load_package_json(err, package, expectation):
# def _load_manifest_json(err, package, expectation):
# def populate_chrome_manifest(err, xpi_package):
#         def get_linked_manifest(path, from_path, from_chrome, from_triple):
# def test_inner_package(err, xpi_package, for_appversions=None):
# 
# Path: validator/unicodehelper.py
# UNICODE_BOMS = [
#     (codecs.BOM_UTF8, 'utf-8'),
#     (codecs.BOM_UTF32_LE, 'utf-32-le'),
#     (codecs.BOM_UTF32_BE, 'utf-32-be'),
#     (codecs.BOM_UTF16_LE, 'utf-16-le'),
#     (codecs.BOM_UTF16_BE, 'utf-16-be'),
# ]
# COMMON_ENCODINGS = ('latin_1', 'utf-16')
# NON_ASCII_FILTER = re.compile(r'[^\t\r\n\x20-\x7f]+')
# def decode(data):


import hashlib
import os
import re
import validator.testcases.markup.markuptester as testendpoint_markup
import validator.testcases.markup.csstester as testendpoint_css
import validator.testcases.scripting as testendpoint_js
import validator.testcases.langpack as testendpoint_langpack
from StringIO import StringIO
from zipfile import BadZipfile
from regex import run_regex_tests
from validator.constants import MAX_JS_THRESHOLD
from validator import decorator
from validator import submain as testendpoint_validator
from validator import unicodehelper
from validator.constants import (BUGZILLA_BUG, PACKAGE_LANGPACK,
                                 PACKAGE_SUBPACKAGE, PACKAGE_THEME)
from validator.xpi import XPIManager

    # If that item is a container file, unzip it and scan it.
    if name_lower.endswith('.jar'):
        # This is either a subpackage or a nested theme.
        is_subpackage = not err.get_resource('is_multipackage')
        # Unpack the package and load it up.
        package = StringIO(file_data)
        try:
            sub_xpi = XPIManager(package, mode='r', name=name,
                                 subpackage=is_subpackage)
        except BadZipfile:
            err.error(('testcases_content',
                       'test_packed_packages',
                       'jar_subpackage_corrupt'),
                      'Subpackage corrupt.',
                      'The subpackage appears to be corrupt, and could not '
                      'be opened.',
                      name)
            return None

        # Let the error bunder know we're in a sub-package.
        err.push_state(name)
        err.detected_type = (PACKAGE_SUBPACKAGE if is_subpackage else
                             PACKAGE_THEME)
        err.set_tier(1)
        supported_versions = (err.supported_versions.copy() if
                              err.supported_versions else
                              err.supported_versions)

        if is_subpackage:

# Path: validator/decorator.py
# TEST_TIERS = {}
# CLEANUP_FUNCTIONS = []
# def register_test(tier=1, expected_type=None, simple=False, versions=None):
#     def wrap(function):
# def register_cleanup(cleanup):
# def cleanup():
# def get_tiers():
# def get_tests(tier, type_=None):
# def version_range(guid, version, before=None, app_versions=None):
# 
# Path: validator/submain.py
# def prepare_package(err, path, expectation=0, for_appversions=None,
#                     timeout=-1):
#         def timeout_handler(signum, frame):
# def test_search(err, package, expectation=0):
# def test_package(err, file_, name, expectation=PACKAGE_ANY,
#                  for_appversions=None):
# def _load_install_rdf(err, package, expectation):
# def _load_package_json(err, package, expectation):
# def _load_manifest_json(err, package, expectation):
# def populate_chrome_manifest(err, xpi_package):
#         def get_linked_manifest(path, from_path, from_chrome, from_triple):
# def test_inner_package(err, xpi_package, for_appversions=None):
# 
# Path: validator/unicodehelper.py
# UNICODE_BOMS = [
#     (codecs.BOM_UTF8, 'utf-8'),
#     (codecs.BOM_UTF32_LE, 'utf-32-le'),
#     (codecs.BOM_UTF32_BE, 'utf-32-be'),
#     (codecs.BOM_UTF16_LE, 'utf-16-le'),
#     (codecs.BOM_UTF16_BE, 'utf-16-be'),
# ]
# COMMON_ENCODINGS = ('latin_1', 'utf-16')
# NON_ASCII_FILTER = re.compile(r'[^\t\r\n\x20-\x7f]+')
# def decode(data):


# Path: validator/testcases/content.py
import hashlib
import os
import re
import validator.testcases.markup.markuptester as testendpoint_markup
import validator.testcases.markup.csstester as testendpoint_css
import validator.testcases.scripting as testendpoint_js
import validator.testcases.langpack as testendpoint_langpack
from StringIO import StringIO
from zipfile import BadZipfile
from regex import run_regex_tests
from validator.constants import MAX_JS_THRESHOLD
from validator import decorator
from validator import submain as testendpoint_validator
from validator import unicodehelper
from validator.constants import (BUGZILLA_BUG, PACKAGE_LANGPACK,
                                 PACKAGE_SUBPACKAGE, PACKAGE_THEME)
from validator.xpi import XPIManager


    # If that item is a container file, unzip it and scan it.
    if name_lower.endswith('.jar'):
        # This is either a subpackage or a nested theme.
        is_subpackage = not err.get_resource('is_multipackage')
        # Unpack the package and load it up.
        package = StringIO(file_data)
        try:
            sub_xpi = XPIManager(package, mode='r', name=name,
                                 subpackage=is_subpackage)
        except BadZipfile:
            err.error(('testcases_content',
                       'test_packed_packages',
                       'jar_subpackage_corrupt'),
                      'Subpackage corrupt.',
                      'The subpackage appears to be corrupt, and could not '
                      'be opened.',
                      name)
            return None

        # Let the error bunder know we're in a sub-package.
        err.push_state(name)
        err.detected_type = (PACKAGE_SUBPACKAGE if is_subpackage else
                             PACKAGE_THEME)
        err.set_tier(1)
        supported_versions = (err.supported_versions.copy() if
                              err.supported_versions else
                              err.supported_versions)

        if is_subpackage:

            testendpoint_validator.test_inner_package(err, sub_xpi)