Skip to content

Commit

Permalink
Added(yaml): specified SafeLoader everywhere to avoid warning (strizh…
Browse files Browse the repository at this point in the history
  • Loading branch information
strizhechenko committed Feb 19, 2021
1 parent dfcb090 commit 9561efe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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)

0 comments on commit 9561efe

Please sign in to comment.