33
33
temp_directory ,
34
34
)
35
35
from planemo .shed2tap .base import BasePackage
36
- from planemo .tools import load_tool_elements_from_path
36
+ from planemo .tools import yield_tool_sources
37
37
38
38
from .diff import diff_and_remove
39
39
from .interface import (
@@ -418,7 +418,7 @@ def _diff_in(ctx, working, realized_repository, **kwds):
418
418
return exit
419
419
420
420
421
- def shed_repo_config (path , name = None ):
421
+ def shed_repo_config (ctx , path , name = None ):
422
422
shed_yaml_path = os .path .join (path , SHED_CONFIG_NAME )
423
423
config = {}
424
424
if os .path .exists (shed_yaml_path ):
@@ -427,7 +427,7 @@ def shed_repo_config(path, name=None):
427
427
428
428
if config is None : # yaml may yield None
429
429
config = {}
430
- _expand_raw_config (config , path , name = name )
430
+ _expand_raw_config (ctx , config , path , name = name )
431
431
return config
432
432
433
433
@@ -504,7 +504,7 @@ def find_repository_id(ctx, shed_context, path, **kwds):
504
504
repo_config = kwds .get ("config" , None )
505
505
if repo_config is None :
506
506
name = kwds .get ("name" , None )
507
- repo_config = shed_repo_config (path , name = name )
507
+ repo_config = shed_repo_config (ctx , path , name = name )
508
508
name = repo_config ["name" ]
509
509
find_kwds = kwds .copy ()
510
510
if "name" in find_kwds :
@@ -537,7 +537,7 @@ def _owner(ctx, repo_config, shed_context=None, **kwds):
537
537
return owner
538
538
539
539
540
- def _expand_raw_config (config , path , name = None ):
540
+ def _expand_raw_config (ctx , config , path , name = None ):
541
541
name_input = name
542
542
if "name" not in config :
543
543
config ["name" ] = name
@@ -554,7 +554,7 @@ def _expand_raw_config(config, path, name=None):
554
554
if auto_tool_repos and name_input :
555
555
raise Exception (AUTO_NAME_CONFLICT_MESSAGE )
556
556
if auto_tool_repos :
557
- repos = _build_auto_tool_repos (path , config , auto_tool_repos )
557
+ repos = _build_auto_tool_repos (ctx , path , config , auto_tool_repos )
558
558
if suite_config :
559
559
if repos is None :
560
560
repos = odict .odict ()
@@ -571,15 +571,15 @@ def _expand_raw_config(config, path, name=None):
571
571
config ["repositories" ] = repos
572
572
573
573
574
- def _build_auto_tool_repos (path , config , auto_tool_repos ):
574
+ def _build_auto_tool_repos (ctx , path , config , auto_tool_repos ):
575
575
default_include = config .get ("include" , ["**" ])
576
- tool_els = list (load_tool_elements_from_path ( path , recursive = True ))
577
- paths = list (map (lambda pair : pair [0 ], tool_els ))
576
+ tool_source_pairs = list (yield_tool_sources ( ctx , path , recursive = True ))
577
+ paths = list (map (lambda pair : pair [0 ], tool_source_pairs ))
578
578
excludes = _shed_config_excludes (config )
579
579
580
- def _build_repository (tool_path , tool_el ):
581
- tool_id = tool_el . getroot (). get ( "id" ).lower ()
582
- tool_name = tool_el . getroot (). get ( "name" )
580
+ def _build_repository (tool_path , tool_source ):
581
+ tool_id = tool_source . parse_id ( ).lower ()
582
+ tool_name = tool_source . parse_name ( )
583
583
template_vars = dict (
584
584
tool_id = tool_id ,
585
585
tool_name = tool_name ,
@@ -600,8 +600,8 @@ def _build_repository(tool_path, tool_el):
600
600
return repo_dict
601
601
602
602
repos = odict .odict ()
603
- for tool_path , tool_el in tool_els :
604
- repository_config = _build_repository (tool_path , tool_el )
603
+ for tool_path , tool_source in tool_source_pairs :
604
+ repository_config = _build_repository (tool_path , tool_source )
605
605
repository_name = repository_config ["name" ]
606
606
repos [repository_name ] = repository_config
607
607
return repos
@@ -744,7 +744,7 @@ def find_raw_repositories(ctx, paths, **kwds):
744
744
"""Return a list of "raw" repository objects for each repo on paths."""
745
745
raw_repo_objects = []
746
746
for path in paths :
747
- raw_repo_objects .extend (_find_raw_repositories (path , ** kwds ))
747
+ raw_repo_objects .extend (_find_raw_repositories (ctx , path , ** kwds ))
748
748
return raw_repo_objects
749
749
750
750
@@ -804,7 +804,7 @@ def _realize_effective_repositories(ctx, path, **kwds):
804
804
code repository but are published to the tool shed as one repository per
805
805
tool).
806
806
"""
807
- raw_repo_objects = _find_raw_repositories (path , ** kwds )
807
+ raw_repo_objects = _find_raw_repositories (ctx , path , ** kwds )
808
808
failed = False
809
809
with temp_directory () as base_dir :
810
810
for raw_repo_object in raw_repo_objects :
@@ -904,7 +904,7 @@ def _path_on_disk(ctx, path):
904
904
yield git_repo
905
905
906
906
907
- def _find_raw_repositories (path , ** kwds ):
907
+ def _find_raw_repositories (ctx , path , ** kwds ):
908
908
name = kwds .get ("name" , None )
909
909
recursive = kwds .get ("recursive" , False )
910
910
@@ -916,7 +916,7 @@ def _find_raw_repositories(path, **kwds):
916
916
if len (shed_file_dirs ) == 1 :
917
917
shed_file_dir = shed_file_dirs [0 ]
918
918
try :
919
- config = shed_repo_config (shed_file_dir , name = name )
919
+ config = shed_repo_config (ctx , shed_file_dir , name = name )
920
920
except Exception as e :
921
921
error_message = PARSING_PROBLEM % (shed_file_dir , e )
922
922
exception = RuntimeError (error_message )
@@ -932,10 +932,10 @@ def _find_raw_repositories(path, **kwds):
932
932
raw_dirs = shed_file_dirs or [path ]
933
933
kwds_copy = kwds .copy ()
934
934
kwds_copy ["name" ] = name
935
- return _build_raw_repo_objects (raw_dirs , ** kwds_copy )
935
+ return _build_raw_repo_objects (ctx , raw_dirs , ** kwds_copy )
936
936
937
937
938
- def _build_raw_repo_objects (raw_dirs , ** kwds ):
938
+ def _build_raw_repo_objects (ctx , raw_dirs , ** kwds ):
939
939
"""
940
940
From specific directories with .shed.yml files or specified directly from
941
941
the command-line build abstract description of directories that should be
@@ -949,7 +949,7 @@ def _build_raw_repo_objects(raw_dirs, **kwds):
949
949
raw_repo_objects = []
950
950
for raw_dir in raw_dirs :
951
951
try :
952
- config = shed_repo_config (raw_dir , name = name )
952
+ config = shed_repo_config (ctx , raw_dir , name = name )
953
953
except Exception as e :
954
954
error_message = PARSING_PROBLEM % (raw_dir , e )
955
955
exception = RuntimeError (error_message )
0 commit comments