# Path: binstar_client/inspect_package/pypi.py
# PARTIAL_PYPI_SPEC_PATTERN = re.compile(r'''
#     # Text needs to be stripped and all extra spaces replaced by single spaces
#     (?P<name>^[A-Z0-9][A-Z0-9._-]*)?
#     \s?
#     (\[(?P<extras>.*)\])?
#     \s?
#     (?P<constraints>\(? \s? ([\w\d<>=!~,\s\.\*]*) \s? \)? )?
#     \s?
# ''', re.VERBOSE | re.IGNORECASE)
# def norm_package_name(name):
# def norm_package_version(version):
# def split_spec(spec, sep):
# def parse_specification(spec):
# def get_header_description(filedata):
# def python_version_check(filedata):
# def parse_requirement(line, deps, extras, extra):
# def parse_requires_txt(requires_txt):
# def format_requirements(requires):
# def format_run_requires_metadata(run_requires):
# def format_requires_metadata(run_requires):
# def format_sdist_header_metadata(data, filename):
# def format_wheel_json_metadata(data, filename, zipfile):
# def inspect_pypi_package_whl(filename, fileobj):
# def disutils_dependencies(config_items):
# def inspect_pypi_package_sdist(filename, fileobj):
# def inspect_pypi_package_egg(filename, fileobj):
# def inspect_pypi_package_zip(filename, fileobj):
# def inspect_pypi_package_exe(filename, fileobj):
# def inspect_pypi_package_rpm(filename, fileobj):
# def inspect_pypi_package(filename, fileobj, *args, **kwargs):
# def main():
# 
# Path: binstar_client/utils/test/utils.py
# def data_dir(filename):
#     base_path = inspect.stack()[1][1]  # function caller path
#     test_data = os.path.join(os.path.dirname(base_path), 'data')
#     return os.path.join(test_data, filename)


import os
import shutil
import tempfile
import unittest
from pprint import pprint
from binstar_client.inspect_package import pypi
from binstar_client.utils.test.utils import data_dir


        self.assertEqual(expected_package_data, package_data)
        self.assertEqual(expected_version_data, version_data)

        self.assertEqual(set(expected_egg_file_data), set(file_data))
        for key in expected_egg_file_data:
            self.assertEqual(expected_egg_file_data[key], file_data[key])

    def test_bdist_egg_dashed_path(self):
        filename = data_dir('test_package34-0.3.1-py2.7.egg')
        tmpdir = tempfile.gettempdir()
        dash_count = tmpdir.count('-')
        if dash_count == 0:
            tmpdir = os.path.join(tmpdir, 'has-dash')
            try:
                os.mkdir(tmpdir)
            except (IOError, OSError):
                raise unittest.SkipTest('Cannot create temporary directory %r' % tmpdir)
        elif dash_count > 1:
            raise unittest.SkipTest('Too many dashes in temporary directory path %r' % tmpdir)

        try:
            shutil.copy(filename, tmpdir)
        except (IOError, OSError):
            raise unittest.SkipTest('Cannot copy package to temporary directory')

        tmpfilename = os.path.join(tmpdir, 'test_package34-0.3.1-py2.7.egg')

        with open(tmpfilename, 'rb') as fd:

# Path: binstar_client/inspect_package/pypi.py
# PARTIAL_PYPI_SPEC_PATTERN = re.compile(r'''
#     # Text needs to be stripped and all extra spaces replaced by single spaces
#     (?P<name>^[A-Z0-9][A-Z0-9._-]*)?
#     \s?
#     (\[(?P<extras>.*)\])?
#     \s?
#     (?P<constraints>\(? \s? ([\w\d<>=!~,\s\.\*]*) \s? \)? )?
#     \s?
# ''', re.VERBOSE | re.IGNORECASE)
# def norm_package_name(name):
# def norm_package_version(version):
# def split_spec(spec, sep):
# def parse_specification(spec):
# def get_header_description(filedata):
# def python_version_check(filedata):
# def parse_requirement(line, deps, extras, extra):
# def parse_requires_txt(requires_txt):
# def format_requirements(requires):
# def format_run_requires_metadata(run_requires):
# def format_requires_metadata(run_requires):
# def format_sdist_header_metadata(data, filename):
# def format_wheel_json_metadata(data, filename, zipfile):
# def inspect_pypi_package_whl(filename, fileobj):
# def disutils_dependencies(config_items):
# def inspect_pypi_package_sdist(filename, fileobj):
# def inspect_pypi_package_egg(filename, fileobj):
# def inspect_pypi_package_zip(filename, fileobj):
# def inspect_pypi_package_exe(filename, fileobj):
# def inspect_pypi_package_rpm(filename, fileobj):
# def inspect_pypi_package(filename, fileobj, *args, **kwargs):
# def main():
# 
# Path: binstar_client/utils/test/utils.py
# def data_dir(filename):
#     base_path = inspect.stack()[1][1]  # function caller path
#     test_data = os.path.join(os.path.dirname(base_path), 'data')
#     return os.path.join(test_data, filename)


# Path: binstar_client/inspect_package/tests/test_pypi.py
import os
import shutil
import tempfile
import unittest
from pprint import pprint
from binstar_client.inspect_package import pypi
from binstar_client.utils.test.utils import data_dir



        self.assertEqual(expected_package_data, package_data)
        self.assertEqual(expected_version_data, version_data)

        self.assertEqual(set(expected_egg_file_data), set(file_data))
        for key in expected_egg_file_data:
            self.assertEqual(expected_egg_file_data[key], file_data[key])

    def test_bdist_egg_dashed_path(self):
        filename = data_dir('test_package34-0.3.1-py2.7.egg')
        tmpdir = tempfile.gettempdir()
        dash_count = tmpdir.count('-')
        if dash_count == 0:
            tmpdir = os.path.join(tmpdir, 'has-dash')
            try:
                os.mkdir(tmpdir)
            except (IOError, OSError):
                raise unittest.SkipTest('Cannot create temporary directory %r' % tmpdir)
        elif dash_count > 1:
            raise unittest.SkipTest('Too many dashes in temporary directory path %r' % tmpdir)

        try:
            shutil.copy(filename, tmpdir)
        except (IOError, OSError):
            raise unittest.SkipTest('Cannot copy package to temporary directory')

        tmpfilename = os.path.join(tmpdir, 'test_package34-0.3.1-py2.7.egg')

        with open(tmpfilename, 'rb') as fd:

            package_data, version_data, file_data = pypi.inspect_pypi_package(tmpfilename, fd)