yashsinghcodes / wik

wik is use to get information about anything on the shell using Wikipedia.
https://pypi.org/project/wik/
MIT License
616 stars 22 forks source link

error parsing Quotebox #20

Closed jklebes closed 3 months ago

jklebes commented 3 months ago

Nice software.

wik -i Lahore gets me

...
History
---------
[-] Taank Kingdom 550–950Hindu Shahis 1001–1020  Ghaznavid Empire 1020–1186 Delhi Sultanate 1186–1223 Khwarazmian Empire 1223–1228 Delhi Sultanate 1228–1241 Mongol Empire 1241– 1266 Delhi Sultanate 1266–1287 Mongol Empire 1287–1305 Delhi Sultanate 1320–1325 Chagatai Khanate 1329 Khokars 1394–1398 Timurid Empire 1398–1414 Delhi Sultanate 1414–1524 Mughal Empire 1524–1540Suri Empire 1540–1550  Mughal Empire 1550–1739  Afsharid Empire 1739   Durrani Empire 1748–1758   Maratha Empire 1758–1759   Durrani Empire 1759–1765 Sikh Misls 1767–1799   Sikh Empire 1799–1846   British East India Company 1846–1858    British Raj / British Empire 1858–1947   Pakistan 1947– present

Traceback (most recent call last):
  File "/usr/local/bin/wik", line 8, in <module>
    sys.exit(arguments())
  File "/usr/local/lib/python3.10/dist-packages/wik/wik.py", line 24, in arguments
    info.getInfo(a.info, a.lang)
  File "/usr/local/lib/python3.10/dist-packages/wik/info.py", line 136, in getInfo
    if str(i[0]) == "!":

This section of content at the bottom of the box

<p style="padding-bottom: 0em;"></p>

is turned into a zero-length string.

yashsinghcodes commented 3 months ago

Thank @jklebes for bringing it to my attention. I will look into it and if you want I can assign it to you :)

jklebes commented 3 months ago

You can assign me. But how do you run your unit tests? hatch test test/test.py didn't do it.

yashsinghcodes commented 3 months ago

Hey @jklebes, sorry to be late I'll assign you for this :)

As for the test I don't think it works anymore as wikipedia contents changes time on time it would be hard to implement any direct assertion. Still the script does not run as it is not in actual test format and there were addition of unicode color in the text which just breaks it entirely.

yashsinghcodes commented 3 months ago

The codebase is very messy so good luck.

yashsinghcodes commented 3 months ago

I did write a new test and it should work for now :)

jklebes commented 3 months ago

Yes the "Lahore" case works now / bug can't be reproduced, even without changing the code. Something changed on wikipedia. <p style="padding-bottom: 0em;"></p> is no longer in the html source. I'll fix it when I find another broken example to test.

yashsinghcodes commented 3 months ago

Sure :+1:

I'm closing it for now. If in future you face anything similar feel free to reopen it again or you can create a new issue.