<commit_before># Copyright (c) 2007-2008 The PyAMF Project.
# See LICENSE for details.

"""
Extracts and displays information for files that contain AMF data.

@author: U{<NAME><mailto:<EMAIL>>}
@author: U{<NAME><mailto:<EMAIL>>}
@author: U{<NAME><mailto:<EMAIL>>}

@since: 0.1.0
"""

import glob
from optparse import OptionParser

import pyamf
from pyamf import remoting

def parse_options():
    """
    Parse command-line arguments.
    """
    parser = OptionParser()

    parser.add_option("-d", "--debug", action="store_true", dest="debug",
        default=False, help="Enable debugging")
    parser.add_option("--dump", action="store_true", dest="dump",
        default=False, help="Shows a hexdump of the file")

    return parser.parse_args()

def read_file(fname):
    """
    Read file containing AMF data.
    """
    f = file(fname, "r")
    data = f.read()
    f.close()

    return data
               
def main():
    """
    Run AMF decoder on input file.
    """
    (options, args) = parse_options()

    for arg in args:
        for fname in glob.glob(arg):

            body = read_file(fname)

            try:
                print "\nDecoding file:", fname
                request = remoting.decode(body)

                for name, message in request:
                    print "  %s: %s" % (name, message)
                
            except pyamf.UnknownClassAlias, c:
                if options.debug:
                    print '\n    Warning: %s' % c
                pass
            except:
                raise
            
            if options.dump:
                print
                print pyamf.util.hexdump(body)

            print "-" * 80
            
if __name__ == '__main__':
    main()
<commit_msg>update.<commit_after># Copyright (c) 2007-2008 The PyAMF Project.
# See LICENSE for details.

"""
Extracts and displays information for files that contain AMF data.

@author: U{<NAME><mailto:<EMAIL>>}
@author: U{<NAME><mailto:<EMAIL>>}
@author: U{<NAME><mailto:<EMAIL>>}

@since: 0.1.0
"""

import glob
from optparse import OptionParser

import pyamf
from pyamf import remoting

def parse_options():
    """
    Parse command-line arguments.
    """
    parser = OptionParser()

    parser.add_option("-d", "--debug", action="store_true", dest="debug",
        default=False, help="Enable debugging")
    parser.add_option("--dump", action="store_true", dest="dump",
        default=False, help="Shows a hexdump of the file")

    return parser.parse_args()

def read_file(fname):
    """
    Read file containing AMF data.
    """
    f = file(fname, "r")
    data = f.read()
    f.close()

    return data
               
def main():
    """
    Run AMF decoder on input file.
    """
    (options, args) = parse_options()

    for arg in args:
        for fname in glob.glob(arg):

            body = read_file(fname)

            try:
                print "\nDecoding file:", fname
                request = remoting.decode(body)

                if options.debug:
                    for name, message in request:
                        print "  %s: %s" % (name, message)
                
            except pyamf.UnknownClassAlias, c:
                if options.debug:
                    print '\n    Warning: %s' % c
                pass
            except:
                raise
            
            if options.dump:
                print
                print pyamf.util.hexdump(body)

            print "-" * 80
            
if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.12230419977298525, 'fraction_numerical': 0.0073779795686719635, 'mean_word_length': 1.7909738717339667, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2945434', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1033, 'n_words': 290}