rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.set_info_text() | def populate_tree(self): ''' Bookmarks code from Quod Libet ''' assert self.tree is None self.createTree() #self.tree.set_row_separator_func(lambda model, iter: model[iter][ROW_NAME] is None) self.tree.set_row_separator_func(self._is_separator) # Restore the tree if we have any to restore, else build new one if self.t... | |
self.__stopUpdateTimer() | def __onTrackEnded(self, error): """ Called to signal eos and errors """ self.__stopUpdateTimer() | |
return __getNextTrackIdx() != -1 | return self.__getNextTrackIdx() != -1 | def __hasNextTrack(self): """ Return whether there is a next track """ return __getNextTrackIdx() != -1 |
return __getPreviousTrackIdx() != -1 | return self.__getPreviousTrackIdx() != -1 | def __hasPreviousTrack(self): """ Return whether there is a previous track """ return __getPreviousTrackIdx() != -1 |
for subdir in trackdir.subdirs: self.insertDir(subdir, new, drop_mode) for track in trackdir.tracks: self.insertTrack(track, new, drop_mode) | drop_mode = gtk.TREE_VIEW_DROP_INTO_OR_AFTER dest = new for index, subdir in enumerate(trackdir.subdirs): drop = drop_mode if index == 0 else gtk.TREE_VIEW_DROP_AFTER dest = self.insertDir(subdir, dest, drop) dest = new for index, track in enumerate(trackdir.tracks): drop = drop_mode if index == 0 else gtk.TREE_VIEW_... | def insertDir(self, trackdir, target=None, drop_mode=None): ''' Insert a directory recursively, return the iter of the first added element ''' model = self.tree.store if trackdir.flat: new = target else: string = gobject.markup_escape_text(trackdir.dirname) source_row = (icons.mediaDirMenuIcon(), string, None) new = s... |
if target is None: | if target is None or model.iter_depth(target) == 0: | def insertDir(self, trackdir, target=None, drop_mode=None): ''' Insert a directory recursively, return the iter of the first added element ''' model = self.tree.store if trackdir.flat: new = target else: string = gobject.markup_escape_text(trackdir.dirname) source_row = (icons.mediaDirMenuIcon(), string, None) new = s... |
def insertTrack(self, track, parentPath=None, drop_mode=None): | return new def insertTrack(self, track, target=None, drop_mode=None): | def insertTrack(self, track, parentPath=None, drop_mode=None): ''' Insert a new track into the tracktree under parentPath ''' ##rows = [[icons.nullMenuIcon(), track.getNumber(), track.getTitle(), track.getArtist(), track.getExtendedAlbum(), ## track.getLength(), track.getBitrate(), track.getGenre(), track.ge... |
assert name is not None self.tree.appendRow((icons.nullMenuIcon(), name, track), parentPath) | row = (icons.nullMenuIcon(), name, track) return self.tree.insert(target, row, drop_mode) | def insertTrack(self, track, parentPath=None, drop_mode=None): ''' Insert a new track into the tracktree under parentPath ''' ##rows = [[icons.nullMenuIcon(), track.getNumber(), track.getTitle(), track.getArtist(), track.getExtendedAlbum(), ## track.getLength(), track.getBitrate(), track.getGenre(), track.ge... |
self.btnPlay.set_tooltip_text(_('Play the first track of the playlist')) | self.btnPlay.set_tooltip_text(_('Play the first selected track of the playlist')) | def onStopped(self): """ The playback has been stopped """ self.btnStop.set_sensitive(False) self.btnNext.set_sensitive(False) self.btnPrev.set_sensitive(False) self.btnPlay.set_image(gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_BUTTON)) self.btnPlay.set_tooltip_text(_('Play the first track of the playl... |
gtk.tooltips_data_get(self.btnPlay)[0].set_tip(self.btnPlay, _('Continue playing the current track')) | self.btnPlay.set_tooltip_text(_('Continue playing the current track')) | def onPaused(self): """ The playback has been paused """ self.btnPlay.set_image(gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_BUTTON)) gtk.tooltips_data_get(self.btnPlay)[0].set_tip(self.btnPlay, _('Continue playing the current track')) |
gtk.tooltips_data_get(self.btnPlay)[0].set_tip(self.btnPlay, _('Pause the current track')) | self.btnPlay.set_tooltip_text(_('Pause the current track')) | def onUnpaused(self): """ The playback has been unpaused """ self.btnPlay.set_image(gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON)) gtk.tooltips_data_get(self.btnPlay)[0].set_tip(self.btnPlay, _('Pause the current track')) |
print 'LOAD', tracks | def onAppStarted(self): """ Try to fill the playlist by using the files given on the command line or by restoring the last playlist """ # The file 'saved-playlist.txt' uses an old format, we now use 'saved-playlist-2.txt' (options, args) = prefs.getCmdLine() self.savedPlaylist = os.path.join(consts.dirCfg, 'saved-pl... | |
print 'SAVE', self.tracks | def onAppQuit(self): print 'SAVE', self.tracks pickleSave(self.savedPlaylist, self.tracks) | |
def on_key_pressed(widget, event): | def on_key_pressed(self, widget, event): | def on_key_pressed(widget, event): """ Let search box grab the focus when "Ctrl-F" is hit """ key_name = gtk.gdk.keyval_name(event.keyval) modifiers = event.get_state() ctrl_pressed = modifiers & gtk.gdk.CONTROL_MASK if key_name == 'f' and ctrl_pressed: self.searchbox.grab_focus() return True |
print 'NAME', self.tree.getLabel(iter), iter | def getTrackDir(self, root=None): flat = False if root else True name = self.tree.getLabel(root) if root else 'playtree' trackdir = media.TrackDir(name=name, flat=flat) for iter in self.tree.iter_children(root): print 'NAME', self.tree.getLabel(iter), iter track = self.tree.getTrack(iter) if track: trackdir.tracks.app... | |
def insert(self, tracks, target=None, drop_mode=None): | def insert(self, tracks, target=None, drop_mode=None, playNow=True): | def insert(self, tracks, target=None, drop_mode=None): if type(tracks) == list: trackdir = media.TrackDir(None, flat=True) trackdir.tracks = tracks tracks = trackdir self.insertDir(tracks, target, drop_mode) return # TODO: playNow wanted? Buggy in current state if playNow: if parent is None: dest = self.tree.get_lowe... |
assert string is not None if drop_mode == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE: new = model.prepend(target, source_row) elif drop_mode == gtk.TREE_VIEW_DROP_INTO_OR_AFTER or drop_mode is None: new = model.append(target, source_row) elif drop_mode == gtk.TREE_VIEW_DROP_BEFORE: new = model.insert_before(None, target, sou... | new = self.tree.insert(target, source_row, drop_mode) | def insertDir(self, trackdir, target=None, drop_mode=None): ''' Insert a directory recursively, return the iter of the first added element ''' model = self.tree.store if trackdir.flat: new = target else: string = gobject.markup_escape_text(trackdir.dirname) source_row = (icons.mediaDirMenuIcon(), string, None) assert s... |
self.tree.store.connect('row-inserted', self.on_row_inserted) self.tree.store.connect('row-deleted', self.on_row_deleted) | def onAppStarted(self): """ This is the real initialization function, called when the module has been loaded """ wTree = tools.prefs.getWidgetsTree() self.playtime = 0 self.bufferedTrack = None self.previousTracklist = None # Retrieve widgets self.window = wTree.get_widget('win-main') ... | |
self.tree.connect('extlistview-modified', self.onListModified) | def onAppStarted(self): """ This is the real initialization function, called when the module has been loaded """ wTree = tools.prefs.getWidgetsTree() self.playtime = 0 self.bufferedTrack = None self.previousTracklist = None # Retrieve widgets self.window = wTree.get_widget('win-main') ... | |
print 'MODIFIED:' print tracks | def onListModified(self): """ Some rows have been added/removed/moved """ #self.btnClear.set_sensitive(len(list) != 0) #self.btnShuffle.set_sensitive(len(list) != 0) | |
print 'Constructing player' | def __constructPlayer(self): """ Create the GStreamer pipeline """ print 'Constructing player' if self.usePlaybin2: self.player = gst.element_factory_make('playbin2', 'player') self.player.connect('about-to-finish', self.__onAboutToFinish) else: self.player = gst.element_factory_make('playbin', 'player') | |
self.dirname = '' | self.dirname = 'noname' | def __init__(self, name='', dir=None, flat=False): self.dir = dir if name: self.dirname = name elif dir: self.dirname = dirname(dir) else: self.dirname = '' # If flat is True, add files without directories self.flat = flat self.tracks = [] self.subdirs = [] if dir and not flat: self.scan() |
trackdir = TrackDir(path) self.subdirs.append(trackdir) | trackdir = TrackDir(dir=path) if trackdir.tracks or trackdir.subdirs: self.subdirs.append(trackdir) | def scan(self): import tools for filename, path in sorted(tools.listDir(self.dir)): #print 'PATH', path if os.path.isdir(path): trackdir = TrackDir(path) self.subdirs.append(trackdir) elif isSupported(filename): track = getTrackFromFile(path) self.tracks.append(track) |
print 'Sending', event | def sendToZeitgeist(self, track): """ Send track information to Zeitgeist """ import mimetypes, os.path | |
mTxtBuffer.create_tag('title', weight=pango.WEIGHT_BOLD, scale=pango.SCALE_X_LARGE, justification=pango.ALIGN_RIGHT) | mTxtBuffer.create_tag('title', weight=pango.WEIGHT_BOLD, scale=pango.SCALE_X_LARGE) | def __init__(self, title): """ Constructor """ global mDlg, mTxtBuffer |
matches = re.search( r'>IMDB</td><td valign="top" align=left><a href="http://www.imdb.com/title/tt(\d+)/">', response ) | matches = re.search( r'<a href="http://www.imdb.com/title/tt(\d+)/"', response ) | def __DownloadNfo(announcement): url = "http://cinemageddon.net/details.php?id=%s&filelist=1" % announcement.AnnouncementId Globals.Logger.info( "Collecting info from torrent page '%s'." % url ) opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ) request = urllib2.Request( url ) result = ... |
codec = regexFind[ 0 ] container = regexFind[ 1 ] source = regexFind[ 2 ] resolution = regexFind[ 3 ] | elements = regexFind.split( " / " ) if len( elements ) < 4: raise PtpUploaderException( "Error! Unknown torrent format on movie page: '%s'." % elements ); codec = elements[ 0 ] container = elements[ 1 ] source = elements[ 2 ] resolution = elements[ 3 ] | def __ParseMoviePageMakeItems(itemList, regexFindList): for regexFind in regexFindList: codec = regexFind[ 0 ] container = regexFind[ 1 ] source = regexFind[ 2 ] resolution = regexFind[ 3 ] itemList.append( PtpMovieSearchResultItem( codec, container, source, resolution ) ) |
++runningDownloads | runningDownloads += 1 | def IsSourceAvailable(self, source): runningDownloads = 0 for releaseInfo in self.PendingDownloads: if releaseInfo.Announcement.Source.Name == source.Name: ++runningDownloads return runningDownloads < source.MaximumParallelDownloads |
@staticmethod def __FixFillImdbText(text): text = text.replace( "& text = text.replace( "& return text; | def GetMoviePageOnPtp(imdbId): Globals.Logger.info( "Trying to find movie with IMDb id '%s' on PTP." % imdbId ); opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); request = urllib2.Request( "http://passthepopcorn.me/torrents.php?imdb=%s" % imdbId ); result = opener.open( request ); res... | |
if ( releaseInfo.PtpUploadInfo.Source == "Blu-Ray" or releaseInfo.PtpUploadInfo.Source == "HD-DVD" ) and releaseInfo.ResolutionType == "720p": | if ( releaseInfo.PtpUploadInfo.Source == "Blu-Ray" or releaseInfo.PtpUploadInfo.Source == "HD-DVD" ) and releaseInfo.PtpUploadInfo.ResolutionType == "720p": | def IsReleaseExists(self, releaseInfo): if self.PtpId is None: return False; |
elif ( releaseInfo.PtpUploadInfo.Source == "Blu-Ray" or releaseInfo.PtpUploadInfo.Source == "HD-DVD" ) and releaseInfo.ResolutionType == "1080p": | elif ( releaseInfo.PtpUploadInfo.Source == "Blu-Ray" or releaseInfo.PtpUploadInfo.Source == "HD-DVD" ) and releaseInfo.PtpUploadInfo.ResolutionType == "1080p": | def IsReleaseExists(self, releaseInfo): if self.PtpId is None: return False; |
announcement = Announcement( announcementFilePath = "", source = manualSource, id = "", self.ReleaseName ) | announcement = Announcement( announcementFilePath = "", source = manualSource, id = "", releaseName = self.ReleaseName ) | def MakeReleaseInfo(self, createTorrent): if not self.CollectVideoFiles(): return # Make sure the files we are generating are not present. |
if response.find( '<td class="heading" align="right" valign="top">Visible</td><td align="left" valign="top"><b>no</b>' ) != -1: | if re.search( r'">Visible</td><td.+><b>no</b> \(dead\)', response ): | def __DownloadNfo(announcement, getReleaseName = False, checkPretime = True): url = "http://www.thegft.org/details.php?id=%s" % announcement.AnnouncementId; Globals.Logger.info( "Downloading NFO from page '%s'." % url ); opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); request = urlli... |
if len( sys.argv ) == 2: | if len( sys.argv ) == 3: | def Notify(releaseName, uploadedTorrentUrl): logger = Globals.Logger userId = LoadNotifierSettings() userId = userId.strip() if not userId.isdigit(): return Ptp.Login() subject = "[PtpUploader] %s" % releaseName message = "This is an automatic notification about a new [url=%s]upload[/url]." % uploadedTorrentUrl Ptp.S... |
if checkPretime and response.find( '<tr><td class="heading" align="right" valign="top">Pretime</td><td align="left" valign="top">Too quick, bitches!!</td></tr>' ) != -1: | if checkPretime and response.find( ">Too quick, bitches!!<" ) != -1: | def DownloadNfo(announcement, getReleaseName = False, checkPretime = True): url = "http://www.thegft.org/details.php?id=%s" % announcement.AnnouncementId; Globals.Logger.info( "Downloading NFO from page '%s'." % url ); opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); request = urllib2... |
matches = re.search( r'<a href="http://www.imdb.com/title/tt(\d+)/"', response ) | matches = re.search( r'imdb\.com/title/tt(\d+)', response ) | def __DownloadNfo(announcement): url = "http://cinemageddon.net/details.php?id=%s&filelist=1" % announcement.AnnouncementId Globals.Logger.info( "Collecting info from torrent page '%s'." % url ) opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ) request = urllib2.Request( url ) result = ... |
args = [ Settings.ChtorPath, "--set=info.source=PTP", destinationTorrentPath ] | args = [ Settings.ChtorPath, "--set=info.source=PTP", torrentPath ] | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ) sourceSize = MakeTorrent.GetSourceSize( path ) |
@staticmethod def __FixFillImdbText(text): text = text.replace( "& text = text.replace( "& text = text.replace( "& return text; | def GetMoviePageOnPtp(imdbId): Globals.Logger.info( "Trying to find movie with IMDb id '%s' on PTP." % imdbId ); opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); request = urllib2.Request( "http://passthepopcorn.me/torrents.php?imdb=%s" % imdbId ); result = opener.open( request ); res... | |
htmlParser = HTMLParser.HTMLParser() | def FillImdbInfo(ptpUploadInfo): Globals.Logger.info( "Downloading movie info from PTP for IMDb id '%s'." % ptpUploadInfo.ImdbId ); # Get IMDb info through PTP's ajax API used by the site when the user presses the auto fill button. opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); requ... | |
ptpUploadInfo.Title = Ptp.__FixFillImdbText( ptpUploadInfo.Title ) | ptpUploadInfo.Title = htmlParser.unescape( ptpUploadInfo.Title ) | def FillImdbInfo(ptpUploadInfo): Globals.Logger.info( "Downloading movie info from PTP for IMDb id '%s'." % ptpUploadInfo.ImdbId ); # Get IMDb info through PTP's ajax API used by the site when the user presses the auto fill button. opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); requ... |
ptpUploadInfo.Directors.append( directorName ); | directorName = htmlParser.unescape( directorName ) ptpUploadInfo.Directors.append( directorName ) | def FillImdbInfo(ptpUploadInfo): Globals.Logger.info( "Downloading movie info from PTP for IMDb id '%s'." % ptpUploadInfo.ImdbId ); # Get IMDb info through PTP's ajax API used by the site when the user presses the auto fill button. opener = urllib2.build_opener( urllib2.HTTPCookieProcessor( Globals.CookieJar ) ); requ... |
Globals.Logger.exception( "Couldn't refresh data for 'http://passthepopcorn.me/torrents.php?id=%s'. Got exception." % ptpId ); pass; | Globals.Logger.exception( "Couldn't refresh data for 'http://passthepopcorn.me/torrents.php?id=%s'. Got exception." % ptpId ); | def TryRefreshMoviePage(ptpId, page): Globals.Logger.info( "Trying to refresh data for 'http://passthepopcorn.me/torrents.php?id=%s'." % ptpId ); |
logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); | logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ) sourceSize = MakeTorrent.GetSourceSize( path ) | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); |
pieceSize = "-l 19"; | pieceSize = "-l 19" | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); |
pieceSize = "-l 22"; | pieceSize = "-l 22" | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); |
args = [ Settings.MktorrentPath, '-a', Settings.PtpAnnounceUrl, '-p', pieceSize, '-o', torrentPath, path ]; errorCode = subprocess.call( args ); | args = [ Settings.MktorrentPath, '-a', Settings.PtpAnnounceUrl, '-p', pieceSize, '-o', torrentPath, path ] errorCode = subprocess.call( args ) | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); |
raise PtpUploaderException( "Process execution '%s' returned with error code '%s'." % ( args, errorCode ) ); | raise PtpUploaderException( "Process execution '%s' returned with error code '%s'." % ( args, errorCode ) ) args = [ Settings.ChtorPath, "--set=info.source=PTP", destinationTorrentPath ] errorCode = subprocess.call( args ) if errorCode != 0: raise PtpUploaderException( "Process execution '%s' returned with error c... | def Make(logger, path, torrentPath): logger.info( "Making torrent from '%s' to '%s'." % ( path, torrentPath ) ); sourceSize = MakeTorrent.GetSourceSize( path ); |
return os.path.getsize( path ); | return os.path.getsize( path ) | def GetSourceSize(path): if os.path.isfile( path ): return os.path.getsize( path ); totalSize = 0; for ( dirPath, dirNames, fileNames ) in os.walk( path ): for file in fileNames: filePath = os.path.join( dirPath, file ); totalSize += os.path.getsize( filePath ); |
totalSize = 0; | totalSize = 0 | def GetSourceSize(path): if os.path.isfile( path ): return os.path.getsize( path ); totalSize = 0; for ( dirPath, dirNames, fileNames ) in os.walk( path ): for file in fileNames: filePath = os.path.join( dirPath, file ); totalSize += os.path.getsize( filePath ); |
filePath = os.path.join( dirPath, file ); totalSize += os.path.getsize( filePath ); | filePath = os.path.join( dirPath, file ) totalSize += os.path.getsize( filePath ) | def GetSourceSize(path): if os.path.isfile( path ): return os.path.getsize( path ); totalSize = 0; for ( dirPath, dirNames, fileNames ) in os.walk( path ): for file in fileNames: filePath = os.path.join( dirPath, file ); totalSize += os.path.getsize( filePath ); |
return totalSize; | return totalSize | def GetSourceSize(path): if os.path.isfile( path ): return os.path.getsize( path ); totalSize = 0; for ( dirPath, dirNames, fileNames ) in os.walk( path ): for file in fileNames: filePath = os.path.join( dirPath, file ); totalSize += os.path.getsize( filePath ); |
subprocess.Popen( command ) | subprocess.Popen( command, shell = True ) | def OnSuccessfulUpload(releaseName, ptpId): if len( Settings.OnSuccessfulUpload ) <= 0: return uploadedTorrentUrl = "http://passthepopcorn.me/torrents.php?id=" + ptpId command = Settings.OnSuccessfulUpload % { "releaseName": releaseName, "uploadedTorrentUrl": uploadedTorrentUrl } subprocess.Popen( command ) |
def OnSuccessfulUpload(releaseName, ptpId): | def __OnSuccessfulUpload(releaseName, ptpId): | def OnSuccessfulUpload(releaseName, ptpId): if len( Settings.OnSuccessfulUpload ) <= 0: return uploadedTorrentUrl = "http://passthepopcorn.me/torrents.php?id=" + ptpId command = Settings.OnSuccessfulUpload % { "releaseName": releaseName, "uploadedTorrentUrl": uploadedTorrentUrl } subprocess.Popen( command, shell = Tru... |
logger = releaseInfo.Announcement.Logger | def __GetFinishedDownloadToProcess(self): logger = releaseInfo.Announcement.Logger if len( self.PendingDownloads ) > 0: print "Pending downloads: %s" % len( self.PendingDownloads ) # TODO: can we use a multicast RPC call get all the statuses in one call? for downloadIndex in range( len( self.PendingDownloads ) ): rel... | |
(re.compile(r'Mozilla/5,0 \([^X].+\) .* Chrome/(3\.0\.1(8[2-9]|9)|4)'), | (re.compile(r'Mozilla/5.0 \([^X].+\) .* Chrome/(3\.0\.1(8[2-9]|9)|4)'), | def _get_variable_or_string(name): if name[0] in '"\'': return name[1:-1] else: return Variable(name) |
r.append('\\%s%s' % (_unicodeToTex.combined_text[cm],ch)) | r.append('\\%s%s' % (_unicodeToTex.combchar_text[cm],ch)) | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
r.append('\\%s{%s}' % (_unicodeToTex.combined_math[cm],ch)) | r.append('\\%s{%s}' % (_unicodeToTex.combchar_math[cm],ch)) | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
r.append('\\%s%s' % (_unicodeToTex.combined_math[cm],_unicodeToTex.unicodetotex[ch])) | r.append('\\%s%s' % (_unicodeToTex.combchar_math[cm],_unicodeToTex.unicodetotex[ch])) | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
print repr(self),self.__class__.__name__,self.nodeName assert 0 | def on_close(): item = cstack.pop() debug('Onstack close %s' % item) if isinstance(item,LazyElement): cstack[-1].append(item) else: raise NodeError('Tag <%s> starting at %s:%d is not correctly closed' % (name,self.nodeName, filename,line)) | |
d['texml:conditional'] = Nodes.TexmlConditionalNode | d['sdocml:conditional'] = Nodes.SDocMLConditionalNode | ' <def m="endtag" n="1"><d></{{0}}></d></def>', |
r2 = evalxorlist(skip or (r0 and r1), r0 or r1) | r2 = evalxorlist(skip or (r and r1), r or r1) | def evalxorlist(skip,r0): #print "eval xorlist:",rev(T) r = False if T: t = T[-1] if t.type == t.XOR: T.pop() r1 = evalcond(skip) r2 = evalxorlist(skip or (r0 and r1), r0 or r1) r = (r1 and not r2) or (r2 and not r1) return r |
return t | return r | def evalsubcond(skip): #print "eval parexpr:",rev(T) t = T.pop() assert t.type == t.LPAR r = evallist(skip) t = T.pop() if t.type != t.RPAR: raise CondError('Expected a ")" in position %d' % t.pos) return t |
r1 = evalcond(skip or r0) | r1 = evalcond(skip or r) | def evalorlist(skip): #print "eval orlist:",rev(T) r = True if T: t = T[-1] if t.type == t.OR: T.pop() r1 = evalcond(skip or r0) r = evalorlist(skip or r1) or r1 return r |
'D' : False } | 'D' : False, 'pf:c' : False, 'pf:mex' : False, 'pf:cmdln' : False, 'true' : True, 'false' : False } | def evallist(skip): #print 'eval list:',rev(T) r0 = evalcond(skip) #print " ...rest:",rev(T) if not T: return r0 t = T[-1] if t.type == t.AND: r = evalandlist(skip or not r0) and r0 elif t.type == t.OR: r = evalorlist(skip or r0) or r0 elif t.type == t.XOR: r1 = evalxorlist(skip,r0) r = (r0 and not r1) or (r1 and not... |
for c in [ '(A | B)', | for c in [ 'true + true', '(true + true)', 'false | false | false', '(false | false | false)', "(pf:c | pf:mex | pf:cmdln)", "pf:c | pf:mex | pf:cmdln", '(A | B | C)', 'A | B | C', | def evallist(skip): #print 'eval list:',rev(T) r0 = evalcond(skip) #print " ...rest:",rev(T) if not T: return r0 t = T[-1] if t.type == t.AND: r = evalandlist(skip or not r0) and r0 elif t.type == t.OR: r = evalorlist(skip or r0) or r0 elif t.type == t.XOR: r1 = evalxorlist(skip,r0) r = (r0 and not r1) or (r1 and not... |
if self.__includedfiles.has_key(bn): pass else: self.__includedfiles[bn] = bn | if not self.__includedfiles.has_key(bn): print "Adding to archive: %s" % bn | def includeExternalURL(self,url): proto,server,address,_,_ = urlparse.urlsplit(url) address = str(address) for p in self.__searchpaths: try: fn = os.path.join(p,address) bn = os.path.basename(fn) |
self.writelinesfile('data/%s' % bn,f.readlines()) | zi = zipfile.ZipInfo(self.__topdir + '/data/%s' % bn, self.__timestamp) zi.internal_attr |= 1 zi.external_attr = 0x81a40001 self.__zipfile.writestr(zi, f.read()) | def includeExternalURL(self,url): proto,server,address,_,_ = urlparse.urlsplit(url) address = str(address) for p in self.__searchpaths: try: fn = os.path.join(p,address) bn = os.path.basename(fn) |
res.extend([tag('div',{ 'class' : 'page-footer'}),self.__manager.getTimeStamp(),tag('br'), tagend('div')]) | res.extend([self.__manager.getTimeStamp()]) | def makeFooter(self,res): res.extend([tag('div',{ 'class' : 'page-footer'}),self.__manager.getTimeStamp(),tag('br'), tagend('div')]) |
if k == 'href' and urlparse.urlparse(v)[0] != 'javascript': | if k == 'href' and urlparse.urlparse(v)[0] in ['','file']: | def handle_starttag(self,tag,attrs): if tag == 'sdoc:if': d = dict(attrs) self.__stack.append(self.__state) if d.has_key('has'): self.__state = self.__state and self.sub.has_key(d['has']) elif d.has_key('hasnot'): self.__state = self.__state and not self.sub.has_key(d['has']) elif tag == 'sdoc:item': if attrs and a... |
t = o.group('combined') | t = o.group('unicodecombined') | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
else: texescape(i,r) | else: r.append(i) | def contentToTeX(self,r): for i in self: if isinstance(i,ParagraphNode): print self.__class__.__name__ assert 0 |
topnode = self.__nodestack[-1] topnode.handleText(content,self.__filename,self.__locator.getLineNumber()) | self.__textline = self.__locator.getLineNumber() self.__storedtext.append(content) | def characters(self,content): topnode = self.__nodestack[-1] topnode.handleText(content,self.__filename,self.__locator.getLineNumber()) #if c: print ">>%s<<" % c |
r'(?P<space>\s\+)', | r'(?P<space>\s+)', | def counter(start): i = int(start) while True: yield i i += 1 |
raise CondError('Invalid condition syntax at %d' % t.pos) | raise CondError('Invalid condition syntax "%s" at %d' % (tok.group('error'),tok.pos)) | def tokenize(s): it = condregex.finditer(s) while True: tok = it.next() if tok.group('error') is not None: raise CondError('Invalid condition syntax at %d' % t.pos) elif tok.group('space') is None: yield Token(tok) |
for c in [ 'A/B', | for c in [ '(A | B)', '(A/B)', 'A/B', | def evallist(skip): #print 'eval list:',rev(T) r0 = evalcond(skip) #print " ...rest:",rev(T) if not T: return r0 t = T[-1] if t.type == t.AND: r = evalandlist(skip or not r0) and r0 elif t.type == t.OR: r = evalorlist(skip or r0) or r0 elif t.type == t.XOR: r1 = evalxorlist(skip,r0) r = (r0 and not r1) or (r1 and not... |
r.append(i) | texescape(i,r) | def toTeX(self,r): r.append('$\displaystyle ') for i in self: if isinstance(i,Node): i.toTeX(r) else: r.append(i) r.append('$') return r |
raise IncludeError('File "%s" already included' % address) | pass else: self.__includedfiles[bn] = bn | def includeExternalURL(self,url): proto,server,address,_,_ = urlparse.urlsplit(url) address = str(address) for p in self.__searchpaths: try: fn = os.path.join(p,address) bn = os.path.basename(fn) |
data = str(open(fn,'rt').read()) zi = zipfile.ZipInfo('/'.join([self.__topdir, 'data', bn]), self.__timestamp) self.__zipfile.writestr(zi,data) | f = open(fn,'rt') self.writelinesfile('data/%s' % bn,f.readlines()) f.close() | def includeExternalURL(self,url): proto,server,address,_,_ = urlparse.urlsplit(url) address = str(address) for p in self.__searchpaths: try: fn = os.path.join(p,address) bn = os.path.basename(fn) |
r = subprocess.call([ 'pdflatex', filename ]) | r = subprocess.call([ 'pdflatex', filename ], env = os.environ) | def writeTexMath(self,filename): if self.__eqnlist: outf = open(filename,'w') outf.write('\\documentclass[12pt]{book}\n') |
'template' : config.UniqueDirEntry('template') | 'template' : config.UniqueDirEntry('template'), 'tempdir' : config.UniqueDirEntry('tempdir'), | def dump(self,out): self.__rootnode.dump(out,0) |
tempimgdir = 'imgs' timestamp = '%s @ host %s' % (time.strftime("%a, %d %b %Y %H:%M:%S"),os.environ['HOSTNAME']) | tempimgdir = os.path.join(conf['tempdir'] or '.','imgs') try: timestamp = '%s @ host %s' % (time.strftime("%a, %d %b %Y %H:%M:%S"),os.environ['HOSTNAME']) except KeyError: timestamp = '%s' % (time.strftime("%a, %d %b %Y %H:%M:%S")) | def dump(self,out): self.__rootnode.dump(out,0) |
r = True | r = False | def evalorlist(skip): #print "eval orlist:",rev(T) r = True if T: t = T[-1] if t.type == t.OR: T.pop() r1 = evalcond(skip or r) r = evalorlist(skip or r1) or r1 return r |
'true' : True, 'false' : False } for c in [ 'true + true', '(true + true)', 'false | false | false', '(false | false | false)', "(pf:c | pf:mex | pf:cmdln)", "pf:c | pf:mex | pf:cmdln", '(A | B | C)', 'A | B | C', '(A/B)', 'A/B', 'A/B/C', 'B/D/A', 'A+B', 'A|B', 'A|B|(A+B+C)|D', '?X+X', ]: | 'T' : True, 'F' : False } ok = True for c,res in [ ('T + T',True), ('T + F',False), ('F + T',False), ('F + F',False), ('(T + T)',True), ('F | F',False), ('T | F',True), ('F | T',True), ('T | T',True), ('(F | F)',False), ('T',True), ('(T)',True), ('F',False), ('(F)',False), ("(pf:c | pf:mex | pf:cmdln)",None), ("pf:c ... | def evallist(skip): r0 = evalcond(skip) if not T: return r0 t = T[-1] if t.type == t.AND: r = evalandlist(skip or not r0) and r0 elif t.type == t.OR: r = evalorlist(skip or r0) or r0 elif t.type == t.XOR: r1 = evalxorlist(skip,r0) r = (r0 and not r1) or (r1 and not r0) else: raise CondError('Invalid condition syntax ... |
print '\t%s -> %s' % (c,r) | if res is not None: if res is not r: ok = False print '\t%s -> %s%s' % (c,r,'' if res is None else '/%s' % res) print "Failed!!" if not ok else "Succeeded." | def evallist(skip): r0 = evalcond(skip) if not T: return r0 t = T[-1] if t.type == t.AND: r = evalandlist(skip or not r0) and r0 elif t.type == t.OR: r = evalorlist(skip or r0) or r0 elif t.type == t.XOR: r1 = evalxorlist(skip,r0) r = (r0 and not r1) or (r1 and not r0) else: raise CondError('Invalid condition syntax ... |
r.append(_unicodeToTex.unicodetotex[uidx]) | r.append('%s' % _unicodeToTex.unicodetotex[uidx]) | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
r.append(_mathUnicodeToTex.textunicodetotex[uidx]) | r.append('$%s$' % _mathUnicodeToTex.unicodetotex[uidx]) | def texescape(self,data,r): pos = 0 #unicoderegex = re.compile(u'[\u0080-\u8000]') for o in re.finditer(ur'(?P<backslash>\\)|(?P<spctex>{|}|<|>|#|\$|\^|_|&|%)|(?P<combined>[a-zA-Z][\u0300-\u036f]+)|(?P<unicodecombined>[\u0080-\u8000][\u0300-\u036f]?)',data): # backslash -> '\' # spctex -> single char special tex cha... |
if _mathUnicodeToTex.textunicodetotex.has_key(uidx): r.append(_mathUnicodeToTex.textunicodetotex[uidx]) | if _unicodeToTex.unicodetotex.has_key(uidx): r.append('%s' % _unicodeToTex.unicodetotex[uidx]) | def texverbatim(self,data,r): pos = 0 for o in re.finditer(ur'(?P<unicode>[\u0080-\u8000])|(?P<lf>\n)|(?P<space>[ ]+)|(?P<escape>%|\#|&)|(?P<special>\\|~|\^|\$|{|}|_|%)',data,re.MULTILINE): if o.start(0) > pos: r.append(str(data[pos:o.start(0)])) pos = o.end(0) if o.group('space'): #r.append('\\ ' * len(o.group('space'... |
self.last_record = conversation.start_time | self.last_record = None | def __init__(self, conversation): self.conversation = conversation try: self.archive = cjc_globals.application.plugins.get_service(Archive) except KeyError: self.archive = None if conversation.peer: ui.TextBuffer.__init__(self, {"peer": conversation.peer}, "message.descr-per-user","message buffer", conversation) else: ... |
older_than = self.last_record, limit = lines_needed, | older_than = older_than, limit = lines_needed, | def fill_top_underflow(self, lines_needed): if not self.archive: return record_iter = self.archive.get_records('message', self.conversation.peer, older_than = self.last_record, limit = lines_needed, order = Archive.REVERSE_CHRONOLOGICAL) records = list(record_iter) if not records: return records.reverse() self.last_rec... |
self.start_time = datetime.now() | self.start_time = None | def __init__(self,plugin,peer,thread): self.start_time = datetime.now() self.plugin=plugin self.peer=peer self.thread=thread self.buffer = MessagesBuffer(self) self.buffer.preference=plugin.settings["buffer_preference"] self.buffer.update() self.last_sender=None self.last_subject=None self.last_body=None self.last_thre... |
self.buffers={} | self.conversations={} | def __init__(self,app,name): PluginBase.__init__(self,app,name) self.buffers={} self.last_thread=0 cjc_globals.theme_manager.set_default_attrs(theme_attrs) cjc_globals.theme_manager.set_default_formats(theme_formats) self.available_settings={ "buffer": ("How received messages should be put in buffers" " (single|separat... |
def send_message(self,recipient,subject,body,thread=0,buff=None): | def send_message(self,recipient,subject,body,thread=0,conv=None): | def send_message(self,recipient,subject,body,thread=0,buff=None): if thread==0: self.last_thread+=1 thread="message-thread-%i" % (self.last_thread,) m=pyxmpp.Message(to_jid=recipient,stanza_type="normal",subject=subject,body=body,thread=thread) self.cjc.stream.send(m) if buff is None: buff=self.find_or_make(recipient,t... |
if buff is None: buff=self.find_or_make(recipient,thread) | if conv is None: conv=self.find_or_make(recipient,thread) conv.add_sent(recipient,subject,body,thread) | def send_message(self,recipient,subject,body,thread=0,buff=None): if thread==0: self.last_thread+=1 thread="message-thread-%i" % (self.last_thread,) m=pyxmpp.Message(to_jid=recipient,stanza_type="normal",subject=subject,body=body,thread=thread) self.cjc.stream.send(m) if buff is None: buff=self.find_or_make(recipient,t... |
buff.add_sent(recipient,subject,body,thread) | def send_message(self,recipient,subject,body,thread=0,buff=None): if thread==0: self.last_thread+=1 thread="message-thread-%i" % (self.last_thread,) m=pyxmpp.Message(to_jid=recipient,stanza_type="normal",subject=subject,body=body,thread=thread) self.cjc.stream.send(m) if buff is None: buff=self.find_or_make(recipient,t... | |
if not self.buffers.has_key(key): return for buff in self.buffers[key]: if buff.peer==arg or buff.peer==arg.bare(): buff.buffer.update() | if not self.conversations.has_key(key): return for conv in self.conversations[key]: if conv.peer==arg or conv.peer==arg.bare(): conv.buffer.update() | def ev_presence_changed(self,event,arg): key=arg.bare().as_unicode() if not self.buffers.has_key(key): return for buff in self.buffers[key]: if buff.peer==arg or buff.peer==arg.bare(): buff.buffer.update() |
for buffers in self.buffers.values(): for buf in buffers: buf.buffer.append_themed("message.day_change",{},activity_level=0) buf.buffer.update() | for buffers in self.conversations.values(): for conv in buffers: conv.buffer.append_themed("message.day_change",{},activity_level=0) conv.buffer.update() | def ev_day_changed(self,event,arg): for buffers in self.buffers.values(): for buf in buffers: buf.buffer.append_themed("message.day_change",{},activity_level=0) buf.buffer.update() |
def find_buffer(self,user,thread): buff=None | def find_conversation(self,user,thread): conv=None | def find_buffer(self,user,thread): buff=None if user: key=user.bare().as_unicode() else: key=user if self.buffers.has_key(key): buffs=self.buffers[key] for b in buffs: if thread==b.thread: buff=b break return buff |
if self.buffers.has_key(key): buffs=self.buffers[key] | if self.conversations.has_key(key): buffs=self.conversations[key] | def find_buffer(self,user,thread): buff=None if user: key=user.bare().as_unicode() else: key=user if self.buffers.has_key(key): buffs=self.buffers[key] for b in buffs: if thread==b.thread: buff=b break return buff |
buff=b | conv=b | def find_buffer(self,user,thread): buff=None if user: key=user.bare().as_unicode() else: key=user if self.buffers.has_key(key): buffs=self.buffers[key] for b in buffs: if thread==b.thread: buff=b break return buff |
return buff | return conv | def find_buffer(self,user,thread): buff=None if user: key=user.bare().as_unicode() else: key=user if self.buffers.has_key(key): buffs=self.buffers[key] for b in buffs: if thread==b.thread: buff=b break return buff |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.