This file is indexed.

/usr/bin/hachoir-metadata is in python-hachoir-metadata 1.3.3-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/python

import sys
try:
    from hachoir_core.error import error, HachoirError
    from hachoir_core.cmd_line import unicodeFilename
    from hachoir_core.i18n import getTerminalCharset, _
    from hachoir_core.benchmark import Benchmark
    from hachoir_core.stream import InputStreamError
    from hachoir_core.tools import makePrintable
    from hachoir_parser import createParser, ParserList
    import hachoir_core.config as hachoir_config
    from hachoir_metadata import config
except ImportError, err:
    raise
    print >>sys.stderr, "Unable to import an Hachoir module: %s" % err
    sys.exit(1)
from optparse import OptionGroup, OptionParser
from hachoir_metadata import extractMetadata
from hachoir_metadata.metadata import extractors as metadata_extractors


def displayParserList(*args):
    parser_list = ParserList()
    for parser in metadata_extractors.keys():
        parser_list.add(parser)
    parser_list.print_(_("List of metadata extractors."))
    sys.exit(0)

def displayVersion(*args):
    import hachoir_core
    from hachoir_metadata import __version__
    print _("Metadata extractor version %s") % __version__
    print _("Hachoir library version %s") % hachoir_core.__version__
    print
    print _("Website: %s/wiki/hachoir-metadata") % hachoir_core.WEBSITE
    sys.exit(0)

def parseOptions():
    parser = OptionParser(usage="%prog [options] files")
    parser.add_option("--type", help=_("Only display file type (description)"),
        action="store_true", default=False)
    parser.add_option("--mime", help=_("Only display MIME type"),
        action="store_true", default=False)
    parser.add_option("--level",
        help=_("Quantity of information to display from 1 to 9 (9 is the maximum)"),
        action="store", default="9", type="choice",
        choices=[ str(choice) for choice in xrange(1,9+1) ])
    parser.add_option("--raw", help=_("Raw output"),
        action="store_true", default=False)
    parser.add_option("--bench", help=_("Run benchmark"),
        action="store_true", default=False)
    parser.add_option("--force-parser",help=_("List all parsers then exit"),
        type="str")
    parser.add_option("--parser-list",help=_("List all parsers then exit"),
        action="callback", callback=displayParserList)
    parser.add_option("--profiler", help=_("Run profiler"),
        action="store_true", default=False)
    parser.add_option("--version", help=_("Display version and exit"),
        action="callback", callback=displayVersion)
    parser.add_option("--quality", help=_("Information quality (0.0=fastest, 1.0=best, and default is 0.5)"),
        action="store", type="float", default="0.5")
    parser.add_option("--maxlen", help=_("Maximum string length in characters, 0 means unlimited (default: %s)" % config.MAX_STR_LENGTH),
        type="int", default=config.MAX_STR_LENGTH)
    parser.add_option("--verbose", help=_("Verbose mode"),
        default=False, action="store_true")
    parser.add_option("--debug", help=_("Debug mode"),
        default=False, action="store_true")

    values, filename = parser.parse_args()
    if len(filename) == 0:
        parser.print_help()
        sys.exit(1)

    # Update limits
    config.MAX_STR_LENGTH = values.maxlen
    if values.raw:
        config.RAW_OUTPUT = True

    return values, filename

def processFile(values, filename,
display_filename=False, priority=None, human=True, display=True):
    charset = getTerminalCharset()
    filename, real_filename = unicodeFilename(filename, charset), filename

    # Create parser
    try:
        if values.force_parser:
            tags = [ ("id", values.force_parser), None ]
        else:
            tags = None
        parser = createParser(filename, real_filename=real_filename, tags=tags)
    except InputStreamError, err:
        error(unicode(err))
        return False
    if not parser:
        error(_("Unable to parse file: %s") % filename)
        return False

    # Extract metadata
    extract_metadata = not(values.mime or values.type)
    if extract_metadata:
        try:
            metadata = extractMetadata(parser, values.quality)
        except HachoirError, err:
            error(unicode(err))
            metadata = None
        if not metadata:
            parser.error(_("Hachoir can't extract metadata, but is able to parse: %s")
                % filename)
            return False

    if display:
        # Display metadatas on stdout
        if extract_metadata:
            text = metadata.exportPlaintext(priority=priority, human=human)
            if not text:
                text = [_("(no metadata, priority may be too small)")]
            if display_filename:
                for line in text:
                    line = "%s: %s" % (filename, line)
                    print makePrintable(line, charset)
            else:
                for line in text:
                    print makePrintable(line, charset)
        else:
            if values.type:
                text = parser.description
            else:
                text = parser.mime_type
            if display_filename:
                text = "%s: %s" % (filename, text)
            print text
    return True

def processFiles(values, filenames, display=True):
    human = not(values.raw)
    ok = True
    priority = int(values.level)*100 + 99
    display_filename = (1 < len(filenames))
    for filename in filenames:
        ok &= processFile(values, filename, display_filename, priority, human, display)
    return ok

def benchmarkMetadata(values, filenames):
    bench = Benchmark()
    bench.run(processFiles, values, filenames, display=False)

def profile(values, filenames):
    from hachoir_core.profiler import runProfiler
    return runProfiler(processFiles, (values, filenames), {'display': False})

def main():
    try:
        # Parser options and initialize Hachoir
        values, filenames = parseOptions()

        if values.debug:
            hachoir_config.debug = True
        elif values.verbose:
            hachoir_config.verbose = True
        else:
            hachoir_config.quiet = True

        if values.profiler:
            ok = profile(values, filenames)
        elif values.bench:
            ok = benchmarkMetadata(values, filenames)
        else:
            ok = processFiles(values, filenames)
    except KeyboardInterrupt:
        print _("Program interrupted (CTRL+C).")
        ok = False
    sys.exit(int(not ok))

if __name__ == "__main__":
    main()