How to use getFirstLine method in autotest

Best Python code snippet using autotest_python

bdefile.py

Source:bdefile.py Github

copy

Full Screen

...96 97 def getStartedSumups(self):98 sums = []99 for sumup in self.sumups:100 if sumup.getFirstLine() == self:101 sums.append(sumup)102 return sums103 104 def getTerminatedSumups(self):105 sums = []106 for sumup in self.sumups:107 if sumup.getLastLine() == self:108 sums.append(sumup)109 return sums110 111 112class BdeSumup(object):113 '''114 classdocs115 '''116117 def __init__(self, name):118 '''119 Constructor120 '''121 self.name = name122 self.lines = []123 self.status = 0124 self.reporting = None125 126 def addLine(self, line):127 self.lines.append(line);128 line.addSumup(self)129 130 def getFirstLine(self):131 return self.lines[0]132 133 def getLastLine(self):134 return self.lines[len(self.lines)-1]135 136 def getStartTime(self):137 return self.getFirstLine().getDateTime()138 139 def getEndTime(self):140 return self.getLastLine().getDateTime()141 142 def calculateDuration(self):143 '''144 Calculate the duration of the sumup by take the time difference of145 the first line and the last line. Duration unit is hour.146 '''147 stime = self.getStartTime()148 etime = self.getEndTime()149 return (etime-stime).seconds/3600.150 151 def calculateImpressionTotal(self):152 sit = self.getFirstLine().getImpressionTotal()153 eit = self.getLastLine().getImpressionTotal()154 return eit-sit155156157class BdeSumupList(object):158 159 def __init__(self):160 self.list = []161 162 def add(self, sumup):163 # Add the sumup in order of start time164 stime = sumup.getFirstLine().getDateTime()165 if self.list == []:166 self.list.append(sumup)167 else:168 for idx, element in enumerate(self.list):169 if element.getFirstLine().getDateTime() > stime:170 self.list.insert(idx, sumup)171 return172 self.list.append(sumup)173 174 def __iter__(self):175 return iter(self.list)176 177 def __len__(self):178 return len(self.list)179 180 def __getitem__(self, index):181 return self.list[index]182 183 def show(self):184 for sumup in self.list:185 print '%10s %8.2f %5d %5d %s %s %12d' % (sumup.name,186 sumup.calculateDuration(),187 sumup.getFirstLine().getLineNumber(),188 sumup.getLastLine().getLineNumber(),189 sumup.getStartTime(),190 sumup.getEndTime(),191 sumup.calculateImpressionTotal())192 193 194class BdeReporting(object):195 196 def __init__(self):197 self.sumups = []198199 def addSumup(self, sumup):200 # Add the sumup in order of start time201 stime = sumup.getFirstLine().getDateTime()202 if self.sumups == []:203 self.sumups.append(sumup)204 else:205 for idx, element in enumerate(self.sumups):206 if element.name != sumup.name:207 raise BdeException, 'Only one category Sumup can be added into one Reporting.'208 if element.lines[0].getDateTime() > stime:209 self.sumups.insert(idx, sumup)210 return211 self.sumups.append(sumup)212 # Mark the sumup's reporting 213 sumup.reporting = self214 215 def getFirstSumup(self):216 return self.sumups[0]217 218 def getLastSumup(self):219 return self.sumups[len(self.sumups)-1]220 221 def calculateDuration(self):222 stime = self.getFirstSumup().getFirstLine().getDateTime()223 etime = self.getLastSumup().getLastLine().getDateTime()224 return (etime-stime).seconds/3600.225 226 def calculateImpressionTotal(self):227 sit = self.getFirstSumup().getFirstLine().getImpressionTotal()228 eit = self.getLastSumup().getLastLine().getImpressionTotal()229 return eit-sit230 231 def getName(self):232 return self.getFirstSumup().name233 234 def merge(self, reporting):235 for sumup in reporting.sumups:236 self.addSumup(sumup)237 238239class BdeReportingList(object):240 241 def __init__(self):242 self.list = []243 244 def add(self, reporting):245 self.list.append(reporting)246247 def __iter__(self):248 return iter(self.list)249 250 def __len__(self):251 return len(self.list)252 253 def __getitem__(self, index):254 return self.list[index]255 256 257 def show(self):258 for reporting in self.list:259 print '%10s %8.2f %5d %5d %s %s %12d' % (reporting.getName(),260 reporting.calculateDuration(),261 reporting.getFirstSumup().getFirstLine().getLineNumber(),262 reporting.getLastSumup().getLastLine().getLineNumber(),263 reporting.getFirstSumup().getStartTime(),264 reporting.getLastSumup().getEndTime(),265 reporting.calculateImpressionTotal())266 267 def report(self, output=sys.stdout):268 for reporting in self.list:269 output.write('0, %d, %s, %s, %s, %0.2f, %d\n' %270 (reporting.getFirstSumup().getFirstLine().getLineNumber(),271 reporting.getFirstSumup().getStartTime(),272 reporting.getFirstSumup().getFirstLine().getJobID(),273 reporting.getName(),274 reporting.calculateDuration(),275 reporting.calculateImpressionTotal())) ...

