Failed Conditions
Pull Request — master (#1307)
by Lasse
04:07
created

download()   A

Complexity

Conditions 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 4
dl 0
loc 18
rs 9.2
1
#!/usr/bin/env python3
2
3
import locale
4
from urllib.request import urlopen
5
from shutil import copyfileobj
6
from os.path import exists
7
from setuptools import setup, find_packages
8
import setuptools.command.build_py
9
10
from coalib import assert_supported_version
11
assert_supported_version()
12
from coalib.misc.BuildManPage import BuildManPage
13
from coalib.output.dbus.BuildDbusService import BuildDbusService
14
from coalib.misc import Constants
15
16
try:
17
    locale.getlocale()
18
except (ValueError, UnicodeError):
19
    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
20
21
22
def download(url, filename, overwrite=False):
23
    """
24
    Downloads the given URL to the given filename. If the file exists, it won't
25
    be downloaded.
26
27
    :param url:       A URL to download.
28
    :param filename:  The file to store the downloaded file to.
29
    :param overwrite: Set to True if the file should be downloaded even if it
30
                      already exists.
31
    :return:          The filename.
32
    """
33
    if not exists(filename) or overwrite:
34
        print("Downloading", filename + "...")
35
        with urlopen(url) as response, open(filename, 'wb') as out_file:
36
            copyfileobj(response, out_file)
37
        print("DONE.")
38
39
    return filename
40
41
42
class BuildPyCommand(setuptools.command.build_py.build_py):
43
44
    def run(self):
45
        self.run_command('build_manpage')
46
        self.run_command('build_dbus')
47
        setuptools.command.build_py.build_py.run(self)
48
49
50
with open('requirements.txt') as requirements:
51
    required = requirements.read().splitlines()
52
53
54
if __name__ == "__main__":
55
    download('http://sourceforge.net/projects/checkstyle/files/checkstyle/'
56
             '6.15/checkstyle-6.15-all.jar',
57
             'bears/java/checkstyle.jar')
58
    data_files = [('.', ['coala.1']), ('.', [Constants.BUS_NAME + '.service'])]
59
60
    setup(name='coala',
61
          version=Constants.VERSION,
62
          description='Code Analysis Application (coala)',
63
          author="The coala developers",
64
          maintainer="Lasse Schuirmann, Fabian Neuschmidt, Mischa Kr\xfcger",
65
          maintainer_email=('[email protected], '
66
                            '[email protected], '
67
                            '[email protected]'),
68
          url='http://coala.rtfd.org/',
69
          platforms='any',
70
          packages=find_packages(exclude=["build.*", "*.tests.*", "*.tests"]),
71
          install_requires=required,
72
          package_data={'coalib': ['default_coafile', "VERSION"],
73
                        'bears.java': ['checkstyle.jar', 'google_checks.xml']},
74
          license="AGPL v3",
75
          data_files=data_files,
76
          long_description="coala is a simple COde AnaLysis Application. Its "
77
                           "goal is to make static code analysis easy while "
78
                           "remaining completely modular and therefore "
79
                           "extendable and language independent. Code analysis"
80
                           " happens in python scripts while coala manages "
81
                           "these, tries to provide helpful libraries and "
82
                           "provides a user interface. Please visit "
83
                           "http://coala.rtfd.org/ for more information or our"
84
                           "development repository on "
85
                           "https://github.com/coala-analyzer/coala/.",
86
          entry_points={
87
              "console_scripts": [
88
                  "coala = coalib.coala:main",
89
                  "coala-ci = coalib.coala_ci:main",
90
                  "coala-dbus = coalib.coala_dbus:main",
91
                  "coala-json = coalib.coala_json:main",
92
                  "coala-format = coalib.coala_format:main"]},
93
          # from http://pypi.python.org/pypi?%3Aaction=list_classifiers
94
          classifiers=[
95
              'Development Status :: 3 - Alpha',
96
97
              'Environment :: Console',
98
              'Environment :: MacOS X',
99
              'Environment :: Win32 (MS Windows)',
100
              'Environment :: X11 Applications :: Gnome',
101
102
              'Intended Audience :: Science/Research',
103
              'Intended Audience :: Developers',
104
105
              'License :: OSI Approved :: GNU Affero General Public License '
106
              'v3 or later (AGPLv3+)',
107
108
              'Operating System :: OS Independent',
109
110
              'Programming Language :: Python :: Implementation :: CPython',
111
              'Programming Language :: Python :: 3.3',
112
              'Programming Language :: Python :: 3.4',
113
              'Programming Language :: Python :: 3.5',
114
              'Programming Language :: Python :: 3 :: Only',
115
116
              'Topic :: Scientific/Engineering :: Information Analysis',
117
              'Topic :: Software Development :: Quality Assurance',
118
              'Topic :: Text Processing :: Linguistic'],
119
          cmdclass={'build_manpage': BuildManPage,
120
                    'build_dbus': BuildDbusService,
121
                    'build_py': BuildPyCommand})
122