@@ -80,18 +80,18 @@ def _init_entri(self, laman):
8080 sup = BeautifulSoup (laman .text , "html.parser" )
8181 estr = ""
8282 self .entri = []
83- for label in sup .find ("hr" ).next_siblings :
84- if label .name == "hr" :
85- if label .get ("style" ) is None :
86- self .entri .append (Entri (estr , self .terautentikasi ))
87- break
83+ label = sup .find ("hr" ).next_sibling
84+ while not (label .name == "hr" and label .get ("style" ) is None ):
8885 if label .name == "h2" :
89- if label .get ("style" ) == "color:gray" :
86+ if label .get ("style" ) == "color:gray" : # Lampiran
87+ label = label .next_sibling
9088 continue
9189 if estr :
9290 self .entri .append (Entri (estr , self .terautentikasi ))
93- estr = ""
91+ estr = ""
9492 estr += str (label ).strip ()
93+ label = label .next_sibling
94+ self .entri .append (Entri (estr , self .terautentikasi ))
9595
9696 def serialisasi (self , fitur_pengguna = True ):
9797 """Mengembalikan hasil serialisasi objek KBBI ini.
@@ -134,8 +134,6 @@ def __init__(self, entri_html, terautentikasi=False):
134134
135135 def _init_nama (self , judul ):
136136 self .nama = ambil_teks_dalam_label (judul , ambil_italic = True )
137- if not self .nama :
138- self .nama = judul .find_all (text = True )[0 ].strip ()
139137
140138 def _init_nomor (self , judul ):
141139 nomor = judul .find ("sup" , recursive = False )
@@ -254,8 +252,7 @@ def _makna(self, contoh=True):
254252 f"{ i } . { makna .__str__ (contoh = contoh )} "
255253 for i , makna in enumerate (self .makna , 1 )
256254 )
257- if len (self .makna ) == 1 :
258- return self .makna [0 ].__str__ (contoh = contoh )
255+ return self .makna [0 ].__str__ (contoh = contoh )
259256
260257 def _nama (self ):
261258 hasil = self .nama
@@ -456,8 +453,7 @@ def _arti(self):
456453 def __str__ (self ):
457454 hasil = f"[{ self .bahasa } ]" if self .bahasa else ""
458455 hasil += f" { self ._kelas ()} " if self .kelas else ""
459- if self .asal_kata or self .pelafalan :
460- hasil += f" { self ._asal_kata ()} "
456+ hasil += f" { self ._asal_kata ()} "
461457 hasil += f": { self ._arti ()} " if self .arti else ""
462458 return hasil
463459
0 commit comments