示例#1
0
def document1_loader():
    class Document1Loader(yatiml.Loader):
        pass

    yatiml.add_to_loader(Document1Loader, Document1)
    yatiml.set_document_type(Document1Loader, Document1)
    return Document1Loader
示例#2
0
def vector_loader():
    class VectorLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(VectorLoader, Vector2D)
    yatiml.set_document_type(VectorLoader, Vector2D)
    return VectorLoader
示例#3
0
def dict_attribute_loader():
    class DictAttributeLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(DictAttributeLoader, DictAttribute)
    yatiml.set_document_type(DictAttributeLoader, DictAttribute)
    return DictAttributeLoader
示例#4
0
def parsed_class_loader():
    class ParsedClassLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(ParsedClassLoader, Postcode)
    yatiml.set_document_type(ParsedClassLoader, Postcode)
    return ParsedClassLoader
示例#5
0
def enum_list_loader():
    class EnumListLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(EnumListLoader, Color2)
    yatiml.set_document_type(EnumListLoader, List[Color2])
    return EnumListLoader
示例#6
0
def bool_fix_union_loader():
    class BoolUnionFixLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolUnionFixLoader, Union[int, bool,
                                                       yatiml.bool_union_fix])
    return BoolUnionFixLoader
示例#7
0
def union_attribute_loader():
    class UnionAttributeLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(UnionAttributeLoader, UnionAttribute)
    yatiml.set_document_type(UnionAttributeLoader, UnionAttribute)
    return UnionAttributeLoader
示例#8
0
def enum_dict_loader():
    class EnumDictLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(EnumDictLoader, Color2)
    yatiml.set_document_type(EnumDictLoader, Dict[str, Color2])
    return EnumDictLoader
示例#9
0
def universal_loader():
    class UniversalLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(UniversalLoader, Universal)
    yatiml.set_document_type(UniversalLoader, Universal)
    return UniversalLoader
示例#10
0
def extensible_loader():
    class ExtensibleLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(ExtensibleLoader, Extensible)
    yatiml.set_document_type(ExtensibleLoader, Extensible)
    return ExtensibleLoader
示例#11
0
def super_loader():
    class SuperLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(SuperLoader, [Super, SubA, SubB])
    yatiml.set_document_type(SuperLoader, Super)
    return SuperLoader
示例#12
0
def super2_loader():
    class Super2Loader(yatiml.Loader):
        pass

    yatiml.add_to_loader(Super2Loader, [Super2, SubA2, SubB2])
    yatiml.set_document_type(Super2Loader, Super2)
    return Super2Loader
示例#13
0
def user_string_loader():
    class UserStringLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(UserStringLoader, ConstrainedString)
    yatiml.set_document_type(UserStringLoader, ConstrainedString)
    return UserStringLoader
示例#14
0
def enum_loader2():
    class EnumLoader2(yatiml.Loader):
        pass

    yatiml.add_to_loader(EnumLoader2, Color2)
    yatiml.set_document_type(EnumLoader2, Color2)
    return EnumLoader2
示例#15
0
def bool_fix_tester_loader():
    class BoolFixTesterLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolFixTesterLoader, BoolFixTester)
    yatiml.add_to_loader(BoolFixTesterLoader, BoolFixTester)
    return BoolFixTesterLoader
示例#16
0
def dashed_attribute_loader():
    class DashedAttributeLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(DashedAttributeLoader, DashedAttribute)
    yatiml.set_document_type(DashedAttributeLoader, DashedAttribute)
    return DashedAttributeLoader
示例#17
0
def missing_circle_loader():
    class MissingCircleLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(MissingCircleLoader,
                         [Shape, Rectangle, Ellipse, Vector2D])
    yatiml.set_document_type(MissingCircleLoader, Shape)
    return MissingCircleLoader
示例#18
0
def shape_loader():
    class ShapeLoader(yatiml.Loader):
        pass

    yatiml.add_to_loader(ShapeLoader,
                         [Shape, Rectangle, Circle, Ellipse, Vector2D])
    yatiml.set_document_type(ShapeLoader, Shape)
    return ShapeLoader
