~cm-t/ubuntu-fr-tour/ubuntu-fr-tour

« back to all changes in this revision

Viewing changes to 12.10/translate-html/setup.py

  • Committer: cm-t arudy
  • Date: 2013-10-22 01:24:09 UTC
  • Revision ID: arudy@ubuntu-fr.org-20131022012409-3dmo4i9u4ufohe5f
First Fr push to 13.10
Fixed many icons (updated to new version or fixed graphic)
Added Cloud indicator
Added Keyboard uindicator
Fixed many layout to fit Fr string

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
 
### BEGIN LICENSE
4
 
# Copyright (C) 2011 David Planella <david.planella@ubuntu.com>
5
 
# This program is free software: you can redistribute it and/or modify it 
6
 
# under the terms of the GNU General Public License version 3, as published 
7
 
# by the Free Software Foundation.
8
 
9
 
# This program is distributed in the hope that it will be useful, but 
10
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
11
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
12
 
# PURPOSE.  See the GNU General Public License for more details.
13
 
14
 
# You should have received a copy of the GNU General Public License along 
15
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
### END LICENSE
17
 
 
18
 
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
19
 
 
20
 
import os
21
 
import sys
22
 
 
23
 
try:
24
 
    import DistUtilsExtra.auto
25
 
except ImportError:
26
 
    print >> sys.stderr, 'To build translate-html you need https://launchpad.net/python-distutils-extra'
27
 
    sys.exit(1)
28
 
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
29
 
 
30
 
def update_config(values = {}):
31
 
 
32
 
    oldvalues = {}
33
 
    try:
34
 
        fin = file('translate_html/translate_htmlconfig.py', 'r')
35
 
        fout = file(fin.name + '.new', 'w')
36
 
 
37
 
        for line in fin:
38
 
            fields = line.split(' = ') # Separate variable from value
39
 
            if fields[0] in values:
40
 
                oldvalues[fields[0]] = fields[1].strip()
41
 
                line = "%s = %s\n" % (fields[0], values[fields[0]])
42
 
            fout.write(line)
43
 
 
44
 
        fout.flush()
45
 
        fout.close()
46
 
        fin.close()
47
 
        os.rename(fout.name, fin.name)
48
 
    except (OSError, IOError), e:
49
 
        print ("ERROR: Can't find translate_html/translate_htmlconfig.py")
50
 
        sys.exit(1)
51
 
    return oldvalues
52
 
 
53
 
 
54
 
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
55
 
    def run(self):
56
 
        values = {'__translate_html_data_directory__': "'%s'" % (self.prefix + '/share/translate-html/'),
57
 
                  '__version__': "'%s'" % (self.distribution.get_version())}
58
 
        previous_values = update_config(values)
59
 
        DistUtilsExtra.auto.install_auto.run(self)
60
 
        update_config(previous_values)
61
 
 
62
 
 
63
 
        
64
 
##################################################################################
65
 
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
66
 
##################################################################################
67
 
 
68
 
DistUtilsExtra.auto.setup(
69
 
    name='translate-html',
70
 
    version='0.1',
71
 
    license='GPL-3',
72
 
    #author='Your Name',
73
 
    #author_email='email@ubuntu.com',
74
 
    #description='UI for managing …',
75
 
    #long_description='Here a longer description',
76
 
    #url='https://launchpad.net/translate-html',
77
 
    cmdclass={'install': InstallAndUpdateDataDirectory}
78
 
    )
79