mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Refactor collection test def objects out of galaxy.tools.
Part of ongoing effort to isolate the galaxy.tools.parser and not have it depend on things in galaxy.tools outside that module.
This commit is contained in:
@@ -2989,42 +2989,6 @@ class BadValue( object ):
|
||||
self.value = value
|
||||
|
||||
|
||||
class TestCollectionDef( object ):
|
||||
|
||||
def __init__( self, elem, parse_param_elem ):
|
||||
self.elements = []
|
||||
attrib = dict( elem.attrib )
|
||||
self.collection_type = attrib[ "type" ]
|
||||
self.name = attrib.get( "name", "Unnamed Collection" )
|
||||
for element in elem.findall( "element" ):
|
||||
element_attrib = dict( element.attrib )
|
||||
element_identifier = element_attrib[ "name" ]
|
||||
nested_collection_elem = element.find( "collection" )
|
||||
if nested_collection_elem is not None:
|
||||
self.elements.append( ( element_identifier, TestCollectionDef( nested_collection_elem, parse_param_elem ) ) )
|
||||
else:
|
||||
self.elements.append( ( element_identifier, parse_param_elem( element ) ) )
|
||||
|
||||
def collect_inputs( self ):
|
||||
inputs = []
|
||||
for element in self.elements:
|
||||
value = element[ 1 ]
|
||||
if isinstance( value, TestCollectionDef ):
|
||||
inputs.extend( value.collect_inputs() )
|
||||
else:
|
||||
inputs.append( value )
|
||||
return inputs
|
||||
|
||||
|
||||
class TestCollectionOutputDef( object ):
|
||||
|
||||
def __init__( self, name, attrib, element_tests ):
|
||||
self.name = name
|
||||
self.collection_type = attrib.get( "type", None )
|
||||
self.attrib = attrib
|
||||
self.element_tests = element_tests
|
||||
|
||||
|
||||
def json_fix( val ):
|
||||
if isinstance( val, list ):
|
||||
return [ json_fix( v ) for v in val ]
|
||||
|
||||
@@ -280,3 +280,41 @@ class ToolStdioExitCode( object ):
|
||||
# TODO: Define a common class or constant for error level:
|
||||
self.error_level = "fatal"
|
||||
self.desc = ""
|
||||
|
||||
|
||||
class TestCollectionDef( object ):
|
||||
# TODO: do not require XML directly here.
|
||||
|
||||
def __init__( self, elem, parse_param_elem ):
|
||||
self.elements = []
|
||||
attrib = dict( elem.attrib )
|
||||
self.collection_type = attrib[ "type" ]
|
||||
self.name = attrib.get( "name", "Unnamed Collection" )
|
||||
for element in elem.findall( "element" ):
|
||||
element_attrib = dict( element.attrib )
|
||||
element_identifier = element_attrib[ "name" ]
|
||||
nested_collection_elem = element.find( "collection" )
|
||||
if nested_collection_elem is not None:
|
||||
self.elements.append( ( element_identifier, TestCollectionDef( nested_collection_elem, parse_param_elem ) ) )
|
||||
else:
|
||||
self.elements.append( ( element_identifier, parse_param_elem( element ) ) )
|
||||
|
||||
def collect_inputs( self ):
|
||||
inputs = []
|
||||
for element in self.elements:
|
||||
value = element[ 1 ]
|
||||
if isinstance( value, TestCollectionDef ):
|
||||
inputs.extend( value.collect_inputs() )
|
||||
else:
|
||||
inputs.append( value )
|
||||
return inputs
|
||||
|
||||
|
||||
class TestCollectionOutputDef( object ):
|
||||
# TODO: do not require XML directly here.
|
||||
|
||||
def __init__( self, name, attrib, element_tests ):
|
||||
self.name = name
|
||||
self.collection_type = attrib.get( "type", None )
|
||||
self.attrib = attrib
|
||||
self.element_tests = element_tests
|
||||
|
||||
@@ -12,6 +12,8 @@ from .interface import (
|
||||
InputSource,
|
||||
ToolStdioExitCode,
|
||||
ToolStdioRegex,
|
||||
TestCollectionDef,
|
||||
TestCollectionOutputDef,
|
||||
)
|
||||
from galaxy.util import string_as_bool, xml_text, xml_to_string
|
||||
from galaxy.util.odict import odict
|
||||
@@ -321,7 +323,7 @@ def __parse_output_collection_elem( output_collection_elem ):
|
||||
if identifier is None:
|
||||
raise Exception( "Test primary dataset does not have a 'identifier'" )
|
||||
element_tests[ identifier ] = __parse_test_attributes( element, element_attrib )
|
||||
return galaxy.tools.TestCollectionOutputDef( name, attrib, element_tests )
|
||||
return TestCollectionOutputDef( name, attrib, element_tests )
|
||||
|
||||
|
||||
def __parse_test_attributes( output_elem, attrib ):
|
||||
@@ -486,7 +488,7 @@ def __parse_param_elem( param_elem, i=0 ):
|
||||
elif child.tag == 'edit_attributes':
|
||||
attrib['edit_attributes'].append( child )
|
||||
elif child.tag == 'collection':
|
||||
attrib[ 'collection' ] = galaxy.tools.TestCollectionDef( child, __parse_param_elem )
|
||||
attrib[ 'collection' ] = TestCollectionDef( child, __parse_param_elem )
|
||||
if composite_data_name:
|
||||
# Composite datasets need implicit renaming;
|
||||
# inserted at front of list so explicit declarations
|
||||
|
||||
@@ -7,7 +7,7 @@ from galaxy import util
|
||||
from galaxy.datatypes import checkers
|
||||
from galaxy.model.orm import and_
|
||||
from galaxy.tools.data_manager.manager import DataManager
|
||||
from galaxy.tools import TestCollectionDef
|
||||
from galaxy.tools.parser.interface import TestCollectionDef
|
||||
from galaxy.web import url_for
|
||||
|
||||
from tool_shed.repository_types import util as rt_util
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
from StringIO import StringIO
|
||||
from galaxy.tools import TestCollectionDef
|
||||
from galaxy.tools.parser.interface import TestCollectionDef
|
||||
from galaxy import eggs
|
||||
eggs.require( "requests" )
|
||||
from galaxy import util
|
||||
|
||||
Reference in New Issue
Block a user