示例#19
0
def test_load_dict_invalid_key():
    class IntKeyDictLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(IntKeyDictLoader, Dict[int, str])

    text = ('1: one\n' '2: two\n' '3: three\n')
    with pytest.raises(RuntimeError):
        yaml.load(text, Loader=IntKeyDictLoader)
示例#20
0
def document2_loader():
    class Document2Loader(yatiml.Loader):
        pass

    yatiml.add_to_loader(
        Document2Loader,
        [Color2, Document2, Shape, Rectangle, Circle, Vector2D])
    yatiml.set_document_type(Document2Loader, Document2)
    return Document2Loader
示例#21
0
def test_load_bool():
    class BoolLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolLoader, bool)

    text = 'True'
    data = yaml.load(text, Loader=BoolLoader)
    assert isinstance(data, bool)
    assert data is True
示例#22
0
def test_load_float():
    class FloatLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(FloatLoader, float)

    text = '3.1415'
    data = yaml.load(text, Loader=FloatLoader)
    assert isinstance(data, float)
    assert data == 3.1415
示例#23
0
def test_load_int():
    class IntLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(IntLoader, int)

    text = '42'
    data = yaml.load(text, Loader=IntLoader)
    assert isinstance(data, int)
    assert data == 42
        self.echo_run = echo_run
        self.enable_callers = enable_callers
        self.mode = mode
        self.genome = genome
        self.exclusion_list = exclusion_list
        self.exclude_regions = exclude_regions
        self.file_exts = file_exts
        self.samples = samples
        self.callers = callers
        self.postproc = postproc


# Create loader
class MyLoader(yatiml.Loader):
    """
    MyLoader class.
    """
    pass


def load_configfile(yaml_file: str) -> Dict:
    with open(yaml_file, 'r') as conf:
        return yaml.load(conf, MyLoader)


yatiml.logger.setLevel(logging.DEBUG)
yatiml.add_to_loader(MyLoader, [Mode, FileExtension, Resource, Manta, Delly,
                     Lumpy, Gridss, Caller, SurvivorFilter, SurvivorMerge,
                     Survivor, PostProcess, Analysis])
yatiml.set_document_type(MyLoader, Analysis)
示例#25
0
from ruamel import yaml
from typing import Dict
import yatiml


# Create loader
class MyLoader(yatiml.Loader):
    pass

yatiml.set_document_type(MyLoader, Dict[str, str])

# Load YAML
yaml_text = ('name: Janice\n'
             'age: Six\n')
doc = yaml.load(yaml_text, Loader=MyLoader)
print(doc)
示例#26
0
def bool_union_loader():
    class BoolUnionLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolUnionLoader, Union[int, bool])
    return BoolUnionLoader
示例#27
0
def bool_fix_loader():
    class BoolFixLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolFixLoader, yatiml.bool_union_fix)
    return BoolFixLoader
示例#28
0
def bool_loader():
    class BoolLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(BoolLoader, bool)
    return BoolLoader
示例#29
0
    @classmethod
    def _yatiml_savorize(cls, node: yatiml.Node) -> None:
        str_to_int = {
            'five': 5,
            'six': 6,
            'seven': 7,
        }
        if node.has_attribute_type('age', str):
            str_val = node.get_attribute('age').get_value()
            if str_val in str_to_int:
                node.set_attribute('age', str_to_int[str_val])
            else:
                raise yatiml.SeasoningError('Invalid age string')


# Create loader
class MyLoader(yatiml.Loader):
    pass


yatiml.add_to_loader(MyLoader, Submission)
yatiml.set_document_type(MyLoader, Submission)

# Load YAML
yaml_text = ('name: Janice\n' 'age: six\n')
doc = yaml.load(yaml_text, Loader=MyLoader)

print(doc.name)
print(doc.age)
print(doc.tool)
示例#30
0
def union_loader():
    class UnionLoader(yatiml.Loader):
        pass

    yatiml.set_document_type(UnionLoader, Union[str, int])
    return UnionLoader