def startProcess(self, movies, length): stats = {"added": 0, "updated": 0, "removed": 0} for count, movie in enumerate(movies): if util.abortRequested() or (not(HIDE_TOP250) and self.progress.iscanceled()): break result = self.checkMovie(movie) if result != None: stats[result] += 1 if not(HIDE_TOP250): self.progress.update((count * 100) // length, "%s %s" % (l("Searching_for"), movie["label"])) else: util.writeDate("top250") self.createMissingCSV() if OPEN_MISSING: util.openFile("missingTop250.csv") stats["missing"] = len(self.top250) util.log("Movies IMDb Top250 summary: updated: %(updated)s, added: %(added)s, removed: %(removed)s, missing: %(missing)s" % stats) if HIDE_TOP250: util.notification("%s %s" % (l("Completed"), l("Top250"))) else: util.dialogOk(l("Completed"), l("Movies_IMDb_Top250_summary"), "%s %s" % (stats["updated"], l("were_updated")), "%s %s %s %s" % (stats["added"], l("were_added_and"), stats["removed"], l("were_removed!")))
def startProcess(self, movies, length): stats = {"added": 0, "updated": 0, "removed": 0} for count, movie in enumerate(movies): if util.abortRequested() or (not (HIDE_TOP250) and self.progress.iscanceled()): break result = self.checkMovie(movie) if result != None: stats[result] += 1 if not (HIDE_TOP250): self.progress.update( (count * 100) // length, "%s %s" % (l("Searching_for"), movie["label"])) else: util.writeDate("top250") self.createMissingCSV() if OPEN_MISSING: util.openFile("missingTop250.csv") stats["missing"] = len(self.top250) util.log( "Movies IMDb Top250 summary: updated: %(updated)s, added: %(added)s, removed: %(removed)s, missing: %(missing)s" % stats) if HIDE_TOP250: util.notification("%s %s" % (l("Completed"), l("Top250"))) else: util.dialogOk( l("Completed"), l("Movies_IMDb_Top250_summary"), "%s %s" % (stats["updated"], l("were_updated")), "%s %s %s %s" % (stats["added"], l("were_added_and"), stats["removed"], l("were_removed!")))
def OnDropFiles(self, x, y, fullnames): logging.debug("These files were dropped: %s", fullnames) for fullname in fullnames: fileExtension = os.path.splitext(fullname)[1] if fileExtension == PVS_EXTENSION: util.openFile(fullname)
def onOpenFile(event): """called to handle 'open file' request""" logging.debug("Starting") frame = util.getMainFrame() filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION dialog = wx.FileDialog (frame, "Open PVS file", wildcard = filters, style = wx.OPEN ) if dialog.ShowModal() == wx.ID_OK: fullname = dialog.GetPath() logging.info("Opening file %s", fullname) util.openFile(fullname) else: logging.info("Nothing was selected.") dialog.Destroy()
def onCreateNewFile(event): """called to handle 'create new file' request""" logging.debug("Starting") frame = util.getMainFrame() filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION dialog = wx.FileDialog (frame, "Create a new PVS file", wildcard = filters, style = wx.SAVE | wx.OVERWRITE_PROMPT ) if dialog.ShowModal() == wx.ID_OK: fullname = dialog.GetPath() if not fullname.endswith(PVS_EXTENSION): fullname = fullname + PVS_EXTENSION logging.info("Creating new file %s", fullname) util.openFile(fullname) else: logging.info("Nothing was selected.") dialog.Destroy()
def onOpenFile(event): """called to handle 'open file' request""" logging.debug("Starting") frame = util.getMainFrame() filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION dialog = wx.FileDialog(frame, "Open PVS file", wildcard=filters, style=wx.OPEN) if dialog.ShowModal() == wx.ID_OK: fullname = dialog.GetPath() logging.info("Opening file %s", fullname) util.openFile(fullname) else: logging.info("Nothing was selected.") dialog.Destroy()
def getTeamSeasonHtml(self): html = INVALID_STRING if cmp(self._htmlWebSite, INVALID_STRING) == 0: print "htmlWebSite has not been initialized yet" else: #If we have already synced the data we need to fetch the html from local instead of reloading the website again pathNeed2Test = CURRENT_PATH + self._Season0 + self._Season1 + '/' + self._Team_id print "Constructing path as ", pathNeed2Test self._dataStoredPath = pathNeed2Test util.mkdir(pathNeed2Test) htmlFile = pathNeed2Test + '/' + self._GameType + '.html' self._seasonDataHtmlFile = htmlFile print "Check if html file exist or not ", htmlFile if os.path.isfile(htmlFile): print "html file exists, open the file, read it and return the string" html = util.openFile(htmlFile) #print html else: print "html file does not exist, now loading the webpage from network" html = util.getHtmlFromUrl(self._htmlWebSite) if cmp(html, INVALID_STRING) != 0: util.saveFile(htmlFile, html) return html return html
def getTeamSeasonHtml(self): html = INVALID_STRING if cmp(self._htmlWebSite, INVALID_STRING) == 0: print "htmlWebSite has not been initialized yet" else: #If we have already synced the data we need to fetch the html from local instead of reloading the website again pathNeed2Test = CURRENT_PATH + self._Season0 + self._Season1 + '/' + self._Team_id print "Constructing path as ", pathNeed2Test self._dataStoredPath = pathNeed2Test util.mkdir(pathNeed2Test) htmlFile = pathNeed2Test + '/' + self._GameType + '.html' self._seasonDataHtmlFile = htmlFile print "Check if html file exist or not ", htmlFile if os.path.isfile(htmlFile): print "html file exists, open the file, read it and return the string" html = util.openFile(htmlFile) #print html else: print "html file does not exist, now loading the webpage from network" html = util.getHtmlFromUrl(self._htmlWebSite) if cmp(html, INVALID_STRING)!=0: util.saveFile(htmlFile,html) return html return html
def onCreateNewFile(event): """called to handle 'create new file' request""" logging.debug("Starting") frame = util.getMainFrame() filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION dialog = wx.FileDialog(frame, "Create a new PVS file", wildcard=filters, style=wx.SAVE | wx.OVERWRITE_PROMPT) if dialog.ShowModal() == wx.ID_OK: fullname = dialog.GetPath() if not fullname.endswith(PVS_EXTENSION): fullname = fullname + PVS_EXTENSION logging.info("Creating new file %s", fullname) util.openFile(fullname) else: logging.info("Nothing was selected.") dialog.Destroy()
def openImage(file_path=None): # Open Image file_path = openFile() if not file_path else file_path img = cv.imread(file_path,1) # Image can be resized to a standard size to speed up processing. c = 1000.0/img.shape[0] x = int(img.shape[0] * c) y = int(img.shape[1] * c) img = cv.resize(img, (y,x)) return img
def openImage(): # Open Image file_path = openFile() img = cv2.imread(file_path,1) # Image can be resized to a standard size to speed up processing. c = 1000.0/img.shape[0] x = int(img.shape[0] * c) y = int(img.shape[1] * c) img = cv2.resize(img, (y,x)) return img
def getSingleGameHtml(self, singleGameLink): singleGameUrl = 'http://stat-nba.com/' + singleGameLink singleGameHtmlFileName = re.sub('\/', '_', singleGameLink) print singleGameHtmlFileName singleGameHtmlFilePath = self._dataStoredPath + '/' + singleGameHtmlFileName print singleGameHtmlFilePath singleGameHtml = INVALID_STRING if os.path.isfile(singleGameHtmlFilePath): #If html file exist, read it and return the html content print singleGameHtmlFilePath + " exist, open the file and read it" singleGameHtml = util.openFile(singleGameHtmlFilePath) else: print singleGameHtmlFilePath + " doesn't exist, load the webpage" singleGameHtml = util.getHtmlFromUrl(singleGameUrl) util.saveFile(singleGameHtmlFilePath, singleGameHtml) return singleGameHtml
def getSingleGameHtml(self, singleGameLink): singleGameUrl = 'http://stat-nba.com/'+singleGameLink singleGameHtmlFileName = re.sub('\/', '_', singleGameLink) print singleGameHtmlFileName singleGameHtmlFilePath = self._dataStoredPath + '/' + singleGameHtmlFileName print singleGameHtmlFilePath singleGameHtml = INVALID_STRING if os.path.isfile(singleGameHtmlFilePath): #If html file exist, read it and return the html content print singleGameHtmlFilePath+ " exist, open the file and read it" singleGameHtml = util.openFile(singleGameHtmlFilePath) else: print singleGameHtmlFilePath + " doesn't exist, load the webpage" singleGameHtml = util.getHtmlFromUrl(singleGameUrl) util.saveFile(singleGameHtmlFilePath, singleGameHtml) return singleGameHtml
import knn import util test = knn.KNN() data = util.openFile("data/iris.csv") print(test.knnRun(data, 5))