~raoul-snyman/openlp/fix-translations-2.4

753.1.1 by Raoul Snyman
Updated copyright.
1
# -*- coding: utf-8 -*-
2279.1.1 by Andreas Preikschat
changed to 120 chars
2
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
753.1.1 by Raoul Snyman
Updated copyright.
3
4
###############################################################################
5
# OpenLP - Open Source Lyrics Projection                                      #
6
# --------------------------------------------------------------------------- #
2663.1.1 by Tim Bentley
Yet another year goes by
7
# Copyright (c) 2008-2017 OpenLP Developers                                   #
753.1.1 by Raoul Snyman
Updated copyright.
8
# --------------------------------------------------------------------------- #
9
# This program is free software; you can redistribute it and/or modify it     #
10
# under the terms of the GNU General Public License as published by the Free  #
11
# Software Foundation; version 2 of the License.                              #
12
#                                                                             #
13
# This program is distributed in the hope that it will be useful, but WITHOUT #
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
16
# more details.                                                               #
17
#                                                                             #
18
# You should have received a copy of the GNU General Public License along     #
19
# with this program; if not, write to the Free Software Foundation, Inc., 59  #
20
# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
21
###############################################################################
712.1.3 by Michael Gorven
Make setup.py executable.
22
2230.2.3 by Andreas Preikschat
fixed setup.py
23
import re
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
24
from setuptools import setup, find_packages
2230.2.3 by Andreas Preikschat
fixed setup.py
25
from subprocess import Popen, PIPE
26
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
27
28
VERSION_FILE = 'openlp/.version'
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
29
SPLIT_ALPHA_DIGITS = re.compile(r'(\d+|\D+)')
30
2230.2.3 by Andreas Preikschat
fixed setup.py
31
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
32
def try_int(s):
33
    """
34
    Convert string s to an integer if possible. Fail silently and return
35
    the string as-is if it isn't an integer.
36
2328.1.20 by Tim Bentley
Fix up comments
37
    :param s: The string to try to convert.
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
38
    """
39
    try:
40
        return int(s)
2422.3.2 by Raoul Snyman
The code in setup.py was written at around the time Noah got off the ark. Python 3 does not have a "cmp" function, nor does sorted() have a "cmp" parameter. Lose the extras that we don't need any more.
41
    except (TypeError, ValueError):
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
42
        return s
43
2230.2.3 by Andreas Preikschat
fixed setup.py
44
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
45
def natural_sort_key(s):
46
    """
47
    Return a tuple by which s is sorted.
48
2328.1.20 by Tim Bentley
Fix up comments
49
    :param s: A string value from the list we want to sort.
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
50
    """
2218.1.123 by Andreas Preikschat
2to3 and resources.py
51
    return list(map(try_int, SPLIT_ALPHA_DIGITS.findall(s)))
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
52
2230.2.3 by Andreas Preikschat
fixed setup.py
53
2422.3.2 by Raoul Snyman
The code in setup.py was written at around the time Noah got off the ark. Python 3 does not have a "cmp" function, nor does sorted() have a "cmp" parameter. Lose the extras that we don't need any more.
54
def natural_sort(seq):
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
55
    """
56
    Returns a copy of seq, sorted by natural string sort.
2422.3.2 by Raoul Snyman
The code in setup.py was written at around the time Noah got off the ark. Python 3 does not have a "cmp" function, nor does sorted() have a "cmp" parameter. Lose the extras that we don't need any more.
57
58
    :param seq: The sequence to sort.
59
    :param compare: The comparison method to use
60
    :return: The sorted sequence
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
61
    """
62
    import copy
63
    temp = copy.copy(seq)
2422.3.2 by Raoul Snyman
The code in setup.py was written at around the time Noah got off the ark. Python 3 does not have a "cmp" function, nor does sorted() have a "cmp" parameter. Lose the extras that we don't need any more.
64
    temp.sort(key=natural_sort_key)
2022.2.2 by Raoul Snyman
Pulled natural sorting methods out from the try (no real reason for them to be in there) and moved "try_int" to outside the other method (then it is only compiled once).
65
    return temp
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
66
2422.3.2 by Raoul Snyman
The code in setup.py was written at around the time Noah got off the ark. Python 3 does not have a "cmp" function, nor does sorted() have a "cmp" parameter. Lose the extras that we don't need any more.
67
2230.2.4 by Andreas Preikschat
fixed code
68
# NOTE: The following code is a duplicate of the code in openlp/core/utils/__init__.py. Any fix applied here should also
69
# be applied there.
2422.3.3 by Raoul Snyman
Added and updated tests:
70
ver_file = None
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
71
try:
2230.2.4 by Andreas Preikschat
fixed code
72
    # Get the revision of this tree.
2218.1.123 by Andreas Preikschat
2to3 and resources.py
73
    bzr = Popen(('bzr', 'revno'), stdout=PIPE)
2230.2.4 by Andreas Preikschat
fixed code
74
    tree_revision, error = bzr.communicate()
75
    code = bzr.wait()
76
    if code != 0:
2218.1.123 by Andreas Preikschat
2to3 and resources.py
77
        raise Exception('Error running bzr log')
2230.2.4 by Andreas Preikschat
fixed code
78
79
    # Get all tags.
2218.1.123 by Andreas Preikschat
2to3 and resources.py
80
    bzr = Popen(('bzr', 'tags'), stdout=PIPE)
2230.2.3 by Andreas Preikschat
fixed setup.py
81
    output, error = bzr.communicate()
