Changeset 3551 for proto/xmlschema
 Timestamp:
 Nov 3, 2013, 10:42:49 AM (6 years ago)
 Location:
 proto/xmlschema
 Files:

 2 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

proto/xmlschema/src/po_gen.py
r3549 r3551 1 1 import random 2 3 f_street_name = open('street_name_list','r') 4 street_lst = [] 5 s = f_street_name.readlines() 6 for line in s: 7 street_lst.append(line[:1]) 8 9 f_street_name.close() 2 10 3 11 name_lst = ['Bruna Gullett','Terrence Stearns', 'Perry Sensabaugh', … … 20 28 'Lawerence Backes' ] 21 29 22 name_lg = len( name_lst)30 name_lg = len(street_lst) 23 31 24 32 def phone_gen(): … … 28 36 return (str(s1)+''+str(s2)+''+str(s3)) 29 37 30 def payment_gen():31 r1 = ''32 for i in range(16):33 r = random.randint(1,9)34 r1+=str(r)35 r2 = ''36 for i in range(13):37 r = random.randint(1,9)38 r2+=str(r)39 return r1,r240 41 38 def decription_write(fin,t1,t2): 39 count = 0 40 count2 = 0 41 count_e = 0 42 42 tmp = '<decription>\n' 43 count += (len(tmp)) 44 count_e += 1 43 45 fin.write(tmp) 44 s = '<productor>\n' 46 s = '<productor>' 47 count += (len(s)) 48 count_e += 1 45 49 fin.write(s) 46 50 r1 = random.randint(1,name_lg) 47 s1 = name_lst[r11] 48 fin.write(s1+'\n') 51 s1 = street_lst[r11] 52 count += (len(s1)) 53 fin.write(s1) 49 54 s = '</productor>\n' 55 count += (len(s)) 50 56 fin.write(s) 51 s = '<distributor>\n' 57 s = '<distributor>' 58 count += (len(s)) 59 count_e += 1 52 60 fin.write(s) 53 61 r1 = random.randint(1,name_lg) 54 s1 = name_lst[r11] 55 fin.write(s1+'\n') 62 s1 = street_lst[r11] 63 count += (len(s1)) 64 fin.write(s1) 56 65 s = '</distributor>\n' 66 count += (len(s)) 57 67 fin.write(s) 58 s = '<retailer>\n' 68 s = '<retailer>' 69 count += (len(s)) 70 count_e += 1 59 71 fin.write(s) 60 72 r1 = random.randint(1,name_lg) 61 s1 = name_lst[r11] 62 fin.write(s1+'\n') 73 s1 = street_lst[r11] 74 count += (len(s1)) 75 fin.write(s1) 63 76 s = '</retailer>\n' 77 count += (len(s)) 64 78 fin.write(s) 65 79 num = random.randint(t1,t2) 66 80 for i in range(num): 67 s = '<phone>\n' 81 s = '<phone>' 82 count += (len(s)) 83 count_e += 1 68 84 fin.write(s) 69 85 s1 = phone_gen() 70 fin.write(s1+'\n') 86 count += (len(s1)) 87 count2 += (len(s1)) 88 fin.write(s1) 71 89 s = '</phone>\n' 90 count += (len(s)) 72 91 fin.write(s) 73 92 tmp = '</decription>\n' 93 count += (len(tmp)) 74 94 fin.write(tmp) 95 return count,count2,count_e 75 96 76 97 77 98 def payment_write(fin): 99 count = 0 78 100 tmp = '<payment>\n' 101 count += (len(tmp)) 79 102 fin.write(tmp) 80 103 r = random.randint(1,2) … … 84 107 r = random.randint(1,9) 85 108 r1+=str(r) 86 tmp = '<creditCard>\n' 109 tmp = '<creditCard>' 110 count += (len(tmp)) 87 111 fin.write(tmp) 88 fin.write(r1+'\n') 112 count += (len(r1)) 113 fin.write(r1) 89 114 tmp = '</creditCard>\n' 115 count += (len(tmp)) 90 116 fin.write(tmp) 91 117 else: … … 94 120 r = random.randint(1,9) 95 121 r1+=str(r) 96 tmp = '<debitCard>\n' 122 tmp = '<debitCard>' 123 count += (len(tmp)) 97 124 fin.write(tmp) 98 fin.write(r1+'\n') 125 count += (len(r1)) 126 fin.write(r1) 99 127 tmp = '</debitCard>\n' 128 count += (len(tmp)) 100 129 fin.write(tmp) 101 130 tmp = '</payment>\n' 102 fin.write(tmp) 131 count += (len(tmp)) 132 fin.write(tmp) 133 return count,2 103 134 104 135 def po_write(fin,t1,t2): 136 count = 0 137 count_e = 0 105 138 tmp = '<purchaseOrder>\n' 139 count += (len(tmp)) 106 140 fin.write(tmp) 107 decription_write(fin,t1,t2) 108 payment_write(fin) 141 count_d,count_2,count_e1 = decription_write(fin,t1,t2) 142 count += count_d 143 count_e += count_e1 144 count_p,count_e2 = payment_write(fin) 145 count += count_p 146 count_e += count_e2 109 147 tmp = '</purchaseOrder>\n' 148 count += (len(tmp)) 110 149 fin.write(tmp) 150 return count,count_2,count_e 111 151 112 152 113 153 def records_write(fin,p1,p2,t1,t2): 114 tmp = "<?xml version='1.0' encoding='UTF8' ?>\n" 154 count = 0 155 count_2 = 0 156 count_e = 0 157 tmp = "<?xml version='1.0' encoding='UTF8' ?>\n\n" 158 count += (len(tmp)) 115 159 fin.write(tmp) 116 tmp = '<records xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:noNamespaceSchemaLocation="po.xsd">\n' 160 tmp = '<records xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"\n xsi:noNamespaceSchemaLocation="po.xsd">\n' 161 count += (len(tmp)) 117 162 fin.write(tmp) 118 count = random.randint(p1,p2)119 163 r = random.randint(p1,p2) 120 164 for i in range(r): 121 po_write(fin,t1,t2) 165 count_po,count_ph,count_e1 = po_write(fin,t1,t2) 166 count += count_po 167 count_2 += count_ph 168 count_e += count_e1 122 169 tmp = '</records>\n' 170 count += (len(tmp)) 123 171 fin.write(tmp) 124 172 return count,count_2,count_e 173 ''' 125 174 fin = open('po_new.xml','w') 126 175 p1 = 1 … … 128 177 t1 = 1 129 178 t2 = 5 130 records_write(fin,p1,p2,t1,t2) 179 180 print records_write(fin,p1,p2,t1,t2) 181 ''' 131 182 132 
proto/xmlschema/validation_template_onevec_po.cpp
r3550 r3551 22 22 #define VECTOR_TYPE (char) 23 23 24 #define DEBUG 124 //#define DEBUG 1 25 25 26 26 //#define DATATYPE 1
Note: See TracChangeset
for help on using the changeset viewer.