Created
June 22, 2017 00:00
-
-
Save ubershmekel/f7a0b8f85d2335df7a324ef5e3cf4294 to your computer and use it in GitHub Desktop.
How to open .sgn file types from Israeli Courts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
court.gov.il for some reason send out these signed files with the "sgn" file extension. | |
They're xml files with base64 encoded contents, this is how you can get them out. | |
open_sgn.py myfile.sgn | |
""" | |
import base64 | |
import xml.etree.ElementTree as ET | |
import sys | |
if len(sys.argv) < 2: | |
print("Usage: %s file_to_extract.sgn" % __file__) | |
exit(1) | |
fpath = sys.argv[1] | |
tree = ET.parse(fpath) | |
root = tree.getroot() | |
extension = list(root.iter('DocumentExtension'))[0].text | |
text = list(root.iter('DocumentContent'))[0].text | |
decoded = base64.decodestring(text) | |
dst = fpath + '.' + extension | |
print("Saving results to '%s'" % dst) | |
open(dst, 'wb').write(decoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🤦♂️