(self,textoutfile)
Formats site information correctly and prints it to an output file in text format.
        Returns nothing.

        Argument(s):
        textoutfile -- A string representation of a file that will store the output.

        Return value(s):
        Nothing is returned from this Method.

        Restriction(s):
        The Method has no restrictions.
Formats site information correctly and prints it to an output file in text format.
        Returns nothing.
Formats site information correctly and prints it to an output file in text format . Returns nothing .
def PrintToTextFile(self,textoutfile):
        """
        Formats site information correctly and prints it to an output file in text format.
        Returns nothing.

        Argument(s):
        textoutfile -- A string representation of a file that will store the output.

        Return value(s):
        Nothing is returned from this Method.

        Restriction(s):
        The Method has no restrictions.
        """
        sites = sorted(self.ListOfSites, key=attrgetter('Target'))
        target = ""
        print "\n[+] Generating text output: " + textoutfile
        f = open(textoutfile, "w")
        if sites is not None:
            for site in sites:
                if not isinstance(site._regex,basestring): #this is a multisite
                    for index in range(len(site.RegEx)): #the regexs will ensure we have the exact number of lookups
                        siteimpprop = site.getImportantProperty(index)
                        if target != site.Target:
                            f.write("\n____________________     Results found for: " + site.Target + "     ____________________")
                            target = site.Target
                        if siteimpprop is None or len(siteimpprop)==0:
                            f.write("\nNo results in the " + site.FriendlyName[index] + " category")
                        else:
                            if siteimpprop[index] is None or len(siteimpprop[index]) == 0:
                                f.write('\n' + site.ReportStringForResult[index] + ' No results found')
                            else:
                                laststring = ""
                                #if it's just a string we don't want it to output like a list
                                if isinstance(siteimpprop[index], basestring):
                                    if "" + site.ReportStringForResult[index] + " " + str(siteimpprop) != laststring:
                                        f.write("\n" + site.ReportStringForResult[index] + " " + str(siteimpprop))
                                        laststring = "" + site.ReportStringForResult[index] + " " + str(siteimpprop)
                                #must be a list since it failed the isinstance check on string
                                else:
                                    laststring = ""
                                    for siteresult in siteimpprop[index]:
                                        if "" + site.ReportStringForResult[index] + " " + str(siteresult) != laststring:
                                            f.write("\n" + site.ReportStringForResult[index] + " " + str(siteresult))
                                            laststring = "" + site.ReportStringForResult[index] + " " + str(siteresult)
                else:#this is a singlesite
                    siteimpprop = site.getImportantProperty(0)
                    if target != site.Target:
                        f.write("\n____________________     Results found for: " + site.Target + "     ____________________")
                        target = site.Target
                    if siteimpprop is None or len(siteimpprop)==0:
                        f.write("\nNo results found in the " + site.FriendlyName)
                    else:
                        laststring = ""
                        #if it's just a string we don't want it output like a list
                        if isinstance(siteimpprop, basestring):
                            if "" + site.ReportStringForResult + " " + str(siteimpprop) != laststring:
                                f.write("\n" + site.ReportStringForResult + " " + str(siteimpprop))
                                laststring = "" + site.ReportStringForResult + " " + str(siteimpprop)
                        else:
                            laststring = ""
                            for siteresult in siteimpprop:
                                if "" + site.ReportStringForResult + " " + str(siteresult) != laststring:
                                    f.write("\n" + site.ReportStringForResult + " " + str(siteresult))
                                    laststring = "" + site.ReportStringForResult + " " + str(siteresult)
        f.flush()
        f.close()
        print "" + textoutfile + " Generated"
def PrintToTextFile ( self , textoutfile ) : sites = sorted ( self . ListOfSites , key = attrgetter ( 'Target' ) ) target = "" print "\n[+] Generating text output: " + textoutfile f = open ( textoutfile , "w" ) if sites is not None : for site in sites : if not isinstance ( site . _regex , basestring ) : #this is a multisite for index in range ( len ( site . RegEx ) ) : #the regexs will ensure we have the exact number of lookups siteimpprop = site . getImportantProperty ( index ) if target != site . Target : f . write ( "\n____________________     Results found for: " + site . Target + "     ____________________" ) target = site . Target if siteimpprop is None or len ( siteimpprop ) == 0 : f . write ( "\nNo results in the " + site . FriendlyName [ index ] + " category" ) else : if siteimpprop [ index ] is None or len ( siteimpprop [ index ] ) == 0 : f . write ( '\n' + site . ReportStringForResult [ index ] + ' No results found' ) else : laststring = "" #if it's just a string we don't want it to output like a list if isinstance ( siteimpprop [ index ] , basestring ) : if "" + site . ReportStringForResult [ index ] + " " + str ( siteimpprop ) != laststring : f . write ( "\n" + site . ReportStringForResult [ index ] + " " + str ( siteimpprop ) ) laststring = "" + site . ReportStringForResult [ index ] + " " + str ( siteimpprop ) #must be a list since it failed the isinstance check on string else : laststring = "" for siteresult in siteimpprop [ index ] : if "" + site . ReportStringForResult [ index ] + " " + str ( siteresult ) != laststring : f . write ( "\n" + site . ReportStringForResult [ index ] + " " + str ( siteresult ) ) laststring = "" + site . ReportStringForResult [ index ] + " " + str ( siteresult ) else : #this is a singlesite siteimpprop = site . getImportantProperty ( 0 ) if target != site . Target : f . write ( "\n____________________     Results found for: " + site . Target + "     ____________________" ) target = site . Target if siteimpprop is None or len ( siteimpprop ) == 0 : f . write ( "\nNo results found in the " + site . FriendlyName ) else : laststring = "" #if it's just a string we don't want it output like a list if isinstance ( siteimpprop , basestring ) : if "" + site . ReportStringForResult + " " + str ( siteimpprop ) != laststring : f . write ( "\n" + site . ReportStringForResult + " " + str ( siteimpprop ) ) laststring = "" + site . ReportStringForResult + " " + str ( siteimpprop ) else : laststring = "" for siteresult in siteimpprop : if "" + site . ReportStringForResult + " " + str ( siteresult ) != laststring : f . write ( "\n" + site . ReportStringForResult + " " + str ( siteresult ) ) laststring = "" + site . ReportStringForResult + " " + str ( siteresult ) f . flush ( ) f . close ( ) print "" + textoutfile + " Generated"