本文整理汇总了Python中pyLibrary.dot.set_default函数的典型用法代码示例。如果您正苦于以下问题:Python set_default函数的具体用法?Python set_default怎么用?Python set_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_default函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: append_query
def append_query(self, es_query, start):
self.start = start
parts = self.edge.domain.partitions
filters = []
notty = []
for p in parts:
filters.append(AndOp("and", [p.where]+notty).to_esfilter())
notty.append(NotOp("not", p.where))
missing_filter = None
if self.edge.allowNulls: # TODO: Use Expression.missing().esfilter() TO GET OPTIMIZED FILTER
missing_filter = set_default(
{"filter": AndOp("and", notty).to_esfilter()},
es_query
)
return wrap({"aggs": {
"_match": set_default(
{"filters": {"filters": filters}},
es_query
),
"_missing": missing_filter
}})
示例2: _range_composer
def _range_composer(edge, domain, es_query, to_float):
# USE RANGES
_min = coalesce(domain.min, MAX(domain.partitions.min))
_max = coalesce(domain.max, MAX(domain.partitions.max))
if isinstance(edge.value, Variable):
calc = {"field": edge.value.var}
else:
calc = {"script_field": edge.value.to_ruby()}
if edge.allowNulls: # TODO: Use Expression.missing().esfilter() TO GET OPTIMIZED FILTER
missing_filter = set_default(
{"filter": {"or": [
OrOp("or", [
BinaryOp("lt", [edge.value, Literal(None, to_float(_min))]),
BinaryOp("gte", [edge.value, Literal(None, to_float(_max))]),
]).to_esfilter(),
edge.value.missing().to_esfilter()
]}},
es_query
)
else:
missing_filter = None
return wrap({"aggs": {
"_match": set_default(
{"range": calc},
{"range": {"ranges": [{"from": to_float(p.min), "to": to_float(p.max)} for p in domain.partitions]}},
es_query
),
"_missing": missing_filter
}})
示例3: _delayed_imports
def _delayed_imports():
global _ListContainer
global _meta
global _containers
from pyLibrary.queries import meta as _meta
from pyLibrary.queries.containers.list_usingPythonList import ListContainer as _ListContainer
from pyLibrary.queries import containers as _containers
_ = _ListContainer
_ = _meta
_ = _containers
try:
from pyLibrary.queries.jx_usingMySQL import MySQL
except Exception:
MySQL = None
from pyLibrary.queries.jx_usingES import FromES
from pyLibrary.queries.meta import FromESMetadata
set_default(_containers.type2container, {
"elasticsearch": FromES,
"mysql": MySQL,
"memory": None,
"meta": FromESMetadata
})
示例4: append_query
def append_query(self, es_query, start):
self.start = start
if not isinstance(self.edge.value, Variable):
script_field = self.edge.value.to_ruby()
missing = self.edge.value.missing().to_esfilter()
output = wrap(
{
"aggs": {
"_match": set_default(
{"terms": {"script_field": script_field, "size": self.domain.limit}}, es_query
),
"_missing": set_default({"filter": missing}, es_query),
}
}
)
return output
output = wrap(
{
"aggs": {
"_match": set_default(
{"terms": {"field": self.edge.value.var, "size": self.domain.limit}}, es_query
),
"_missing": set_default({"missing": {"field": self.edge.value}}, es_query),
}
}
)
return output
示例5: _range_composer
def _range_composer(edge, domain, es_query, to_float):
# USE RANGES
_min = coalesce(domain.min, MAX(domain.partitions.min))
_max = coalesce(domain.max, MAX(domain.partitions.max))
if is_keyword(edge.value):
calc = {"field": edge.value}
else:
calc = {"script": qb_expression_to_ruby(edge.value)}
if is_keyword(edge.value):
missing_range = {"or": [
{"range": {edge.value: {"lt": to_float(_min)}}},
{"range": {edge.value: {"gte": to_float(_max)}}}
]}
else:
missing_range = {"script": {"script": qb_expression_to_ruby({"or": [
{"lt": [edge.value, to_float(_min)]},
{"gt": [edge.value, to_float(_max)]},
]})}}
return wrap({"aggs": {
"_match": set_default(
{"range": calc},
{"range": {"ranges": [{"from": to_float(p.min), "to": to_float(p.max)} for p in domain.partitions]}},
es_query
),
"_missing": set_default(
{"filter": {"or": [
missing_range,
{"missing": {"field": get_all_vars(edge.value)}}
]}},
es_query
),
}})
示例6: append_query
def append_query(self, es_query, start):
self.start = start
if not isinstance(self.edge.value, Variable):
script_field = self.edge.value.to_ruby()
missing = self.edge.value.missing()
output = wrap(
{
"aggs": {
"_match": set_default(
{"terms": {"script_field": script_field, "size": self.domain.limit}}, es_query
),
"_missing": set_default({"filter": missing.to_esfilter()}, es_query) if missing else None,
}
}
)
return output
output = wrap(
{
"aggs": {
"_match": set_default(
{"terms": {"field": self.edge.value.var, "size": self.domain.limit}}, es_query
),
"_missing": set_default(
{"missing": {"field": self.edge.value}}, es_query
), # TODO: Use Expression.missing().esfilter() TO GET OPTIMIZED FILTER
}
}
)
return output
示例7: _delayed_imports
def _delayed_imports():
global type2container
global _ListContainer
global _Cube
global _run
global _Query
global _Normal
try:
from pyLibrary.queries.jx_usingMySQL import MySQL as _MySQL
except Exception:
_MySQL = None
from pyLibrary.queries.jx_usingES import FromES as _FromES
from pyLibrary.queries.containers.list_usingPythonList import ListContainer as _ListContainer
from pyLibrary.queries.containers.cube import Cube as _Cube
from pyLibrary.queries.jx import run as _run
from pyLibrary.queries.query import QueryOp as _Query
from pyLibrary.queries.containers.list_usingSQLite import Table_usingSQLite
set_default(type2container, {
"elasticsearch": _FromES,
"mysql": _MySQL,
"sqlite": Table_usingSQLite,
"memory": None
})
_ = _run
_ = _Query
_ = _Normal
示例8: __init__
def __init__(self, **desc):
desc = wrap(desc)
self._set_slots_to_null(self.__class__)
set_default(self, desc)
self.name = coalesce(desc.name, desc.type)
self.isFacet = coalesce(desc.isFacet, False)
self.dimension = Null
示例9: _get_branches_from_hg
def _get_branches_from_hg(settings):
# GET MAIN PAGE
response = http.get(settings.url)
doc = BeautifulSoup(response.all_content)
all_repos = doc("table")[1]
branches = UniqueIndex(["name", "locale"], fail_on_dup=False)
for i, r in enumerate(all_repos("tr")):
dir, name = [v.text.strip() for v in r("td")]
b = _get_single_branch_from_hg(settings, name, dir.lstrip("/"))
branches.extend(b)
# branches.add(set_default({"name": "release-mozilla-beta"}, branches["mozilla-beta", DEFAULT_LOCALE]))
for b in list(branches["mozilla-beta", ]):
branches.add(set_default({"name": "release-mozilla-beta"}, b)) # THIS IS THE l10n "name"
b.url = "https://hg.mozilla.org/releases/mozilla-beta" # THIS IS THE
for b in list(branches["mozilla-release", ]):
branches.add(set_default({"name": "release-mozilla-release"}, b))
for b in list(branches["mozilla-aurora", ]):
if b.locale == "en-US":
continue
branches.add(set_default({"name": "comm-aurora"}, b))
# b.url = "https://hg.mozilla.org/releases/mozilla-aurora"
return branches
示例10: es_setop
def es_setop(es, query):
es_query, filters = es14.util.es_query_template(query.frum.name)
set_default(filters[0], simplify_esfilter(query.where.to_esfilter()))
es_query.size = coalesce(query.limit, queries.query.DEFAULT_LIMIT)
es_query.sort = jx_sort_to_es_sort(query.sort)
es_query.fields = DictList()
return extract_rows(es, es_query, query)
示例11: _delayed_imports
def _delayed_imports():
global type2container
from pyLibrary.queries.qb_usingMySQL import MySQL
from pyLibrary.queries.qb_usingES import FromES
set_default(type2container, {
"elasticsearch": FromES,
"mysql": MySQL,
"memory": None
})
示例12: _convert_clause
def _convert_clause(self, clause):
"""
JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
"""
if clause == None:
return None
elif isinstance(clause, Mapping):
return set_default({"value": self.convert(clause["value"])}, clause)
else:
return [set_default({"value": self.convert(c.value)}, c) for c in clause]
示例13: append_query
def append_query(self, es_query, start):
self.start = start
return wrap({"aggs": {
"_match": set_default(
{"terms": {
"field": self.edge.value,
"size": self.edge.domain.limit
}},
es_query
),
"_missing": set_default({"missing": {"field": self.edge.value}}, es_query),
}})
示例14: _convert_clause
def _convert_clause(self, clause):
"""
Qb QUERIES HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
"""
clause = wrap(clause)
if clause == None:
return None
elif isinstance(clause, Mapping):
return set_default({"value": self.convert(clause.value)}, clause)
else:
return [set_default({"value": self.convert(c.value)}, c) for c in clause]
示例15: parse_comment
def parse_comment(bug, comment):
bug = bug.copy()
subtests = []
lines = comment.comment.split('\n')
for line in lines:
if not line.strip():
continue
elif line.startswith('log: https://treeherder.mozilla.org'):
bug.treeherder = line.split('log: ')[1]
continue
elif line.startswith('buildname'):
bug.build.name = line.split('buildname: ')[1]
continue
elif line.startswith('repository: '):
bug.branch.name = line.split('repository: ')[1]
continue
elif line.startswith('machine: '):
bug.machine.name = line.split('machine: ')[1]
continue
elif line.startswith('who: '):
continue
elif line.startswith('revision'):
try:
bug.build.revision = line.split('revision: ')[1]
continue
except:
Log.error("exception splitting bug {{bug_id}} line on 'revision: ', {{line}}", bug_id=bug.id, line=line)
elif line.startswith('start_time'):
bug.timestamp = Date(line.split('start_time: ')[1])
continue
elif line.startswith('submit_timestamp'):
bug.timestamp = line.split('submit_timestamp: ')[1]
continue
parts = line.split("|")
if len(parts) == 3:
try:
subtest = Dict()
subtest.subtest = parse_status(parts[0])
subtest.subtest.name = parts[1].strip()
subtest.subtest.message = parts[2].strip()
subtest.subtest.in_ad = any(subtest.subtest.message.find(t)>=0 for t in timeouts)
set_default(subtest, bug)
subtest.subtest.comment_line = line
subtest.subtest.report_ts = Date(comment.modified_ts)
subtests.append(subtest)
except Exception, e:
Log.note("IGNORED LINE {{bug_id}} {{line}}", line=line, bug_id=bug.bug_id)
else:
Log.note("IGNORED LINE {{bug_id}} {{line}}", line=line, bug_id=bug.bug_id)