~wolterh/gtg/1039655

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Getting Things GNOME! - a personal organizer for the GNOME desktop
# Copyright(c) 2008-2012 - Lionel Dricot & Bertrand Rousseau
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or(at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

from distutils.core     import setup
from distutils.command.install_data import install_data
from subprocess import call

import glob
import os

from GTG import info

### CONSTANTS ################################################################

HELP_DIR = "share/help"
GLOBAL_ICON_DIR = "share/icons"

### TOOLS ####################################################################

def create_icon_list():
    fileList = []
    rootdir = "data/icons"
    for root, subFolders, files in os.walk(rootdir):
        dirList = []
        for file in files:
            if file.endswith(".png") or file.endswith(".svg"):
                dirList.append(os.path.join(root, file))
        if len(dirList)!=0:
            newroot = root.replace(rootdir + "/", "")
            fileList.append((os.path.join(GLOBAL_ICON_DIR, newroot), dirList))
    return fileList


def create_userdoc_list():
    fileList = []
    rootdir = "doc/userdoc"
    for root, subFolders, files in os.walk(rootdir):
        dirList = []
        for file in files:
            dirList.append(os.path.join(root, file))
        if len(dirList)!=0:
            comps = root.split(os.sep)
            prefix = os.path.join(comps[0], comps[1], comps[2])+os.sep
            if root != prefix[:-1]:
                newroot = root.replace(prefix, "")
            else:
                newroot = ""
            newroot = os.path.join(HELP_DIR, comps[2], "gtg", newroot)
            fileList.append((newroot, dirList))
    return fileList


def create_data_files():
    data_files = []
    # icons
    icons = create_icon_list()
    data_files.extend(icons)
    # gtg .desktop icon
    data_files.append(('share/icons/hicolor/16x16/apps',
                       ['data/icons/hicolor/16x16/apps/gtg.png']))
    data_files.append(('share/icons/hicolor/22x22/apps',
                       ['data/icons/hicolor/22x22/apps/gtg.png']))
    data_files.append(('share/icons/hicolor/24x24/apps',
                       ['data/icons/hicolor/24x24/apps/gtg.png']))
    data_files.append(('share/icons/hicolor/32x32/apps',
                       ['data/icons/hicolor/32x32/apps/gtg.png']))
    data_files.append(('share/icons/hicolor/scalable/apps',
                       ['data/icons/hicolor/scalable/apps/gtg.svg']))
    # documentation
    helpfiles = create_userdoc_list()
    data_files.extend(helpfiles)
    # misc
    data_files.append(('share/applications', ['gtg.desktop']))
    data_files.append(('share/dbus-1/services', ['org.gnome.GTG.service']))
    data_files.append(('share/man/man1',
                       ['doc/gtg.1', 'doc/gtcli.1', 'doc/gtg_new_task.1']))

    # bash completion
    data_files.append(('share/gtg/', ['gtcli_bash_completion']))
    return data_files


#### TRANSLATIONS(from pyroom setup.py) ######################################

PO_DIR = 'po'
MO_DIR = os.path.join('build', 'po')

for po in glob.glob(os.path.join(PO_DIR, '*.po')):
    lang = os.path.basename(po[:-3])
    mo = os.path.join(MO_DIR, lang, 'gtg.mo')
    target_dir = os.path.dirname(mo)
    if not os.path.isdir(target_dir):
        os.makedirs(target_dir)
    try:
        return_code = call(['msgfmt', '-o', mo, po])
    except OSError:
        print 'Translation not available, please install gettext'
        break
    if return_code:
        raise Warning('Error when building locales')


class InstallData(install_data):

    def run(self):
        self.data_files.extend(self.find_mo_files())
        install_data.run(self)

    def find_mo_files(self):
        data_files = []
        for mo in glob.glob(os.path.join(MO_DIR, '*', 'gtg.mo')):
            lang = os.path.basename(os.path.dirname(mo))
            dest = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
            data_files.append((dest, [mo]))
        return data_files

### SETUP SCRIPT ##############################################################

author = 'The GTG Team'

setup(
  name = 'gtg',
  version = info.VERSION,
  url = info.URL,
  author = author,
  author_email = info.EMAIL,
  description = info.SHORT_DESCRIPTION,
  packages = [
    'GTG',
    'GTG.backends',
    'GTG.backends.rtm',
    'GTG.core',
    'GTG.core.plugins',
    'GTG.gtk',
    'GTG.gtk.editor',
    'GTG.gtk.browser',
    'GTG.gtk.backends_dialog',
    'GTG.gtk.backends_dialog.parameters_ui',
    'GTG.tools',
    'GTG.plugins',
    'GTG.plugins.bugzilla',
    'GTG.plugins.export',
    'GTG.plugins.geolocalized_tasks',
    'GTG.plugins.hamster',
    'GTG.plugins.notification_area',
    'GTG.plugins.task_reaper',
    'GTG.plugins.send_email',
    'GTG.plugins.tomboy',
    'GTG.plugins.urgency_color',
    'GTG.plugins.untouched_tasks',
    'GTG.plugins.not_today',
    ],
  package_data = {
    'GTG.core.plugins': ['pluginmanager.glade'],
    'GTG.gtk': [
        'preferences.glade',
        'plugins.glade',
        'deletion.glade',
        'backends_dialog.glade',
        ],
    'GTG.gtk.browser': ['taskbrowser.glade', 'modifytags_dialog.glade'],
    'GTG.gtk.editor': ['taskeditor.glade'],
    'GTG.plugins': [
        'bugzilla.gtg-plugin',
        'export.gtg-plugin',
        'geolocalized-tasks.gtg-plugin',
        'hamster.gtg-plugin',
        'notification-area.gtg-plugin',
        'task-reaper.gtg-plugin',
        'send-email.gtg-plugin',
        'tomboy.gtg-plugin',
        'urgency-color.gtg-plugin',
        'not-today.gtg-plugin',
        'untouched-tasks.gtg-plugin',
        ],
    'GTG.plugins.export': ['export.ui',
                          './export_templates/description_pocketmod.py',
                          './export_templates/description_sexy.py',
                          './export_templates/description_simple.py',
                          './export_templates/description_statusrpt.py',
                          './export_templates/description_textual.py',
                          './export_templates/graphics_pocketmod.svg',
                          './export_templates/script_pocketmod',
                          './export_templates/template_pocketmod.tex',
                          './export_templates/template_sexy.html',
                          './export_templates/template_simple.html',
                          './export_templates/template_statusrpt.txt',
                          './export_templates/template_textual.txt',
                          './export_templates/thumbnail_pocketmod.png',
                          './export_templates/thumbnail_sexy.png',
                          './export_templates/thumbnail_simple.png',
                          './export_templates/thumbnail_statusrpt.png',
                          './export_templates/thumbnail_textual.png',
                          ],
    'GTG.plugins.geolocalized_tasks': ['geolocalized.glade',
                          'icons/hicolor/24x24/geolocalization.png',
                          'icons/hicolor/16x16/assign-location.png',
                          'icons/hicolor/svg/assign-location.svg',
                          'icons/hicolor/svg/geolocalization.svg'],
    'GTG.plugins.tomboy': ['tomboy.ui'],
    'GTG.plugins.hamster': ['prefs.ui'],
    'GTG.plugins.task_reaper': ['reaper.ui'],
    'GTG.plugins.notification_area': ['notification_area.ui',
                     './data/icons/hicolor/22x22/apps/gtg_need_attention.png',
            './data/icons/ubuntu-mono-dark/22x22/apps/gtg_need_attention.svg',
           './data/icons/ubuntu-mono-light/22x22/apps/gtg_need_attention.svg',
                            ],
    'GTG.plugins.urgency_color': ['preferences.ui'],
    'GTG.plugins.untouched_tasks': ['untouchedTasks.ui'],
   },
  data_files = create_data_files(),
  scripts=['gtg', 'gtcli', 'gtg_new_task'],
  cmdclass={'install_data': InstallData},
)