<commit_before>#!/usr/bin/python2.4
import sys
import os
import inspect
import dbus

inspectmod=__import__(sys.argv[1],globals(), locals(),['*'])

doc={}

for (cname,val) in inspectmod.__dict__.items():
    if inspect.isclass(val):
        if val.__dict__.has_key("_dbus_interfaces"):
            for iname in val._dbus_interfaces:
                doc[iname]={}
                doc[iname]["maintext"]=val.__doc__
                doc[iname]["methods"]={}
                doc[iname]["signals"]={}
        for (mname, mval) in val.__dict__.items():
            if inspect.isfunction(mval) and mval.__dict__.has_key("_dbus_is_method"):
                iname=mval.__dict__["_dbus_interface"]
                if not doc.has_key(iname):
                    doc[iname]={}
                    doc[iname]["maintext"]=val.__doc__
                    doc[iname]["methods"]={}
                    doc[iname]["signals"]={}
                doc[iname]["methods"][mname]={}
                sigin=dbus.Signature(mval.__dict__["_dbus_in_signature"])
                argspec=inspect.getargspec(mval)
                args=', '.join(map(lambda tup: str(tup[0])+": "+tup[1], zip(sigin,argspec[0][1:]))) # chop off self
                doc[iname]["methods"][mname]["in_sig"]=args
                if mval.__dict__["_dbus_out_signature"] == "":
                    doc[iname]["methods"][mname]["out_sig"]="None"
                else:
                    doc[iname]["methods"][mname]["out_sig"]=mval.__dict__["_dbus_out_signature"]
                doc[iname]["methods"][mname]["text"]= mval.__doc__
            elif inspect.isfunction(mval) and mval.__dict__.has_key("_dbus_is_signal"):
                iname=mval.__dict__["_dbus_interface"]
                if not doc.has_key(iname):
                    doc[iname]={}
                    doc[iname]["maintext"]=val.__doc__
                    doc[iname]["methods"]={}
                    doc[iname]["signals"]={}
                doc[iname]["signals"][mname]={}
                sig=dbus.Signature(mval.__dict__["_dbus_signature"])
                argspec=mval.__dict__["_dbus_args"]
                args=', '.join(map(lambda tup: str(tup[0])+": "+tup[1], zip(sig,argspec)))
                doc[iname]["signals"][mname]["sig"]=args
                doc[iname]["signals"][mname]["text"]= mval.__doc__


if sys.argv[2][:17]== "--generate-order=":
    order=file(sys.argv[2][17:],'w')
    order.write('\n'.join(doc.keys()))
    sys.exit(0)
else:
    print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
    print '<head>'
    print '<title>Telepathy: D-Bus Interface Specification</title>' # inspectmod.__name__,'</title>'
#    print '<link rel="stylesheet" type="text/css" media="screen" href="style.css" />'
    print '<style type="text/css">'
    style = file('style.css')
    for line in style:
        print line.strip()
    del style
    print '</style>'
    print '</head>'
    print '<body>'
    print '<div class="topbox">Telepathy</div>'

#    print '<div class="sidebar">'
#    order = file(sys.argv[2])<commit_msg>add checks so that number of arguments equal signal length<commit_after>#!/usr/bin/python2.4
import sys
import os
import inspect
import dbus

inspectmod=__import__(sys.argv[1],globals(), locals(),['*'])

doc={}

for (cname,val) in inspectmod.__dict__.items():
    if inspect.isclass(val):
        if val.__dict__.has_key("_dbus_interfaces"):
            for iname in val._dbus_interfaces:
                doc[iname]={}
                doc[iname]["maintext"]=val.__doc__
                doc[iname]["methods"]={}
                doc[iname]["signals"]={}
        for (mname, mval) in val.__dict__.items():
            if inspect.isfunction(mval) and mval.__dict__.has_key("_dbus_is_method"):
                iname=mval.__dict__["_dbus_interface"]
                if not doc.has_key(iname):
                    doc[iname]={}
                    doc[iname]["maintext"]=val.__doc__
                    doc[iname]["methods"]={}
                    doc[iname]["signals"]={}
                doc[iname]["methods"][mname]={}
                sigin=tuple(dbus.Signature(mval.__dict__["_dbus_in_signature"]))
                argspec=inspect.getargspec(mval)
                args=argspec[0][1:] # chop off self
                if len(args) != len(sigin):
                    raise Exception('number of arguments in signature %s differs from number of arguments to method %s in interface %s' % (mval.__dict__["_dbus_in_signature"], mname, iname))
                decorated_args=', '.join(map(lambda tup: str(tup[0])+": "+tup[1], zip(sigin,args)))
                doc[iname]["methods"][mname]["in_sig"]=decorated_args
                if mval.__dict__["_dbus_out_signature"] == "":
                    doc[iname]["methods"][mname]["out_sig"]="None"
                else:
                    doc[iname]["methods"][mname]["out_sig"]=mval.__dict__["_dbus_out_signature"]
                doc[iname]["methods"][mname]["text"]= mval.__doc__
            elif inspect.isfunction(mval) and mval.__dict__.has_key("_dbus_is_signal"):
                iname=mval.__dict__["_dbus_interface"]
                if not doc.has_key(iname):
                    doc[iname]={}
                    doc[iname]["maintext"]=val.__doc__
                    doc[iname]["methods"]={}
                    doc[iname]["signals"]={}
                doc[iname]["signals"][mname]={}
                sig=tuple(dbus.Signature(mval.__dict__["_dbus_signature"]))
                argspec=mval.__dict__["_dbus_args"]
                if len(argspec) != len(sig):
                    raise Exception('number of arguments in signature %s differs from number of arguments to signature %s in interface %s' % (mval.__dict__["_dbus_signature"], mname, iname))
                args=', '.join(map(lambda tup: str(tup[0])+": "+tup[1], zip(sig,argspec)))
                doc[iname]["signals"][mname]["sig"]=args
                doc[iname]["signals"][mname]["text"]= mval.__doc__


if sys.argv[2][:17]== "--generate-order=":
    order=file(sys.argv[2][17:],'w')
    order.write('\n'.join(doc.keys()))
    sys.exit(0)
else:
    print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
    print '<head>'
    print '<title>Telepathy: D-Bus Interface Specification</title>' # inspectmod.__name__,'</title>'
#    print '<link rel="stylesheet" type="text/css" media="screen" href="style.css" />'
    print '<style type="text/css">'
    style = file('style.css')
    for line in style:
        print line.strip()
    del style
    print '</style>'
    print '</head>'
    print '<body>'
    print '<div class="topbox">Telepathy</div>'

#    print '<div class="sidebar">'
#    order = file(sys.argv[2])
{'fraction_non_alphanumeric': 0.17555173402120952, 'fraction_numerical': 0.008025222126683863, 'mean_word_length': 2.443019240256537, 'pattern_counts': {'":': 8, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, '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': '3463961', 'n_tokens_mistral': 2377, 'n_tokens_neox': 2288, 'n_words': 359}