Beispiel #1
0
 def add_poems(self, *a):
     open_dlg = Gtk.FileChooserDialog(u'إضافة دوواوين وقصائد جديدة',
                                      self.parent, Gtk.FileChooserAction.OPEN,
                                     (Gtk.STOCK_OK, Gtk.ResponseType.OK,
                                      Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
     open_dlg.set_select_multiple(True)
     Filter = Gtk.FileFilter()
     Filter.set_name(u"ملفات .dwn")
     Filter.add_pattern("*.[dD][wW][nN]")
     open_dlg.add_filter(Filter)
     
     res = open_dlg.run()
     if res == Gtk.ResponseType.OK:
         for filename in open_dlg.get_filenames():
             ls_poems = self.parent.db.add_file_db(filename)     
             for poem in ls_poems:
                 i = poem[0]
                 name = poem[1]
                 if poem[2] != 0: n_poet, l_poet = self.parent.db.name_poet_newfile(poem[2], filename)
                 else: l_poet = u'أحدهم'
                 if poem[5] != 9: age = daw_tools.get_name(daw_tools.age_poet, poem[5])
                 else: age = u'____'
                 abiat = poem[6]
                 if poem[7] != 0: baher = daw_tools.get_name(daw_tools.elbehor, poem[7])
                 else: baher = u'____'
                 if poem[8] != 0: rawi = daw_tools.get_name(daw_tools.elrawi, poem[8])
                 else: rawi = u'____'
                 if poem[11] != 0: gharadh = daw_tools.get_name(daw_tools.elgharadh, poem[11])
                 else: gharadh = u'____'
                 if poem[12] != 0: naw3 = daw_tools.get_name(daw_tools.elnaw3, poem[12])
                 else: naw3 = u'____'
                 source = basename(filename)
                 self.poems_store_import.append([i, True, name, l_poet, age, naw3, baher, gharadh, rawi, abiat, filename, source])
     open_dlg.destroy()
     self.all_poems.set_active(True)
Beispiel #2
0
 def load_poems(self, v):
     self.poems_store.clear()
     self.names_list = []
     self.modelfilter = self.poems_store.filter_new()
     if len(self.poems_id) != 0:
         for a in range(v*50, (v+1)*50):
             if a < len(self.poems_id):
                 ls = self.parent.db.poem_info(self.poems_id[a])
                 i = self.poems_id[a]
                 name = ls[1]
                 if ls[2] != 0: n_poet, l_poet = self.parent.db.name_poet(ls[2])
                 else: l_poet = u'أحدهم'
                 abiat = ls[6]
                 if ls[7] != 0: baher = daw_tools.get_name(daw_tools.elbehor, ls[7])
                 else: baher = u'____'
                 if ls[8] != 0: rawi = daw_tools.get_name(daw_tools.elrawi, ls[8])
                 else: rawi = u'____'
                 if ls[11] != 0: gharadh = daw_tools.get_name(daw_tools.elgharadh, ls[11])
                 else: gharadh = u'____'
                 if ls[12] != 0: naw3 = daw_tools.get_name(daw_tools.elnaw3, ls[12])
                 else: naw3 = u'____'
                 self.poems_store.append([i, name, l_poet, naw3, baher, gharadh, rawi, abiat])
                 self.names_list.append(name)
     self.theword = self.names_list[:]
     self.modelfilter.set_visible_func(self.visible_cb, self.theword) 
     self.tree_poems.set_model(self.modelfilter)
Beispiel #3
0
 def get_nabdha(self, id_poem):
     text = u'\n\
     - الشاعر : {} \n\
     - القصيدة : {} \n\
     - الأبيات : {} \n\
     - الغرض : {} \n\
     - البحر : {} \n\
     - سبب النظم : {} \n' .format(
     self.name_poet, 
     self.parent.db.name_poem(id_poem), 
     self.parent.db.abiat_poem(id_poem), 
     daw_tools.get_name(daw_tools.elgharadh, self.parent.db.gharadh_poem(id_poem)),
     daw_tools.get_name(daw_tools.elbehor, self.parent.db.get_id_baher(id_poem)), 
     self.text_sabab)
     return text
Beispiel #4
0
 def a3aridh_elbaher(self, *a):
     model = self.arodh.get_model()
     model.clear()
     baher = daw_customs.value_active(self.baher)
     if baher == None: return
     a3aridh = daw_tools.ela3aridh_in_behor[baher]
     for a in a3aridh:
         nm = daw_tools.get_name(daw_tools.ela3aridh, a)
         model.append([a, nm])
Beispiel #5
0
 def ok_poet(self, *a):
     model, i = self.sel_poet.get_selected()
     if i:
         id_poet = model.get_value(i,0)
         list_poems, tarjama = self.db.poems_of_poet(id_poet)
         self.tarjama_bfr.set_text(tarjama)
         ls = [tarjama.splitlines(1)[0],]
         daw_customs.with_tag(self.tarjama_bfr, self.tarjama_tag, ls)
         self.poems_store.clear()
         n = self.notebook.get_current_page()
         if n > 1:
             self.notebook.set_current_page(daw_config.getn('open'))
         if len(list_poems) != 0:
             self.names_list0 = []
             self.modelfilter0 = self.poems_store.filter_new()
             for a in list_poems:
                 i = a[0]
                 rakm = list_poems.index(a, )+1
                 name = a[1]
                 abiat = a[2]
                 if a[3] != 0: baher = daw_tools.get_name(daw_tools.elbehor, a[3])
                 else: baher = u'____'
                 if a[4] != 0: rawi = daw_tools.get_name(daw_tools.elrawi, a[4])
                 else: rawi = u'____'
                 if a[6] != 0: gharadh = daw_tools.get_name(daw_tools.elgharadh, a[6])
                 else: gharadh = u'____'
                 if a[7] != 0: naw3 = daw_tools.get_name(daw_tools.elnaw3, a[7])
                 else: naw3 = u'____'
                 self.poems_store.append([i, rakm, name, naw3, baher, gharadh, rawi, abiat])
                 self.names_list0.append(name)
             self.theword0 = self.names_list0[:]
             self.modelfilter0.set_visible_func(self.visible_cb0, self.theword0) 
             self.tree_poems.set_model(self.modelfilter0)
         lab = '  .: {} :.    عدد القصائد : {} ، عدد الأبيات : {}'.format((self.db.name_poet(id_poet)[1]).encode('utf8'),
                                                       self.db.n_poems_poet(id_poet).decode('utf8'),
                                                       self.db.n_verses_poet(id_poet).decode('utf8'))
         self.lab_count.set_label(lab)
Beispiel #6
0
 def a3aridh_elbaher(self, *a):
     #self.refresh(self.select_page, 9)
     model = self.arodh.get_model()
     model.clear()
     baher = daw_customs.value_active(self.baher)
     model.append([0, 'الكل'])
     if baher == 0:
         for a in daw_tools.ela3aridh:
             model.append(a)
         self.arodh.set_active(0)
         return
     a3aridh = daw_tools.ela3aridh_in_behor[baher]
     for a in a3aridh:
         nm = daw_tools.get_name(daw_tools.ela3aridh, a)
         model.append([a, nm])
     self.arodh.set_active(0)
Beispiel #7
0
 def search(self, text, dict_perf, selected_list):
     self.text = text
     self.cursive = dict_perf['cursive']
     text = text.replace('"','')
     text = text.replace("'","")
     ls_term = []
     if dict_perf['with_tachkil'] == True: 
         cond = 'nasse LIKE ?'
     else:
         cond = 'fuzzy(nasse) LIKE ?'
         text = daw_araby.fuzzy_plus(text)
     if dict_perf['identical'] == True:  pfx, sfx = '% ', ' %'
     else: pfx, sfx = '%', '%'
     if dict_perf['cursive'] == True:
         self.condition = 'fuzzy(nasse) LIKE ?'
         ls_term.append(pfx+text+sfx)
     else: 
         for a in text.split(u' '):
             ls_term.append(pfx+a+sfx)
         #if dict_perf['one_verse'] == True:
         #    self.condition = u'fuzzy(nasse) LIKE ?'
         #    ls_term = ['%'+u'%[.+]%'.join(text.split(u' '))+u'%',]
         #else:
         if dict_perf['one_term'] == True:
             self.condition = ' OR '.join([cond]*len(ls_term))
         else :
             self.condition = ' AND '.join([cond]*len(ls_term))
     n = 0
     for a in selected_list:
         ls = self.parent.db.poems_id(a)
         for b in ls:
             check = self.parent.db.search(b, self.condition, ls_term)
             if check == True:
                 n += 1
                 self.results_store.append([b, n, self.parent.db.name_poem(b),
                                            self.parent.db.name_poet(self.parent.db.id_poet(b))[1],
                                            daw_tools.get_name(daw_tools.elbehor, self.parent.db.get_id_baher(b)),
                                            daw_tools.get_name(daw_tools.elgharadh, self.parent.db.gharadh_poem(b)),
                                            daw_tools.get_name(daw_tools.elrawi, self.parent.db.rawi_poem(b)),])
                 self.results_list.append([b, n, self.parent.db.name_poem(b),
                                            self.parent.db.name_poet(self.parent.db.id_poet(b))[1],
                                            daw_tools.get_name(daw_tools.elbehor, self.parent.db.get_id_baher(b)),
                                            daw_tools.get_name(daw_tools.elgharadh, self.parent.db.gharadh_poem(b)),
                                            daw_tools.get_name(daw_tools.elrawi, self.parent.db.rawi_poem(b)),])
             else: pass
     if len(self.results_list)>0:
         output = open(join(daw_customs.HOME_DIR,'آخر بحث.pkl'), 'wb')
         cPickle.dump(self.results_list, output)
         output.close()