[library-web] [app] fixed symbols extraction
- From: Frederic Peters <fpeters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [library-web] [app] fixed symbols extraction
- Date: Wed, 12 Aug 2009 07:58:19 +0000 (UTC)
commit 34a853f2dcd5cec15e54a5f7fe7357f6f3cab1e4
Author: Frédéric Péters <fpeters 0d be>
Date: Wed Aug 12 09:56:27 2009 +0200
[app] fixed symbols extraction
src/app.py | 61 +++++++++++++++++++++++++++++++++++------------------------
src/lgo.py | 5 ----
2 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/src/app.py b/src/app.py
index 0f72c35..c0682f2 100644
--- a/src/app.py
+++ b/src/app.py
@@ -25,6 +25,16 @@ import shutil
import stat
import urllib2
+try:
+ from pysqlite2 import dbapi2 as sqlite
+except ImportError:
+ sqlite = None
+
+try:
+ import elementtree.ElementTree as ET
+except ImportError:
+ import xml.etree.ElementTree as ET
+
from config import Config
import utils
@@ -159,38 +169,39 @@ class App:
sqlcon = None
sqlcur = None
- def symbols_iterator():
- for doc in self.documents:
- if doc.category != 'api':
- continue
- if not doc.module or not doc.path:
- continue
-
- web_dir = os.path.join(app.config.output_dir, doc.path[1:])
-
- devhelp_path = os.path.join(web_dir, '%s.devhelp2' % doc.module)
- if os.path.exists(devhelp_path):
- tree = ET.parse(devhelp_path)
- for keyword in tree.findall('//{http://www.devhelp.net/book}keyword'):
- key = keyword.attrib.get('name').replace('()', '').strip()
- if not key or ' ' in key:
- # ignore keys with spaces in their name
- continue
- value = os.path.join(doc.path, keyword.attrib.get('link'))
- if httxt2dbm:
- print >> httxt2dbm, key, value
- yield (key, value)
- return
-
# if active, the dbm symbol file will be generated while iterating for
# SQLite.
if sqlcur:
- sqlcur.executemany('insert into symbols values (?, ?)', symbols_iterator())
+ sqlcur.executemany('insert into symbols values (?, ?)',
+ self.symbols_iterator(httxt2dbm))
sqlcur.execute('create index symbols_idx on symbols(symbol)')
else:
- for x in symbols_iterator():
+ for x in self.symbols_iterator(httxt2dbm):
pass
if httxt2dbm:
httxt2dbm.close()
+ def symbols_iterator(self, httxt2dbm=None):
+ for doc in self.documents:
+ if doc.category != 'api':
+ continue
+ if not doc.module or not doc.path:
+ continue
+
+ web_dir = os.path.join(app.config.output_dir, doc.path[1:])
+
+ devhelp_path = os.path.join(web_dir, '%s.devhelp2' % doc.module)
+ if os.path.exists(devhelp_path):
+ tree = ET.parse(devhelp_path)
+ for keyword in tree.findall('//{http://www.devhelp.net/book}keyword'):
+ key = keyword.attrib.get('name').replace('()', '').strip()
+ if not key or ' ' in key:
+ # ignore keys with spaces in their name
+ continue
+ value = os.path.join(doc.path, keyword.attrib.get('link'))
+ if httxt2dbm:
+ print >> httxt2dbm, key, value
+ yield (key, value)
+ return
+
diff --git a/src/lgo.py b/src/lgo.py
index e9300c8..2c2fc50 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -37,11 +37,6 @@ import shutil
import socket
import __builtin__
-try:
- from pysqlite2 import dbapi2 as sqlite
-except ImportError:
- sqlite = None
-
data_dir = os.path.join(os.path.dirname(__file__), '../data')
__builtin__.__dict__['data_dir'] = data_dir
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]