mirror of
https://github.com/alvierahman90/otfmacros.git
synced 2024-12-15 12:01:59 +00:00
Add ability to source from external macro files
This commit is contained in:
parent
3f8326cd33
commit
75587f7b3a
@ -3,3 +3,6 @@
|
|||||||
.ca carbon
|
.ca carbon
|
||||||
.ox oxygen
|
.ox oxygen
|
||||||
:wink: 😉
|
:wink: 😉
|
||||||
|
source tests/test_macros_biology
|
||||||
|
source tests/test_macros_custom_plurals
|
||||||
|
source tests/test_macros_plural
|
||||||
|
@ -129,18 +129,20 @@ def get_macros(input):
|
|||||||
"""
|
"""
|
||||||
Turn a string into a list of tuples of macros
|
Turn a string into a list of tuples of macros
|
||||||
"""
|
"""
|
||||||
|
response = []
|
||||||
|
|
||||||
# turn input into unvalidated list of macros
|
# turn input into unvalidated list of macros
|
||||||
macros = [re.split('[ \t]', x) for x in input.split('\n')]
|
macros = [re.split('[ \t]', x) for x in input.split('\n')]
|
||||||
|
|
||||||
# validate macros
|
# validate macros
|
||||||
for index, macro in enumerate(macros):
|
for index, macro in enumerate(macros):
|
||||||
|
if macro[0] == "source":
|
||||||
|
with open(macro[1]) as file:
|
||||||
|
response += get_macros(file.read())
|
||||||
if len(macro) == 2 or len(macro) == 3:
|
if len(macro) == 2 or len(macro) == 3:
|
||||||
macros[index] = tuple(macros[index])
|
response.append(tuple(macros[index]))
|
||||||
else:
|
|
||||||
macros.pop(index)
|
|
||||||
|
|
||||||
return macros
|
return response
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env sh
|
#/usr/bin/env sh
|
||||||
./pymacro -sm tests/test_macros_plural -m tests/test_macros_biology tests/test_input tests/test_actual_output
|
./pymacro -s tests/test_input tests/test_actual_output
|
||||||
diff tests/test_actual_output tests/test_expected_output
|
git diff tests/test_actual_output tests/test_expected_output
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user