File: gen-index_setup.py.diff

package info (click to toggle)
othman 0.6.0-3
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 3,512 kB
  • sloc: python: 923; makefile: 63
file content (60 lines) | stat: -rw-r--r-- 1,921 bytes parent folder | download | duplicates (2)
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
Description: Move call to generate Qur'an index from Makefile to setup.py
 That would make the package build even if python2.5 is the default python.
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy@users.sourceforge.net>
Forwarded: no

Index: othman/Makefile
===================================================================
--- othman.orig/Makefile	2019-10-18 02:50:31.727167557 +0200
+++ othman/Makefile	2019-10-18 02:50:31.723167540 +0200
@@ -7,7 +7,7 @@
 TARGETS=${SOURCES:.in=}
 TEST_DEPS=0
 
-all: $(TARGETS) icons othman-data/ix.db
+all: $(TARGETS) icons
 
 icons:
 	install -d icons; 
Index: othman/setup.py
===================================================================
--- othman.orig/setup.py	2019-10-18 02:50:31.727167557 +0200
+++ othman/setup.py	2019-10-18 02:50:31.723167540 +0200
@@ -8,6 +8,29 @@
 # to install type: 
 # python setup.py install --root=/
 
+from distutils.command.build import build
+from distutils.command.clean import clean
+
+class my_build(build):
+  def run(self):
+    build.run(self)
+    # generate data
+    from othman.core import othmanCore, searchIndexer
+
+    if not os.path.isfile('othman-data/ix.db'):
+      q=othmanCore(False)
+      ix=searchIndexer(True)
+      for n,(o,i) in enumerate(q.getAyatIter(1, 6236)):
+        for w in i.split(): ix.addWord(w,n+1)
+      d=os.path.dirname(sys.argv[0])
+      ix.save()
+
+class my_clean(clean):
+  def run(self):
+    clean.run(self)
+    try: os.unlink('othman-data/ix.db')
+    except OSError: pass
+
 locales=map(lambda i: ('share/'+i,[''+i+'/othman.mo',]),glob('locale/*/LC_MESSAGES'))
 data_files=[('share/othman/',glob('othman-data/*'))]
 data_files.extend(locales)
@@ -31,6 +54,7 @@
           "Programming Language :: Python :: 3.6",
           "Programming Language :: Python :: 3.7",
           ],
+      cmdclass={'build': my_build, 'clean': my_clean},
       data_files=data_files
 )