Ejemplo n.º 1
0
 def getBookMeta(self, bkid):
   if self.__meta_by_bkid.has_key(bkid): return self.__meta_by_bkid[bkid]
   else:
     r=self.c.execute('SELECT bk, shortname, cat, betaka, inf, bkord, authno, auth, higrid, ad, islamshort FROM main WHERE bkid=?', (bkid,)).fetchone()
     if not r: m=None
     else:
       r=dict(r)
       # FIXME: make "releaseMajor" "releaseMinor" integers
       m={
         "repo":"_user", "lang":"ar", "type": int(self._is_tafseer(bkid)),
         "version":"0."+str(bkid), "releaseMajor":0, "releaseMinor":0,
         'originalKitab':None, 'originalVersion':None,
         'originalAuthor':None, 'originalYear':None
       }
       m['kitab']=makeId(r['bk'])
       m['author'],m['year']=self.authorByID(r['authno'], r)
       m['classification']=self.classificationByBookId(bkid)
       m['keywords']=u''
       matn_bkid=self._get_matn(bkid)
       #print "%d is sharh for %d" % (bkid, matn_bkid)
       if matn_bkid>0:
         matn_m=self.getBookMeta(matn_bkid)
         if matn_m:
           m['originalKitab']=matn_m['kitab']
           m['originalVersion']=matn_m['version']
           m['originalAuthor']=matn_m['author']
           m['originalYear']=matn_m['year']
     self.__meta_by_bkid[bkid]=m
     return m
Ejemplo n.º 2
0
 def getBookMeta(self, bkid):
     if self.__meta_by_bkid.has_key(bkid):
         return self.__meta_by_bkid[bkid]
     else:
         r = self.c.execute('SELECT bk, shortname, cat, betaka, inf, bkord, authno, auth, higrid, ad, islamshort FROM main WHERE bkid = ?', (bkid,)).fetchone()
         if not r:
             m = None
         else:
             r = dict(r)
             # FIXME: make "releaseMajor" "releaseMinor" integers
             m = {
                 "repo":"_user", "lang":"ar", "type": int(self._is_tafseer(bkid)),
                 "version":"0."+str(bkid), "releaseMajor":0, "releaseMinor":0,
                 'originalKitab':None, 'originalVersion':None,
                 'originalAuthor':None, 'originalYear':None
             }
             m['kitab'] = makeId(r['bk'])
             m['author'], m['year'] = self.authorByID(r['authno'], r)
             m['classification'] = self.classificationByBookId(bkid)
             m['keywords'] = u''
             matn_bkid = self._get_matn(bkid)
             #print "%d is sharh for %d" % (bkid, matn_bkid)
             if matn_bkid>0:
                 matn_m = self.getBookMeta(matn_bkid)
                 if matn_m:
                     m['originalKitab'] = matn_m['kitab']
                     m['originalVersion'] = matn_m['version']
                     m['originalAuthor'] = matn_m['author']
                     m['originalYear'] = matn_m['year']
         self.__meta_by_bkid[bkid] = m
         return m
Ejemplo n.º 3
0
 def _get_kitab_details(self, rq, *args):
     ki, m = self._getKitabObject(rq, *args)
     if not ki or not m:
         return None, None, {}
     lang = m.get('lang', 'ar')
     if lang in ('ar', 'fa', 'he'):
         d = 'rtl'
     else:
         d = 'ltr'
     kitabId = escape(makeId(m['kitab']))
     t = escape(prettyId(m['kitab']))
     r = self._emptyViewResp.copy()
     r.update({
         u"script": rq.script,
         u"kitabTitle": t,
         u"kitabId": kitabId,
         u"headingId": u"_i0",
         u"app": u"Thawab",
         u"version": u"3.0.1",
         u"lang": lang,
         u"dir": d,
         u"title": t,
         u"content": t,
         "args": '/'.join(args)
     })
     return ki, m, r
Ejemplo n.º 4
0
 def getIndexedVersion(self, name):
   """
   return a Version-Release string if in index, otherwise return None
   """
   try: d=self.__ix_searcher.document(kitab=unicode(makeId(name)))
   except TypeError: return None
   except KeyError: return None
   if d: return d['vrr']
   return None
Ejemplo n.º 5
0
 def getIndexedVersion(self, name):
     """
 return a Version-Release string if in index, otherwise return None
 """
     try:
         d = self.__ix_searcher.document(kitab=unicode(makeId(name)))
     except TypeError:
         return None
     except KeyError:
         return None
     if d: return d['vrr']
     return None
Ejemplo n.º 6
0
 def authorByID(self, authno, main_tb={}):
   # TODO: use authno to search shamela specific database
   a,y='_unset',0
   if main_tb:
     a=makeId(main_tb.get('auth','') or '')
     y=main_tb.get('higrid',0) or 0
     if not y: y=main_tb.get('ad',0) or 0
     if isinstance(y,basestring) and y.isdigit():
       y=int(y)
     else:
       m=digits_re.search(unicode(y))
       if m: y=int(m.group(0))
       else: y=0
   return a,y
Ejemplo n.º 7
0
 def _get_kitab_details(self, rq, *args):
   ki,m=self._getKitabObject(rq, *args)
   if not ki or not m: return None,None, {}
   lang=m.get('lang','ar')
   if lang in ('ar','fa','he'): d='rtl'
   else: d='ltr'
   kitabId=escape(makeId(m['kitab']))
   t=escape(prettyId(m['kitab']))
   r=self._emptyViewResp.copy()
   r.update({
     u"script":rq.script,
     u"kitabTitle":t,
     u"kitabId":kitabId,
     u"headingId":u"_i0",
     u"app":u"Thawab", u"version":u"3.0.1",
     u"lang":lang, u"dir":d,
     u"title": t,
     u"content": t,
     "args":'/'.join(args)})
   return ki,m,r