Full Screen

Full Screen

SmaliEntry.py

Source:SmaliEntry.py Github

copy

Full Screen

...111 return False112 113 def undoFormatUsingField(self, formatMap):114 return False115 def getFirstLine(self):116 if self.mFirstLine is None: 117 self.mFirstLine = self.getContent().getFirstLine()118 119 return self.mFirstLine120 121 def getName(self):122 if self.mName is None:123 if self.getFirstLine() is None:124 return ""125 splitArray = self.getFirstLine().split()126 self.mName = splitArray[len(splitArray) - 1]127 return self.mName128 def getKeyList(self):129 if self.mKeyList is None:130 splitArray = self.getFirstLine().split()131 if len(splitArray) >= 3:132 self.mKeyList = splitArray[1:len(splitArray) - 1]133 else:134 self.mKeyList = []135 136 # print "keyList: %s" %self.mKeyList137 return self.mKeyList138 139 def hasKey(self, key):140 if key is None:141 return False142 143 for k in self.getKeyList():144 if k == key:145 return True146 147 return False148 149 def hasKeyList(self, keyList):150 if keyList is None:151 return False152 153 for k in keyList:154 if self.hasKey(k):155 return True156 157 return False158 159 def getAttributeList(self):160 firstLine = self.getContent().getFirstLine()161 splitArray = firstLine.split()162 return splitArray[1:(len(splitArray) - 1)]163 164 def getAttributes(self):165 return string.join(self.getAttributeList())166 def getSimpleString(self):167 return "%s %s->%s" % (self.getType(), self.getClassName(), self.getName())168 def toString(self):169 if self.getPreContentStr() is not None: 170 if self.getContentStr() is not None:171 return "%s\n%s" % (self.getPreContentStr(), self.getContentStr())172 else:173 return self.getPreContentStr()174 else:...

Full Screen

Full Screen

cr_dict.py

Source:cr_dict.py Github

copy

Full Screen

...56def getExtension(filename):7 return filename.split('.').pop()89def getFirstLine(file):10 return file.readlines()[0].strip()1112def getFilename(path):13 return path.split('/').pop()14 15 16for subdir, dirs, files in os.walk(rootdir):17 for file in files:18 ext = getExtension(file)19 20 if ext == "zip":21 try:22 z = zipfile.ZipFile(file)23 except zipfile.BadZipfile:24 continue25 for f in z.namelist():26 ext_zip = getExtension(f)27 if ext_zip in ['truck', 'trailer', 'airplane', 'boat', 'load']:28 list[getFilename(f)] = getFirstLine(z.open(f))29 z.close()30 elif ext in ['truck', 'trailer', 'airplane', 'boat', 'load']:31 f = open(file, 'r')32 list[getFilename(file)] = getFirstLine(f)33 f.close()3435output = open('output.txt', 'w')36output.write("list = {\n")37for filename in list:38 output.write(" '%s': '%s',\n" % (filename, list[filename]))39output.write("}") ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful