mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-29 17:42:12 +08:00
WIP: metadata validation.
This commit is contained in:
committed by
Matthias Bernt
parent
bddd8909e4
commit
1f56fa37d7
@@ -559,7 +559,32 @@ class MetadataValidator(Validator):
|
||||
super().validate(isinstance(value, model.DatasetInstance) and not missing, value_to_show=missing)
|
||||
|
||||
|
||||
class UnspecifiedBuildValidator(Validator):
|
||||
class MetadataEqualsValidator(Validator):
|
||||
"""
|
||||
"""
|
||||
requires_dataset_metadata = True
|
||||
|
||||
def __init__(self, metadata_name=None, value=None, message=None):
|
||||
self.metadata_name = metadata_name
|
||||
self.value = value
|
||||
self.message = message or 'Metadata value for (%s) must be (%s) and is not.' % (metadata_name, value)
|
||||
|
||||
@classmethod
|
||||
def from_element(cls, param, elem):
|
||||
return cls(
|
||||
metadata_name=elem.get('metadata_name', None),
|
||||
value=elem.get('value', None),
|
||||
message=elem.get('message', None),
|
||||
)
|
||||
|
||||
def validate( self, value, trans=None ):
|
||||
if value:
|
||||
metdata_value = getattr(value.metadata, self.metadata_name)
|
||||
if metdata_value != self.value:
|
||||
raise ValueError( self.message )
|
||||
|
||||
|
||||
class UnspecifiedBuildValidator( Validator ):
|
||||
"""
|
||||
Validator that checks for dbkey not equal to '?'
|
||||
|
||||
@@ -949,6 +974,7 @@ validator_types = dict(
|
||||
in_range=InRangeValidator,
|
||||
length=LengthValidator,
|
||||
metadata=MetadataValidator,
|
||||
metadata_eq=MetadataEqualsValidator,
|
||||
unspecified_build=UnspecifiedBuildValidator,
|
||||
no_options=NoOptionsValidator,
|
||||
empty_field=EmptyTextfieldValidator,
|
||||
|
||||
+79
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
|
||||
<tool id="metadata_check_eq" name="metadata_check_eq" version="1.0.0">
|
||||
<description>Tests whether asserting metadata equals something works.</description>
|
||||
<command><![CDATA[
|
||||
cp '$input' '$output'
|
||||
]]></command>
|
||||
<inputs>
|
||||
<param name="input" type="data" multiple="false" format="tabular,csv">
|
||||
<validator type="metdata_eq" metadata_name="delimiter" value="	" />
|
||||
</param>
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="tabular" name="output" format_source="input">
|
||||
</data>
|
||||
</outputs>
|
||||
<tests>
|
||||
<test>
|
||||
<param name="input" value="1.tabular" format="tabular" />
|
||||
<output name="output">
|
||||
<metadata name="delimiter" value="	"/>
|
||||
</output>
|
||||
</test>
|
||||
<test>
|
||||
<param name="input" value="1.csv" format="csv" />
|
||||
<output name="output">
|
||||
<metadata name="delimiter" value="	"/>
|
||||
</output>
|
||||
</test>
|
||||
</tests>
|
||||
</tool>
|
||||
@@ -72,6 +72,7 @@
|
||||
<tool file="metadata_bcf.xml" />
|
||||
<tool file="metadata_bed.xml" />
|
||||
<tool file="metadata_biom1.xml" />
|
||||
<tool file="metadata_check_eq.xml" />
|
||||
<tool file="metadata_column_names.xml" />
|
||||
<tool file="strict_shell.xml" />
|
||||
<tool file="strict_shell_default_off.xml" />
|
||||
|
||||
Reference in New Issue
Block a user