Browse Source

rearrange to more reliably detect urls

kle2json_hyper
Zach White 3 years ago
parent
commit
0177fbd65b
1 changed files with 13 additions and 14 deletions
  1. +13
    -14
      lib/python/qmk/cli/kle2json.py

+ 13
- 14
lib/python/qmk/cli/kle2json.py View File

@ -70,23 +70,22 @@ def kle2json(cli):
file_path = Path(os.environ['ORIG_CWD'], cli.args.kle)
# Find our KLE text
if file_path.exists():
if cli.args.kle.startswith('http') and '#' in cli.args.kle:
kle_path = cli.args.kle.split('#', 1)[1]
if 'gists' not in kle_path:
cli.log.error('Invalid KLE url: {fg_cyan}%s', cli.args.kle)
return False
else:
raw_code = fetch_kle(kle_path.split('/')[-1])
elif file_path.exists():
raw_code = file_path.open().read()
else:
if cli.args.kle.startswith('http') and '#' in cli.args.kle:
kle_path = cli.args.kle.split('#', 1)[1]
if 'gists' not in kle_path:
cli.log.error('Invalid KLE url: {fg_cyan}%s', cli.args.kle)
return False
else:
raw_code = fetch_kle(kle_path.split('/')[-1])
else:
raw_code = fetch_kle(cli.args.kle)
if not raw_code:
cli.log.error('File {fg_cyan}%s{style_reset_all} was not found.', file_path)
return False
raw_code = fetch_kle(cli.args.kle)
if not raw_code:
cli.log.error('File {fg_cyan}%s{style_reset_all} was not found.', file_path)
return False
# Make sure the user supplied a keyboard
if not cli.args.keyboard:


Loading…
Cancel
Save