Keep track of category associations when exporting repositories from the tool shed.

This commit is contained in:
Greg Von Kuster
2013-08-06 11:04:54 -04:00
parent 41e8df0ea5
commit 92e4dbfcdd
2 changed files with 18 additions and 1 deletions
+6
View File
@@ -246,6 +246,12 @@ def get_repository_attributes_and_sub_elements( repository, archive_name ):
sub_elements[ 'description' ] = str( repository.description )
sub_elements[ 'long_description' ] = str( repository.long_description )
sub_elements[ 'archive' ] = archive_name
# Keep track of Category associations.
categories = []
for rca in repository.categories:
category = rca.category
categories.append( ( 'category', str( category.name ) ) )
sub_elements[ 'categories' ] = categories
return attributes, sub_elements
def get_repository_ids( trans, repo_info_dicts ):
+12 -1
View File
@@ -62,7 +62,18 @@ def create_element( tag, attributes=None, sub_elements=None ):
# Don't include fields that are blank.
if v:
sub_elem = XmlET.SubElement( elem, k )
sub_elem.text = v
if isinstance( v, list ):
# If the sub_elem is a list, then it must be a list of tuples where the first item is the tag and the second item is the text value.
for v_tuple in v:
if len( v_tuple ) == 2:
v_tag = v_tuple[ 0 ]
v_text = v_tuple[ 1 ]
# Don't include fields that are blank.
if v_text:
v_elem = XmlET.SubElement( sub_elem, v_tag )
v_elem.text = v_text
else:
sub_elem.text = v
return elem
return None