File: 130-special.py

package info (click to toggle)
hivex 1.3.24-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,928 kB
  • sloc: ansic: 7,385; sh: 5,314; ml: 4,424; makefile: 559; perl: 528; python: 253; ruby: 123; xml: 104; sed: 16
file content (41 lines) | stat: -rwxr-xr-x 1,179 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding: utf-8
# http://stackoverflow.com/questions/6625782/unicode-literals-that-work-in-python-3-and-2
import sys
if sys.version < '3':
    import codecs
    def u(x):
        return codecs.unicode_escape_decode(x)[0]
else:
    def u(x):
        return x

import os
import hivex

srcdir = os.environ["srcdir"]
if not srcdir:
    srcdir = "."

h = hivex.Hivex ("%s/../images/special" % srcdir)
assert h

root = h.root ()
assert root

# "abcd_äöüß"
ns = [ n for n in h.node_children (root) if h.node_name(n) == u("abcd_\u00e4\u00f6\u00fc\u00df") ]
assert len (ns) == 1
# "abcd_äöüß"
vs = [ v for v in h.node_values (ns[0]) if h.value_key(v) == u("abcd_\u00e4\u00f6\u00fc\u00df") ]
assert len (vs) == 1
ns = [ n for n in h.node_children (root) if h.node_name(n) == u("zero\0key") ]
assert len (ns) == 1
vs = [ v for v in h.node_values (ns[0]) if h.value_key(v) == u("zero\0val") ]
assert len (vs) == 1
# "weird™"
ns = [ n for n in h.node_children (root) if h.node_name(n) == u("weird\u2122") ]
assert len (ns) == 1
# "symbols $£₤₧€"
vs = [ v for v in h.node_values (ns[0]) if h.value_key(v) == u("symbols \u0024\u00a3\u20a4\u20a7\u20ac") ]
assert len (vs) == 1