Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml upgrade #714

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rez/cli/_bez.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run():
sys.exit(1)

with open(".bez.yaml") as f:
doc = yaml.load(f.read())
doc = yaml.load(f.read(), Loader=yaml.FullLoader)

source_path = doc["source_path"]
buildfile = os.path.join(source_path, "rezbuild.py")
Expand Down
2 changes: 1 addition & 1 deletion src/rez/cli/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def command(opts, parser, extra_arg_groups=None):
with open(yaml_file) as f:
content = f.read()
try:
doc = yaml.load(content)
doc = yaml.load(content, Loader=yaml.FullLoader)
except YAMLError as e:
raise RezSystemError("Invalid executable file %s: %s"
% (yaml_file, str(e)))
Expand Down
2 changes: 1 addition & 1 deletion src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def _load_config_yaml(filepath):
with open(filepath) as f:
content = f.read()
try:
doc = yaml.load(content) or {}
doc = yaml.load(content, Loader=yaml.FullLoader) or {}
except YAMLError as e:
raise ConfigurationError("Error loading configuration from %s: %s"
% (filepath, str(e)))
Expand Down
2 changes: 1 addition & 1 deletion src/rez/resolved_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ def _read_from_buffer(cls, buf, identifier_str=None):
if content.startswith('{'): # assume json content
doc = json.loads(content)
else:
doc = yaml.load(content)
doc = yaml.load(content, Loader=yaml.FullLoader)

context = cls.from_dict(doc, identifier_str)
return context
Expand Down
2 changes: 1 addition & 1 deletion src/rez/serialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def load_yaml(stream, **kwargs):
# "<string>" with the filename if there's an error...
content = stream.read()
try:
return yaml.load(content) or {}
return yaml.load(content, Loader=yaml.FullLoader) or {}
except Exception as e:
if stream.name and stream.name != '<string>':
for mark_name in 'context_mark', 'problem_mark':
Expand Down
2 changes: 1 addition & 1 deletion src/rez/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def load(cls, path):

try:
with open(filepath) as f:
data = yaml.load(f.read())
data = yaml.load(f.read(), Loader=yaml.FullLoader)
except YAMLError as e:
raise SuiteError("Failed loading suite: %s" % str(e))

Expand Down
4 changes: 2 additions & 2 deletions src/rez/tests/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _setup_release(self):

self.packagefile = os.path.join(self.src_root, "package.yaml")
with open(self.packagefile) as f:
self.package_data = yaml.load(f.read())
self.package_data = yaml.load(f.read(), Loader=yaml.FullLoader)

# check build system type
buildsys = create_build_system(self.src_root, verbose=True)
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_1(self):
# check the vcs contains the tags we expect
expected_value = set(["foo-1.0", "foo-1.0.1", "foo-1.1"])
with open(self.stubfile) as f:
stub_data = yaml.load(f.read())
stub_data = yaml.load(f.read(), Loader=yaml.FullLoader)
tags = set(stub_data.get("tags", {}).keys())
self.assertEqual(tags, expected_value)

Expand Down
25 changes: 1 addition & 24 deletions src/rez/utils/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ class _Dumper(SafeDumper):
"""Dumper which can serialise custom types such as Version, and keeps
long strings nicely formatted in >/| block-style format.
"""
# modified from yaml.representer.SafeRepresenter.represent_str()
def represent_str(self, data):
tag = None

if '\n' in data:
style = '|'
elif len(data) > 80:
style = '>'
else:
style = None

try:
data = unicode(data, 'ascii')
tag = u'tag:yaml.org,2002:str'
except UnicodeDecodeError:
try:
data = unicode(data, 'utf-8')
tag = u'tag:yaml.org,2002:str'
except UnicodeDecodeError:
data = data.encode('base64')
tag = u'tag:yaml.org,2002:binary'
style = '|'
return self.represent_scalar(tag, data, style=style)

def represent_as_str(self, data):
return self.represent_str(str(data))
Expand Down Expand Up @@ -73,7 +50,7 @@ def load_yaml(filepath):
"""Convenience function for loading yaml-encoded data from disk."""
with open(filepath) as f:
txt = f.read()
return yaml.load(txt)
return yaml.load(txt, Loader=yaml.FullLoader)


# Copyright 2013-2016 Allan Johns.
Expand Down
4 changes: 2 additions & 2 deletions src/rez/vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Note that the latest versions column is just to give us an idea of how far back
| six | 1.12.0 (Dec 9, 2018) | 1.12.0 (Dec 9, 2018) | Used only for its exec_ function for now. I guess if we want to support python 2 and 3 we will use it more and more. Updated (July 2019) to coincide with packaging lib addition that depends on it. |
| sortedcontainers | 1.5.7 (Dec 22, 2016) | 2.1.0 (Mar 5, 2019) | Used in the resolver. Updating would possibly give us some speed improvements. |
| version | ? | | This is actually part of rez. It's here because I've been intending on releasing it separately for ages. |
| yaml (PyYAML) | 3.10 (May 30, 2011) | 5.1 (Mar 13, 2019) | Not much changes, mostly broken releases that never made it. Between 3.10 and 5.1 there is only 3 versions that made it to the public (3.11 and 3.12, 3.13), the rest were all removed or marked as pre-release. It's safe to update. |

| yaml lib (PyYAML) | 5.1 (May 30, 2011) | 5.1.2 (Jul 5, 2018) | No changes but must maintain separate version between py2 and py3 for time being |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the doc :)

| yaml lib3 (PyYAML) | 5.1 (May 30, 2011) | 5.1.2 (Jul 31, 2019) | No changes but must maintain separate version between py2 and py3 for time being |

# Development

Expand Down
Loading