Пример #1
0
class _TSV2JSONOutputSpec(TraitedSpec):
    output = traits.Either(
        traits.Dict,
        File(exists=True),
        traits.Instance(OrderedDict),
        desc="Output dictionary or JSON file",
    )
Пример #2
0
class _TSV2JSONInputSpec(BaseInterfaceInputSpec):
    in_file = File(exists=True, mandatory=True, desc='Input TSV file')
    index_column = traits.Str(mandatory=True,
                              desc='Name of the column in the TSV to be used '
                              'as the top-level key in the JSON. All '
                              'remaining columns will be assigned as '
                              'nested keys.')
    output = traits.Either(None,
                           File,
                           desc='Path where the output file is to be saved. '
                           'If this is `None`, then a JSON-compatible '
                           'dictionary is returned instead.')
    additional_metadata = traits.Either(None,
                                        traits.Dict,
                                        traits.Instance(OrderedDict),
                                        usedefault=True,
                                        desc='Any additional metadata that '
                                        'should be applied to all '
                                        'entries in the JSON.')
    drop_columns = traits.Either(None,
                                 traits.List(),
                                 usedefault=True,
                                 desc='List of columns in the TSV to be '
                                 'dropped from the JSON.')
    enforce_case = traits.Bool(True,
                               usedefault=True,
                               desc='Enforce snake case for top-level keys '
                               'and camel case for nested keys')
Пример #3
0
class _TSV2JSONInputSpec(BaseInterfaceInputSpec):
    in_file = File(exists=True, mandatory=True, desc="Input TSV file")
    index_column = traits.Str(
        mandatory=True,
        desc="Name of the column in the TSV to be used "
        "as the top-level key in the JSON. All "
        "remaining columns will be assigned as "
        "nested keys.",
    )
    output = traits.Either(
        None,
        File,
        desc="Path where the output file is to be saved. "
        "If this is `None`, then a JSON-compatible "
        "dictionary is returned instead.",
    )
    additional_metadata = traits.Either(
        None,
        traits.Dict,
        traits.Instance(OrderedDict),
        usedefault=True,
        desc="Any additional metadata that "
        "should be applied to all "
        "entries in the JSON.",
    )
    drop_columns = traits.Either(
        None,
        traits.List(),
        usedefault=True,
        desc="List of columns in the TSV to be "
        "dropped from the JSON.",
    )
    enforce_case = traits.Bool(
        True,
        usedefault=True,
        desc="Enforce snake case for top-level keys "
        "and camel case for nested keys",
    )
Пример #4
0
class _DictMergeInputSpec(BaseInterfaceInputSpec):
    in_dicts = traits.List(
        traits.Either(traits.Dict, traits.Instance(OrderedDict)),
        desc="Dictionaries to be merged. In the event of a collision, values "
        "from dictionaries later in the list receive precedence.",
    )