Skip to content

Instantly share code, notes, and snippets.

@Riatre
Created May 28, 2020 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riatre/a7d0e3cc9f76e156111a30c509b70143 to your computer and use it in GitHub Desktop.
Save Riatre/a7d0e3cc9f76e156111a30c509b70143 to your computer and use it in GitHub Desktop.
import sys, re, json
COLOR_NAME = [
"foreground",
"// Default Bold Foreground",
"background",
"// Default Bold Background",
"// Cursor Text",
"cursorColor",
"black",
"brightBlack",
"red",
"brightRed",
"green",
"brightGreen",
"yellow",
"brightYellow",
"blue",
"brightBlue",
"purple",
"brightPurple",
"cyan",
"brightCyan",
"white",
"brightWhite",
"// Cursor Text (IME ON)",
"// Cursor Colour (IME ON)",
]
scheme = {
"name": "Converted From putty.ini",
}
for line in sys.stdin.readlines():
m = re.match(r'Colour(\d+)="(\d+),(\d+),(\d+)"', line.strip())
if m:
idx, r, g, b = map(int, m.groups())
scheme[COLOR_NAME[idx]] = "#{:02X}{:02X}{:02X}".format(r, g, b)
print(json.dumps(scheme, indent=2).replace('"// ', '// "'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment