Skip to content

Instantly share code, notes, and snippets.

@moonexpr
Created April 6, 2022 02:02
Show Gist options
  • Save moonexpr/553f24f959a01d64b65d3977e634c5c8 to your computer and use it in GitHub Desktop.
Save moonexpr/553f24f959a01d64b65d3977e634c5c8 to your computer and use it in GitHub Desktop.
Small curly-brace validator for anything. (Used for Valve Data Format)
#!/usr/bin/env python
import sys
import os
counter = 0
with open(sys.argv[1], "r") as fd:
while True:
c = fd.read(1)
if (c == '{'):
counter += 1
elif (c == '}'):
counter -= 1
elif not c:
break
if counter != 0:
print(f"{sys.argv[1]}: FAIL")
@moonexpr
Copy link
Author

moonexpr commented Apr 6, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment