import os
import imp
from setuphelpers import setup, install_other

def generate_version():
    base_path, _ = os.path.split(__file__)
    module_path = os.path.join(base_path, "abusehelper", "core")

    module_info = imp.find_module("version", [module_path])
    version_module = imp.load_module("version", *module_info)

    version_module.generate(base_path)
    return version_module.version_str()
version = generate_version()

install_other("idiokit")

setup(
    name="abusehelper",
    version="2." + version,
    packages=[
        "abusehelper",
        "abusehelper.core",
        "abusehelper.contrib",
        "abusehelper.contrib.confgen",
        "abusehelper.contrib.archivebot",
        "abusehelper.contrib.tailbot",
        "abusehelper.contrib.bridgebot",
        "abusehelper.contrib.windowbot",
        "abusehelper.contrib.reprbot",
        "abusehelper.contrib.opencollabbot",
        "abusehelper.contrib.wikiruntime",
        "abusehelper.contrib.arbor",
        "abusehelper.contrib.dragon",
        "abusehelper.contrib.rssbot",
        "abusehelper.contrib.abusechbot",
        "abusehelper.contrib.cleanmxbot",
        "abusehelper.contrib.phishtankbot",
        "abusehelper.contrib.runtime2dot",
        "abusehelper.contrib.experts"
    ],
    package_dir={
        "abusehelper.contrib": "contrib",
        "abusehelper.contrib.confgen": "contrib/confgen",
        "abusehelper.contrib.archivebot": "contrib/archivebot",
        "abusehelper.contrib.bridgebot": "contrib/bridgebot",
        "abusehelper.contrib.tailbot": "contrib/tailbot",
        "abusehelper.contrib.windowbot": "contrib/windowbot",
        "abusehelper.contrib.reprbot": "contrib/reprbot",
        "abusehelper.contrib.opencollabbot": "contrib/opencollabbot",
        "abusehelper.contrib.wikiruntime": "contrib/wikiruntime",
        "abusehelper.contrib.arbor": "contrib/arbor",
        "abusehelper.contrib.dragon": "contrib/dragon",
        "abusehelper.contrib.rssbot": "contrib/rssbot",
        "abusehelper.contrib.abusechbot": "contrib/abusechbot",
        "abusehelper.contrib.cleanmxbot": "contrib/cleanmxbot",
        "abusehelper.contrib.phishtankbot": "contrib/phishtankbot",
        "abusehelper.contrib.runtime2dot": "contrib/runtime2dot",
        "abusehelper.contrib.experts": "contrib/experts",
	},
    package_data={
        "abusehelper.contrib.confgen": [
            "confgen/*.py",
            "confgen/config-template/*.py",
            "confgen/config-template/custom/*.py",
            "confgen/config-template/template/default"
        ]
    },
    scripts=[
        "scripts/abusehelperctl",
        "scripts/roomreader"
    ],
    description="A framework for receiving and redistributing abuse feeds",
    long_description=(
        "AbuseHelper is a modular, scalable and robust " +
        "framework to help you in your abuse handling."
    ),
    author="Clarified Networks",
    author_email="contact@clarifiednetworks.com",
    url="https://bitbucket.org/clarifiednetworks/abusehelper",
    download_url="https://bitbucket.org/clarifiednetworks/abusehelper/downloads",
    license="MIT"
)

@@ -426,16 +426,415 @@
 sion()%0A%0A
+def collect_package_data(src, dst):%0A    paths = list()%0A%0A    cwd = os.getcwd()%0A    try:%0A        os.chdir(src)%0A%0A        for dirpath, dirnames, filenames in os.walk(dst):%0A            for filename in filenames:%0A                normalized = os.path.normpath(os.path.join(dirpath, filename))%0A                paths.append(os.path.normpath(normalized))%0A    finally:%0A        os.chdir(cwd)%0A%0A    return paths%0A%0A
 install_
@@ -2770,18 +2770,16 @@
 onfgen%22:
- %5B
 %0A       
@@ -2787,183 +2787,66 @@
     
-%22
 co
-nfgen/*.py%22,%0A            %22confgen/config-template/*.py%22,%0A            %22confgen/config-template/custom/*.py%22,%0A            %22confgen/config-template/template/default%22%0A        %5D
+llect_package_data(%22contrib/confgen%22, %22config-template%22)
 %0A   

Fix confgen data file installation.