Skip to content

Commit

Permalink
Update extratools.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyBukake committed Feb 21, 2020
1 parent 3f6f997 commit 8a53f90
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions automathemely/autoth_tools/extratools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ def scan_vscode_extensions(path):
t_list = []
try:
for k in next(os.walk(path))[1]:
with Path(path).joinpath(k, 'package.json').open() as f:
data = json.load(f)
if 'themes' in data['contributes']:
for i in data['contributes']['themes']:
if 'id' in i:
t_list.append(i['id'])
elif 'label' in i:
t_list.append(i['label'])
if k.startswith('theme-'):
with Path(path).joinpath(k, 'package.json').open() as f:
data = json.load(f)
if 'themes' in data['contributes']:
for i in data['contributes']['themes']:
if 'id' in i:
t_list.append(i['id'])
elif 'label' in i:
t_list.append(i['label'])
except StopIteration:
pass

Expand Down

1 comment on commit 8a53f90

@RockyBukake
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once i enabled auto VSCode theming it gave me this error :

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/AutomaThemely-1.3.0.dev1-py3.7.egg/automathemely/autoth_tools/settsmanager.py", line 363, in on_enable_extra
    self.extras[extra_type] = extratools.get_installed_extra_themes(extra_type)
  File "/usr/local/lib/python3.7/dist-packages/AutomaThemely-1.3.0.dev1-py3.7.egg/automathemely/autoth_tools/extratools.py", line 66, in get_installed_extra_themes
    vscode_themes += scan_vscode_extensions(p)
  File "/usr/local/lib/python3.7/dist-packages/AutomaThemely-1.3.0.dev1-py3.7.egg/automathemely/autoth_tools/extratools.py", line 18, in scan_vscode_extensions
    if 'themes' in data['contributes']:
KeyError: 'contributes'

Found out it was because some of the packages.json didn't have a 'contributes' line, fixed it by adding if k.startswith('theme-'): on line 16 of autoth_tools/extratools.py, but this fix doesn't work with custom/downloaded themes on .vscode home folder for that add or k.startswith('.vscode-theme-',6):, the 6 is for OneDark/OneLight theme (Length of the developer name).

Please sign in to comment.