# Path: blackbelt/dependencies.py
# def parse_dep(dep):
#     split_result = re.split(r'==|@', dep)
#     if split_result[0] != '':
#         try:
#             return (split_result[0], split_result[1])
#         except IndexError:
#             return (split_result[0], 'latest')
#     else:
#         try:
#             return ('@' + split_result[1], split_result[2])
#         except IndexError:
#             return ('@' + split_result[1], 'latest')
# 
# def parse_license_text(text):
#     license_text = (text or '').strip()
#     copyright_notice = detect_copyright_notice(license_text, require_year=True)
# 
#     # If the license doesn't contain any of the following words, it's suspicius
#     # and should be classified as "rubbish" (sometimes the license-checker picks
#     # up a README file without any real license text).
#     license_text_lc = license_text.lower()
#     if (
#         'software' not in license_text_lc and
#         'copyright' not in license_text_lc and
#         'license' not in license_text_lc
#     ):
#         return (None, None)
# 
#     if 'Apache License' in license_text:
#         return (copyright_notice, license_text)
# 
#     copyright_notice = detect_copyright_notice(license_text)
#     if copyright_notice:
#         license_text = text.split(copyright_notice)[1]
#         license_text = license_text.strip()
#         license_text = re.sub(r' +', ' ', license_text)
#         license_text = re.sub(r' ?(\r\n|\n)+ ?', remove_newlines_keep_paragraps, license_text)
#     return (copyright_notice, license_text)


from nose.tools import assert_equal
from blackbelt.dependencies import (
    parse_dep,
    parse_license_text,
)
            Black belt is collection of scripts, tools and guidelines used for developing projects The Apiary Way.

            ## Installation & Usage

            Please refer to [The Black Belt Documentation](http://black-belt.readthedocs.org/).
        '''), (
            None,
            None,
        ))

    def test_apache(self):
        apache = '''
                                Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

            TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

            1. Definitions.

                "License" shall mean the terms and conditions for use, reproduction,
                and distribution as defined by Sections 1 through 9 of this document.

                "Licensor" shall mean the copyright owner or entity authorized by
                the copyright owner that is granting the License.

                ...
                "Source" form shall mean the preferred form for making modifications,
                ...
        '''

# Path: blackbelt/dependencies.py
# def parse_dep(dep):
#     split_result = re.split(r'==|@', dep)
#     if split_result[0] != '':
#         try:
#             return (split_result[0], split_result[1])
#         except IndexError:
#             return (split_result[0], 'latest')
#     else:
#         try:
#             return ('@' + split_result[1], split_result[2])
#         except IndexError:
#             return ('@' + split_result[1], 'latest')
# 
# def parse_license_text(text):
#     license_text = (text or '').strip()
#     copyright_notice = detect_copyright_notice(license_text, require_year=True)
# 
#     # If the license doesn't contain any of the following words, it's suspicius
#     # and should be classified as "rubbish" (sometimes the license-checker picks
#     # up a README file without any real license text).
#     license_text_lc = license_text.lower()
#     if (
#         'software' not in license_text_lc and
#         'copyright' not in license_text_lc and
#         'license' not in license_text_lc
#     ):
#         return (None, None)
# 
#     if 'Apache License' in license_text:
#         return (copyright_notice, license_text)
# 
#     copyright_notice = detect_copyright_notice(license_text)
#     if copyright_notice:
#         license_text = text.split(copyright_notice)[1]
#         license_text = license_text.strip()
#         license_text = re.sub(r' +', ' ', license_text)
#         license_text = re.sub(r' ?(\r\n|\n)+ ?', remove_newlines_keep_paragraps, license_text)
#     return (copyright_notice, license_text)


# Path: test/test_dependencies.py
from nose.tools import assert_equal
from blackbelt.dependencies import (
    parse_dep,
    parse_license_text,
)

            Black belt is collection of scripts, tools and guidelines used for developing projects The Apiary Way.

            ## Installation & Usage

            Please refer to [The Black Belt Documentation](http://black-belt.readthedocs.org/).
        '''), (
            None,
            None,
        ))

    def test_apache(self):
        apache = '''
                                Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

            TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

            1. Definitions.

                "License" shall mean the terms and conditions for use, reproduction,
                and distribution as defined by Sections 1 through 9 of this document.

                "Licensor" shall mean the copyright owner or entity authorized by
                the copyright owner that is granting the License.

                ...
                "Source" form shall mean the preferred form for making modifications,
                ...
        '''

        assert_equal(parse_license_text(apache), (None, apache.strip()))