diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2010-11-28 11:14:11 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-11-28 16:11:14 +0000 |
commit | 5094414d86f574a0dd061565bfad6526a9e0ea97 (patch) | |
tree | 708ea43ccc7ad75a0600f989a1ab4191d6d4c55e /python | |
parent | be89eeaad2929155d4ab1a721bdb6e3b55ceab0c (diff) | |
download | hivex-5094414d86f574a0dd061565bfad6526a9e0ea97.tar.gz hivex-5094414d86f574a0dd061565bfad6526a9e0ea97.tar.xz hivex-5094414d86f574a0dd061565bfad6526a9e0ea97.zip |
Python bindings.
Diffstat (limited to 'python')
-rw-r--r-- | python/t/010-import.py | 18 | ||||
-rw-r--r-- | python/t/020-open.py | 26 | ||||
-rw-r--r-- | python/t/021-close.py | 28 | ||||
-rw-r--r-- | python/t/200-write.py | 43 | ||||
-rw-r--r-- | python/t/210-setvalue.py | 57 |
5 files changed, 172 insertions, 0 deletions
diff --git a/python/t/010-import.py b/python/t/010-import.py new file mode 100644 index 0000000..9979914 --- /dev/null +++ b/python/t/010-import.py @@ -0,0 +1,18 @@ +# hivex Python bindings +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import hivex diff --git a/python/t/020-open.py b/python/t/020-open.py new file mode 100644 index 0000000..57339a7 --- /dev/null +++ b/python/t/020-open.py @@ -0,0 +1,26 @@ +# hivex Python bindings +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +import hivex + +srcdir = os.environ["srcdir"] +if not srcdir: + srcdir = "." + +h = hivex.Hivex ("%s/../images/minimal" % srcdir) +assert h diff --git a/python/t/021-close.py b/python/t/021-close.py new file mode 100644 index 0000000..876836d --- /dev/null +++ b/python/t/021-close.py @@ -0,0 +1,28 @@ +# hivex Python bindings +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +import hivex + +srcdir = os.environ["srcdir"] +if not srcdir: + srcdir = "." + +h = hivex.Hivex ("%s/../images/minimal" % srcdir) +assert h + +del h diff --git a/python/t/200-write.py b/python/t/200-write.py new file mode 100644 index 0000000..0692f11 --- /dev/null +++ b/python/t/200-write.py @@ -0,0 +1,43 @@ +# hivex Python bindings +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +import hivex + +srcdir = os.environ["srcdir"] +if not srcdir: + srcdir = "." + +h = hivex.Hivex ("%s/../images/minimal" % srcdir, + write = True) +assert h + +root = h.root () +assert root + +h.node_add_child (root, "A") + +h.node_add_child (root, "B") + +b = h.node_get_child (root, "B") +assert b + +values = [ + { "key": "Key1", "t": 3, "value": "ABC" }, + { "key": "Key2", "t": 3, "value": "DEF" } +] +h.node_set_values (b, values) diff --git a/python/t/210-setvalue.py b/python/t/210-setvalue.py new file mode 100644 index 0000000..1cb8c52 --- /dev/null +++ b/python/t/210-setvalue.py @@ -0,0 +1,57 @@ +# hivex Python bindings +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +import hivex + +srcdir = os.environ["srcdir"] +if not srcdir: + srcdir = "." + +h = hivex.Hivex ("%s/../images/minimal" % srcdir, + write = True) +assert h + +root = h.root () +assert root + +h.node_add_child (root, "B") + +b = h.node_get_child (root, "B") +assert b + +values = [ + { "key": "Key1", "t": 3, "value": "ABC" }, + { "key": "Key2", "t": 3, "value": "DEF" } +] +h.node_set_values (b, values) + +value1 = { "key": "Key3", "t": 3, "value": "GHI" } +h.node_set_value (b, value1) + +value1 = { "key": "Key1", "t": 3, "value": "JKL" } +h.node_set_value (b, value1) + +val = h.node_get_value (b, "Key1") +t_data = h.value_value (val) +assert t_data[0] == 3 +assert t_data[1] == "JKL" + +val = h.node_get_value (b, "Key3") +t_data = h.value_value (val) +assert t_data[0] == 3 +assert t_data[1] == "GHI" |