82
    code = bzr.wait()
83
    if code != 0:
2218.1.123 by Andreas Preikschat
2to3 and resources.py
84
        raise Exception('Error running bzr tags')
2230.2.4 by Andreas Preikschat
fixed code
85
    tags = output.splitlines()
86
    if not tags:
2218.1.123 by Andreas Preikschat
2to3 and resources.py
87
        tag_version = '0.0.0'
88
        tag_revision = '0'
2230.2.4 by Andreas Preikschat
fixed code
89
    else:
90
        # Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
91
        # another series.
2218.1.123 by Andreas Preikschat
2to3 and resources.py
92
        tags = [tag for tag in tags if tag.split()[-1].strip() != '?']
2230.2.4 by Andreas Preikschat
fixed code
93
        # Get the last tag and split it in a revision and tag name.
94
        tag_version, tag_revision = tags[-1].split()
95
    # If they are equal, then this tree is tarball with the source for the release. We do not want the revision number
96
    # in the version string.
2328.1.67 by Tim Bentley
Fix setup.py
97
    tree_revision = tree_revision.strip()
98
    tag_revision = tag_revision.strip()
2230.2.4 by Andreas Preikschat
fixed code
99
    if tree_revision == tag_revision:
2328.1.62 by Tim Bentley
Fix setup.py
100
        version_string = tag_version.decode('utf-8')
2230.2.4 by Andreas Preikschat
fixed code
101
    else:
2328.1.62 by Tim Bentley
Fix setup.py
102
        version_string = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8'))
2218.1.123 by Andreas Preikschat
2to3 and resources.py
103
    ver_file = open(VERSION_FILE, 'w')
2230.2.4 by Andreas Preikschat
fixed code
104
    ver_file.write(version_string)
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
105
except:
2218.1.123 by Andreas Preikschat
2to3 and resources.py
106
    ver_file = open(VERSION_FILE, 'r')
2230.2.4 by Andreas Preikschat
fixed code
107
    version_string = ver_file.read().strip()
108
finally:
701.1.5 by Raoul Snyman
Merged from trunk.
109
    ver_file.close()
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
110
512.1.1 by Jon Tibble
Fixed carriage returns
111
112
setup(
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
113
    name='OpenLP',
2230.2.4 by Andreas Preikschat
fixed code
114
    version=version_string,
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
115
    description="Open source Church presentation and lyrics projection application.",
116
    long_description="""\
2328.1.28 by Tim Bentley
test fixes
117
OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display
118
slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship
119
using a computer and a data projector.""",
1405.1.1 by Raoul Snyman
Add the .png files to the package and set OpenLP's classification.
120
    classifiers=[
121
        'Development Status :: 4 - Beta',
122
        'Environment :: MacOS X',
123
        'Environment :: Win32 (MS Windows)',
124
        'Environment :: X11 Applications',
125
        'Environment :: X11 Applications :: Qt',
126
        'Intended Audience :: End Users/Desktop',
127
        'Intended Audience :: Religion',
128
        'License :: OSI Approved :: GNU General Public License (GPL)',
129
        'Natural Language :: Afrikaans',
130
        'Natural Language :: Dutch',
131
        'Natural Language :: English',
132
        'Natural Language :: French',
133
        'Natural Language :: German',
134
        'Natural Language :: Hungarian',
135
        'Natural Language :: Indonesian',
136
        'Natural Language :: Japanese',
137
        'Natural Language :: Norwegian',
138
        'Natural Language :: Portuguese (Brazilian)',
139
        'Natural Language :: Russian',
140
        'Natural Language :: Swedish',
141
        'Operating System :: MacOS :: MacOS X',
142
        'Operating System :: Microsoft :: Windows',
143
        'Operating System :: POSIX :: BSD :: FreeBSD',
144
        'Operating System :: POSIX :: Linux',
145
        'Programming Language :: Python',
2328.1.62 by Tim Bentley
Fix setup.py
146
        'Programming Language :: Python :: 3',
1405.1.1 by Raoul Snyman
Add the .png files to the package and set OpenLP's classification.
147
        'Topic :: Desktop Environment :: Gnome',
148
        'Topic :: Desktop Environment :: K Desktop Environment (KDE)',
149
        'Topic :: Multimedia',
150
        'Topic :: Multimedia :: Graphics :: Presentation',
151
        'Topic :: Multimedia :: Sound/Audio',
152
        'Topic :: Multimedia :: Video',
153
        'Topic :: Religion'
2328.1.28 by Tim Bentley
test fixes
154
    ],  # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
155
    keywords='open source church presentation lyrics projection song bible display project',
156
    author='Raoul Snyman',
157
    author_email='raoulsnyman@openlp.org',
158
    url='http://openlp.org/',
159
    license='GNU General Public License',
160
    packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
1989.3.151 by Tim Bentley
Head and merge failures
161
    scripts=['openlp.py'],
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
162
    include_package_data=True,
163
    zip_safe=False,
164
    install_requires=[
165
        # -*- Extra requirements: -*-
2225.2.2 by Raoul Snyman
Migrated to Alembic (if you'll excuse the pun)
166
        'sqlalchemy',
167
        'alembic'
701.1.1 by Raoul Snyman
Working on a "Source Distribution" - aka source tarball
168
    ],
169
    entry_points="""
170
    # -*- Entry points: -*-
171
    """
1328.1.1 by Raoul Snyman
Updated copyright information. Removed .eric4project directory from version control.
172
)