<s> import cPickle <EOL> import errno <EOL> import itertools <EOL> import os <EOL> import sys <EOL> import tempfile <EOL> import traceback <EOL> from conary import files , trove , callbacks <EOL> from conary . deps import deps <EOL> from conary . lib import util , openpgpfile , openpgpkey <EOL> from conary . repository import changeset , errors , filecontents <EOL> from conary . repository . datastore import ( DataStoreRepository , DataStore , <EOL> DataStoreSet , ShallowDataStore , FlatDataStore ) <EOL> from conary . repository . repository import AbstractRepository <EOL> from conary . repository . repository import ChangeSetJob <EOL> from conary . repository . netrepos . repo_cfg import CfgContentStore <EOL> class FilesystemChangeSetJob ( ChangeSetJob ) : <EOL> def __init__ ( self , repos , cs , * args , ** kw ) : <EOL> self . mirror = kw . get ( '<STR_LIT>' , False ) <EOL> self . requireSigs = kw . pop ( '<STR_LIT>' , False ) <EOL> self . callback = kw . get ( '<STR_LIT>' , False ) <EOL> self . addTroveSetStart ( repos , cs ) <EOL> ChangeSetJob . __init__ ( self , repos , cs , * args , ** kw ) <EOL> repos . troveStore . addTroveSetDone ( self . callback ) <EOL> def addTroveSetStart ( self , repos , cs ) : <EOL> newDirNames = set ( ) <EOL> newBaseNames = set ( ) <EOL> oldTroves = [ ] <EOL> for i , csTrove in enumerate ( cs . iterNewTroveList ( ) ) : <EOL> if csTrove . getOldVersion ( ) : <EOL> oldTroves . append ( csTrove . getOldNameVersionFlavor ( ) ) <EOL> for fileInfo in itertools . chain ( <EOL> csTrove . getNewFileList ( raw = True ) , <EOL> csTrove . getChangedFileList ( raw = True ) ) : <EOL> if fileInfo [ <NUM_LIT:1> ] is None : <EOL> continue <EOL> newDirNames . add ( fileInfo [ <NUM_LIT:1> ] ) <EOL> newBaseNames . add ( fileInfo [ <NUM_LIT:2> ] ) <EOL> repos . troveStore . addTroveSetStart ( oldTroves , newDirNames , newBaseNames ) <EOL> def _containsFileContents ( self , sha1iter ) : <EOL> return self . repos . troveStore . hasFileContents ( sha1iter ) <EOL> def markTroveRemoved ( self , name , version , flavor ) : <EOL> self . repos . markTroveRemoved ( name , version , flavor ) <EOL> def checkTroveCompleteness ( self , trv ) : <EOL> if not self . mirror and not trv . troveInfo . sigs . sha1 ( ) : <EOL> raise errors . TroveChecksumMissing ( trv . getName ( ) , trv . getVersion ( ) , <EOL> trv . getFlavor ( ) ) <EOL> if trv . troveInfo . incomplete ( ) : <EOL> if trv . troveInfo . troveVersion ( ) > trove . TROVE_VERSION : <EOL> raise errors . TroveSchemaError ( trv . getName ( ) , trv . getVersion ( ) , <EOL> trv . getFlavor ( ) , <EOL> trv . troveInfo . troveVersion ( ) , <EOL> trove . TROVE_VERSION ) <EOL> else : <EOL> nvf = trv . getName ( ) , trv . getVersion ( ) , trv . getFlavor ( ) , <EOL> err = '<STR_LIT>' % nvf <EOL> raise errors . TroveIntegrityError ( error = err , * nvf ) <EOL> def checkTroveSignatures ( self , trv , callback ) : <EOL> assert ( hasattr ( callback , '<STR_LIT>' ) ) <EOL> if callback . keyCache is None : <EOL> callback . keyCache = openpgpkey . getKeyCache ( ) <EOL> for fingerprint , timestamp , sig in trv . troveInfo . sigs . digitalSigs . iter ( ) : <EOL> try : <EOL> pubKey = callback . keyCache . getPublicKey ( fingerprint ) <EOL> if pubKey . isRevoked ( ) : <EOL> raise openpgpfile . IncompatibleKey ( '<STR_LIT>' <EOL> % pubKey . getFingerprint ( ) ) <EOL> expirationTime = pubKey . getTimestamp ( ) <EOL> if expirationTime and expirationTime < timestamp : <EOL> raise openpgpfile . IncompatibleKey ( '<STR_LIT>' <EOL> % pubKey . getFingerprint ( ) ) <EOL> except openpgpfile . KeyNotFound : <EOL> pass <EOL> res = ChangeSetJob . checkTroveSignatures ( self , trv , callback ) <EOL> if len ( res [ <NUM_LIT:1> ] ) and self . requireSigs : <EOL> raise openpgpfile . KeyNotFound ( '<STR_LIT>' <EOL> '<STR_LIT>' % res [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ) <EOL> def _filterRestoreList ( self , configRestoreList , normalRestoreList ) : <EOL> def filterOne ( restoreList ) : <EOL> inReposList = self . _containsFileContents ( tup [ <NUM_LIT:2> ] <EOL> for tup in restoreList ) <EOL> return [ x for ( x , inRepos ) in zip ( restoreList , inReposList ) <EOL> if not inRepos ] <EOL> configRestoreList = filterOne ( configRestoreList ) <EOL> normalRestoreList = filterOne ( normalRestoreList ) <EOL> return configRestoreList , normalRestoreList <EOL> class UpdateCallback ( callbacks . UpdateCallback ) : <EOL> def __init__ ( self , statusPath , trustThreshold , keyCache ) : <EOL> self . path = statusPath <EOL> if statusPath : <EOL> self . tmpDir = os . path . dirname ( statusPath ) <EOL> callbacks . UpdateCallback . __init__ ( self , trustThreshold , keyCache ) <EOL> def _dumpStatus ( self , * args ) : <EOL> if self . path : <EOL> ( fd , path ) = tempfile . mkstemp ( dir = self . tmpDir , <EOL> suffix = '<STR_LIT>' ) <EOL> buf = cPickle . dumps ( args ) <EOL> os . write ( fd , buf ) <EOL> os . close ( fd ) <EOL> os . rename ( path , self . path ) <EOL> def creatingDatabaseTransaction ( self , * args ) : <EOL> self . _dumpStatus ( '<STR_LIT>' , * args ) <EOL> def updatingDatabase ( self , * args ) : <EOL> self . _dumpStatus ( '<STR_LIT>' , * args ) <EOL> class FilesystemRepository ( DataStoreRepository , AbstractRepository ) : <EOL> def __init__ ( self , serverNameList , troveStore , contentsDir , repositoryMap , <EOL> requireSigs = False , paranoidCommits = False ) : <EOL> self . serverNameList = serverNameList <EOL> self . paranoidCommits = paranoidCommits <EOL> map = dict ( repositoryMap ) <EOL> for serverName in serverNameList : <EOL> map [ serverName ] = self <EOL> self . troveStore = troveStore <EOL> self . requireSigs = requireSigs <EOL> storeType , paths = contentsDir <EOL> if storeType == CfgContentStore . LEGACY : <EOL> storeClass = DataStore <EOL> elif storeType == CfgContentStore . SHALLOW : <EOL> storeClass = ShallowDataStore <EOL> elif storeType == CfgContentStore . FLAT : <EOL> storeClass = FlatDataStore <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % ( storeType , ) ) <EOL> stores = [ ] <EOL> for path in paths : <EOL> util . mkdirChain ( path ) <EOL> stores . append ( storeClass ( path ) ) <EOL> if len ( stores ) == <NUM_LIT:1> : <EOL> store = stores [ <NUM_LIT:0> ] <EOL> else : <EOL> store = DataStoreSet ( * stores ) <EOL> DataStoreRepository . __init__ ( self , dataStore = store ) <EOL> AbstractRepository . __init__ ( self ) <EOL> def close ( self ) : <EOL> if self . troveStore is not None : <EOL> self . troveStore . db . close ( ) <EOL> self . troveStore = None <EOL> def thawFlavor ( self , flavor ) : <EOL> return deps . ThawFlavor ( flavor ) <EOL> def hasTrove ( self , pkgName , version , flavor ) : <EOL> return self . troveStore . hasTrove ( pkgName , troveVersion = version , <EOL> troveFlavor = flavor ) <EOL> def getTrove ( self , pkgName , version , flavor , pristine = True , <EOL> withFiles = True , hidden = False ) : <EOL> return self . troveStore . getTrove ( <EOL> pkgName , version , flavor , withFiles = withFiles , <EOL> hidden = hidden ) <EOL> def iterTroves ( self , troveList , withFiles = True , hidden = False ) : <EOL> return self . troveStore . iterTroves ( troveList , withFiles = withFiles , <EOL> hidden = hidden ) <EOL> def getParentTroves ( self , troveList ) : <EOL> return self . troveStore . getParentTroves ( troveList ) <EOL> def addTrove ( self , trv , trvCs , hidden = False , oldTroveSpec = None ) : <EOL> return self . troveStore . addTrove ( trv , trvCs , hidden = hidden ) <EOL> def addTroveDone ( self , pkg , mirror = False ) : <EOL> self . troveStore . addTroveDone ( pkg , mirror = mirror ) <EOL> def getFileVersion ( self , pathId , fileId , fileVersion , withContents = <NUM_LIT:0> ) : <EOL> if fileVersion . getHost ( ) not in self . serverNameList : <EOL> raise errors . RepositoryMismatch ( self . serverNameList , <EOL> fileVersion . getHost ( ) ) <EOL> fileObj = self . troveStore . getFile ( pathId , fileId ) <EOL> if withContents : <EOL> if fileObj . hasContents : <EOL> cont = filecontents . FromDataStore ( self . contentsStore , <EOL> file . contents . sha1 ( ) ) <EOL> else : <EOL> cont = None <EOL> return ( fileObj , cont ) <EOL> return fileObj <EOL> def getFileVersions ( self , fileList , withContents = False ) : <EOL> crossRepos = False <EOL> for ( pathId , fileId , fileVersion ) in fileList : <EOL> if fileVersion . getHost ( ) not in self . serverNameList : <EOL> crossRepos = True <EOL> if crossRepos : <EOL> for x in fileList : <EOL> yield self . getFileVersion ( withContents = withContents , * x ) <EOL> else : <EOL> fileDict = self . troveStore . getFiles ( fileList ) <EOL> for x in fileList : <EOL> try : <EOL> fileObj = fileDict [ x [ <NUM_LIT:0> : <NUM_LIT:2> ] ] <EOL> except KeyError : <EOL> raise errors . FileStreamMissing ( x [ <NUM_LIT:1> ] ) <EOL> if withContents : <EOL> if file . hasContents : <EOL> cont = filecontents . FromDataStore ( self . contentsStore , <EOL> file . contents . sha1 ( ) ) <EOL> else : <EOL> cont = None <EOL> yield ( fileObj , cont ) <EOL> yield fileObj <EOL> def addFileVersion ( self , troveInfo , pathId , path , fileId , <EOL> fileVersion , fileStream = None , withContents = True ) : <EOL> troveInfo . addFile ( pathId , path , fileId , fileVersion , <EOL> fileStream = fileStream , withContents = withContents ) <EOL> def commitChangeSet ( self , cs , mirror = False , hidden = False , serialize = False , <EOL> callback = None , <EOL> statusPath = None ) : <EOL> for trvCs in cs . iterNewTroveList ( ) : <EOL> v = trvCs . getNewVersion ( ) <EOL> if v . isOnLocalHost ( ) : <EOL> label = v . branch ( ) . label ( ) <EOL> raise errors . CommitError ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( label . asString ( ) ) ) <EOL> if self . requireSigs : <EOL> threshold = openpgpfile . TRUST_FULL <EOL> else : <EOL> threshold = openpgpfile . TRUST_UNTRUSTED <EOL> if statusPath : <EOL> assert not callback <EOL> callback = UpdateCallback ( statusPath = statusPath , <EOL> trustThreshold = threshold , <EOL> keyCache = self . troveStore . keyTable . keyCache ) <EOL> preRestored = set ( ) <EOL> for sha1 , fobj in cs . iterRegularFileContents ( ) : <EOL> cont = filecontents . FromFile ( fobj , compressed = True ) <EOL> self . _storeFileFromContents ( cont , sha1 , restoreContents = True , <EOL> precompressed = True ) <EOL> preRestored . add ( sha1 ) <EOL> cs . reset ( ) <EOL> self . troveStore . begin ( serialize ) <EOL> try : <EOL> FilesystemChangeSetJob ( self , cs , self . serverNameList , <EOL> resetTimestamps = not mirror , <EOL> callback = callback , <EOL> mirror = mirror , <EOL> hidden = hidden , <EOL> requireSigs = self . requireSigs , <EOL> preRestored = preRestored , <EOL> ) <EOL> except ( openpgpfile . KeyNotFound , errors . DigitalSignatureVerificationError ) : <EOL> self . troveStore . rollback ( ) <EOL> raise <EOL> except : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> print >> sys . stderr , '<STR_LIT>' . join ( traceback . format_exception ( * sys . exc_info ( ) ) ) <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> self . troveStore . rollback ( ) <EOL> raise <EOL> else : <EOL> if self . paranoidCommits : <EOL> for trvCs in cs . iterNewTroveList ( ) : <EOL> newTuple = trvCs . getNewNameVersionFlavor ( ) <EOL> if newTuple [ <NUM_LIT:1> ] is None : <EOL> continue <EOL> trv = self . getTrove ( withFiles = True , * newTuple ) <EOL> assert ( trv . verifyDigests ( ) ) <EOL> self . troveStore . commit ( ) <EOL> def markTroveRemoved ( self , name , version , flavor ) : <EOL> sha1s = self . troveStore . markTroveRemoved ( name , version , flavor ) <EOL> for sha1 in sha1s : <EOL> try : <EOL> self . contentsStore . removeFile ( sha1 ) <EOL> except OSError , e : <EOL> if e . errno != errno . ENOENT : <EOL> raise <EOL> def getFileContents ( self , itemList ) : <EOL> contents = [ ] <EOL> for item in itemList : <EOL> ( fileId , fileVersion ) = item [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> if fileVersion . getHost ( ) in self . serverNameList : <EOL> fileObj = item [ <NUM_LIT:2> ] <EOL> cont = filecontents . FromDataStore ( self . contentsStore , <EOL> fileObj . contents . sha1 ( ) ) <EOL> else : <EOL> raise errors . RepositoryMismatch ( self . serverNameList , <EOL> fileVersion . getHost ( ) ) <EOL> contents . append ( cont ) <EOL> return contents <EOL> def createChangeSet ( self , origTroveList , recurse = True , <EOL> withFiles = True , withFileContents = True , <EOL> excludeAutoSource = False , <EOL> mirrorMode = False , roleIds = None ) : <EOL> """<STR_LIT>""" <EOL> cs = changeset . ChangeSet ( ) <EOL> externalTroveList = [ ] <EOL> externalFileList = [ ] <EOL> removedTroveList = [ ] <EOL> dupFilter = set ( ) <EOL> troveList = origTroveList [ : ] <EOL> troveWrapper = _TroveListWrapper ( troveList , self . troveStore , withFiles , <EOL> roleIds = roleIds ) <EOL> for ( job , old , new , streams ) in troveWrapper : <EOL> ( troveName , ( oldVersion , oldFlavor ) , <EOL> ( newVersion , newFlavor ) , absolute ) = job <EOL> if job in dupFilter : <EOL> continue <EOL> else : <EOL> dupFilter . add ( job ) <EOL> done = False <EOL> if not newVersion : <EOL> if oldVersion . getHost ( ) not in self . serverNameList : <EOL> externalTroveList . append ( ( troveName , <EOL> ( oldVersion , oldFlavor ) , <EOL> ( None , None ) , absolute ) ) <EOL> else : <EOL> cs . oldTrove ( troveName , oldVersion , oldFlavor ) <EOL> for ( name , version , flavor ) in old . iterTroveList ( strongRefs = True ) : <EOL> troveWrapper . append ( ( name , ( version , flavor ) , <EOL> ( None , None ) , absolute ) , <EOL> False ) <EOL> done = True <EOL> elif ( newVersion . getHost ( ) not in self . serverNameList <EOL> or ( oldVersion and <EOL> oldVersion . getHost ( ) not in self . serverNameList ) ) : <EOL> externalTroveList . append ( ( troveName , ( oldVersion , oldFlavor ) , <EOL> ( newVersion , newFlavor ) , absolute ) ) <EOL> done = True <EOL> elif ( oldVersion and old . type ( ) == trove . TROVE_TYPE_REMOVED ) : <EOL> removedTroveList . append ( ( troveName , ( oldVersion , oldFlavor ) , <EOL> ( newVersion , newFlavor ) , absolute ) ) <EOL> done = True <EOL> if done : <EOL> if not recurse : <EOL> yield ( cs , externalTroveList , externalFileList , <EOL> removedTroveList ) <EOL> cs = changeset . ChangeSet ( ) <EOL> externalTroveList = [ ] <EOL> externalFileList = [ ] <EOL> removedTroveList = [ ] <EOL> continue <EOL> ( troveChgSet , filesNeeded , pkgsNeeded ) = new . diff ( old , absolute = absolute ) <EOL> if recurse : <EOL> for refJob in pkgsNeeded : <EOL> refOldVersion = refJob [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] <EOL> refNewVersion = refJob [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] <EOL> if ( refNewVersion and <EOL> ( refNewVersion . getHost ( ) not in self . serverNameList ) <EOL> or ( refOldVersion and <EOL> refOldVersion . getHost ( ) not in self . serverNameList ) <EOL> ) : <EOL> externalTroveList . append ( refJob ) <EOL> else : <EOL> troveWrapper . append ( refJob , True ) <EOL> cs . newTrove ( troveChgSet ) <EOL> if job in origTroveList and job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None : <EOL> try : <EOL> primary = troveChgSet . getNewNameVersionFlavor ( ) <EOL> cs . addPrimaryTrove ( * primary ) <EOL> except KeyError : <EOL> pass <EOL> getList = [ ] <EOL> localFilesNeeded = [ ] <EOL> for ( pathId , oldFileId , oldFileVersion , newFileId , newFileVersion ) in filesNeeded : <EOL> if ( newFileVersion . getHost ( ) not in self . serverNameList <EOL> or ( oldFileVersion and <EOL> oldFileVersion . getHost ( ) not in self . serverNameList ) ) : <EOL> externalFileList . append ( ( pathId , troveName , <EOL> ( oldVersion , oldFlavor , oldFileId , oldFileVersion ) , <EOL> ( newVersion , newFlavor , newFileId , newFileVersion ) ) ) <EOL> else : <EOL> localFilesNeeded . append ( ( pathId , oldFileId , oldFileVersion , <EOL> newFileId , newFileVersion ) ) <EOL> if oldFileVersion : <EOL> getList . append ( ( pathId , oldFileId , oldFileVersion ) ) <EOL> getList . append ( ( pathId , newFileId , newFileVersion ) ) <EOL> localFilesNeeded . sort ( ) <EOL> localFilesNeeded . reverse ( ) <EOL> ptrTable = { } <EOL> for ( pathId , oldFileId , oldFileVersion , newFileId , newFileVersion ) in localFilesNeeded : <EOL> oldFile = None <EOL> if oldFileVersion : <EOL> oldFile = files . ThawFile ( streams [ oldFileId ] , pathId ) <EOL> oldCont = None <EOL> newCont = None <EOL> newFile = files . ThawFile ( streams [ newFileId ] , pathId ) <EOL> forceAbsolute = ( mirrorMode and oldFileId <EOL> and oldFileId != newFileId ) <EOL> if forceAbsolute : <EOL> ( filecs , contentsHash ) = changeset . fileChangeSet ( pathId , <EOL> None , <EOL> newFile ) <EOL> else : <EOL> ( filecs , contentsHash ) = changeset . fileChangeSet ( pathId , <EOL> oldFile , <EOL> newFile ) <EOL> cs . addFile ( oldFileId , newFileId , filecs ) <EOL> if ( not withFileContents <EOL> or ( excludeAutoSource and newFile . flags . isAutoSource ( ) ) <EOL> or ( newFile . flags . isEncapsulatedContent ( ) <EOL> and not newFile . flags . isCapsuleOverride ( ) ) ) : <EOL> continue <EOL> if ( contentsHash <EOL> or ( oldFile and newFile . flags . isConfig ( ) <EOL> and not oldFile . flags . isConfig ( ) ) <EOL> or ( forceAbsolute and newFile . hasContents ) <EOL> ) : <EOL> if oldFileVersion and oldFile . hasContents : <EOL> oldCont = self . getFileContents ( <EOL> [ ( oldFileId , oldFileVersion , oldFile ) ] ) [ <NUM_LIT:0> ] <EOL> newCont = self . getFileContents ( <EOL> [ ( newFileId , newFileVersion , newFile ) ] ) [ <NUM_LIT:0> ] <EOL> ( contType , cont ) = changeset . fileContentsDiff ( oldFile , <EOL> oldCont , newFile , newCont , <EOL> mirrorMode = mirrorMode ) <EOL> if not newFile . flags . isConfig ( ) and contType == changeset . ChangedFileTypes . file : <EOL> contentsHash = newFile . contents . sha1 ( ) <EOL> ptr = ptrTable . get ( contentsHash , None ) <EOL> if ptr is not None : <EOL> contType = changeset . ChangedFileTypes . ptr <EOL> cont = filecontents . FromString ( ptr ) <EOL> else : <EOL> ptrTable [ contentsHash ] = pathId + newFileId <EOL> if not newFile . flags . isConfig ( ) and contType == changeset . ChangedFileTypes . file : <EOL> cont = filecontents . CompressedFromDataStore ( <EOL> self . contentsStore , <EOL> newFile . contents . sha1 ( ) ) <EOL> compressed = True <EOL> else : <EOL> compressed = False <EOL> if contType == changeset . ChangedFileTypes . ptr : <EOL> compressed = False <EOL> cs . addFileContents ( pathId , newFileId , contType , cont , <EOL> newFile . flags . isConfig ( ) , <EOL> compressed = compressed ) <EOL> if not recurse : <EOL> yield cs , externalTroveList , externalFileList , removedTroveList <EOL> cs = changeset . ChangeSet ( ) <EOL> externalTroveList = [ ] <EOL> externalFileList = [ ] <EOL> removedTroveList = [ ] <EOL> if recurse : <EOL> yield cs , externalTroveList , externalFileList , removedTroveList <EOL> class _TroveListWrapper : <EOL> def _handleJob ( self , job , recursed , idx ) : <EOL> t = self . trvIterator . next ( ) <EOL> if t is not None : <EOL> if self . withFiles : <EOL> t , streams = t <EOL> else : <EOL> streams = { } <EOL> if t is None : <EOL> if recursed : <EOL> t = trove . Trove ( job [ <NUM_LIT:0> ] , job [ idx ] [ <NUM_LIT:0> ] , job [ idx ] [ <NUM_LIT:1> ] , <EOL> type = trove . TROVE_TYPE_REMOVED ) <EOL> t . setIsMissing ( True ) <EOL> t . computeDigests ( ) <EOL> streams = { } <EOL> else : <EOL> for x in self . trvIterator : pass <EOL> raise errors . TroveMissing ( job [ <NUM_LIT:0> ] , job [ idx ] [ <NUM_LIT:0> ] ) <EOL> return t , streams <EOL> def next ( self ) : <EOL> if not self . l and self . new : <EOL> troveList = [ ] <EOL> for job , recursed in self . new : <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None : <EOL> troveList . append ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None : <EOL> troveList . append ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) ) <EOL> self . trvIterator = self . troveStore . iterTroves ( <EOL> troveList , withFiles = self . withFiles , <EOL> withFileStreams = self . withFiles , <EOL> permCheckFilter = self . _permCheck , <EOL> hidden = True , <EOL> ) <EOL> self . l = self . new <EOL> self . new = [ ] <EOL> if self . l : <EOL> job , recursed = self . l . pop ( <NUM_LIT:0> ) <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is None : <EOL> old = None <EOL> oldStreams = { } <EOL> else : <EOL> old , oldStreams = self . _handleJob ( job , recursed , <NUM_LIT:1> ) <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None : <EOL> new = None <EOL> newStreams = { } <EOL> else : <EOL> new , newStreams = self . _handleJob ( job , recursed , <NUM_LIT:2> ) <EOL> newStreams . update ( oldStreams ) <EOL> return job , old , new , newStreams <EOL> else : <EOL> raise StopIteration <EOL> def _permCheck ( self , cu , instanceTblName ) : <EOL> sql = """<STR_LIT>""" % ( instanceTblName , instanceTblName , instanceTblName , <EOL> "<STR_LIT:U+002C>" . join ( "<STR_LIT>" % x for x in self . roleIds ) ) <EOL> cu . execute ( sql , start_transaction = False ) <EOL> def __iter__ ( self ) : <EOL> while True : <EOL> yield self . next ( ) <EOL> def append ( self , item , recurse ) : <EOL> self . new . append ( ( item , recurse ) ) <EOL> def __init__ ( self , l , troveStore , withFiles , roleIds = None ) : <EOL> self . trvIterator = None <EOL> self . new = [ ( x , False ) for x in l ] <EOL> self . l = [ ] <EOL> self . troveStore = troveStore <EOL> self . withFiles = withFiles <EOL> self . roleIds = roleIds </s>
