本文整理汇总了Python中util.Util.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Util.__init__方法的具体用法?Python Util.__init__怎么用?Python Util.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import __init__ [as 别名]
def __init__(self):
'''
initializes:
1. graph database connection
2. datastore connection
3. graph database indices required
4. url and templates for interaction with the graph database REST API
'''
Util.__init__(self)
if os.environ.get('NEO4J_URL'):
graph_db_url = urlparse(os.environ.get('NEO4J_URL'))
neo4j.authenticate(
"{host}:{port}".format(host = graph_db_url.hostname, port = graph_db_url.port),
graph_db_url.username, graph_db_url.password
)
self.graphdb = neo4j.GraphDatabaseService(
'http://{host}:{port}/db/data'.format(host = graph_db_url.hostname, port = graph_db_url.port)
)
else:
self.graphdb = neo4j.GraphDatabaseService()
self.node_index = self.graphdb.get_or_create_index(neo4j.Node, 'NODE')
self.disambiguation_index = self.graphdb.get_or_create_index(neo4j.Node, self.DISAMBIGUATION)
self._url = lambda present_node: 'http://localhost:7474/db/data/node/{0}'.format(present_node)
self._template = lambda target_node: {
"to" : self._url(target_node),
"relationships": {
"type": "sibling"
},
"cost_property": "weight",
"algorithm" : "dijkstra"
}
self.DataM = RelDataStore()
示例2: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import __init__ [as 别名]
def __init__(self):
Util.__init__(self)
self.fdb = FastDataStore()
if os.environ.get('NEO4J_URL'):
graph_db_url = urlparse(os.environ.get('NEO4J_URL'))
neo4j.authenticate(
"{host}:{port}".format(host = graph_db_url.hostname, port = graph_db_url.port),
graph_db_url.username, graph_db_url.password
)
self.graphdb = neo4j.GraphDatabaseService(
'http://{host}:{port}/db/data'.format(host = graph_db_url.hostname, port = graph_db_url.port)
)
else:
self.graphdb = neo4j.GraphDatabaseService()
#self.graphdb.clear()
#print "cleared database!"
self.rel_key = "REL_CREATED"
self.node_key = "NODE_CREATED"
self.max_tries = 5
self.BATCH_LIM = 50
self.counter = 0
self.node_index = self.graphdb.get_or_create_index(neo4j.Node, 'NODE')
self.disambiguation_index = self.graphdb.get_or_create_index(neo4j.Node, self.DISAMBIGUATION)
示例3: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import __init__ [as 别名]
def __init__(self):
Util.__init__(self)
self.blacklist += ['by country', 'by area', 'by region', 'by continent', 'user:', 'portal:', 'talk', 'name']