summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Naik2014-01-16 17:15:42 +0530
committerAditya Naik2014-01-16 17:15:42 +0530
commit8123a2d2c7becbe8f99548c2eeb4e17e4fe8ac25 (patch)
treeb945e22df1395ace164f7ad9c799656322d435f2
parent2e3893b9f2004c56d9c80252d8ac6c26bc8e4f9f (diff)
Added spacing: code looks prettier now
-rw-r--r--aslclass.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/aslclass.py b/aslclass.py
index d3c499e..31fda2a 100644
--- a/aslclass.py
+++ b/aslclass.py
@@ -15,6 +15,7 @@ from paths import listpaths
import re
class ASLreport:
+
def __init__(self):
self.shotcount=0
self.pauseinterval=[]
@@ -27,8 +28,11 @@ class ASLreport:
# load a file or start a new state?
if load=='y': pass
elif load=='n': self.loader()
+
self.name=input("\nEnter movie name:\n")
+
print("press enter to start")
+
keystroke=str(msvcrt.getch())[-2]
if keystroke=="r":
print("counter begins")
@@ -38,13 +42,16 @@ class ASLreport:
def loader(self):
pathlist=os.listdir(".")
print(pathlist)
+
serial=input("Enter the serial number of the savefile (starts from 0)\n")
# if the filetype does not have the required extension
if listpaths('.')[int(serial)][-9:len(listpaths('.')[int(serial)])]!="savestate":
sys.exit("unknown filetype")
loader=open(listpaths('.')[int(serial)], mode="r").read()
+
# loading algorithm: search for required values with regex
data=re.search(r"(?P<MovieName>.+)\n(?P<TotalTime>.+)\n(?P<ShotCount>\d+)",loader)
+
# assign values
try:
self.name=data.group('MovieName')
@@ -54,6 +61,7 @@ class ASLreport:
except AttributeError:
sys.exit("unknown filetype")
print("press enter to start loaded state")
+
if str(msvcrt.getch())[-2]=="r":
print("loaded state")
self.key()
@@ -69,6 +77,7 @@ class ASLreport:
# shot detected
timestamp=clock()
self.shotcount=self.shotcount+1
+
if self.pauseinterval!=[]:
# if 'pause' has never been used before
for pausetime in self.pauseinterval: tottime=tottime+pausetime
@@ -79,6 +88,7 @@ class ASLreport:
self.shotlist.append((self.shotcount,timestamp ))
print("Shot #%d at %fs "%(self.shotcount,timestamp))
self.key()
+
elif keystroke=="p": self.pause()
elif keystroke=="e" : self.reset()
else: print("Unkown keystroke")
@@ -87,6 +97,7 @@ class ASLreport:
print("paused")
self.startpause=clock()
startagain=str(msvcrt.getch())[-2]
+
if startagain=="p":
self.endpause=clock()
print("restarted")
@@ -99,14 +110,17 @@ class ASLreport:
def reset(self):
print('\n==ASLreport for "%s"=='%self.name)
self.totaltime=clock()
+
for pausetime in self.pauseinterval:
# subtract pausetime from the totaltime of the session
self.totaltime=self.totaltime-pausetime
print(self.totaltime)
+
try: self.totaltime/self.shotcount
# if shotcount is 0
except ZeroDivisionError: sys.exit("no shots recorded")
self.ASL=self.totaltime/self.shotcount
+
print("number of shots=%d"%self.shotcount)
print("ASL =%fseconds"%self.ASL)
self.report=input("\nDo you want to generate report file?(y/n)\n")