@@ -125,25 +125,17 @@ def matches(r):
125125def create_repository (ctx , tsi , path , ** kwds ):
126126 repo_config = shed_repo_config (path )
127127 name = kwds .get ("name" , None ) or repo_config .get ("name" , None )
128+ if name is None :
129+ name = path_to_repo_name (path )
128130
129131 description = repo_config .get ("description" , None )
130132 long_description = repo_config .get ("long_description" , None )
131- type = repo_config . get ( "type" , None )
133+ repo_type = shed_repo_type ( repo_config , name )
132134 remote_repository_url = repo_config .get ("remote_repository_url" , None )
133135 homepage_url = repo_config .get ("homepage_url" , None )
134136 categories = repo_config .get ("categories" , [])
135137 category_ids = find_category_ids (tsi , categories )
136138
137- if name is None :
138- name = path_to_repo_name (path )
139-
140- if type is None and name .startswith ("package_" ):
141- type = "tool_dependency_definition"
142- elif type is None and name .startswith ("suite_" ):
143- type = "repository_suite_definition"
144- elif type is None :
145- type = "unrestricted"
146-
147139 # description is required, as is name.
148140 if description is None :
149141 message = "description required for automatic creation of repositories"
@@ -153,7 +145,7 @@ def create_repository(ctx, tsi, path, **kwds):
153145 name = name ,
154146 synopsis = description ,
155147 description = long_description ,
156- type = type ,
148+ type = repo_type ,
157149 remote_repository_url = remote_repository_url ,
158150 homepage_url = homepage_url ,
159151 category_ids = category_ids
@@ -257,6 +249,17 @@ def path_to_repo_name(path):
257249 return os .path .basename (os .path .abspath (path ))
258250
259251
252+ def shed_repo_type (config , name ):
253+ repo_type = config .get ("type" , None )
254+ if repo_type is None and name .startswith ("package_" ):
255+ repo_type = "tool_dependency_definition"
256+ elif repo_type is None and name .startswith ("suite_" ):
257+ repo_type = "repository_suite_definition"
258+ elif repo_type is None :
259+ repo_type = "unrestricted"
260+ return repo_type
261+
262+
260263def _tool_shed_url (kwds ):
261264 url = kwds .get ("shed_target" )
262265 if url in SHED_SHORT_NAMES :
0 commit comments