Skip to content

Commit

Permalink
Support ruamel.yaml 0.15+ API
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard committed Jun 28, 2017
1 parent 1ca163e commit da3864a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion streamparse/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ruamel import yaml
from six import integer_types, string_types


class _StoreDictAction(argparse.Action):
"""Action for storing key=val option strings as a single dict."""
def __init__(self, option_strings, dest, nargs=None, const=None,
Expand All @@ -33,7 +34,11 @@ def __call__(self, parser, namespace, values, option_string=None):
# Only doing a copy here because that's what _AppendAction does
items = copy.copy(getattr(namespace, self.dest))
key, val = values.split("=", 1)
items[key] = yaml.safe_load(val)
if yaml.version_info < (0, 15):
items[key] = yaml.safe_load(val)
else:
yml = yaml.YAML(typ='safe', pure=True)
items[key] = yml.load(val)
setattr(namespace, self.dest, items)


Expand Down
6 changes: 5 additions & 1 deletion streamparse/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def run_local_topology(name=None, env_name=None, time=0, options=None):
with NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as yaml_file:
topology_flux_dict = topology_class.to_flux_dict(name)
topology_flux_dict['config'] = storm_options
yaml.safe_dump(topology_flux_dict, yaml_file)
if yaml.version_info < (0, 15):
yaml.safe_dump(topology_flux_dict, yaml_file)
else:
yml = yaml.YAML(typ='safe', pure=True)
yml.dump(topology_flux_dict, yaml_file)
cmd = ('storm jar {jar} org.apache.storm.flux.Flux --local --no-splash '
'--sleep {time} {yaml}'.format(jar=topology_jar,
time=time,
Expand Down
1 change: 0 additions & 1 deletion streamparse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from fabric.colors import red, yellow
from pkg_resources import parse_version
from prettytable import PrettyTable
from ruamel import yaml
from six import iteritems
from six.moves.socketserver import UDPServer, TCPServer
from thriftpy.protocol import TBinaryProtocolFactory
Expand Down

0 comments on commit da3864a

Please sign in to comment.