View Single Post
Old 04-11-2020, 12:54 PM   #17
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
Well, attached is a new version, with:
- Option 'no tags' removed--it couldn't even be reported, lacking a list of tags for reference.
- Added a message (Qt) with buttons to choose on the fly if run only for reports (default -> OK) or to apply the changes (Cancel).
That would be useful before choosing to add/remove tags from preferences.
- Changed the versioning: this is v1_0, (implicitly making previous ones 0_x)
- Automatically sort the tag list (easier to inspect/edit), besides trying to ensure that it works.
Unfortunately, as it MUST be a comma-separated list, without spaces, the code is quite clumsy. A less unwieldy alternative would be appreciated.
Spoiler:
Code:
# protect editable string from mistype
def sanitize(string):
    if string != (' '):
        string = string.replace(' ','')
        string = string.replace(',,',',')
        string = string.lower()
        lstring = string.split(',')
        ostring = sorted(lstring)[0]
        for s in sorted(lstring)[1:]: # list of comma-separated strings
            ostring = ostring + "," + s
        # MUST be list of words(=tag names) comma-separated & without spaces
        string = ostring.replace(' ','')
    else:
        string = ' ' # Avoid bk.savePrefs(prefs) deleting the "tags" entry?--general havoc
    return string

* Query: are buttons of the message easy to understand, o rather counter-intuitive?

Last edited by carmenchu; 04-11-2020 at 03:34 PM.
carmenchu is offline   Reply With Quote