| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,8 @@ def input(filename, **kwargs): | |||
| 16 | 16 | kwargs['filename'] = filename | |
| 17 | 17 | fmt = kwargs.pop('f', None) | |
| 18 | 18 | if fmt: | |
| 19 | - assert 'format' not in kwargs, "Can't specify both `format` and `f` kwargs" | ||
| 19 | + if 'format' in kwargs: | ||
| 20 | + raise ValueError("Can't specify both `format` and `f` kwargs") | ||
| 20 | 21 | kwargs['format'] = fmt | |
| 21 | 22 | return InputNode(input.__name__, **kwargs) | |
| 22 | 23 | ||
@@ -46,7 +47,8 @@ def output(parent_node, filename, **kwargs): | |||
| 46 | 47 | kwargs['filename'] = filename | |
| 47 | 48 | fmt = kwargs.pop('f', None) | |
| 48 | 49 | if fmt: | |
| 49 | - assert 'format' not in kwargs, "Can't specify both `format` and `f` kwargs" | ||
| 50 | + if 'format' in kwargs: | ||
| 51 | + raise ValueError("Can't specify both `format` and `f` kwargs") | ||
| 50 | 52 | kwargs['format'] = fmt | |
| 51 | 53 | return OutputNode([parent_node], output.__name__, **kwargs) | |
| 52 | 54 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ def _get_input_args(input_node): | |||
| 47 | 47 | args += _convert_kwargs_to_cmd_line_args(kwargs) | |
| 48 | 48 | args += ['-i', filename] | |
| 49 | 49 | else: | |
| 50 | - assert False, 'Unsupported input node: {}'.format(input_node) | ||
| 50 | + raise ValueError('Unsupported input node: {}'.format(input_node)) | ||
| 51 | 51 | return args | |
| 52 | 52 | ||
| 53 | 53 | ||
@@ -56,7 +56,8 @@ def _topo_sort(start_node): | |||
| 56 | 56 | sorted_nodes = [] | |
| 57 | 57 | child_map = {} | |
| 58 | 58 | def visit(node, child): | |
| 59 | - assert node not in marked_nodes, 'Graph is not a DAG' | ||
| 59 | + if node in marked_nodes: | ||
| 60 | + raise RuntimeError('Graph is not a DAG') | ||
| 60 | 61 | if child is not None: | |
| 61 | 62 | if node not in child_map: | |
| 62 | 63 | child_map[node] = [] | |
@@ -89,7 +90,7 @@ def _get_global_args(node): | |||
| 89 | 90 | if node._name == overwrite_output.__name__: | |
| 90 | 91 | return ['-y'] | |
| 91 | 92 | else: | |
| 92 | - assert False, 'Unsupported global node: {}'.format(node) | ||
| 93 | + raise ValueError('Unsupported global node: {}'.format(node)) | ||
| 93 | 94 | ||
| 94 | 95 | ||
| 95 | 96 | def _get_output_args(node, stream_name_map): | |
@@ -107,7 +108,7 @@ def _get_output_args(node, stream_name_map): | |||
| 107 | 108 | args += _convert_kwargs_to_cmd_line_args(kwargs) | |
| 108 | 109 | args += [filename] | |
| 109 | 110 | else: | |
| 110 | - assert False, 'Unsupported output node: {}'.format(node) | ||
| 111 | + raise ValueError('Unsupported output node: {}'.format(node)) | ||
| 111 | 112 | return args | |
| 112 | 113 | ||
| 113 | 114 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,8 @@ class Node(object): | |||
| 9 | 9 | """Node base""" | |
| 10 | 10 | def __init__(self, parents, name, *args, **kwargs): | |
| 11 | 11 | parent_hashes = [hash(parent) for parent in parents] | |
| 12 | - assert len(parent_hashes) == len(set(parent_hashes)), 'Same node cannot be included as parent multiple times' | ||
| 12 | + if len(parent_hashes) != len(set(parent_hashes)): | ||
| 13 | + raise ValueError('Same node cannot be included as parent multiple times') | ||
| 13 | 14 | self._parents = parents | |
| 14 | 15 | self._hash = None | |
| 15 | 16 | self._name = name | |
@@ -65,7 +66,8 @@ class OutputNode(Node): | |||
| 65 | 66 | ||
| 66 | 67 | class GlobalNode(Node): | |
| 67 | 68 | def __init__(self, parent, name, *args, **kwargs): | |
| 68 | - assert isinstance(parent, OutputNode), 'Global nodes can only be attached after output nodes' | ||
| 69 | + if not isinstance(parent, OutputNode): | ||
| 70 | + raise RuntimeError('Global nodes can only be attached after output nodes') | ||
| 69 | 71 | super(GlobalNode, self).__init__([parent], name, *args, **kwargs) | |
| 70 | 72 | ||
| 71 | 73 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments