-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
21,223 additions
and
148 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package gleif | ||
|
||
//go:generate python3 generate.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
|
||
CODE_FILE = "gleif.gen.go" | ||
AUTHORITIES = "testdata/registrationAuthorities.json" | ||
HEADERS = [ | ||
"// Code generated by generate.py. DO NOT EDIT.", | ||
"// source: registrationAuthorities.json", | ||
"", | ||
"package gleif", | ||
"", | ||
"var registrationAuthorities = RegistrationAuthorities{", | ||
"" | ||
] | ||
|
||
|
||
def load_authorities(path=AUTHORITIES): | ||
with open(path, 'r') as f: | ||
return json.load(f) | ||
|
||
|
||
def main(): | ||
authorities = load_authorities() | ||
with open(CODE_FILE, 'w') as f: | ||
f.write("\n".join(HEADERS)) | ||
|
||
for authority in authorities: | ||
f.write("\t{\n") | ||
f.write(f"\t\tOption: \"{authority.get('option')}\",\n") | ||
f.write(f"\t\tCountryName: \"{authority.get('country_name')}\",\n") | ||
f.write(f"\t\tCountry: \"{authority.get('country')}\",\n") | ||
f.write(f"\t\tJurisdiction: \"{authority.get('jurisdiction')}\",\n") # noqa | ||
f.write(f"\t\tRegister: \"{authority.get('register')}\",\n") | ||
f.write(f"\t\tOrganization: \"{authority.get('organization')}\",\n") # noqa | ||
f.write(f"\t\tWebsite: \"{authority.get('website')}\",\n") | ||
f.write(f"\t\tComments: `{authority.get('comments')}`,\n") | ||
f.write("\t},\n") | ||
|
||
f.write("}\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.