diff --git a/patacrep/content/include.py b/patacrep/content/include.py index dbc10fce..9f27c992 100644 --- a/patacrep/content/include.py +++ b/patacrep/content/include.py @@ -28,18 +28,22 @@ def load_from_datadirs(path, datadirs): ) #pylint: disable=unused-argument -def parse(keyword, config, argument, contentlist): +def parse(keyword, config, argument): """Include an external file content. Arguments: - keyword: the string 'include'; - config: the current songbook configuration dictionary; - - argument: None; - - contentlist: a list of file paths to be included. + - argument: + a list of file paths to be included + or a string of the file to include + """ new_contentlist = ContentList() + if isinstance(argument, str): + argument = [argument] - for path in contentlist: + for path in argument: try: filepath = load_from_datadirs(path, config['_datadir']) except ContentError as error: diff --git a/test/test_content/include.control b/test/test_content/include.control index 5ba82a4c..2ee7f993 100644 --- a/test/test_content/include.control +++ b/test/test_content/include.control @@ -1 +1 @@ -["exsong.sg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file +["exsong.sg", "chordpro.csg", "subdir/chordpro.csg", "exsong.sg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/include.source b/test/test_content/include.source index ccd69aa1..3a438e2a 100644 --- a/test/test_content/include.source +++ b/test/test_content/include.source @@ -1 +1,3 @@ -[["include" , "custom_list.json"]] \ No newline at end of file +- include: + - custom_list.json +- include: custom_list.json \ No newline at end of file diff --git a/test/test_songbook/content.sb b/test/test_songbook/content.sb index 4c57a262..5ff0bcca 100644 --- a/test/test_songbook/content.sb +++ b/test/test_songbook/content.sb @@ -16,4 +16,4 @@ content: - "song.csg" - "song.tsg" - ["tex", "foo.tex"] - - ["include", "include.sbc"] \ No newline at end of file + - include: include.sbc \ No newline at end of file