def is_valid_package_name(name, raise_error=False):
is_valid = PACKAGE_NAME_REGEX.match(name)<EOL>if raise_error and not is_valid:<EOL><INDENT>raise PackageRequestError("<STR_LIT>" % name)<EOL><DEDENT>return is_valid<EOL>
Test the validity of a package name string.

    Args:
        name (str): Name to test.
        raise_error (bool): If True, raise an exception on failure

    Returns:
        bool.