Ninovolador created this task.
Ninovolador added a project: Pywikibot.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
  **Feature summary**:
  I would like to easily create multiple <pages /> tags using pywikibot. 
However, when I create a new instance of PagesTagParser and asign the 
attributes, the parser fails when the values have two or more words, as it 
doesn't add quotes automatically as one might expect
  
    tag = PagesTagParser()  
    tag.index = 'Sample index with more than two words.pdf'
    tag.ffrom = 5
    tag.to = "6"
    tag.fromsection = '"chapter XVI"'
    print(tag)
  
  > '<pages index=Sample index with more than two words.pdf from=5 to=6 
fromsection="chapter XVI" />'
  
  This <pages> tag won't display accordingly, as there is no "Sample" index 
page.
  
  I propose the following changes on the definition of PagesTagParser, on 
proofreadpage.py (lines 137 onwards)
  
    if ' ' in str(value) and '"' not in value and "'" not in value:
        self._orig_value = f'"{value}"'
    else:
        self._orig_value = value
  
  this might be not in the coding style of pywikibot, but it does the work and 
it doesn't make a mess when you explicitly add the quotes.
  
    tag = PagesTagParser()  
    tag.index = 'Sample index with more than two words.pdf'
    tag.ffrom = 5
    tag.to = "6"
    tag.fromsection = '"chapter XVI"'
    print(tag)
  
  > <pages index="Sample index with more than two words.pdf" from=5 to=6 
fromsection="chapter XVI" />

TASK DETAIL
  https://phabricator.wikimedia.org/T383506

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Ninovolador
Cc: Aklapper, pywikibot-bugs-list, Ninovolador, mevo, PotsdamLamb, Jyoo1011, 
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho, 
MayS, Mdupont, JJMC89, Dvorapa, Altostratus, Avicennasis, Hannolans, mys_721tx, 
Xqt, jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to