rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.PHOTO_TBL = config.get(section,'photo_tbl') self.PHOTO_TBLSQ = config.get(section,'photo_tblsq') self.NEWS_TBL = config.get(section,'news_tbl') self.NEWS_TBLSQ = config.get(section,'news_tblsq') self.SITE = config.get(section,'site') | self.PHOTO_TBL = ConfObj.get(section,'photo_tbl') self.PHOTO_TBLSQ = ConfObj.get(section,'photo_tblsq') self.NEWS_TBL = ConfObj.get(section,'news_tbl') self.NEWS_TBLSQ = ConfObj.get(section,'news_tblsq') self.SITE = ConfObj.get(section,'site') | def read_conf(self, ConfObj): ''' Getting config options for this handler ''' |
db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) | if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) | def add_news(self, text, img_id=0): db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) date = self.date sender = self.sender subject = re.escape(self.params) dest = self.domext(self.dest) TABLE = "news_test" if dest == "nah-ko.org": SITE = "test" elif dest == "rein-team.darkte... |
mycur = db.cursor() mycur.execute(myquery) self.id = db.insert_id() | if self.DB_TYPE == 'mysql': mycur = db.cursor() mycur.execute(myquery) self.id = db.insert_id() elif self.DB_TYPE == 'postgresql': req = db.query(myquery) SEQ_TABLE = TABLE + '_id_seq' self.id = db.query("select currval('%s')" % SEQ_TABLE).getresult()[0] | def add_news(self, text, img_id=0): db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) date = self.date sender = self.sender subject = re.escape(self.params) dest = self.domext(self.dest) TABLE = "news_test" if dest == "nah-ko.org": SITE = "test" elif dest == "rein-team.darkte... |
if self.sender in BL: | self.log.debug("[check_lists]: BLACK_LIST=%s" % BL) if sender in BL: | def check_lists(self, config): """ Check if the user is authorized to use the handler """ |
return self.sender in WL | self.log.debug("[check_lists]: WHITE_LIST=%s" % WL) return sender in WL | def check_lists(self, config): """ Check if the user is authorized to use the handler """ |
id = getid(db, self.PHOTO_TBLSQ) | id = self.getid(db, self.PHOTO_TBLSQ) | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... |
self.id = getid(db, self.NEWS_TBLSQ) | self.id = self.getid(db, self.NEWS_TBLSQ) | def add_news(self, text, img_id=0): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) date = self.date sender = self.sender subj... |
Encoders.encode_base64(msg) | Encoders.encode_base64(mesg) | def main(): """ Here we do the job """ global DEBUG, LOGFILE, MBOT_ADDRESS, CONFIG_FILE config_file = CONFIG_FILE try: opts, args = getopt.getopt(sys.argv[1:], "c:") except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o == "-c": config_file = a Conf = read_defaults(... |
self.log.notice("[UrlHandler]: %s" % data | self.log.notice("[UrlHandler]: %s" % data) | def handle(self, body): """ The body may contain one url per line """ result = [] glob_size = 0 |
myquery = "insert into %s (description,img_data,tnimg_data,filename,filesize,filetype) values ('%s','%s','%s','%s','%d','%s')" % (TABLE, desc, img_LO.oid, TNimg_LO.oid, filename, filesize, filetype) | req = db.query("insert into %s (description,img_data,tnimg_data,filename,filesize,filetype) values ('%s','%s','%s','%s','%d','%s')" % (TABLE, desc, img_LO.oid, TNimg_LO.oid, filename, filesize, filetype)) | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... |
id = db.query("select currval('%s')" % SEQ_TABLE).getresult()[0] | id = db.query("select currval('%s')" % SEQ_TABLE).getresult()[0][0] | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... |
myquery = "update %s set id_img='%d' where id='%d'" % (TABLE, id, news_id) | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... | |
req = db.query("update %s set id_img='%d' where id='%d'" % (TABLE, id, news_id)) | req = db.query(myquery) | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... |
self.id = db.query("select currval('%s')" % SEQ_TABLE).getresult()[0] | self.id = db.query("select currval('%s')" % SEQ_TABLE).getresult()[0][0] | def add_news(self, text, img_id=0): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) date = self.date sender = self.sender subj... |
log.error("Impossible to load handler: %s" \ | log.err("Impossible to load handler: %s" \ | def main(): """ Here we do the job """ global MBOT_ADDRESS, CONFIG_FILE, LOG_LEVEL, MODULES config_file = CONFIG_FILE try: opts, args = getopt.getopt(sys.argv[1:], "c:") except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o == "-c": config_file = a Conf = read_defau... |
log.error("%s: %s" \ | log.err("%s: %s" \ | def main(): """ Here we do the job """ global MBOT_ADDRESS, CONFIG_FILE, LOG_LEVEL, MODULES config_file = CONFIG_FILE try: opts, args = getopt.getopt(sys.argv[1:], "c:") except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o == "-c": config_file = a Conf = read_defau... |
log.error("No handler found for '%s'" % subject) | log.err("No handler found for '%s'" % subject) | def main(): """ Here we do the job """ global MBOT_ADDRESS, CONFIG_FILE, LOG_LEVEL, MODULES config_file = CONFIG_FILE try: opts, args = getopt.getopt(sys.argv[1:], "c:") except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o == "-c": config_file = a Conf = read_defau... |
TNimg_LO.write(filedata) | TNimg_LO.write(TNfiledata) | def add_img(self, filename, filetype, filedata, TNfiledata, filesize): if self.DB_TYPE == 'mysql': db = MySQLdb.connect(db=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) elif self.DB_TYPE == 'postgresql': db = pg.connect(dbname=self.DB, host=self.HOST, user=self.DB_USER, passwd=self.DB_PASS) news_id =... |
img.thumbnail((self.tnX,self.tnY)) | img.thumbnail((int(self.tnX),int(self.tnY))) | def handle(self, body): "Get news from text and attachment if present" |
uri.Uri(vModellNs['%s_enthaelt_%s' \ | uri.Uri(vModellNs['%s_enthält_%s' \ | def _endElementHandler(self, name): elem = self._popElem() |
if nodeCls == LITERAL: cls = LITERAL | if nodeCls == rdfs.Literal: cls = prefixes.shortenUri(rdfs.Literal) | def __init__(self, model): # Build a table containing all defined classes. self.classes = {} for node, in model.query('SerQL', """select class from {class} rdf:type {rdfs:Class}"""): self.classes[node] = RdfClass(node) |
else: self.basePrefixes = {} | def __init__(self, *args, **kwargs): """Initializes a SPARQL Parser object. | |
class ExpressionNode(list): | class BasicExpressionNode(list): | def prettyPrint(self, stream=None): if stream == None: stream = sys.stdout |
__slots__ = ('id', 'parent', '__weakref__', 'extents', | __slots__ = ('extents', | def prettyPrint(self, stream=None): if stream == None: stream = sys.stdout |
_idCounter = 1 | def prettyPrint(self, stream=None): if stream == None: stream = sys.stdout | |
self.id = ExpressionNode._idCounter ExpressionNode._idCounter += 1 self.parent = None super(ExpressionNode, self).__init__(subexprs) self._addSubexprs(subexprs) | super(BasicExpressionNode, self).__init__(subexprs) | def __init__(self, *subexprs): self.id = ExpressionNode._idCounter ExpressionNode._idCounter += 1 |
def _setParent(self, parent): if parent is not None: newParent = weakref.proxy(parent) else: newParent = None if self.parent is not None: self.parent._pruneSubexpr(self) assert self.parent is None self.parent = newParent def _pruneSubexpr(self, subexpr): for i, se in enumerate(self): if subexpr is se: pos = i s... | def _setParent(self, parent): if parent is not None: newParent = weakref.proxy(parent) else: newParent = None | |
cp.id = ExpressionNode._idCounter ExpressionNode._idCounter += 1 cp.parent = None | def copy(self): """Return a copy of the complete expression tree.""" cp = copy.copy(self) | |
subexprCp._setParent(self) super(ExpressionNode, cp).__setitem__(i, subexprCp) | super(BasicExpressionNode, cp).__setitem__(i, subexprCp) | def copy(self): """Return a copy of the complete expression tree.""" cp = copy.copy(self) |
def __setitem__(self, i, x): if isinstance(i, slice): self._removeSubexprs(self[i]) ret = super(ExpressionNode, self).__setitem__(i, x) self._addSubexprs(x) else: self._removeSubexprs((self[i],)) ret = super(ExpressionNode, self).__setitem__(i, x) self._addSubexprs((x,)) return ret def __setslice__(self, i, j, sequenc... | def copy(self): """Return a copy of the complete expression tree.""" cp = copy.copy(self) | |
if self.id in nodeSet: assert False, 'Node %d multiply referenced' % self.id nodeSet.add(self.id) | if self.getId() in nodeSet: assert False, 'Node %d multiply referenced' % self.getId() nodeSet.add(self.getId()) | def _recursiveCheckTree(self, nodeSet): if self.id in nodeSet: assert False, 'Node %d multiply referenced' % self.id nodeSet.add(self.id) for subexpr in self: subexpr._recursiveCheckTree(nodeSet) |
stream.write('[[%d]] ' % self.id) | stream.write('[[%d]] ' % self.getId()) | def prettyPrint(self, stream=None, indentLevel=0): if stream == None: stream = sys.stdout |
columns = ', '.join(['%s AS %s' % (e, n) | columns = ', '.join(["%s AS '%s'" % (e, n) | def MapResult(self, expr, select, *columnExprs): columns = ', '.join(['%s AS %s' % (e, n) for e, n in zip(columnExprs, expr.columnNames)]) return 'SELECT %s\nFROM %s' % (columns, select) |
[('text/plain', 0, 0)], | [('UTF8_STRING', 0, 0)], | def __init__(self): UiManagerSlaveDelegate.__init__(self, gladefile="browser", toplevel_name='schemaBrowser') self.mainWindow = None |
% (nodeSub, node) | % (unicode(nodeSub).encode('utf-8'), unicode(node).encode('utf-8')) | def __init__(self, model): # Build a table containing all defined classes. self.classes = {} for node, in model.query('SerQL', """select class from {class} rdf:type {rdfs:Class}"""): self.classes[node] = RdfClass(node) |
print "Ignoring: %s is in domain from %s" % (nodeCls, nodeProp) | print "Ignoring: %s is in domain from %s" % \ (unicode(nodeCls).encode('utf-8'), unicode(nodeProp).encode('utf-8')) | def __init__(self, model): # Build a table containing all defined classes. self.classes = {} for node, in model.query('SerQL', """select class from {class} rdf:type {rdfs:Class}"""): self.classes[node] = RdfClass(node) |
print "Ignoring: %s is in range from %s" % (nodeCls, nodeProp) | print "Ignoring: %s is in range from %s" % \ (unicode(nodeCls).encode('utf-8'), unicode(nodeProp).encode('utf-8')) | def __init__(self, model): # Build a table containing all defined classes. self.classes = {} for node, in model.query('SerQL', """select class from {class} rdf:type {rdfs:Class}"""): self.classes[node] = RdfClass(node) |
subexprCp = subexpr.copy() super(BasicExpressionNode, cp).__setitem__(i, subexprCp) | self[i] = subexpr.copy() | def copy(self): """Return a copy of the complete expression tree.""" cp = copy.copy(self) |
for i, subexpr in enumerate(self): subexprCp._setParent(self) | def copy(self): cp = super(ExclusiveExpressionNode, self).copy() | |
__slots__ = ('prunedExpr') | __slots__ = ('prunedExpr',) | def remove(self, x): i = self.index(x) self._removeSubexprs(self[x:x+1]) return super(ExclusiveExpressionNode, self).remove(x) |
self.pendingRows.append("(%s,%s,%s,%s,%s)" % (self.connection.escape( m.digest()), self.connection.escape( unicode(subject).encode('utf-8')), self.connection.escape( unicode(pred).encode('utf-8')), self.connection.escape( unicode(objectType).encode('utf-8')), self.connection.escape( unicode(object).encode('utf-8')))) i... | self.pendingRows.append((m.digest(), unicode(subject).encode('utf-8'), unicode(pred).encode('utf-8'), unicode(objectType).encode('utf-8'), unicode(object).encode('utf-8'))) if len(self.pendingRows) >= self.ROWS_PER_QUERY: | def triple(self, subject, pred, object): if isinstance(object, uri.Uri): objectType = '<RESOURCE>' elif isinstance(object, blanknode.BlankNode): objectType = '<BLANKNODE>' elif isinstance(object, literal.Literal): if object.typeUri is None: objectType = '<LITERAL>' else: objectType = object.typeUri else: assert False, ... |
self.cursor.execute( | self.cursor.executemany( | def _writePendingRows(self): if len(self.pendingRows) == 0: return |
VALUES %s;""" % ','.join(self.pendingRows)) | VALUES (_binary%s,_utf8%s,_utf8%s,_utf8%s,_utf8%s)""", self.pendingRows) | def _writePendingRows(self): if len(self.pendingRows) == 0: return |
if elem.uri is not None: self.sink.triple(elem.uri, commonns.rdf.type, uri.Uri(vModellNs[elem.name])) parent = None for superelem in reversed(self.elems[:-1]): if superelem.uri is not None and \ superelem.name != 'V-Modell': parent = superelem break if parent is not None: self.sink.triple(parent.uri, uri.Uri(vModell... | def _startElementHandler(self, name, attributes): if self.acumText is not None: self.warning('Mixed content') | |
if not cls in prop.domain and \ not cls in prop.range: | if not prop in outgoing and \ not prop in incoming: | def isActive(self, classes, props): if len(classes) != 1: return False |
if cls in prop.domain: | if prop in outgoing: | def getQuery(self, classes, props, shortener): cls = classes[0] |
if cls in prop.range: | if prop in incoming: | def getQuery(self, classes, props, shortener): cls = classes[0] |
self.reifPatternVarNr = 1 | def __init__(self): self.bound = set() self.indepMapping = {} self.reifPatternVarNr = 1 self.reifPatterns = [] | |
var = nodes.Var(' self.reifPatternVarNr += 1 | var = VarMaker.make() | def addReifPattern(self, context, subject, predicate, object): # Use a variable name that isn't allowed in SerQL. var = nodes.Var('#stmt_%d#' % self.reifPatternVarNr) self.reifPatternVarNr += 1 |
def transformIntoCond(self, containing=None): """Transforms this scope into its binding condition. `containing` is the scope object corresponding to the containing scope. The binding condition of a scope is an expression stating that all bindings of every variable in that scope are equal, and that they are equal to at... | def closeScope(self, containing=None, optional=False): """Closes a scope, optionally merging it into its containing scope, given by parameter `containing`. Closing a scope comprises three main operations. The first one is checking that none of the excluded variables in this scope is bound in the containing scope. If i... | def transformIntoCond(self, containing=None): """Transforms this scope into its binding condition. `containing` is the scope object corresponding to the containing scope. |
decoupler._addVariable(var, False) | def transformIntoCond(self, containing=None): """Transforms this scope into its binding condition. `containing` is the scope object corresponding to the containing scope. | |
containing[var] = [bindings[0].copy()] | containing[var] = nodes.Equal(bindings[0].copy()) if optional: containing.excluded.add(var) | def transformIntoCond(self, containing=None): """Transforms this scope into its binding condition. `containing` is the scope object corresponding to the containing scope. |
This transformer also decouples scopes, i.e., when a single variable name is used in different scopes it will be replaced by a different variable in each scope. | This transformer also checks that all patterns in the query are well designed, in accordance to the definition by Perez, Arenas, and Gutierrez (arXiv:cs 0605124). This definition basically states that variables occurring in the optional side of an optional pattern, either must be used in its fixed side, or cannot be us... | def variableRepl(self, var): """Returns one of the bindings for the variable `var` (a `nodes.Var` object). The returned binding is a fresh copy of the one stored in the symbol table.""" return iter(self[var]).next().copy() |
cond = self.currentScope.transformIntoCond() | cond = self.currentScope.closeScope() | def preMapResult(self, expr): # Create a separate scope for the expression. self.currentScope = Scope() |
def preGraphPattern(self, expr): | def preGraphPattern(self, expr, optional=False): | def preGraphPattern(self, expr): # Subexpressions of a complex graph pattern must be processed # in a particular order to make sure that variables are # visible exactly where they should be. We first sort the # subexpressions according to that order. expr.sort(key=self._patternSortKey) |
cond = self.currentScope.transformIntoCond(containing) | cond = self.currentScope.closeScope(containing, optional) | def preGraphPattern(self, expr): # Subexpressions of a complex graph pattern must be processed # in a particular order to make sure that variables are # visible exactly where they should be. We first sort the # subexpressions according to that order. expr.sort(key=self._patternSortKey) |
self.versionMapping = versionUri | self.versionMapping = UriValueMapping(versionUri) | def __init__(self, versionUri=commonns.relrdf.version, stmtUri=commonns.relrdf.stmt, metaInfoVersion=1): super(AllVersionsMapper, self).__init__() |
cp = copy.copy(self) for i, subexpr in enumerate(self): self[i] = subexpr.copy() return cp | return copy.deepcopy(self) | def copy(self): """Return a copy of the complete expression tree.""" cp = copy.copy(self) |
def copy(self): cp = super(ExclusiveExpressionNode, self).copy() for subexpr in cp: assert subexpr.parent.getId() == self.getId() | def __deepcopy__(self, memoDict): cp = copy.copy(self) for i, subexpr in enumerate(self): assert isinstance(subexpr, Pruned) subexpr = subexpr.prunedExpr super(ExclusiveExpressionNode, self).__setitem__(i, subexpr) subexprCp = subexpr.copy() super(ExclusiveExpressionNode, cp).__setitem__(i, subexprCp) subexprCp.... | def copy(self): cp = super(ExclusiveExpressionNode, self).copy() |
def addIndependentPair(self, var1, var2): if var1.name == var2.name: | def addIndependentPair(self, varName1, varName2): if varName1 == varName2: | def addIndependentPair(self, var1, var2): if var1.name == var2.name: return |
group1 = self.indepMapping.get(var1.name) group2 = self.indepMapping.get(var2.name) | group1 = self.indepMapping.get(varName1) group2 = self.indepMapping.get(varName2) | def addIndependentPair(self, var1, var2): if var1.name == var2.name: return |
group = frozenset((var1, var2)) | group = frozenset((varName1, varName2)) | def addIndependentPair(self, var1, var2): if var1.name == var2.name: return |
for var in group: self.indepMapping[var.name] = group self.indepMapping[var1.name] = group self.indepMapping[var2.name] = group | for varName in group: self.indepMapping[varName] = group self.indepMapping[varName1] = group self.indepMapping[varName2] = group | def addIndependentPair(self, var1, var2): if var1.name == var2.name: return |
subconds.append(nodes.Different(*group)) | subconds.append(nodes.Different(*[nodes.Var(n) for n in group])) | def getCondition(self): subconds = [] |
if indepVar1: | if indepVar1 is not None: | def exprFromPattern(self, nodeList1, edge, nodeList2): rels = [] |
.addIndependentPair(indepVar1, node1) | .addIndependentPair(indepVar1.name, node1.name) | def exprFromPattern(self, nodeList1, edge, nodeList2): rels = [] |
if indepVar2: | if indepVar2 is not None: | def exprFromPattern(self, nodeList1, edge, nodeList2): rels = [] |
.addIndependentPair(indepVar2, node2) | .addIndependentPair(indepVar2.name, node2.name) | def exprFromPattern(self, nodeList1, edge, nodeList2): rels = [] |
if indepVar1: | if indepVar1 is not None: | def exprListFromReifPattern(self, nodeList1, edge, nodeList2): vars = [] |
.addIndependentPair(indepVar1, node1) | .addIndependentPair(indepVar1.name, node1.name) | def exprListFromReifPattern(self, nodeList1, edge, nodeList2): vars = [] |
if indepVar2: | if indepVar2 is not None: | def exprListFromReifPattern(self, nodeList1, edge, nodeList2): vars = [] |
.addIndependentPair(indepVar2, node2) | .addIndependentPair(indepVar2.name, node2.name) | def exprListFromReifPattern(self, nodeList1, edge, nodeList2): vars = [] |
def graphPatternExpr(self, node): cond = self.currentContext().getCondition() if cond: node = nodes.Select(node, cond) return node | def exprListFromReifPattern(self, nodeList1, edge, nodeList2): vars = [] | |
if condExpr: | indepCond = self.currentContext().getCondition() if indepCond is not None: current = nodes.Select(current, indepCond) if condExpr is not None: | def selectQueryExpr(self, (columnNames, mappingExprs), patternExpr, condExpr): current = patternExpr |
col = gtk.TreeViewColumn(name) | col = gtk.TreeViewColumn(name.replace('_', '__')) | def showResults(self, results): """Display the query results object as table.""" # Create a list store for the results: |
m.update(unicode(subject)) m.update(unicode(pred)) m.update(unicode(objectType)) m.update(unicode(object)) | m.update(subject.encode('utf-8')) m.update(pred.encode('utf-8')) m.update(objectType.encode('utf-8')) m.update(unicode(object).encode('utf-8')) | def triple(self, subject, pred, object): if isinstance(object, uri.Uri): objectType = '<RESOURCE>' elif isinstance(object, blanknode.BlankNode): objectType = '<BLANKNODE>' elif isinstance(object, literal.Literal): if object.typeUri is None: objectType = '<LITERAL>' else: objectType = object.typeUri else: assert False, ... |
subexprCp.parent = weakref.proxy(self) | subexprCp.parent = weakref.proxy(cp) | def __deepcopy__(self, memoDict): # The basic copy.copy operation calls our own overwritten list # operations when copying the subexpressions, which means they # will be stolen from this object. cp = copy.copy(self) |
super(BinaryOperation, self).__init__(operand) | super(UnaryOperation, self).__init__(operand) | def __init__(self, operand): super(BinaryOperation, self).__init__(operand) |
varName = '?' + propShort.replace(':', '_') | chrs = list(propShort) for i, c in enumerate(chrs): if not c.isalnum(): chrs[i] = '_' if not chrs[0].isalpha(): varName = '?prop_' + ''.join(chrs) else: varName = '?' + ''.join(chrs) | def makeVarName(propShort, varNames): if propShort[0] == '<': varName = '?prop' else: varName = '?' + propShort.replace(':', '_') |
setattr(node[i], propName, result[propPos]) | setattr(node[i], propName, unicode(result[propPos]).encode('utf-8')) | def addResults(self, results): # Create data structures containing the indexes of the # relevant columns: |
setattr(edge, propName, result[propPos]) | setattr(edge, propName, unicode(result[propPos]).encode('utf-8')) | def addResults(self, results): # Create data structures containing the indexes of the # relevant columns: |
match = re.match("^([^ ]+) *= *(.*)$", line) | match = re.match(r"^([^ ]+) *= *([^\r\n]*)[\r\n]*$", line) | def readSimpleConfigFile(path): ret = {} f = open(path, "rt") for line in f.readlines(): # Skip blank lines if re.match("^[ \t]*$", line): continue # Otherwise it'd better be a configuration setting match = re.match("^([^ ]+) *= *(.*)$", line) if not match: print "WARNING: %s: ignored bad configuration directive '%s'... |
if rv in (0, errno.EINPROGRESS): | if rv in (0, errno.EINPROGRESS, errno.EWOULDBLOCK): | def onAddressLookup(address): if self.socket is None: # the connection was closed while we were calling gethostbyname return rv = self.socket.connect_ex((address, port)) if rv in (0, errno.EINPROGRESS): eventloop.addWriteCallback(self.socket, onWriteReady) else: msg = errno.errorcode[rv] trapCall(self, errback, Connect... |
self.openEmptyDB() | try: self.openEmptyDB() except: self.handleDatabaseLoadError() | def __init__(self, dbPath=None, restore=True): try: self.txn = None self.dc = None self.toUpdate = set() self.toRemove = set() self.errorState = False if dbPath is not None: self.dbPath = dbPath else: self.dbPath = config.get(prefs.BSDDB_PATHNAME) start = clock() self.openEmptyDB() if restore: try: try: self.db.open ("... |
self.dbenv.close() | if self.dbenv is not None: self.dbenv.close() | def handleDatabaseLoadError(self): print "WARNING: exception while loading database" traceback.print_exc() self.closeInvalidDB() self.dbenv.close() self.saveInvalidDB() self.openEmptyDB() self.saveDatabase() |
target="file:///""" | """ html += ' target="file:///' | def play(self): print "VideoDisplay play" html = """<?xml version="1.0" encoding="utf-8"?> |
if not feed.validateFeedURL(url): | if url is None or not feed.validateFeedURL(url): | def awakeFromNib(self): url = NSPasteboard.generalPasteboard().stringForType_(NSStringPboardType) if not feed.validateFeedURL(url): url = '' self.addChannelSheetURL.setStringValue_(url) |
seconds = idletime.get() | try: seconds = int(idletime.get()) except: print "WARNING: idletime module returned an invalid value..." seconds = 0.0 | def run(self): seconds = idletime.get() if self.idling: self._whenIdling(seconds) else: self._whenNotIdling(seconds) self.lastTimeout = eventloop.addTimeout(self.periodicity,self.run,"Idle notifier") |
del self.itemList | def remove(self): del self.itemList DDBObject.remove(self) | |
(version, data) = stat | (version, data) = state | def __setstate__(self,state): (version, data) = stat |
return config.get(config.EXPIRE_AFTER_X_DAYS) | return float(config.get(config.EXPIRE_AFTER_X_DAYS)) | def getDefaultExpiration(self): return config.get(config.EXPIRE_AFTER_X_DAYS) |
def isVideoEnclosure(enclosure): """ Pass an enclosure dictionary to this method and it will return a boolean saying if the enclosure is a video or not. """ return (_hasVideoType(enclosure) or _hasVideoExtension(enclosure, 'url') or _hasVideoExtension(enclosure, 'href')) def getFirstVideoEnclosure(entry): """Find the ... | def isVideoEnclosure(enclosure): """ Pass an enclosure dictionary to this method and it will return a boolean saying if the enclosure is a video or not. """ return (_hasVideoType(enclosure) or _hasVideoExtension(enclosure, 'url') or _hasVideoExtension(enclosure, 'href')) def getFirstVideoEnclosure(entry): """Find the ... | def isVideoEnclosure(enclosure): """ Pass an enclosure dictionary to this method and it will return a boolean saying if the enclosure is a video or not. """ return (_hasVideoType(enclosure) or _hasVideoExtension(enclosure, 'url') or _hasVideoExtension(enclosure, 'href')) |
for enclosure in enclosures: if isVideoEnclosure(enclosure): return enclosure return None | def getFirstVideoEnclosure(entry): """Find the first video enclosure in a feedparser entry. Returns the enclosure, or None if no video enclosure is found. """ try: enclosures = entry.enclosures except (KeyError, AttributeError): return None for enclosure in enclosures: if isVideoEnclosure(enclosure): return enclosure... | |
if self.isPlaying: | if self.isPlaying and self.stopOnDeselect: | def onDeselected(self, frame): if self.isPlaying: Controller.instance.playbackController.stop(False) |
self.exitPlayback() | self.stop() | def skip(self, direction): nextItem = None if direction == 1: nextItem = self.currentPlaylist.getNext() else: if self.currentDisplay.getCurrentTime() <= 1.0: nextItem = self.currentPlaylist.getPrev() else: self.currentDisplay.resetMovie() return self.currentPlaylist.cur() if nextItem is None: self.exitPlayback() else: ... |
self.exitPlayback() | self.stop() | def onMovieFinished(self): if self.skip(1) is None: self.exitPlayback() |
return True or isinstance(self.actualFeed, ScraperFeedImpl) | return isinstance(self.actualFeed, ScraperFeedImpl) | def isScraped(self): return True or isinstance(self.actualFeed, ScraperFeedImpl) |
self.addText('<%s'%name) for key in attrs.keys(): if key != 't:repeatForView': self.addAttr(key,attrs[key]) self.addIdAndClose() | self.addElementStart(name, attrs, addId=True) | def startElement(self,name, attrs): self.depth = self.depth + 1 |
self.addText('<%s'%name) for key in attrs.keys(): if key != 't:updateForView': self.addAttr(key,attrs[key]) self.addIdAndClose() | self.addElementStart(name, attrs, addId=True) | def startElement(self,name, attrs): self.depth = self.depth + 1 |
self.addText('<%s'%name) for key in attrs.keys(): if (key not in ['t:hideIf']): self.addAttr(key,attrs[key]) self.addText('>') | self.addElementStart(name, attrs) | def startElement(self,name, attrs): self.depth = self.depth + 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.