ifcode.startswith("elif "):pass# can always remove those lines completely, even if will be followed by an 'else'
elifcode.startswith("if "):
suppressed_if=(indentLevel<=lastIndentLevel)
ifnotsuppressed_if:print""*indentLevel+"pass # trimmed"# just in case there's nothing else in the block
ifcode.startswith("elif "):pass# can always remove those lines completely, even if will be followed by an 'else' (and will never be the only thing in its block)
else:
ifcode.startswith("if "):code="if 0:"
print""*indentLevel+code+" pass # trimmed"
suppressed_if=0
revertToIndent=indentLevel
elifnotcode:
if"# "inlorlCount<2:printl# keep start and GPL comments
else:
ifsuppressed_ifandindentLevel==justRevertedI:
ifcode.startswith("elif "):
l=l.replace("elif","if",1)
code0=code0.replace("elif","if",1)
elifcode=="else:":
l=l.replace("else:","if 1: # trimmed",1)
code0=code0.replace("else:","if 1: # trimmed",1)
elifcode.startswith("else:"):
l=re.subn(r"else:\s*","",l,1)[0]
code0=re.subn(r"else:\s*","",code0,1)[0]
suppressed_if=0
if ('"'incodeand'"'inl[len(code):])or("'"incodeand"'"inl[len(code):]):printl# perhaps # was in a string, keep it
else:printcode0
elif ('"'incodeand'"'inl[len(code):])or("'"incodeand"'"inl[len(code):]):printl# perhaps # was in a string, keep it
else:printcode0
orig="".join(orig)
forointo_omit:
ifnotoinorig:sys.stderr.write("Warning: line not matched: "+o)