Skip to content

Commit

Permalink
Merge branch 'support-python2' of git://github.com/mprahl/libmodulemd
Browse files Browse the repository at this point in the history
  • Loading branch information
sgallagher committed May 2, 2019
2 parents 7d7dfd6 + 925b883 commit 65baa8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bindings/python/gi/overrides/Modulemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
__all__ = []


class ModulemdUtil():
class ModulemdUtil(object):

@staticmethod
def variant_str(s):
""" Converts a string to a GLib.Variant
"""
Expand All @@ -52,6 +53,7 @@ def variant_str(s):

return GLib.Variant('s', s)

@staticmethod
def variant_bool(b):
""" Converts a boolean to a GLib.Varant
"""
Expand All @@ -60,6 +62,7 @@ def variant_bool(b):

return GLib.Variant('b', b)

@staticmethod
def variant_list(l):
""" Converts a list to a GLib.Variant
"""
Expand All @@ -71,6 +74,7 @@ def variant_list(l):
l_variant.append(ModulemdUtil.python_to_variant(item))
return GLib.Variant('av', l_variant)

@staticmethod
def variant_dict(d):
""" Converts a dictionary to a dictionary of GLib.Variant
"""
Expand All @@ -80,6 +84,7 @@ def variant_dict(d):
d_variant = ModulemdUtil.dict_values(d)
return GLib.Variant('a{sv}', d_variant)

@staticmethod
def dict_values(d):
""" Converts each dictionary value to a GLib.Variant
"""
Expand All @@ -94,6 +99,7 @@ def dict_values(d):
d_variant[k] = ModulemdUtil.python_to_variant(v)
return d_variant

@staticmethod
def python_to_variant(obj):
if isinstance(obj, str):
return ModulemdUtil.variant_str(obj)
Expand Down

0 comments on commit 65baa8c

Please sign in to comment.