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

Added(yaml): specified SafeLoader everywhere to avoid warning #220

Merged
merged 1 commit into from
Feb 19, 2021
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
Added(yaml): specified SafeLoader everywhere to avoid warning
  • Loading branch information
strizhechenko committed Sep 22, 2020
commit f75c0fcc7d2c8eba40dd150d9b8e5968bfb8da32
3 changes: 2 additions & 1 deletion netutils_linux_hardware/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def parse(text):
types = ['SSD', 'HDD']
if not text:
return dict()
data = yaml.load(text.replace(':', ': ').replace('/sys/block/', '').replace('/queue/rotational', ''))
_text = text.replace(':', ': ').replace('/sys/block/', '').replace('/queue/rotational', '')
data = yaml.load(_text, yaml.loader.SafeLoader)
return dict((k, types[v]) for k, v in data.items())

class DiskSizeInfo(Parser):
Expand Down
3 changes: 2 additions & 1 deletion netutils_linux_hardware/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class MemInfo(YAMLLike):
)

def parse(self, text):
return dict((k, int(v.replace(' kB', ''))) for k, v in iteritems(yaml.load(text)) if k in self.keys_required)
data = yaml.load(text, yaml.loader.SafeLoader)
return dict((k, int(v.replace(' kB', ''))) for k, v in iteritems(data) if k in self.keys_required)


class MemInfoDMIDevice(object):
Expand Down
2 changes: 1 addition & 1 deletion netutils_linux_hardware/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def parse_file_safe(self, filepath, **kwargs):
class YAMLLike(Parser):
@staticmethod
def parse(text):
return yaml.load(text)
return yaml.load(text, yaml.loader.SafeLoader)