Esempio n. 1
0
def classify_kie_file(pathname):
    """Classify a kie-api-* file.

    :param pathname: the path to the file
    :returns: a BRMS version string, or None if not a Red Hat kie file.
    """
    # os.path.basename behaves differently if the last part of the
    # path ends in a /, so normalize.
    if pathname.endswith('/'):
        pathname = pathname[:-1]

    basename = os.path.basename(pathname)

    version_string = strip_suffix(strip_prefix(basename, 'kie-api-'), '.jar')

    if version_string in BRMS_CLASSIFICATIONS:
        return BRMS_CLASSIFICATIONS[version_string]

    if 'redhat' in version_string:
        return version_string

    return None
Esempio n. 2
0
 def test_strip_prefix_no_prefix(self):
     """Test the strip_prefix method."""
     string = '/opt/eap/modules.jar'
     prefix = '/opt/fuse/'
     stripped = strip_prefix(string, prefix)
     self.assertEqual(stripped, string)