def _get_content(self):
        all_chars = [chr(x) for x in range(128)]
        all_chars.remove(self.TERM)

        result = ''
        b_len = randint(5, self.INBUFSZ - 1)  #TERM is added at the end.
        remaining = b_len
        while 0 < remaining:

            if self.chance(0.7):
                result += sp.random_alpha(0,
                                          10 if remaining > 10 else remaining)
            elif self.chance(0.3):
                result += sp.random_digits(0,
                                           10 if remaining > 10 else remaining)
            else:
                result += ''.join(
                    choice(all_chars)
                    for _ in range(0, 10 if remaining > 10 else remaining))

            if len(result) >= b_len:
                break

            if self.chance(0.7):
                result += ' '
            else:
                result += '.'

            if self.chance(0.1):
                result += '\n'

            remaining = b_len - len(result)

        if True == self.DEBUG_CONTENT:
            result = "Bob's discount randumb stor-E gener8r for only $12.99. Come on in.\nGet your storie today!\n"

        if True == DEBUG:
            r = '\\'.join(hex(ord(c)) for c in result)
            print "result hex: {0}".format(r)
            print "result: {0}".format(result)

        return result
示例#2
0
    def _get_content(self):
        all_chars = [chr(x) for x in range(128)]
        all_chars.remove(self.TERM)

        result = ""
        b_len = randint(5, self.INBUFSZ - 1)  # TERM is added at the end.
        remaining = b_len
        while 0 < remaining:

            if self.chance(0.7):
                result += sp.random_alpha(0, 10 if remaining > 10 else remaining)
            elif self.chance(0.3):
                result += sp.random_digits(0, 10 if remaining > 10 else remaining)
            else:
                result += "".join(choice(all_chars) for _ in range(0, 10 if remaining > 10 else remaining))

            if len(result) >= b_len:
                break

            if self.chance(0.7):
                result += " "
            else:
                result += "."

            if self.chance(0.1):
                result += "\n"

            remaining = b_len - len(result)

        if True == self.DEBUG_CONTENT:
            result = "Bob's discount randumb stor-E gener8r for only $12.99. Come on in.\nGet your storie today!\n"

        if True == DEBUG:
            r = "\\".join(hex(ord(c)) for c in result)
            print "result hex: {0}".format(r)
            print "result: {0}".format(result)

        return result
    def gen_totals_and_ds(self):
        ident = self.id_num
        income = self.wages + self.interest + self.biz_income + self.retirement_income
        expenses = self.biz_expenses + self.edu_expenses + self.self_employ_expenses
        credits = self.edu_credits + self.child_credits + self.retirement_credits + self.home_buyer_credits
        payments = self.tax_withheld + self.tax_paid_non_taxable_income

        base_tax = 12345
        taxable_income = (income >> 3)
        expense_deduction = (expenses >> 4)
        credit_deduction = (credits >> 2)
        total_tax_owed = base_tax + self.amount + taxable_income - expense_deduction - credit_deduction - payments

        # if DEBUG:
        #     print " total_tax_owed: {0} = {1} + {2} + {3} - {4} - {5} - {6}". \
        #         format(total_tax_owed, base_tax, self.amount, taxable_income, expense_deduction, credit_deduction, payments)

        if 0 < total_tax_owed:
            self.tax_due = total_tax_owed
        else:
            self.tax_refund = -total_tax_owed

        l_ident = list(sp.pack_single_uint32(ident))
        l_income = list(sp.pack_single_int64(income))
        l_expenses = list(sp.pack_single_int64(expenses))
        l_credits = list(sp.pack_single_int64(credits))
        l_payments = list(sp.pack_single_int64(payments))

        self.digital_signature[0] = ord(l_ident[0]) ^ ord(self.fname[0])
        self.digital_signature[1] = ord(l_ident[1]) ^ ord(self.mname[0])
        self.digital_signature[2] = ord(l_ident[2]) ^ ord(self.lname[1])
        self.digital_signature[3] = ord(l_ident[3]) ^ ord(self.addy[1])
        self.digital_signature[4] = ord(self.csz[0]) ^ ord(self.fname[1])
        self.digital_signature[5] = ord(self.csz[1]) ^ ord(self.mname[1])
        self.digital_signature[6] = ord(self.csz[2]) ^ ord(self.lname[2])
        self.digital_signature[7] = ord(self.csz[3]) ^ ord(self.addy[2])

        self.digital_signature[4] ^= ord(l_income[0])
        self.digital_signature[5] ^= ord(l_income[1])
        self.digital_signature[6] ^= ord(l_income[2])
        self.digital_signature[7] ^= ord(l_income[3])
        self.digital_signature[8] = ord(l_income[4])
        self.digital_signature[9] = ord(l_income[5])
        self.digital_signature[10] = ord(l_income[6])
        self.digital_signature[11] = ord(l_income[7])

        self.digital_signature[8] ^= ord(l_expenses[0])
        self.digital_signature[9] ^= ord(l_expenses[1])
        self.digital_signature[10] ^= ord(l_expenses[2])
        self.digital_signature[11] ^= ord(l_expenses[3])
        self.digital_signature[12] = ord(l_expenses[4])
        self.digital_signature[13] = ord(l_expenses[5])
        self.digital_signature[14] = ord(l_expenses[6])
        self.digital_signature[15] = ord(l_expenses[7])

        self.digital_signature[12] ^= ord(l_credits[0])
        self.digital_signature[13] ^= ord(l_credits[1])
        self.digital_signature[14] ^= ord(l_credits[2])
        self.digital_signature[15] ^= ord(l_credits[3])
        self.digital_signature[16] = ord(l_credits[4])
        self.digital_signature[17] = ord(l_credits[5])
        self.digital_signature[18] = ord(l_credits[6])
        self.digital_signature[19] = ord(l_credits[7])

        self.digital_signature[16] ^= ord(l_payments[0])
        self.digital_signature[17] ^= ord(l_payments[1])
        self.digital_signature[18] ^= ord(l_payments[2])
        self.digital_signature[19] ^= ord(l_payments[3])
        self.digital_signature[20] = ord(l_payments[4]) ^ ord(self.fname[3])
        self.digital_signature[21] = ord(l_payments[5]) ^ ord(self.mname[4])
        self.digital_signature[22] = ord(l_payments[6]) ^ ord(self.lname[5])
        self.digital_signature[23] = ord(l_payments[7]) ^ ord(self.addy[6])

        self.digital_signature = [chr(x) for x in self.digital_signature]

        self.submission_date = sp.random_digits(8)
        while "00000000" == self.submission_date:
            self.submission_date = sp.random_digits(8)
