Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Smith authored and Thomas Smith committed Dec 21, 2018
2 parents 25eef05 + 396b017 commit 89871d2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/macros.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
from yamlmacros.lib.extend import apply
from yamlmacros.lib.syntax import rule as _rule
from yamlmacros.lib.include import include_resource

from yamlmacros import process_macros

import sublime
from os import path

def include_resource(resource):
file_contents = sublime.load_resource(resource)
return process_macros(
file_contents,
arguments={ "file_path": resource },
)

__all__ = ['apply', 'include_resource', 'get_extensions']


def merge(*args):
ret = {}
for arg in args:
ret.update(arg)
return ret

def has_value(val):
return val is not None and val is not False

def get_extensions(node, eval, arguments):
return [
include_resource(file_path)
process_macros(
sublime.load_resource(file_path),
arguments=merge(arguments, { "file_path": file_path }),
)
for file_path in sublime.find_resources('*.yaml')
if path.dirname(file_path).endswith('Packages/JSCustom/extensions')
and has_value(arguments.get(path.splitext(path.basename(file_path))[0], None))
Expand Down

0 comments on commit 89871d2

Please sign in to comment.