(self,csvoutfile)
Formats site information correctly and prints it to an output file with comma-seperators.
        Returns nothing.

        Argument(s):
        csvoutfile -- 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 with comma-seperators.
        Returns nothing.
Formats site information correctly and prints it to an output file with comma - seperators . Returns nothing .
def PrintToCSVFile(self,csvoutfile):
        """
        Formats site information correctly and prints it to an output file with comma-seperators.
        Returns nothing.

        Argument(s):
        csvoutfile -- 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 CSV output: ' + csvoutfile
        f = open(csvoutfile, "wb")
        csvRW = csv.writer(f, quoting=csv.QUOTE_ALL)
        csvRW.writerow(['Target', 'Type', 'Source', 'Result'])
        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 siteimpprop is None or len(siteimpprop)==0:
                            tgt = site.Target
                            typ = site.TargetType
                            source = site.FriendlyName[index]
                            res = "No results found"
                            csvRW.writerow([tgt,typ,source,res])
                        else:
                            if siteimpprop[index] is None or len(siteimpprop[index])==0:
                                tgt = site.Target
                                typ = site.TargetType
                                source = site.FriendlyName[index]
                                res = "No results found"
                                csvRW.writerow([tgt,typ,source,res])
                            else:
                                laststring = ""
                                #if it's just a string we don't want it to output like a list
                                if isinstance(siteimpprop, basestring):
                                    tgt = site.Target
                                    typ = site.TargetType
                                    source = site.FriendlyName
                                    res = siteimpprop
                                    if "" + tgt + typ + source + res != laststring:
                                        csvRW.writerow([tgt,typ,source,res])
                                        laststring = "" + tgt + typ + source + res
                                #must be a list since it failed the isinstance check on string
                                else:
                                    laststring = ""
                                    for siteresult in siteimpprop[index]:
                                        tgt = site.Target
                                        typ = site.TargetType
                                        source = site.FriendlyName[index]
                                        res = siteresult
                                        if "" + tgt + typ + source + str(res) != laststring:
                                            csvRW.writerow([tgt,typ,source,res])
                                            laststring = "" + tgt + typ + source + str(res)
                else:#this is a singlesite
                    siteimpprop = site.getImportantProperty(0)
                    if siteimpprop is None or len(siteimpprop)==0:
                        tgt = site.Target
                        typ = site.TargetType
                        source = site.FriendlyName
                        res = "No results found"
                        csvRW.writerow([tgt,typ,source,res])
                    else:
                        laststring = ""
                        #if it's just a string we don't want it output like a list
                        if isinstance(siteimpprop, basestring):
                            tgt = site.Target
                            typ = site.TargetType
                            source = site.FriendlyName
                            res = siteimpprop
                            if "" + tgt + typ + source + res != laststring:
                                csvRW.writerow([tgt,typ,source,res])
                                laststring = "" + tgt + typ + source + res
                        else:
                            laststring = ""
                            for siteresult in siteimpprop:
                                tgt = site.Target
                                typ = site.TargetType
                                source = site.FriendlyName
                                res = siteresult
                                if "" + tgt + typ + source + str(res) != laststring:
                                    csvRW.writerow([tgt,typ,source,res])
                                    laststring = "" + tgt + typ + source + str(res)

        f.flush()
        f.close()
        print "" + csvoutfile + " Generated"
def PrintToCSVFile ( self , csvoutfile ) : sites = sorted ( self . ListOfSites , key = attrgetter ( 'Target' ) ) target = "" print '\n[+] Generating CSV output: ' + csvoutfile f = open ( csvoutfile , "wb" ) csvRW = csv . writer ( f , quoting = csv . QUOTE_ALL ) csvRW . writerow ( [ 'Target' , 'Type' , 'Source' , 'Result' ] ) 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 siteimpprop is None or len ( siteimpprop ) == 0 : tgt = site . Target typ = site . TargetType source = site . FriendlyName [ index ] res = "No results found" csvRW . writerow ( [ tgt , typ , source , res ] ) else : if siteimpprop [ index ] is None or len ( siteimpprop [ index ] ) == 0 : tgt = site . Target typ = site . TargetType source = site . FriendlyName [ index ] res = "No results found" csvRW . writerow ( [ tgt , typ , source , res ] ) else : laststring = "" #if it's just a string we don't want it to output like a list if isinstance ( siteimpprop , basestring ) : tgt = site . Target typ = site . TargetType source = site . FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring : csvRW . writerow ( [ tgt , typ , source , res ] ) laststring = "" + tgt + typ + source + res #must be a list since it failed the isinstance check on string else : laststring = "" for siteresult in siteimpprop [ index ] : tgt = site . Target typ = site . TargetType source = site . FriendlyName [ index ] res = siteresult if "" + tgt + typ + source + str ( res ) != laststring : csvRW . writerow ( [ tgt , typ , source , res ] ) laststring = "" + tgt + typ + source + str ( res ) else : #this is a singlesite siteimpprop = site . getImportantProperty ( 0 ) if siteimpprop is None or len ( siteimpprop ) == 0 : tgt = site . Target typ = site . TargetType source = site . FriendlyName res = "No results found" csvRW . writerow ( [ tgt , typ , source , res ] ) else : laststring = "" #if it's just a string we don't want it output like a list if isinstance ( siteimpprop , basestring ) : tgt = site . Target typ = site . TargetType source = site . FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring : csvRW . writerow ( [ tgt , typ , source , res ] ) laststring = "" + tgt + typ + source + res else : laststring = "" for siteresult in siteimpprop : tgt = site . Target typ = site . TargetType source = site . FriendlyName res = siteresult if "" + tgt + typ + source + str ( res ) != laststring : csvRW . writerow ( [ tgt , typ , source , res ] ) laststring = "" + tgt + typ + source + str ( res ) f . flush ( ) f . close ( ) print "" + csvoutfile + " Generated"