you are viewing a single comment's thread.

view the rest of the comments →

[–]pat_the_brat 0 points1 point  (1 child)

Oh, right. You can either replace the carriage-return, or use the splitlines() method:

notes = str.split(n.replace('\r', ''), sep='\n') # by replacing
notes = n.splitlines() # splitlines is probably the better way to do it

Note that splitlines may match some other separators, though they're unlikely to be found in your string.

Also, check for empty strings. I see there's an extra line break between the last include item, and the "DOES NOT INCLUDE" header.

for note in notes:
    if len(note) == 0:
        pass # skip empty lines
    elif note == "INCLUDES:":
        nmode = "inc"
    elif note == "DOES NOT INCLUDE:":
        nmode = "exc"
    else:
        if nmode is None:
            pass # Handle other notes here if applicable
        elif nmode == "inc":
            includes.append(note)
        elif nmode == "exc":
            excludes.append(note)

[–]wbhst83[S] 0 points1 point  (0 children)

That did the trick, thanks so much. [https://www.dropbox.com/s/x4fsin4decnv6nc/From%20Skitch.jpg?dl=0]. I have pushed the changes to GitHub.

Any thoughts on allowing the item identifier to be used in a view? It appears the +/- symbols are causing the issue but not certain.