Vanderhoof/PyDBML

bug here

Closed this issue · 2 comments

hi, i have tried pydbml and it has a bug here:
once you try to parse this snippet using pddbml,

enum business_type {
  Repaid [note: ""]
  Refund [note: ""]
  Rebalance [note: ""]
}

the error occus:

  File ".../lib/python3.9/site-packages/pydbml/tools.py", line 44, in strip_empty_lines
    while not lines[first_line] or lines[first_line].isspace():
IndexError: list index out of range

the reason is note: "" , the empty note was passed to strip_empty_lines function.

the related code in tools.py:

// the passed param source is ""
def strip_empty_lines(source: str) -> str:
    """Remove empty lines or lines with just spaces from beginning and end."""
    first_line = 0
    lines = source.split('\n')
    last_line = len(lines) - 1
    while not lines[first_line] or lines[first_line].isspace():
        first_line += 1
    while not lines[last_line] or lines[last_line].isspace():
        last_line -= 1
    return '\n'.join(lines[first_line: last_line + 1])

hope you can fix this issue, thx

Thanks for the report! I'll fix it

Fixed in 1.0.6
oops, fixed in 1.0.7