示例#4
0
 def rand_barcode(self):
     return sp.random_digits(8)
示例#5
0
    def gen_totals_and_ds(self):
        ident = self.id_num
        income = self.wages + self.interest + self.biz_income + self.retirement_income
        expenses = self.biz_expenses + self.edu_expenses + self.self_employ_expenses
        credits = self.edu_credits + self.child_credits + self.retirement_credits + self.home_buyer_credits
        payments = self.tax_withheld + self.tax_paid_non_taxable_income

        base_tax = 12345
        taxable_income = income >> 3
        expense_deduction = expenses >> 4
        credit_deduction = credits >> 2
        total_tax_owed = base_tax + self.amount + taxable_income - expense_deduction - credit_deduction - payments

        # if DEBUG:
        #     print " total_tax_owed: {0} = {1} + {2} + {3} - {4} - {5} - {6}". \
        #         format(total_tax_owed, base_tax, self.amount, taxable_income, expense_deduction, credit_deduction, payments)

        if 0 < total_tax_owed:
            self.tax_due = total_tax_owed
        else:
            self.tax_refund = -total_tax_owed

        l_ident = list(sp.pack_single_uint32(ident))
        l_income = list(sp.pack_single_int64(income))
        l_expenses = list(sp.pack_single_int64(expenses))
        l_credits = list(sp.pack_single_int64(credits))
        l_payments = list(sp.pack_single_int64(payments))

        self.digital_signature[0] = ord(l_ident[0]) ^ ord(self.fname[0])
        self.digital_signature[1] = ord(l_ident[1]) ^ ord(self.mname[0])
        self.digital_signature[2] = ord(l_ident[2]) ^ ord(self.lname[1])
        self.digital_signature[3] = ord(l_ident[3]) ^ ord(self.addy[1])
        self.digital_signature[4] = ord(self.csz[0]) ^ ord(self.fname[1])
        self.digital_signature[5] = ord(self.csz[1]) ^ ord(self.mname[1])
        self.digital_signature[6] = ord(self.csz[2]) ^ ord(self.lname[2])
        self.digital_signature[7] = ord(self.csz[3]) ^ ord(self.addy[2])

        self.digital_signature[4] ^= ord(l_income[0])
        self.digital_signature[5] ^= ord(l_income[1])
        self.digital_signature[6] ^= ord(l_income[2])
        self.digital_signature[7] ^= ord(l_income[3])
        self.digital_signature[8] = ord(l_income[4])
        self.digital_signature[9] = ord(l_income[5])
        self.digital_signature[10] = ord(l_income[6])
        self.digital_signature[11] = ord(l_income[7])

        self.digital_signature[8] ^= ord(l_expenses[0])
        self.digital_signature[9] ^= ord(l_expenses[1])
        self.digital_signature[10] ^= ord(l_expenses[2])
        self.digital_signature[11] ^= ord(l_expenses[3])
        self.digital_signature[12] = ord(l_expenses[4])
        self.digital_signature[13] = ord(l_expenses[5])
        self.digital_signature[14] = ord(l_expenses[6])
        self.digital_signature[15] = ord(l_expenses[7])

        self.digital_signature[12] ^= ord(l_credits[0])
        self.digital_signature[13] ^= ord(l_credits[1])
        self.digital_signature[14] ^= ord(l_credits[2])
        self.digital_signature[15] ^= ord(l_credits[3])
        self.digital_signature[16] = ord(l_credits[4])
        self.digital_signature[17] = ord(l_credits[5])
        self.digital_signature[18] = ord(l_credits[6])
        self.digital_signature[19] = ord(l_credits[7])

        self.digital_signature[16] ^= ord(l_payments[0])
        self.digital_signature[17] ^= ord(l_payments[1])
        self.digital_signature[18] ^= ord(l_payments[2])
        self.digital_signature[19] ^= ord(l_payments[3])
        self.digital_signature[20] = ord(l_payments[4]) ^ ord(self.fname[3])
        self.digital_signature[21] = ord(l_payments[5]) ^ ord(self.mname[4])
        self.digital_signature[22] = ord(l_payments[6]) ^ ord(self.lname[5])
        self.digital_signature[23] = ord(l_payments[7]) ^ ord(self.addy[6])

        self.digital_signature = [chr(x) for x in self.digital_signature]

        self.submission_date = sp.random_digits(8)
        while "00000000" == self.submission_date:
            self.submission_date = sp.random_digits(8)
示例#6
0
 def rand_barcode(self):
     return sp.random_digits(8)