Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Last active March 22, 2018 15:19
Show Gist options
  • Save tbnorth/4dab3ef67060731024b44b772feb0f0a to your computer and use it in GitHub Desktop.
Save tbnorth/4dab3ef67060731024b44b772feb0f0a to your computer and use it in GitHub Desktop.
theme_name = c.config.getString('theme-name') or c.config.getString('color-theme')
roots = [g.os_path_join(g.computeHomeDir(), '.leo'), g.computeLeoDir()]
theme_subs = ["themes/{theme}/Icons", "themes/{theme}", "Icons/{theme}"]
bare_subs = ["Icons", "."] # "." for icons referred to as Icons/blah/blah.png
paths = []
for root in roots:
for sub in theme_subs:
paths.append(g.os_path_join(root, sub.format(theme=theme_name)))
for root in roots:
for sub in bare_subs:
paths.append(g.os_path_join(root, sub))
paths = [i for i in paths if g.os_path_exists(i)]
[u'/home/tbrown/.leo/themes/leo_dark_0/Icons',
u'/home/tbrown/.leo/themes/leo_dark_0',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/themes/leo_dark_0/Icons',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/themes/leo_dark_0',
u'/home/tbrown/.leo/.',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/Icons',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/.']
icons = [
'box00.png', 'cleo/date_past.png', 'file_icons/file_clean.png',
'file_icons/folder-saved-search.png'
]
found = []
for icon in icons:
for path in paths:
filepath = g.os_path_join(path, icon)
if g.os_path_exists(filepath):
found.append(filepath)
break
found
[u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/themes/leo_dark_0/Icons/box00.png',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/themes/leo_dark_0/Icons/cleo/date_past.png',
u'/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/themes/leo_dark_0/Icons/file_icons/file_clean.png',
u'/home/tbrown/.leo/themes/leo_dark_0/Icons/file_icons/folder-saved-search.png']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment