rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
addModule(f + os.sep + i) | addDir(f + os.sep + i) addModule(f + os.sep + i, recursive=recursive) | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
addModule(f + os.sep + i) | addModule(f + os.sep + i, recursive=recursive) | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
else: addFile(f) | addFile(f) | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
addModule('ui') addModule('socks') | for m in required_modules: addModule(m) | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
print s, | print s.strip() | def log(self, message): s = u'\r\n' + self.getPrefix() + DamnUnicode(message.strip()) if DV.log_to_stdout: try: print s, except: try: print s.encode('utf8', errors='ignore'), except: print 'Cannot echo log string; invalid characters and/or non-tolerant output?' if DV.log_stdout_flush: sys.stdout.flush() if self.stream ... |
Damnlog('!!',u'\n'.join(traceback.format_exception(typ, value, tb))) | info = traceback.format_exception(typ, value, tb) e = [] for i in info: e.append(DamnUnicode(i).strip()) Damnlog('!!',u'\n'.join(e)) | def DamnlogException(typ, value, tb): try: Damnlog('!!',u'\n'.join(traceback.format_exception(typ, value, tb))) except: pass |
pass | try: Damnlog('!! Error while logging exception. Something is very wrong.') except: pass | def DamnlogException(typ, value, tb): try: Damnlog('!!',u'\n'.join(traceback.format_exception(typ, value, tb))) except: pass |
Damnlog('Trying to send event', event, 'to target', target) | def DamnPostEvent(target, event): Damnlog('Trying to send event', event, 'to target', target) try: wx.PostEvent(target, event) except: Damnlog('!! Failed delivering event', event, 'to target', target) | |
class DamnModuleUpdateCheck(thr.Thread): | class DamnModuleUpdateCheck(DamnThread): | def DamnPostEvent(target, event): Damnlog('Trying to send event', event, 'to target', target) try: wx.PostEvent(target, event) except: Damnlog('!! Failed delivering event', event, 'to target', target) |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, parent, modules, byevent=True): Damnlog('Spawned module update checker for modules', modules, 'by event:', byevent) self.parent = parent if type(modules) is not type([]): modules = [modules] self.modules = modules self.done = {} self.downloaded = [] self.byevent = byevent thr.Thread.__init__(self) |
def run(self): | def go(self): | def run(self): for module in self.modules: if not module['about'].has_key('url'): self.postEvent(module, 'cannot') elif module['about']['url'] not in self.downloaded: self.downloaded.append(module['about']['url']) checkingfor = [module] try: http = DamnURLOpen(module['about']['url']) for module2 in self.modules: if mod... |
class DamnVidUpdater(thr.Thread): | class DamnVidUpdater(DamnThread): | def DamnVersionCompare(v1, v2): # Returns 1 if v1 is newer, 0 if equal, -1 if v2 is newer. v1 = v1.split('.') v2 = v2.split('.') for i in range(len(v1)): if len(v2) <= i: return 1 if v1[i] != v2[i]: return 2 * int(v1[i] > v2[i]) - 1 if len(v1) != len(v2): return 2 * (len(v1) > len(v2)) - 1 return 0 |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, parent, verbose=False, main=True, modules=True): Damnlog('Spawned main updater thread') self.parent = parent self.todo = {'main':main, 'modules':modules} self.info = {'main':None, 'modules':{}, 'verbose':verbose} thr.Thread.__init__(self) |
def run(self): | def go(self): | def run(self): if self.todo['main']: regex = re.compile('<tt>([^<>]+)</tt>', re.IGNORECASE) try: html = DamnURLOpen(DV.url_update) for i in html: if regex.search(i): self.info['main'] = regex.search(i).group(1).strip() except: pass if self.todo['modules']: updater = DamnModuleUpdateCheck(self, DamnIterModules(False), F... |
class DamnBugReporter(thr.Thread): | class DamnBugReporter(DamnThread): | def onBtn(self, event): self.Close(True) |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, desc, steps='', sysinfo='', email='', parent=None): self.desc = desc self.steps = steps self.sysinfo = sysinfo self.email = email self.parent = parent thr.Thread.__init__(self) |
def run(self): | def go(self): | def run(self): Damnlog('Bug reporter thread launched.') if not len(self.desc): Damnlog('Bug reporter not sending anything - bug description is empty.') self.postEvent(DV.l('Empty bug description field'), DV.l('You must enter a bug description.'), error=True, closedialog=False) return Damnlog('Ready to submit bug.') Dam... |
class DamnYouTubeService(thr.Thread): | class DamnYouTubeService(DamnThread): | def onBrowse(self, event): dlg = wx.DirDialog(self, self.title, self.filefield.GetValue(), style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON) dlg.SetIcon(DV.icon) path = None if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() self.filefield.SetValue(path) dlg.Destroy() if path != None: self.callback(self, path) |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, parent, query=None): self.parent = parent thr.Thread.__init__(self) if query is None: self.queries = None else: self.queries = [query] |
def run(self): | def go(self): | def run(self): while self.queries is None: time.sleep(.025) try: self.parent.loadlevel += 1 except: pass # Window might have been closed while len(self.queries): query = self.queries[0] if query[0] == 'feed': self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(DamnUnicode(query[1]))) elif query[0] == 'image': http... |
self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(DamnUnicode(query[1]))) | self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(DamnUnicode(query[1]).encode('utf8'))) | def run(self): while self.queries is None: time.sleep(.025) try: self.parent.loadlevel += 1 except: pass # Window might have been closed while len(self.queries): query = self.queries[0] if query[0] == 'feed': self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(DamnUnicode(query[1]))) elif query[0] == 'image': http... |
prefix = 'http://gdata.youtube.com/feeds/api/videos?racy=include&orderby=viewCount&vq=' | prefix = u'http://gdata.youtube.com/feeds/api/videos?racy=include&orderby=viewCount&vq=' | def search(self, event=None, search=u''): Damnlog('YouTube browser is now searching for', search, 'from event', event) self.scrollpanel.Hide() self.waitingpanel.Show() self.toppanel.Layout() if not search: search = self.searchbox.GetValue() if not search: return search=DamnUnicode(search) self.searchbutton.LoadFile(DV.... |
prefix = 'http://gdata.youtube.com/feeds/api/standardfeeds/' | prefix = u'http://gdata.youtube.com/feeds/api/standardfeeds/' | def search(self, event=None, search=u''): Damnlog('YouTube browser is now searching for', search, 'from event', event) self.scrollpanel.Hide() self.waitingpanel.Show() self.toppanel.Layout() if not search: search = self.searchbox.GetValue() if not search: return search=DamnUnicode(search) self.searchbutton.LoadFile(DV.... |
Damnlog('YouTube browser search box populating complete, beginning actual search for', search, 'at URL:', prefix + urllib2.quote(search)) self.getService().query(('feed', DamnUnicode(prefix + urllib2.quote(search)))) | Damnlog('YouTube browser search box populating complete, beginning actual search for', search, 'at URL:', prefix + urllib2.quote(search.encode('utf8'))) self.getService().query(('feed', DamnUnicode(prefix + urllib2.quote(search.encode('utf8'))))) | def search(self, event=None, search=u''): Damnlog('YouTube browser is now searching for', search, 'from event', event) self.scrollpanel.Hide() self.waitingpanel.Show() self.toppanel.Layout() if not search: search = self.searchbox.GetValue() if not search: return search=DamnUnicode(search) self.searchbutton.LoadFile(DV.... |
class DamnVideoLoader(thr.Thread): | class DamnVideoLoader(DamnThread): | def onClose(self, event): DV.prefs = DamnVidPrefs() # Reload from ini self.Close(True) |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, parent, uris, thengo=False, feedback=True, allownonmodules=True): thr.Thread.__init__(self) self.uris = [] if type(uris) not in (type(()), type([])): uris = [uris] for i in uris: self.uris.append(DamnUnicode(i)) self.parent = parent self.thengo = thengo self.feedback = feedback self.done = False self... |
def run(self): | def go(self): | def run(self): if self.feedback: self.parent.toggleLoading(True) self.vidLoop(self.uris) self.done = True if self.feedback: self.parent.toggleLoading(False) else: while self.done: time.sleep(.1) |
class DamnConverter(thr.Thread): | class DamnConverter(DamnThread): | def vidLoop(self, uris): Damnlog('Starting vidLoop with URIs:',uris) for uri in uris: Damnlog('vidLoop considering URI:',uri) self.originaluri = uri bymodule = False for module in DamnIterModules(False): Damnlog('Trying module',module['class'],'for URI',uri) mod = module['class'](uri) if mod.validURI(): Damnlog('Module... |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, parent): self.parent = parent self.sourceuri = parent.videos[parent.converting] self.outdir = None self.filename = None self.tmpfilename = None self.moduleextraargs = [] thr.Thread.__init__(self) |
prefix = DamnUnicode(DamnUnicode(prefix).encode('ascii', 'ignore')) | prefix = DamnUnicode(REGEX_FILENAME_SANE_CHARACTERS.sub(u'', DamnUnicode(DamnUnicode(prefix).encode('ascii', 'ignore')))) | def gettmpfilename(self, path, prefix, ext): prefix = DamnUnicode(DamnUnicode(prefix).encode('ascii', 'ignore')) ext = DamnUnicode(ext) path = DamnUnicode(path) tmpfilename = prefix + u'-0' + ext tmpcount = 0 while os.path.exists(path + tmpfilename): tmpcount += 1 tmpfilename = prefix + u'-' + DamnUnicode(tmpcount) + e... |
def run(self): | def go(self): | def run(self): self.uris = self.getURI(self.sourceuri) self.abort = False if not self.abort: if True: Damnlog('Conversion routine starting, URI is', self.uris[0]) self.uri = self.uris[0] self.update(0) self.parent.thisvideo.append(self.parent.videos[self.parent.converting]) self.filename = unicodedata.normalize('NFKD',... |
class DamnStreamCopy(thr.Thread): | class DamnStreamCopy(DamnThread): | def abortProcess(self): # Cannot send "q" because it's not a shell'd subprocess. Got to kill ffmpeg. Damnlog('I\'m gonna kill dash nine, cause it\'s my time to shine.') self.abort = True # This prevents the converter from going to the next file try: killit = True if self.__dict__.has_key('profile'): if self.profile == ... |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, s1, s2, buffer=1048576, background=True, closes1=True, closes2=True): Damnlog('DamnStreamCopy spawned, will rip', s1, 'to', s2, ' when started. Background?', background) self.s1 = s1 if type(s1) in (type(u''), type('')): self.s1 = DamnOpenFile(DamnUnicode(s1), 'rb') self.s2 = s2 if type(s2) in (type(... |
thr.Thread.start(self) | DamnThread.start(self) | def start(self): if self.background: Damnlog('Starting stream copy in background thread.') thr.Thread.start(self) else: Damnlog('Starting stream copy in current thread.') self.run() |
def run(self): | def go(self): | def run(self): firstread = True firstwrite = True Damnlog('Stream copy: Begin') i = 'Let\'s go' while len(i): try: i = self.s1.read(self.buffer) if firstread: Damnlog('Stream copy: first read successful, read', len(i), 'bytes.') firstread = False try: self.s2.write(i) if firstwrite: Damnlog('Stream copy: first write su... |
class DamnDownloader(thr.Thread): | class DamnDownloader(DamnThread): | def run(self): firstread = True firstwrite = True Damnlog('Stream copy: Begin') i = 'Let\'s go' while len(i): try: i = self.s1.read(self.buffer) if firstread: Damnlog('Stream copy: first read successful, read', len(i), 'bytes.') firstread = False try: self.s2.write(i) if firstwrite: Damnlog('Stream copy: first write su... |
thr.Thread.__init__(self) | DamnThread.__init__(self) | def __init__(self, uri, pipe, copy=None): Damnlog('DamnDownloader spawned. URI:', uri, '; Pipe:', pipe) self.uri = uri self.pipe = pipe self.copy = copy thr.Thread.__init__(self) |
def run(self): | def go(self): | def run(self): self.amountwritten = 0 self.timeouted = True Damnlog('DamnDownloader starting download for first time.') while self.timeouted: self.timeouted = False self.goDownload() Damnlog('DamnDownloader goDownload subroutine done. Total written is', self.amountwritten, 'bytes. Timeout?', self.timeouted) |
DV.youtube_service.ssl = False Damnlog('Init underway, starting to declare fancier stuff.') | DV.youtube_service.ssl = False | def DamnSysinfo(): try: sysinfo = u'DamnVid version: ' + DV.version + u'\nDamnVid mode: ' if DV.bit64: sysinfo += u'64-bit' else: sysinfo += u'32-bit' sysinfo += u'\nDamnVid arguments: ' if len(sys.argv[1:]): sysinfo += DamnUnicode(' '.join(sys.argv[1:])) else: sysinfo += u'(None)' sysinfo += u'\nMachine name: ' if len... |
def DamnLocale(s, asunicode=True, warn=True): k = DamnUnicode(s) | def DamnLocale(s, warn=True, reverse=False): | def DamnLocale(s, asunicode=True, warn=True): k = DamnUnicode(s) s = DamnUnicode(s) if DV.locale is None: Damnlog('Locale warning: Locale is None.') if asunicode: return s return k if not DV.locale['strings'].has_key(k): if warn and k not in DV.locale_warnings: DV.locale_warnings.append(k) Damnlog('Locale warning:', k,... |
if asunicode: return s return k if not DV.locale['strings'].has_key(k): if warn and k not in DV.locale_warnings: DV.locale_warnings.append(k) Damnlog('Locale warning:', k, 'has no key for language', DV.lang) if asunicode: return s return k if asunicode: return DamnUnicode(DV.locale['strings'][k]) return str(DV.locale['... | return s if reverse: for i in DV.locale['strings'].iterkeys(): if DV.locale['strings'][i] == s: return i Damnlog('Reverse locale lookup atempt for:', s, 'failed for language', DV.lang) return s if not DV.locale['strings'].has_key(s): if warn and s not in DV.locale_warnings: DV.locale_warnings.append(s) Damnlog('Locale ... | def DamnLocale(s, asunicode=True, warn=True): k = DamnUnicode(s) s = DamnUnicode(s) if DV.locale is None: Damnlog('Locale warning: Locale is None.') if asunicode: return s return k if not DV.locale['strings'].has_key(k): if warn and k not in DV.locale_warnings: DV.locale_warnings.append(k) Damnlog('Locale warning:', k,... |
return DV.l('(Do not encode)') | return '(Do not encode)' | def getp(self, profile, name): if int(profile) == -1: if name.lower() == 'name': return DV.l('(Do not encode)') if name.lower() == 'outdir': return self.get('defaultoutdir') return self.gets('damnvid-profile-' + str(profile), name) |
treeitem = self.tree.AppendItem(self.profileroot, DV.prefs.getp(i, 'name')) | treeitem = self.tree.AppendItem(self.profileroot, DV.l(DV.prefs.getp(i, 'name'), warn=False)) | def buildTree(self): self.tree.DeleteAllItems() self.treeimages = wx.ImageList(16, 16, True) self.tree.AssignImageList(self.treeimages) self.treeroot = self.tree.AddRoot(DV.l('DamnVid Preferences')) self.tree.SetItemImage(self.treeroot, self.treeimages.Add(wx.Bitmap(DV.images_path + 'icon16.png'))) self.proxyprefs = se... |
elif DV.preferences[i]['kind'][0:3] == 'int': | elif DV.preferences[i]['kind'][:3] == 'int': | def updatePrefPane(self, pane): self.prefpanesizer.Clear(True) # Delete all controls in prefpane for i in range(self.prefpanesizer.GetCols()): try: self.prefpanesizer.RemoveGrowableCol(i) except: pass for i in range(self.prefpanesizer.GetRows()): try: self.prefpanesizer.RemoveGrowableRow(i) except: pass self.pane = pan... |
if DV.preferences[i]['kind'][0:5] == 'intk:': | if DV.preferences[i]['kind'][:5] == 'intk:': | def updatePrefPane(self, pane): self.prefpanesizer.Clear(True) # Delete all controls in prefpane for i in range(self.prefpanesizer.GetCols()): try: self.prefpanesizer.RemoveGrowableCol(i) except: pass for i in range(self.prefpanesizer.GetRows()): try: self.prefpanesizer.RemoveGrowableRow(i) except: pass self.pane = pan... |
elif DV.preferences[i]['kind'][0:4] == 'int:': | elif DV.preferences[i]['kind'][:4] == 'int:': | def updatePrefPane(self, pane): self.prefpanesizer.Clear(True) # Delete all controls in prefpane for i in range(self.prefpanesizer.GetCols()): try: self.prefpanesizer.RemoveGrowableCol(i) except: pass for i in range(self.prefpanesizer.GetRows()): try: self.prefpanesizer.RemoveGrowableRow(i) except: pass self.pane = pan... |
self.controls[i] = wx.TextCtrl(self.prefpane, -1, val) | self.controls[i] = wx.TextCtrl(self.prefpane, -1, DV.l(val, warn=False)) | def updatePrefPane(self, pane): self.prefpanesizer.Clear(True) # Delete all controls in prefpane for i in range(self.prefpanesizer.GetCols()): try: self.prefpanesizer.RemoveGrowableCol(i) except: pass for i in range(self.prefpanesizer.GetRows()): try: self.prefpanesizer.RemoveGrowableRow(i) except: pass self.pane = pan... |
elif DV.preferences[genericpref]['kind'] == 'dir' or DV.preferences[genericpref]['kind'] == 'text': val = self.controls[i].GetValue() | elif DV.preferences[genericpref]['kind'] == 'text': val = DV.l(self.controls[i].GetValue(), warn=False, reverse=True) | def onPrefChange(self, event): Damnlog('Preference changed event caught.') name = None for i in self.controls.iterkeys(): pref = self.splitLongPref(i) prefname = pref[1] if pref[0][0:16] == 'damnvid-profile-': genericpref = pref[0][0:15] else: genericpref = pref[0] genericpref += ':' + pref[1] val = None if type(DV.pre... |
self.tree.SetItemText(self.tree.GetSelection(), name) | self.tree.SetItemText(self.tree.GetSelection(), DV.l(name, warn=False)) | def onPrefChange(self, event): Damnlog('Preference changed event caught.') name = None for i in self.controls.iterkeys(): pref = self.splitLongPref(i) prefname = pref[1] if pref[0][0:16] == 'damnvid-profile-': genericpref = pref[0][0:15] else: genericpref = pref[0] genericpref += ':' + pref[1] val = None if type(DV.pre... |
if value == self.defaultvalue or value == '(default)': | if value == self.defaultvalue or value == '(default)' or value not in choices2: | def makeList(self, strict, choices, panel, value, localize=True): choices2 = [] for c in choices: if not localize or c == self.defaultvalue: choices2.append(c) else: choices2.append(DV.l(c)) if strict: cont = wx.Choice(panel, -1, choices=choices2) if value == self.defaultvalue or value == '(default)': cont.SetSelection... |
cont = wx.ComboBox(panel, -1, choices=choices, value=value) | cont = wx.ComboBox(panel, -1, choices=choices2, value=value) | def makeList(self, strict, choices, panel, value, localize=True): choices2 = [] for c in choices: if not localize or c == self.defaultvalue: choices2.append(c) else: choices2.append(DV.l(c)) if strict: cont = wx.Choice(panel, -1, choices=choices2) if value == self.defaultvalue or value == '(default)': cont.SetSelection... |
if i == val or DV.l(i) == val: | if i == val or DV.l(i, warn=False) == val: | def getListValue(self, name, strict): if strict: val = self.listvalues[name][self.controls[name].GetSelection()] else: val = self.controls[name].GetValue() if val == self.defaultvalue or val == '(default)': val = '' elif type(DV.preference_type[name]['kind']) is type({}): for key, i in DV.preference_type[name]['kind'].... |
'debian/damnvid.desktop': '/usr/share/applications/', | 'build-deb/damnvid.desktop': '/usr/share/applications/', | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in os.listdir(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif f[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') ... |
def __init__(self, parent, id, label, url, background=None): wx.HyperlinkCtrl.__init__(self, parent, id, label, url, style = wx.ALIGN_LEFT) | def __init__(self, parent, id, label, url, background=None, style=None): if style is None: wx.HyperlinkCtrl.__init__(self, parent, id, label, url) else: wx.HyperlinkCtrl.__init__(self, parent, id, label, url, style = style) | def __init__(self, parent, id, label, url, background=None): wx.HyperlinkCtrl.__init__(self, parent, id, label, url, style = wx.ALIGN_LEFT) if background is not None: self.SetBackgroundColour(background) |
tmpSizer.Add(DamnHyperlink(self.historyPanel, -1, title, uri), 1, wx.ALIGN_LEFT) | tmpSizer.Add(DamnHyperlink(self.historyPanel, -1, title, uri, style=wx.ALIGN_LEFT), 1, wx.ALIGN_LEFT) | def addHistoryItem(self, uri, title, icon=None): Damnlog('Creating history item for URI', uri, 'with title', title, 'and icon', icon) tmpSizer = wx.BoxSizer(wx.HORIZONTAL) self.historySizer.Add(tmpSizer, 0, wx.EXPAND) if icon is not None: icon = DV.listicons.getRawBitmap(icon) else: icon = DV.listicons.getRawBitmap('fa... |
video = history[i].split(u'\\') | video = history[i].split(DV.history_split) | def onDel(self, uri, event=None): uri = DamnUnicode(uri) Damnlog('Removing URI', uri,'from history.') history = DV.prefs.geta('damnvid-videohistory','videos') todrop = [] for i in range(len(history)): video = history[i].split(u'\\') if len(video) != 3: todrop.append(i) elif video[0] == uri: Damnlog('Found URI', uri,'at... |
video = history[i].split(u'\\') | video = history[i].split(DV.history_split) | def update(self): Damnlog('Clearing video history panel.') self.historySizer.DeleteWindows() self.historyPanel.DestroyChildren() history = DV.prefs.geta('damnvid-videohistory','videos') histsize = int(DV.prefs.get('videohistorysize')) Damnlog('Video history is',history,'; history size is',histsize) if not histsize: Dam... |
tempvideo = i.split(u'\\') | tempvideo = i.split(DV.history_split) | def addTohistory(self, uri, title, icon=None): uri = DamnUnicode(uri) title = DamnUnicode(title) icon = DamnUnicode(icon) Damnlog('Adding video to history:', uri, 'with title', title, 'and icon', icon) history = DV.prefs.geta('damnvid-videohistory', 'videos') histsize = int(DV.prefs.get('videohistorysize')) if not hist... |
history.append(u'\\'.join([uri,title,icon])) | history.append(DV.history_split.join([uri,title,icon])) | def addTohistory(self, uri, title, icon=None): uri = DamnUnicode(uri) title = DamnUnicode(title) icon = DamnUnicode(icon) Damnlog('Adding video to history:', uri, 'with title', title, 'and icon', icon) history = DV.prefs.geta('damnvid-videohistory', 'videos') histsize = int(DV.prefs.get('videohistorysize')) if not hist... |
video = history[i].split(u'\\') | video = history[i].split(DV.history_split) | def onRename(self, event): item = self.list.getAllSelectedItems() if len(item) > 1: dlg = wx.MessageDialog(None, DV.l('You can only rename one video at a time.'), DV.l('Multiple videos selected.'), wx.ICON_EXCLAMATION | wx.OK) dlg.SetIcon(DV.icon) dlg.ShowModal() dlg.Destroy() elif not len(item): dlg = wx.MessageDialog... |
history[i] = u'\\'.join(video) | history[i] = DV.history_split.join(video) | def onRename(self, event): item = self.list.getAllSelectedItems() if len(item) > 1: dlg = wx.MessageDialog(None, DV.l('You can only rename one video at a time.'), DV.l('Multiple videos selected.'), wx.ICON_EXCLAMATION | wx.OK) dlg.SetIcon(DV.icon) dlg.ShowModal() dlg.Destroy() elif not len(item): dlg = wx.MessageDialog... |
return f.find('.svn')==-1 and f.find('LICENSE')==-1 and f.find('.psd')==-1 and f.find('.noinclude')==-1 and f.find('.module.damnvid')==-1 and f.find('.bmp')==-1 and f.find('.ai')==-1 and f.find('.exe')==-1 and f.find('.zip')==-1 and f.find('fireworks.png')==-1 | return f.find('.svn')==-1 and f.find('LICENSE')==-1 and f.find('.psd')==-1 and f.find('.noinclude')==-1 and f.find('.bmp')==-1 and f.find('.ai')==-1 and f.find('.exe')==-1 and f.find('.zip')==-1 and f.find('fireworks.png')==-1 | def goodFile(f): return f.find('.svn')==-1 and f.find('LICENSE')==-1 and f.find('.psd')==-1 and f.find('.noinclude')==-1 and f.find('.module.damnvid')==-1 and f.find('.bmp')==-1 and f.find('.ai')==-1 and f.find('.exe')==-1 and f.find('.zip')==-1 and f.find('fireworks.png')==-1 |
for d in required_dirs: addDir(d) for f in os.listdir('./'): if f[-15:]=='.module.damnvid': os.remove(f) for f in os.listdir('./modules/'): if f[-15:]=='.module.damnvid': os.remove('./modules/'+f) for f in os.listdir('./modules/'): if os.path.isdir('./modules/'+f) and f.find('.svn')==-1: procs(['python', 'build-any' + ... | def addDir(d): for f in os.listdir(d): if goodFile(f): if os.path.isdir(d+os.sep+f): addDir(d + os.sep + f) else: addFile(d + os.sep + f) | |
for f in os.listdir('.'): if f[-15:]=='.module.damnvid': if os.path.lexists('modules/'+f): os.remove('modules/'+f) os.rename(f,'modules/'+f) addFile('modules'+os.sep+f) if f[-3:] == '.py': addModule(f) | for d in required_dirs: addDir(d) | def addModule(f, recursive=True): if OSNAME != 'posix' or not goodFile(f): return if os.path.isdir(f): for i in os.listdir(f): if os.path.isdir(f + os.sep + i) and recursive: addDir(f + os.sep + i) addModule(f + os.sep + i, recursive=recursive) elif i[-3:] == '.py': addModule(f + os.sep + i, recursive=recursive) elif f... |
info['progress'] = float(progress) | info['progress'] = min(100.0, max(0.0, float(progress))) | def update(self, progress=None, statustext=None, status=None, dialog=None, go=None): info = {} if progress is not None: info['progress'] = float(progress) if statustext is not None: info['statustext'] = DamnUnicode(statustext) if status is not None: info['status'] = DamnUnicode(status) if dialog is not None: info['dial... |
dlg = wx.MessageDialog(self, DV.l('A new version (') + info['updateinfo']['main'] + DV.l(') is available! You are running DamnVid ') + DV.version + '.\n' + DV.l('Want to go to the download page and download the update?'), DV.l('Update available!'), wx.YES | wx.NO | wx.YES_DEFAULT | wx.ICON_INFORMATION) dlg.SetIcon(DV.i... | if DV.os != 'posix': dlg = wx.MessageDialog(self, DV.l('A new version (') + info['updateinfo']['main'] + DV.l(') is available! You are running DamnVid ') + DV.version + '.\n' + DV.l('Want to go to the download page and download the update?'), DV.l('Update available!'), wx.YES | wx.NO | wx.YES_DEFAULT | wx.ICON_INFORMAT... | def onLoading(self, event): info = event.GetInfo() if info.has_key('show'): if info['show']: self.droptarget.LoadFile(DV.images_path + 'droptargetloading.gif') self.droptarget.Play() else: self.droptarget.Stop() self.droptarget.LoadFile(DV.images_path + 'droptarget.gif') if info.has_key('status'): self.SetStatusText(in... |
return | def main(): debugging_on = False if len(sys.argv) > 1: debugging_on = True if debugging_on: games = json.loads(open('terse_games.json').read()) else: games = json.loads(open('condensed_games.json').read()) open('terse_games.json', 'w').write( json.dumps(random.sample(games, 1000))) DecorateTableausInGames(games) by_g... | |
<table><tr><td>Winning Rate</td> | <table><tr><td>Skill Normalized<br>Winning Rate</td> | def RenderCardWinGraph(out_file, card_win_info): out_file.write(""" |
return FilterOutTies( [g for g in games if g.Expansion() == 1]) | return FilterOutTies(GatheringStormGames(games)) | def NonTiedGatheringStormGames(games): return FilterOutTies( [g for g in games if g.Expansion() == 1]) |
for g in games: | for g in GatheringStormGames(games): | def Analyze6Devs(games): dists_with = collections.defaultdict(PointDistribution) dists_without = collections.defaultdict(PointDistribution) tableau_ct = 0 for g in games: for p in g.PlayerList(): tableau_ct += 1 tab_scorer = tableau_scorer.TableauScorer(p.Cards(), p.Chips()) for card in DeckInfo.SixDevList(): hypo_scor... |
rowspan = len(paired_games[opponent]) / 10 + 1 | rowspan = (len(paired_games[opponent]) - 1) / 10 + 1 | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
lambda: collections.defaultdict(int)) | lambda: collections.defaultdict(float)) | def __init__(self, games, skill_model): self.skill_model = skill_model |
lambda: collections.defaultdict(int)) | lambda: collections.defaultdict(float)) self.rating_by_opp_homeworld_flow = collections.defaultdict( lambda: collections.defaultdict(float)) | def __init__(self, games, skill_model): self.skill_model = skill_model |
def WritePlayerFloatPairsAsTableRows(output_file, pairs): for s, f in pairs: output_file.write('<tr><td>%s</td><td>%.1f</td></tr>\n' % (s, f)) | def WritePlayerFloatPairsAsTableRows(output_file, pairs): for s, f in pairs: output_file.write('<tr><td>%s</td><td>%.1f</td></tr>\n' % (s, f)) | |
def CountWinLossTie(games, source, target): | def CountWinLossTieByPlayer(games, source, target): | def CountWinLossTie(games, source, target): ret = [0, 0, 0] for game in games: source_result, target_result = GetResultsForNames(game, source, target) outcome = OutcomeWithPerspective(game, source_result, target_result) ret[outcome] += 1 return ret |
def ComputeSinglePlayerWinningStats(player, player_games, rating_system, gameset): | def GetTableausForPlayer(player, player_games): | def RenderGameWithPerspective(game, source, target): source_result, target_result = GetResultsForNames(game, source, target) color = OUTCOME_TO_COLOR[OutcomeWithPerspective(game, source_result, target_result)] return '<a href="%s"><font color="%s">%s %s</font></a>' % ( game.GameId(), color, RenderTableauShort(source_re... |
return ComputeWinningStatsByCardPlayed(player_tableaus, rating_system, gameset) | return player_tableaus def Compute2PRecordByHomeworld(player_tableaus): player_tableaus = filter(lambda t: len(t.Game().PlayerList()) == 2, player_tableaus) my_rec_by_hw = collections.defaultdict(lambda: [0.0, 0.0, 0.0]) rec_against_opp_by_hw = collections.defaultdict(lambda: [0.0, 0.0, 0.0]) for my_tableau in player... | def ComputeSinglePlayerWinningStats(player, player_games, rating_system, gameset): player_tableaus = [] for game in FilterOutTies(player_games): for player_result in game.PlayerList(): if player_result.Name() == player: player_tableaus.append(player_result) return ComputeWinningStatsByCardPlayed(player_tableaus, ratin... |
card_win_info = ComputeSinglePlayerWinningStats( player, player_games, by_game_type_analysis.AllGamesRatings(), gameset) | card_win_info = ComputeWinningStatsByCardPlayed( player_tableaus, by_game_type_analysis.AllGamesRatings(), gameset) | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
'<td>Net rating change when playing<td></tr>') | '<td>Net rating change</td>' '<td>2 Player record</td></tr>') | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
WritePlayerFloatPairsAsTableRows( player_out, all_games_ratings.GetHomeworldSkillFlow(player)) | my_rec_by_hw, my_rec_against_hw = Compute2PRecordByHomeworld( player_tableaus) skill_flows = all_games_ratings.GetHomeworldSkillFlow(player) for homeworld, net_rating_flow in skill_flows: player_out.write('<tr><td>%s</td><td>%.1f</td><td>%s</td></tr>\n' % ( homeworld, net_rating_flow, RenderRecord(my_rec_by_hw[homeworl... | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
record = CountWinLossTie(paired_games[opponent], player, opponent) | record = CountWinLossTieByPlayer( paired_games[opponent], player, opponent) | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
'<td><font color="%s">%d</font>-' '<font color="%s">%d</font>-' '<font color="%s">%d</font></td>' % ( PlayerLink(opponent), skill_flow, OUTCOME_TO_COLOR[WIN], record[WIN], OUTCOME_TO_COLOR[LOSE], record[LOSE], OUTCOME_TO_COLOR[TIE], record[TIE])) | '<td>%s</td>' % ( PlayerLink(opponent), skill_flow, RenderRecord(record))) ct = 3 | def RenderPlayerPage(player, player_games, by_game_type_analysis, gameset=None): overview = OverviewStats(player_games) player_out = open(PlayerFile(player), 'w') game_ver = '' if gameset: game_ver = gameset.exp_name player_out.write('<html><head><title> %s %s %s' '</title>%s</head><body>\n' % (TITLE, game_ver, player,... |
training_set = TrainingSet() retained_games = [g for g in games if training_set.HasGameId(g['game_id'])] | def DumpSampleGamesForDebugging(games): training_set = TrainingSet() retained_games = [g for g in games if training_set.HasGameId(g['game_id'])] open('terse_games.json', 'w').write( json.dumps(retained_games + random.sample(games, 1000 - len( retained_games)))) | |
json.dumps(retained_games + random.sample(games, 1000 - len( retained_games)))) | json.dumps(random.sample(games, 1000))) | def DumpSampleGamesForDebugging(games): training_set = TrainingSet() retained_games = [g for g in games if training_set.HasGameId(g['game_id'])] open('terse_games.json', 'w').write( json.dumps(retained_games + random.sample(games, 1000 - len( retained_games)))) |
pass | DumpSampleGamesForDebugging(games) | def LoadGames(debugging, gamelist_name): try: #import pymongo con = pymongo.Connection('localhost', 27017) db = con['games'] if debugging: num_games = db.games.count() sample_id = random.randint(0, num_games) games = list(db.games.find(skip = sample_id).limit(1000)) else: games = db.games.find() except Exception, e: pr... |
debugging = False | debugging, just_flex = False, False | def main(argv): debugging = False t0 = time.time() gamelists = ['condensed_games', 'condensed_flex'] if len(argv) > 1: debugging = True gamelist = ['terse_games'] games = [] for gamelist in gamelists: games.extend(LoadGames(debugging, gamelist)) t1 = time.time() print 'games loaded time', t1 - t0 RenderTopPage(games... |
debugging = True gamelist = ['terse_games'] | if argv[1] == '-d': debugging = True gamelists = ['terse_games'] elif argv[1] == '-f': debugging, just_flex = True, True gamelists = ['condensed_flex'] | def main(argv): debugging = False t0 = time.time() gamelists = ['condensed_games', 'condensed_flex'] if len(argv) > 1: debugging = True gamelist = ['terse_games'] games = [] for gamelist in gamelists: games.extend(LoadGames(debugging, gamelist)) t1 = time.time() print 'games loaded time', t1 - t0 RenderTopPage(games... |
for idx, exp_abbrev in enumerate(EXP_ABBREV): | exp_versions = enumerate(EXP_ABBREV) if just_flex: exp_versions = [(2, "rvi")] for idx, exp_abbrev in exp_versions: | def main(argv): debugging = False t0 = time.time() gamelists = ['condensed_games', 'condensed_flex'] if len(argv) > 1: debugging = True gamelist = ['terse_games'] games = [] for gamelist in gamelists: games.extend(LoadGames(debugging, gamelist)) t1 = time.time() print 'games loaded time', t1 - t0 RenderTopPage(games... |
self.__admin = None | self.__admin = self.__groupsInfo = None @property def groupsInfo(self): if self.__groupsInfo == None: self.__groupsInfo = createObject('groupserver.GroupsInfo', self.context) assert self.__groupsInfo != None return self.__groupsInfo | def __init__(self, context, request): PageForm.__init__(self, context, request) self.siteInfo = createObject('groupserver.SiteInfo', context) groupInfo = self.groupInfo = \ createObject('groupserver.GroupInfo', context) |
form_fields = form.Fields(IGSGroupBasicPrivacySettings, render_context=False) | def radio_widget(field, request): return NotBrokenRadioWidget(field, field.vocabulary, request) | |
grp = groupInfo.groupObj if not(request.form.get('form.basicPrivacy', None)): request.form['form.basicPrivacy'] = self.group_visibility(grp) self.form_fields['basicPrivacy'].custom_widget = radio_widget self.__admin = self.__groupsInfo = None | self.__admin = self.__groupsInfo = self.__formFields = None def setUpWidgets(self, ignore_request=False): data = {'basicPrivacy': self.group_visibility()} self.widgets = form.setUpWidgets( self.form_fields, self.prefix, self.context, self.request, form=self, data=data, ignore_request=ignore_request) @property def for... | def __init__(self, context, request): PageForm.__init__(self, context, request) self.siteInfo = createObject('groupserver.SiteInfo', context) groupInfo = self.groupInfo = \ createObject('groupserver.GroupInfo', context) |
self.group_visibility(self.groupInfo.groupObj), | self.group_visibility(), | def handle_change(self, action, data): assert self.context assert self.form_fields m = u'Changing privacy of the group %s (%s) on %s (%s) from "%s" '\ u'to "%s" for the administrator %s (%s)' % \ (self.groupInfo.name, self.groupInfo.id, self.siteInfo.name, self.siteInfo.id, self.group_visibility(self.groupInfo.groupOb... |
def group_visibility(self, grp): | def group_visibility(self): | def group_visibility(self, grp): # TODO: Move to a utility assert grp msgs = getattr(grp, 'messages', None) msgsVis = get_visibility(msgs) files = getattr(grp, 'files', None) filesVis = get_visibility(files) grpVis = get_visibility(grp) |
assert grp | grp = self.groupInfo.groupObj | def group_visibility(self, grp): # TODO: Move to a utility assert grp msgs = getattr(grp, 'messages', None) msgsVis = get_visibility(msgs) files = getattr(grp, 'files', None) filesVis = get_visibility(files) grpVis = get_visibility(grp) |
vis = self.group_visibility(self.groupInfo.groupObj) | vis = self.group_visibility() | def set_group_public(self): '''Set the Group Visibility to Public SIDE EFFECTS * The group is visible to the anonymous user * The messages are visible to the anonymous user [acquire] * The files are visible to the anonymous user [acquire] * The members-list is visible to the anonymous user [acquire] ''' self.set_group... |
vis = self.group_visibility(self.groupInfo.groupObj) | vis = self.group_visibility() | def set_group_private(self): self.set_group_visibility(self.everyone) self.set_messages_visibility(self.group) self.set_files_visibility(self.group) self.set_joinability_request() |
vis = self.group_visibility(self.groupInfo.groupObj) | vis = self.group_visibility() | def set_group_secret(self): self.set_group_visibility(self.group) self.set_messages_visibility(self.group) self.set_files_visibility(self.group) self.set_joinability_invite() vis = self.group_visibility(self.groupInfo.groupObj) assert vis == 'secret', 'Visibility of %s (%s) is %s, not secret' % \ (self.groupInfo.name,... |
admins = self.groupObj.users_with_local_role('GroupAdmin') retval = [ createObject('groupserver.UserFromId', self.context, a) for a in admins ] | adminIds = self.groupObj.users_with_local_role('GroupAdmin') admins = [ createObject('groupserver.UserFromId', self.context, a) for a in adminIds ] retval = [ a for a in admins if not a.anonymous ] | def get_group_admins(self): admins = self.groupObj.users_with_local_role('GroupAdmin') retval = [ createObject('groupserver.UserFromId', self.context, a) for a in admins ] return retval |
self.context = context | ctx = get_the_actual_instance_from_zope(context) self.context = ctx | def __init__(self, context, groupId=None): self.context = context self.groupId = groupId self.siteInfo = createObject('groupserver.SiteInfo', context) self.groupObj = self.__get_group_object() |
self.siteInfo = createObject('groupserver.SiteInfo', context) | self.siteInfo = createObject('groupserver.SiteInfo', ctx) | def __init__(self, context, groupId=None): self.context = context self.groupId = groupId self.siteInfo = createObject('groupserver.SiteInfo', context) self.groupObj = self.__get_group_object() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.