1
by Hemanth
Initial project creation with Quickly! |
1 |
#!/usr/bin/env python
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
### BEGIN LICENSE
|
|
10
by Hemanth
commit before release |
4 |
# Copyright (C) 2010 hemanth.hm hemanth.hm@gmail.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/>.
|
|
1
by Hemanth
Initial project creation with Quickly! |
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 rfc-search 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_data_path(prefix, oldvalue=None): |
|
31 |
||
32 |
try: |
|
33 |
fin = file('rfc_search/rfc_searchconfig.py', 'r') |
|
34 |
fout = file(fin.name + '.new', 'w') |
|
35 |
||
36 |
for line in fin: |
|
37 |
fields = line.split(' = ') # Separate variable from value |
|
38 |
if fields[0] == '__rfc_search_data_directory__': |
|
39 |
# update to prefix, store oldvalue
|
|
40 |
if not oldvalue: |
|
41 |
oldvalue = fields[1] |
|
42 |
line = "%s = '%s'\n" % (fields[0], prefix) |
|
43 |
else: # restore oldvalue |
|
44 |
line = "%s = %s" % (fields[0], oldvalue) |
|
45 |
fout.write(line) |
|
46 |
||
47 |
fout.flush() |
|
48 |
fout.close() |
|
49 |
fin.close() |
|
50 |
os.rename(fout.name, fin.name) |
|
51 |
except (OSError, IOError), e: |
|
52 |
print ("ERROR: Can't find rfc_search/rfc_searchconfig.py") |
|
53 |
sys.exit(1) |
|
54 |
return oldvalue |
|
55 |
||
56 |
||
57 |
def update_desktop_file(datadir): |
|
58 |
||
59 |
try: |
|
60 |
fin = file('rfc-search.desktop.in', 'r') |
|
61 |
fout = file(fin.name + '.new', 'w') |
|
62 |
||
63 |
for line in fin: |
|
64 |
if 'Icon=' in line: |
|
65 |
line = "Icon=%s\n" % (datadir + 'media/icon.png') |
|
66 |
fout.write(line) |
|
67 |
fout.flush() |
|
68 |
fout.close() |
|
69 |
fin.close() |
|
70 |
os.rename(fout.name, fin.name) |
|
71 |
except (OSError, IOError), e: |
|
72 |
print ("ERROR: Can't find rfc-search.desktop.in") |
|
73 |
sys.exit(1) |
|
74 |
||
75 |
||
76 |
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto): |
|
77 |
def run(self): |
|
78 |
previous_value = update_data_path(self.prefix + '/share/rfc-search/') |
|
79 |
update_desktop_file(self.prefix + '/share/rfc-search/') |
|
80 |
DistUtilsExtra.auto.install_auto.run(self) |
|
81 |
update_data_path(self.prefix, previous_value) |
|
82 |
||
83 |
||
84 |
||
85 |
##################################################################################
|
|
86 |
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
|
|
87 |
##################################################################################
|
|
88 |
||
89 |
DistUtilsExtra.auto.setup( |
|
90 |
name='rfc-search', |
|
23
by Hemanth
commit before release |
91 |
version='1.0', |
10
by Hemanth
commit before release |
92 |
license='GPL-3', |
93 |
author='Hemanth', |
|
94 |
author_email='hemanth.hm@gmail.com', |
|
1
by Hemanth
Initial project creation with Quickly! |
95 |
#description='UI for managing …',
|
96 |
#long_description='Here a longer description',
|
|
10
by Hemanth
commit before release |
97 |
url='https://launchpad.net/rfc', |
1
by Hemanth
Initial project creation with Quickly! |
98 |
cmdclass={'install': InstallAndUpdateDataDirectory} |
99 |
)
|
|
100 |