code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
'''taobao.fenxiao.cooperation.update 更新合作关系等级
供应商更新合作的分销商等级'''
request = TOPRequest('taobao.fenxiao.cooperation.update')
request['distributor_id'] = distributor_id
request['grade_id'] = grade_id
if trade_type!=None: request['trade_type'] = trade_type
self... | def update(self, distributor_id, grade_id, session, trade_type=None) | taobao.fenxiao.cooperation.update 更新合作关系等级
供应商更新合作的分销商等级 | 4.444949 | 2.382894 | 1.865357 |
'''taobao.fenxiao.distributor.items.get 查询商品下载记录
供应商查询分销商商品下载记录。'''
request = TOPRequest('taobao.fenxiao.distributor.items.get')
for k, v in kwargs.iteritems():
if k not in ('distributor_id', 'start_modified', 'end_modified', 'page_no', 'page_size', 'product_id') and... | def items_get(self, session, **kwargs) | taobao.fenxiao.distributor.items.get 查询商品下载记录
供应商查询分销商商品下载记录。 | 6.671969 | 4.478537 | 1.489765 |
'''taobao.fenxiao.distributors.get 获取分销商信息
查询和当前登录供应商有合作关系的分销商的信息'''
request = TOPRequest('taobao.fenxiao.distributors.get')
request['nicks'] = nicks
self.create(self.execute(request, session))
return self.distributors | def get(self, nicks, session) | taobao.fenxiao.distributors.get 获取分销商信息
查询和当前登录供应商有合作关系的分销商的信息 | 8.933761 | 3.024434 | 2.953862 |
'''taobao.fenxiao.product.add 添加产品
添加分销平台产品数据。业务逻辑与分销系统前台页面一致
- 产品图片默认为空
- 产品发布后默认为下架状态'''
request = TOPRequest('taobao.fenxiao.product.add')
request['name'] = name
request['productcat_id'] = productcat_id
request['standard_price'] = sta... | def add(self, name, productcat_id, standard_price, retail_price_low, retail_price_high, category_id, quantity, alarm_number, desc, prov, city, postage_type, have_invoice, have_guarantee, session, **kwargs) | taobao.fenxiao.product.add 添加产品
添加分销平台产品数据。业务逻辑与分销系统前台页面一致
- 产品图片默认为空
- 产品发布后默认为下架状态 | 4.110545 | 2.857968 | 1.438275 |
'''taobao.fenxiao.product.image.delete 产品图片删除
产品图片删除,只删除图片信息,不真正删除图片'''
request = TOPRequest('taobao.fenxiao.product.image.delete')
request['product_id'] = product_id
request['position'] = position
self.create(self.execute(request, session), fields=['result','cre... | def image_delete(self, product_id, position, session) | taobao.fenxiao.product.image.delete 产品图片删除
产品图片删除,只删除图片信息,不真正删除图片 | 6.066739 | 3.604318 | 1.683186 |
'''taobao.fenxiao.product.image.upload 产品图片上传
产品主图图片空间相对路径或绝对路径添加或更新,或者是图片上传。如果指定位置的图片已存在,则覆盖原有信息,如果位置为1,自动设为主图。'''
request = TOPRequest('taobao.fenxiao.product.image.upload')
request['product_id'] = product_id
request['position'] = position
if pic_path!=None: re... | def image_upload(self, product_id, position, session, pic_path=None, image=None) | taobao.fenxiao.product.image.upload 产品图片上传
产品主图图片空间相对路径或绝对路径添加或更新,或者是图片上传。如果指定位置的图片已存在,则覆盖原有信息,如果位置为1,自动设为主图。 | 6.773612 | 2.562225 | 2.643644 |
'''taobao.fenxiao.product.sku.delete 产品SKU删除接口
根据sku properties删除sku数据'''
request = TOPRequest('taobao.fenxiao.product.sku.delete')
request['product_id'] = product_id
request['properties'] = properties
self.create(self.execute(request, session), fields=['result',... | def sku_delete(self, product_id, properties, session) | taobao.fenxiao.product.sku.delete 产品SKU删除接口
根据sku properties删除sku数据 | 6.887855 | 4.002792 | 1.720763 |
'''taobao.fenxiao.product.sku.update 产品sku编辑接口
产品SKU信息更新'''
request = TOPRequest('taobao.fenxiao.product.sku.update')
request['product_id'] = product_id
request['properties'] = properties
for k, v in kwargs.iteritems():
if k not in ('quantity', 'stand... | def sku_update(self, product_id, properties, session, **kwargs) | taobao.fenxiao.product.sku.update 产品sku编辑接口
产品SKU信息更新 | 6.102689 | 4.63535 | 1.316554 |
'''taobao.fenxiao.product.skus.get SKU查询接口
产品sku查询'''
request = TOPRequest('taobao.fenxiao.product.skus.get')
request['product_id'] = product_id
self.create(self.execute(request, session), fields=['skus','total_results'], models={'skus':FenxiaoSku})
return self.s... | def skus_get(self, product_id, session) | taobao.fenxiao.product.skus.get SKU查询接口
产品sku查询 | 6.402938 | 4.05113 | 1.580531 |
'''taobao.fenxiao.product.update 更新产品
- 更新分销平台产品数据,不传更新数据返回失败
- 对sku进行增、删操作时,原有的sku_ids字段会被忽略,请使用sku_properties和sku_properties_del。'''
request = TOPRequest('taobao.fenxiao.product.update')
request['pid'] = pid
for k, v in kwargs.iteritems():
if k not ... | def update(self, pid, session, **kwargs) | taobao.fenxiao.product.update 更新产品
- 更新分销平台产品数据,不传更新数据返回失败
- 对sku进行增、删操作时,原有的sku_ids字段会被忽略,请使用sku_properties和sku_properties_del。 | 8.831191 | 5.103606 | 1.730383 |
'''taobao.fenxiao.products.get 查询产品列表
查询供应商的产品数据
- 入参传入pids将优先查询,即只按这个条件查询。
- 入参传入sku_number将优先查询(没有传入pids),即只按这个条件查询(最多显示50条)
- 入参fields传skus将查询sku的数据,不传该参数默认不查询,返回产品的其它信息。
- 入参fields传入images将查询多图数据,不传只返回主图数据。
- 入参fields仅对传入pids生效(只有按ID查询时,才能查询额外的数据)... | def get(self, session, **kwargs) | taobao.fenxiao.products.get 查询产品列表
查询供应商的产品数据
- 入参传入pids将优先查询,即只按这个条件查询。
- 入参传入sku_number将优先查询(没有传入pids),即只按这个条件查询(最多显示50条)
- 入参fields传skus将查询sku的数据,不传该参数默认不查询,返回产品的其它信息。
- 入参fields传入images将查询多图数据,不传只返回主图数据。
- 入参fields仅对传入pids生效(只有按ID查询时,才能查询额外的数据)
-... | 11.087727 | 2.323697 | 4.77159 |
'''taobao.fenxiao.productcats.get 查询产品线列表
查询供应商的所有产品线数据。根据登陆用户来查询,不需要其他入参'''
request = TOPRequest('taobao.fenxiao.productcats.get')
if fields: request['fields'] = fields
self.create(self.execute(request, session))
return self.productcats | def get(self, session, fields=None) | taobao.fenxiao.productcats.get 查询产品线列表
查询供应商的所有产品线数据。根据登陆用户来查询,不需要其他入参 | 11.377089 | 3.010737 | 3.778839 |
'''taobao.fenxiao.order.confirm.paid 确认收款
供应商确认收款(非支付宝交易)。'''
request = TOPRequest('taobao.fenxiao.order.confirm.paid')
request['purchase_order_id'] = purchase_order_id
if confirm_remark!=None: request['confirm_remark'] = confirm_remark
self.create(self.execute(r... | def confirm_paid(self, purchase_order_id, session, confirm_remark=None) | taobao.fenxiao.order.confirm.paid 确认收款
供应商确认收款(非支付宝交易)。 | 4.607749 | 2.492982 | 1.848288 |
if value is None:
value = not self.shuffled
spotifyconnect.Error.maybe_raise(lib.SpPlaybackEnableShuffle(value)) | def enable_shuffle(self, value=None) | Enable shuffle mode | 14.595645 | 14.436353 | 1.011034 |
if value is None:
value = not self.repeated
spotifyconnect.Error.maybe_raise(lib.SpPlaybackEnableRepeat(value)) | def enable_repeat(self, value=None) | Enable repeat mode | 17.311686 | 16.516644 | 1.048136 |
links = obj.get(LINKS_KEY, {})
for detector in [LATEST, DRAFT_3]:
if detector.draft.curies_rel in links:
return detector.detect(obj)
return LATEST.detect(obj) | def detect(self, obj) | Identifies the HAL draft level of a given JSON object. | 15.186907 | 12.626176 | 1.202811 |
if thing is None:
return []
if isinstance(thing, set):
return list(thing)
if isinstance(thing, types.StringTypes):
if thing.startswith("["):
# handle a list inside a string coming from the batch navigation
return ast.literal_eval(thing)
if not (is_lis... | def to_list(thing) | converts an object to a list
>>> to_list(1)
[1]
>>> to_list([1,2,3])
[1, 2, 3]
>>> to_list(("a", "b", "c"))
['a', 'b', 'c']
>>> to_list(dict(a=1, b=2))
[{'a': 1, 'b': 2}]
>>> to_list(None)
[]
>>> to_list("['a', 'b', 'c']")
... | 3.988197 | 4.368334 | 0.912979 |
if not (is_list(col) or is_tuple(col)):
fail("First argument must be a list or tuple")
def _block(dct):
if not is_dict(dct):
return []
return dct.get(key, default)
return map(_block, col) | def pluck(col, key, default=None) | Extracts a list of values from a collection of dictionaries
>>> stooges = [{"name": "moe", "age": 40},
... {"name": "larry", "age": 50},
... {"name": "curly", "age": 60}]
>>> pluck(stooges, "name")
['moe', 'larry', 'curly']
It only works with col... | 4.247094 | 4.707667 | 0.902165 |
copy = dict()
for key in keys:
if key in dct.keys():
copy[key] = dct[key]
return copy | def pick(dct, *keys) | Returns a copy of the dictionary filtered to only have values for the
whitelisted keys (or list of valid keys)
>>> pick({"name": "moe", "age": 50, "userid": "moe1"}, "name", "age")
{'age': 50, 'name': 'moe'} | 2.578328 | 3.747099 | 0.688086 |
copy = dict()
for key in dct:
if key not in keys:
copy[key] = dct[key]
return copy | def omit(dct, *keys) | Returns a copy of the dictionary filtered to omit the blacklisted keys
(or list of keys)
>>> omit({"name": "moe", "age": 50, "userid": "moe1"}, "userid", "age")
{'name': 'moe'} | 2.282323 | 4.158263 | 0.548865 |
def _block(memo, key):
if key in dct:
memo[mapping[key]] = dct[key]
return memo
else:
return memo
return reduce(_block, mapping, omit(dct, *mapping.keys())) | def rename(dct, mapping) | Rename the keys of a dictionary with the given mapping
>>> rename({"a": 1, "BBB": 2}, {"a": "AAA"})
{'AAA': 1, 'BBB': 2} | 6.266144 | 6.05152 | 1.035466 |
if not is_list(col):
col = [col]
def _block(dct):
return rename(dct, mapping)
return map(_block, col) | def alias(col, mapping) | Returns a collection of dictionaries with the keys renamed according to
the mapping
>>> libraries = [{"isbn": 1, "ed": 1}, {"isbn": 2, "ed": 2}]
>>> alias(libraries, {"ed": "edition"})
[{'edition': 1, 'isbn': 1}, {'edition': 2, 'isbn': 2}]
>>> alias({"a": 1}, {"a": "b"})
... | 7.176312 | 10.953618 | 0.655155 |
n = to_int(n)
if is_list(thing) or is_tuple(thing):
if len(thing) == 0:
return None
if n > 0:
return thing[0:n]
return thing[0]
return thing | def first(thing, n=0) | get the first element of a list
>>> lst = [1, 2, 3, 4, 5]
>>> first(lst)
1
>>> first(lst, 3)
[1, 2, 3]
>>> first(lst, 10)
[1, 2, 3, 4, 5]
>>> first({"key": "value"})
{'key': 'value'}
>>> first(("a", "b", "c"))
'a'
>>> first... | 2.69312 | 4.345444 | 0.619757 |
stbs = []
try:
async with timeout(max_wait, loop=loop):
def responses_callback(notify):
_LOGGER.debug("Found: %s", notify.ip_address)
stbs.append(notify.ip_address)
mr_protocol = await install_mediaroom_protocol(responses_cal... | async def discover(ignore_list=[], max_wait=30, loop=None) | List STB in the network. | 5.148208 | 4.43874 | 1.159835 |
_LOGGER.info("Send cmd = %s", cmd)
if cmd not in COMMANDS and cmd not in range(0, 999):
_LOGGER.error("Unknown command")
raise PyMediaroomError("Unknown commands")
keys = []
if cmd in range(0, 999):
for character in str(cmd):
... | async def send_cmd(self, cmd, loop=None) | Send remote command to STB. | 2.928391 | 2.827302 | 1.035754 |
_LOGGER.debug("turn_on while %s", self._state)
if self._state in [State.STANDBY, State.OFF, State.UNKNOWN]:
await self.send_cmd('Power')
self._state = State.PLAYING_LIVE_TV
return self._state | async def turn_on(self) | Turn off media player. | 5.717238 | 5.036129 | 1.135245 |
_LOGGER.debug("turn_off while %s", self._state)
if self._state in [State.PLAYING_LIVE_TV, State.PLAYING_RECORDED_TV,
State.PLAYING_TIMESHIFT_TV, State.UNKNOWN]:
await self.send_cmd('Power')
self._state = State.OFF
return self._state | async def turn_off(self) | Turn off media player. | 5.22882 | 4.645442 | 1.125581 |
_LOGGER.debug(notify)
if notify.ip_address != self.stb_ip:
return
if notify.tune:
self._state = State.PLAYING_LIVE_TV
self.tune_src = notify.tune['@src']
try:
if notify.stopped:
self._state = State.STO... | def notify_callback(self, notify) | Process State from NOTIFY message. | 4.729974 | 4.675038 | 1.011751 |
if not hasattr(self, 'queue'):
raise RuntimeError("Audio queue is not intialized.")
chunk = None
channel = None
self.keep_listening = True
while self.keep_listening:
if chunk is None:
try:
frame = self.queue.get(timeout=queue_timeout)
chunk = pygame.sndarray.make_sound(frame)
excep... | def run(self) | Main thread function. | 3.135283 | 3.033138 | 1.033676 |
assert isinstance(A, cspmatrix) and A.is_factor is False, "A must be a cspmatrix"
tol = kwargs.get('tol',1e-15)
X = matrix(A.spmatrix(reordered = True, symmetric = True))
symb = A.symb
n = symb.n
snptr = symb.snptr
sncolptr = symb.sncolptr
snrowidx = symb.snrowidx
# visit... | def edmcompletion(A, reordered = True, **kwargs) | Euclidean distance matrix completion. The routine takes an EDM-completable
cspmatrix :math:`A` and returns a dense EDM :math:`X`
that satisfies
.. math::
P( X ) = A
:param A: :py:class:`cspmatrix`
:param reordered: boolean | 3.248158 | 3.285489 | 0.988638 |
logger.info("Catalog query={}".format(query))
# Support to set the catalog as a request parameter
catalogs = _.to_list(req.get("catalog", None))
if catalogs:
return senaiteapi.search(query, catalog=catalogs)
# Delegate to the search API of Bika LIMS
... | def search(self, query) | search the catalog | 13.202157 | 12.51625 | 1.054801 |
catalog = self.get_catalog()
index = catalog._catalog.getIndex(name)
logger.debug("get_index={} of catalog '{}' --> {}".format(
name, catalog.__name__, index))
return index | def get_index(self, name) | get an index by name
TODO: Combine indexes of relevant catalogs depending on the portal_type
which is searched for. | 7.785637 | 6.774516 | 1.149254 |
# ZPublisher records can be passed to the catalog as is.
if isinstance(value, HTTPRequest.record):
return value
if isinstance(index, basestring):
index = self.get_index(index)
if index.id == "portal_type":
return filter(lambda x: x, _.to_li... | def to_index_value(self, value, index) | Convert the value for a given index | 5.924089 | 5.882784 | 1.007021 |
query = kw.pop("query", {})
query.update(self.get_request_query())
query.update(self.get_custom_query())
query.update(self.get_keyword_query(**kw))
sort_on, sort_order = self.get_sort_spec()
if sort_on and "sort_on" not in query:
query.update({"sort... | def make_query(self, **kw) | create a query suitable for the catalog | 2.933369 | 2.798028 | 1.04837 |
query = {}
# only known indexes get observed
indexes = self.catalog.get_indexes()
for index in indexes:
# Check if the request contains a parameter named like the index
value = req.get(index)
# No value found, continue
if value i... | def get_request_query(self) | Checks the request for known catalog indexes and converts the values
to fit the type of the catalog index.
:param catalog: The catalog to build the query for
:type catalog: ZCatalog
:returns: Catalog query
:rtype: dict | 5.163697 | 4.599857 | 1.122578 |
query = {}
# searchable text queries
q = req.get_query()
if q:
query["SearchableText"] = q
# physical path queries
path = req.get_path()
if path:
query["path"] = {'query': path, 'depth': req.get_depth()}
# special handli... | def get_custom_query(self) | Extracts custom query keys from the index.
Parameters which get extracted from the request:
`q`: Passes the value to the `SearchableText`
`path`: Creates a path query
`recent_created`: Creates a date query
`recent_modified`: Creates a date query
:param ... | 3.432656 | 2.634149 | 1.303137 |
query = dict()
# Only known indexes get observed
indexes = self.catalog.get_indexes()
# Handle additional keyword parameters
for k, v in kw.iteritems():
# handle uid in keywords
if k.lower() == "uid":
k = "UID"
# hand... | def get_keyword_query(self, **kw) | Generates a query from the given keywords.
Only known indexes make it into the generated query.
:returns: Catalog query
:rtype: dict | 4.256279 | 3.989866 | 1.066772 |
all_indexes = self.catalog.get_indexes()
si = req.get_sort_on(allowed_indexes=all_indexes)
so = req.get_sort_order()
return si, so | def get_sort_spec(self) | Build sort specification | 8.425052 | 7.531644 | 1.118621 |
r
if trans=='N':
cp.trsm(self._L0,B)
pftrsm(self._V,self._L,self._B,B,trans='N')
elif trans=='T':
pftrsm(self._V,self._L,self._B,B,trans='T')
cp.trsm(self._L0,B,trans='T')
elif type(trans) is str:
raise ValueError("tran... | def trsm(self,B,trans='N') | r"""
Solves a triangular system of equations with multiple righthand
sides. Computes
.. math::
B &:= L^{-1} B \text{ if trans is 'N'}
B &:= L^{-T} B \text{ if trans is 'T'} | 3.289212 | 3.396036 | 0.968544 |
r
if trans=='N':
pftrmm(self._V,self._L,self._B,B,trans='N')
cp.trmm(self._L0,B)
elif trans=='T':
cp.trmm(self._L0,B,trans='T')
pftrmm(self._V,self._L,self._B,B,trans='T')
elif type(trans) is str:
raise Valu... | def trmm(self,B,trans='N') | r"""
Multiplication with product-form Cholesky factor. Computes
.. math::
B &:= L B \text{ if trans is 'N'}
B &:= L^T B \text{ if trans is 'T'} | 3.436434 | 3.46021 | 0.993129 |
s = session()
return s.request(
method=method,
url=url,
params=params,
data=data,
headers=headers,
cookies=cookies,
files=files,
auth=auth,
timeout=timeout,
allow_redirects=allow_redirects,
proxies=proxies,
hoo... | def request(method, url,
params=None,
data=None,
headers=None,
cookies=None,
files=None,
auth=None,
timeout=None,
allow_redirects=False,
proxies=None,
hooks=None,
return_response=True,
prefetch=False,
config=None) | Constructs and sends a :class:`Request <Request>`.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Re... | 1.498751 | 1.808039 | 0.828937 |
rl_canvas.setPageSize(papersize_tuple)
layout.render(
Rectangle(0, 0, *papersize_tuple),
dict(output=ReportlabOutput(rl_canvas))
) | def render_to_reportlab_canvas(rl_canvas, papersize_tuple, layout) | Renders the given layout manager on a page of the given canvas. | 6.296303 | 6.443626 | 0.977137 |
c = Canvas(output_filename, papersize_tuple)
render_to_reportlab_canvas(c, papersize_tuple, layout)
c.save() | def render_to_reportlab_document(output_filename, papersize_tuple, layout) | Create and save a document with contents of the given layout manager. | 2.784798 | 3.026364 | 0.92018 |
c = self.c
c.saveState()
if stroke is not None:
c.setStrokeColorRGB(*stroke)
c.setLineWidth(stroke_width)
c.setDash(stroke_dash)
if fill is not None:
c.setFillColorRGB(*fill)
p = c.beginPath()
fn = p.moveTo
... | def draw_polygon(
self,
*pts,
close_path=True,
stroke=None,
stroke_width=1,
stroke_dash=None,
fill=None
) -> None | Draws the given polygon. | 2.396322 | 2.307034 | 1.038703 |
username = str(username)
password = str(password)
auth_s = b64encode('%s:%s' % (username, password))
r.headers['Authorization'] = ('Basic %s' % auth_s)
return r | def http_basic(r, username, password) | Attaches HTTP Basic Authentication to the given Request object.
Arguments should be considered non-positional. | 2.86043 | 3.22496 | 0.886966 |
def handle_401(r):
s_auth = r.headers.get('www-authenticate', '')
if 'digest' in s_auth.lower():
last_nonce = ''
nonce_count = 0
chal = parse_dict_header(s_auth.replace('Digest ', ''))
realm = chal['realm']
nonce = chal[... | def http_digest(r, username, password) | Attaches HTTP Digest Authentication to the given Request object.
Arguments should be considered non-positional. | 2.724371 | 2.75903 | 0.987438 |
if not t:
return t
else:
t = list(t)
# Make sure they're passing in something.
assert len(t) >= 2
# If only two items are passed in, assume HTTPBasic.
if (len(t) == 2):
t.insert(0, 'basic')
# Allow built-in string referenced auths.
if isinstance(t[0], bas... | def dispatch(t) | Given an auth tuple, return an expanded version. | 5.127666 | 4.467319 | 1.147817 |
# We have a UID, return the record
if uid and not resource:
return api.get_record(uid)
# we have a UID as resource, return the record
if api.is_uid(resource):
return api.get_record(resource)
portal_type = api.resource_to_portal_type(resource)
if portal_type is None:
... | def get(context, request, resource=None, uid=None) | GET | 5.638021 | 5.53862 | 1.017947 |
# allow to set the method via the header
if action is None:
action = request.get_header("HTTP_X_HTTP_METHOD_OVERRIDE", "CREATE").lower()
# Fetch and call the action function of the API
func_name = "{}_items".format(action)
action_func = getattr(api, func_name, None)
if action_func... | def action(context, request, action=None, resource=None, uid=None) | Various HTTP POST actions | 5.166821 | 5.105956 | 1.01192 |
remove_from_help = ["not-in-help", "copyright"]
if sys.platform in ["win32", "cygwin"]:
remove_from_help.extend(["osx", "linux"])
elif sys.platform == "darwin":
remove_from_help.extend(["linux", "windows", "linux-windows"])
else:
remove_from_help.extend(["osx", "windows"])
... | def build_help_html() | Build the help HTML using the shared resources. | 5.273819 | 5.246715 | 1.005166 |
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
dialog_box = wx.Dialog(None, wx.ID_ANY, HELP_TITLE,
style=style, size=(620, 450))
html_widget = HtmlHelp(dialog_box, wx.ID_ANY)
html_widget.page = build_help_html()
dialog_box.ShowModal()
dialog_box.Destroy() | def help_box() | A simple HTML help dialog box using the distribution data files. | 3.448576 | 3.294894 | 1.046642 |
if not self.keep_listening:
raise sd.CallbackStop
try:
chunk = self.queue.get_nowait()
# Check if the chunk contains the expected number of frames
# The callback function raises a ValueError otherwise.
if chunk.shape[0] == frames:
outdata[:] = chunk
else:
outdata.fill(0)
except Em... | def get_frame(self, outdata, frames, timedata, status) | Callback function for the audio stream. Don't use directly. | 4.350501 | 4.231282 | 1.028176 |
self.keep_listening = False
self.stream.stop()
self.stream.close() | def close_stream(self) | Closes the stream. Performs cleanup. | 4.600568 | 4.243839 | 1.084058 |
return Point(self.x * other.x, self.y * other.y) | def get_component_product(self, other) | Returns the component product of this vector and the given
other vector. | 4.232146 | 3.821228 | 1.107535 |
magnitude = self.get_magnitude()
if magnitude > 0:
magnitude = 1.0 / magnitude
return Point(self.x * magnitude, self.y * magnitude)
else:
return self | def get_normalized(self) | Returns a vector of unit length, unless it is the zero
vector, in which case it is left as is. | 2.966325 | 2.656522 | 1.11662 |
ca = math.cos(angle)
sa = math.sin(angle)
return Point(self.x*ca-self.y*sa, self.x*sa+self.y*ca) | def get_rotated(self, angle) | Rotates this vector through the given anti-clockwise angle
in radians. | 2.121423 | 2.088173 | 1.015923 |
return math.sqrt(self.x*self.x + self.y*self.y) | def get_magnitude(self) | Returns the magnitude of this vector. | 3.077782 | 2.214059 | 1.390108 |
return self.x*self.x + self.y*self.y | def get_magnitude_squared(self) | Returns the square of the magnitude of this vector. | 3.998942 | 2.511132 | 1.592486 |
return self.x*other.x+self.y*other.y | def get_scalar_product(self, other) | Returns the scalar product of this vector with the given
other vector. | 4.02387 | 3.651681 | 1.101922 |
# The scalar product is the sum of the squares of the
# magnitude times the cosine of the angle - so normalizing the
# vectors first means the scalar product is just the cosine of
# the angle.
normself = self.get_normalized()
normother = other.get_normalized()
... | def get_angle_between(self, other) | Returns the smallest angle between this vector and the
given other vector. | 5.318531 | 4.949074 | 1.074652 |
return Point(min(self.x, other.x), min(self.y, other.y)) | def get_minimum(self, other) | Updates this vector so its components are the lower of its
current components and those of the given other value. | 2.739335 | 3.118402 | 0.878442 |
return Point(max(self.x, other.x), max(self.y, other.y)) | def get_maximum(self, other) | Updates this vector so its components are the higher of its
current components and those of the given other value. | 2.839397 | 3.181056 | 0.892596 |
result = Point(random.random(), random.random())
return result.get_component_product(max_pt - min_pt) + min_pt | def get_random(min_pt, max_pt) | Returns a random vector in the given range. | 6.381646 | 4.993463 | 1.278 |
return self.x, self.y, self.w, self.h | def get_data(self) | Returns the x, y, w, h, data as a tuple. | 6.373828 | 2.138406 | 2.980644 |
dirlist = []
# First, try the environment.
for envname in 'TMPDIR', 'TEMP', 'TMP':
dirname = _os.getenv(envname)
if dirname: dirlist.append(dirname)
# Failing that, try OS-specific locations.
if _os.name == 'nt':
dirlist.extend([ r'c:\temp', r'c:\tmp', r'\temp', r'\tm... | def _candidate_tempdir_list() | Generate a list of candidate temporary directories which
_get_default_tempdir will try. | 2.766217 | 2.613566 | 1.058407 |
namer = _RandomNameSequence()
dirlist = _candidate_tempdir_list()
for dir in dirlist:
if dir != _os.curdir:
dir = _os.path.abspath(dir)
# Try only a few names per directory.
for seq in range(100):
name = next(namer)
filename = _os.path.join(... | def _get_default_tempdir() | Calculate the default directory to use for temporary files.
This routine should be called exactly once.
We determine whether or not a candidate temp dir is usable by
trying to create and write to a file in that directory. If this
is successful, the test file is deleted. To prevent denial of
servi... | 3.55378 | 3.299935 | 1.076924 |
global _name_sequence
if _name_sequence is None:
_once_lock.acquire()
try:
if _name_sequence is None:
_name_sequence = _RandomNameSequence()
finally:
_once_lock.release()
return _name_sequence | def _get_candidate_names() | Common setup sequence for all user-callable interfaces. | 3.290388 | 2.691948 | 1.222307 |
names = _get_candidate_names()
for seq in range(TMP_MAX):
name = next(names)
file = _os.path.join(dir, pre + name + suf)
try:
fd = _os.open(file, flags, 0o600)
return (fd, _os.path.abspath(file))
except FileExistsError:
continue # try... | def _mkstemp_inner(dir, pre, suf, flags) | Code common to mkstemp, TemporaryFile, and NamedTemporaryFile. | 3.757555 | 3.412702 | 1.10105 |
global tempdir
if tempdir is None:
_once_lock.acquire()
try:
if tempdir is None:
tempdir = _get_default_tempdir()
finally:
_once_lock.release()
return tempdir | def gettempdir() | Accessor for tempfile.tempdir. | 2.967255 | 2.82643 | 1.049824 |
if dir is None:
dir = gettempdir()
if text:
flags = _text_openflags
else:
flags = _bin_openflags
return _mkstemp_inner(dir, prefix, suffix, flags) | def mkstemp(suffix="", prefix=template, dir=None, text=False) | User-callable function to create and return a unique temporary
file. The return value is a pair (fd, name) where fd is the
file descriptor returned by os.open, and name is the filename.
If 'suffix' is specified, the file name will end with that suffix,
otherwise there will be no suffix.
If 'prefi... | 3.372221 | 3.687006 | 0.914623 |
if dir is None:
dir = gettempdir()
names = _get_candidate_names()
for seq in range(TMP_MAX):
name = next(names)
file = _os.path.join(dir, prefix + name + suffix)
try:
_os.mkdir(file, 0o700)
return file
except FileExistsError:
... | def mkdtemp(suffix="", prefix=template, dir=None) | User-callable function to create and return a unique temporary
directory. The return value is the pathname of the directory.
Arguments are as for mkstemp, except that the 'text' argument is
not accepted.
The directory is readable, writable, and searchable only by the
creating user.
Caller is... | 3.537007 | 3.554128 | 0.995183 |
if dir is None:
dir = gettempdir()
flags = _bin_openflags
# Setting O_TEMPORARY in the flags causes the OS to delete
# the file when it is closed. This is only supported by Windows.
if _os.name == 'nt' and delete:
flags |= _os.O_TEMPORARY
(fd, name) = _mkstemp_inner(dir... | def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
newline=None, suffix="", prefix=template,
dir=None, delete=True) | Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
'mode' -- the mode argument to io.open (default "w+b").
'buffering' -- the buffer size argument to io.open (default -1).
'encoding' -- the encoding argument to io.open (default None)
'newline' -- the newl... | 3.491672 | 3.704608 | 0.942521 |
pool_key = (scheme, host, port)
# If the scheme, host, or port doesn't match existing open connections,
# open a new ConnectionPool.
pool = self.pools.get(pool_key)
if pool:
return pool
# Make a fresh ConnectionPool of the desired type
pool_... | def connection_from_host(self, host, port=80, scheme='http') | Get a :class:`ConnectionPool` based on the host, port, and scheme.
Note that an appropriate ``port`` value is required here to normalize
connection pools in our container most effectively. | 3.564025 | 3.496933 | 1.019186 |
scheme, host, port = get_host(url)
port = port or port_by_scheme.get(scheme, 80)
return self.connection_from_host(host, port=port, scheme=scheme) | def connection_from_url(self, url) | Similar to :func:`urllib3.connectionpool.connection_from_url` but
doesn't pass any additional parameters to the
:class:`urllib3.connectionpool.ConnectionPool` constructor.
Additional parameters are taken from the :class:`.PoolManager`
constructor. | 4.113567 | 4.578787 | 0.898397 |
conn = self.connection_from_url(url)
return conn.urlopen(method, url, assert_same_host=False, **kw) | def urlopen(self, method, url, **kw) | Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`.
``url`` must be absolute, such that an appropriate
:class:`urllib3.connectionpool.ConnectionPool` can be chosen for it. | 4.161676 | 3.994353 | 1.04189 |
"Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
kw['assert_same_host'] = False
return self.proxy_pool.urlopen(method, url, **kw) | def urlopen(self, method, url, **kw) | Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute. | 7.307207 | 3.862104 | 1.892028 |
r
assert X.is_factor is False, "cspmatrix factor object"
symb = X.symb
n = symb.n
snptr = symb.snptr
snode = symb.snode
blkval = X.blkval
blkptr = symb.blkptr
relptr = symb.relptr
snrowidx = symb.snrowidx
sncolptr = symb.sncolptr
if symb.p is not None and reordered is Fa... | def syr2(X, u, v, alpha = 1.0, beta = 1.0, reordered=False) | r"""
Computes the projected rank 2 update of a cspmatrix X
.. math::
X := \alpha*P(u v^T + v u^T) + \beta X. | 4.131868 | 4.024609 | 1.026651 |
if func is None:
return None
self_arg = 1 if inspect.ismethod(func) else 0
if len(inspect.getargspec(func)[0]) == 5 + self_arg:
return func
if len(inspect.getargspec(func)[0]) == 4 + self_arg:
return lambda t, y, J, dfdt, fy=None: func(t, y, J, dfdt)
else:
raise... | def _ensure_5args(func) | Conditionally wrap function to ensure 5 input arguments
Parameters
----------
func: callable
with four or five positional arguments
Returns
-------
callable which possibly ignores 0 or 1 positional arguments | 3.304492 | 3.542111 | 0.932916 |
if mod_name is None:
frame = inspect.currentframe()
try:
mod_name = frame.f_back.f_locals['__name__']
finally:
del frame
orig_mod = sys.modules[mod_name]
lazy_mod = cls(orig_mod.__name__, orig_mod.__doc__, orig_mod)
... | def shadow_normal_module(cls, mod_name=None) | Shadow a module with an instance of LazyModule
:param mod_name:
Name of the module to shadow. By default this is the module that is
making the call into this method. This is not hard-coded as that
module might be called '__main__' if it is executed via 'python -m'
:r... | 2.109087 | 2.060157 | 1.023751 |
self._lazy[name] = callable, args
self._all.add(name) | def lazily(self, name, callable, args) | Load something lazily | 6.651662 | 6.423996 | 1.03544 |
setattr(self, name, value)
self._all.add(name) | def immediate(self, name, value) | Load something immediately | 6.678648 | 8.665123 | 0.770751 |
'''taobao.crm.group.add 卖家创建一个分组
卖家创建一个新的分组,接口返回一个创建成功的分组的id'''
request = TOPRequest('taobao.crm.group.add')
request['group_name'] = group_name
self.create(self.execute(request, session), fields=['is_success', 'group_id'])
return self.is_success, self.group_id | def add(self, group_name, session) | taobao.crm.group.add 卖家创建一个分组
卖家创建一个新的分组,接口返回一个创建成功的分组的id | 5.808246 | 3.09696 | 1.875467 |
'''taobao.crm.group.append 将一个分组添加到另外一个分组
将某分组下的所有会员添加到另一个分组,注
- 1.该操作为异步任务,建议先调用taobao.crm.grouptask.check 确保涉及分组上没有任务;
- 2.若分组下某会员分组数超最大限额,则该会员不会被添加到新分组,同时不影响其余会员添加分组,接口调用依然返回成功。'''
request = TOPRequest('taobao.crm.group.append')
request['from_group_id... | def append(self, from_group_id, to_group_id, session) | taobao.crm.group.append 将一个分组添加到另外一个分组
将某分组下的所有会员添加到另一个分组,注
- 1.该操作为异步任务,建议先调用taobao.crm.grouptask.check 确保涉及分组上没有任务;
- 2.若分组下某会员分组数超最大限额,则该会员不会被添加到新分组,同时不影响其余会员添加分组,接口调用依然返回成功。 | 7.745118 | 1.822626 | 4.249428 |
'''taobao.crm.group.delete 删除分组
将该分组下的所有会员移除出该组,同时删除该分组。注:删除分组为异步任务,必须先调用taobao.crm.grouptask.check 确保涉及属性上没有任务。'''
request = TOPRequest('taobao.crm.group.delete')
request['group_id'] = group_id
self.create(self.execute(request, session), fields=['is_success',])
... | def delete(self, group_id, session) | taobao.crm.group.delete 删除分组
将该分组下的所有会员移除出该组,同时删除该分组。注:删除分组为异步任务,必须先调用taobao.crm.grouptask.check 确保涉及属性上没有任务。 | 9.879404 | 2.620888 | 3.769488 |
'''taobao.crm.group.update 修改一个已经存在的分组
修改一个已经存在的分组,接口返回分组的修改是否成功'''
request = TOPRequest('taobao.crm.group.update')
request['group_id'] = group_id
request['new_group_name'] = new_group_name
self.create(self.execute(request, session), fields=['is_success',])
... | def update(self, group_id, new_group_name, session) | taobao.crm.group.update 修改一个已经存在的分组
修改一个已经存在的分组,接口返回分组的修改是否成功 | 4.961798 | 2.624762 | 1.890381 |
'''taobao.crm.groups.get 查询卖家的分组
查询卖家的分组,返回查询到的分组列表,分页返回分组'''
request = TOPRequest('taobao.crm.groups.get')
request['page_size'] = page_size
request['current_page'] = current_page
self.create(self.execute(request, session))
return self.groups | def get(self, page_size, current_page, session) | taobao.crm.groups.get 查询卖家的分组
查询卖家的分组,返回查询到的分组列表,分页返回分组 | 5.613034 | 2.730241 | 2.055875 |
'''taobao.crm.grouptask.check 查询分组任务是否完成
检查一个分组上是否有异步任务,异步任务包括
- 1.将一个分组下的所有用户添加到另外一个分组
- 2.将一个分组下的所有用户移动到另外一个分组
- 3.删除某个分组 若分组上有任务则该属性不能被操作。'''
request = TOPRequest('taobao.crm.grouptask.check')
request['group_id'] = group_id
self.create... | def check(self, group_id, session) | taobao.crm.grouptask.check 查询分组任务是否完成
检查一个分组上是否有异步任务,异步任务包括
- 1.将一个分组下的所有用户添加到另外一个分组
- 2.将一个分组下的所有用户移动到另外一个分组
- 3.删除某个分组 若分组上有任务则该属性不能被操作。 | 7.611189 | 1.970707 | 3.862162 |
'''taobao.crm.memberinfo.update 编辑会员资料
检查一个分组上是否有异步任务,异步任务包括
- 1.将一个分组下的所有用户添加到另外一个分组
- 2.将一个分组下的所有用户移动到另外一个分组
- 3.删除某个分组 若分组上有任务则该属性不能被操作。'''
request = TOPRequest('taobao.crm.memberinfo.update')
request['buyer_nick'] = buyer_nick
request... | def update(self, buyer_nick, status, session, grade=None, province=None, city=None) | taobao.crm.memberinfo.update 编辑会员资料
检查一个分组上是否有异步任务,异步任务包括
- 1.将一个分组下的所有用户添加到另外一个分组
- 2.将一个分组下的所有用户移动到另外一个分组
- 3.删除某个分组 若分组上有任务则该属性不能被操作。 | 5.541966 | 1.788272 | 3.099062 |
'''taobao.crm.members.group.batchadd 给一批会员添加一个分组
为一批会员添加分组,接口返回添加是否成功,如至少有一个会员的分组添加成功,接口就返回成功,否则返回失败,如果当前会员已经拥有当前分组,则直接跳过'''
request = TOPRequest('taobao.crm.members.group.batchadd')
request['buyer_ids'] = buyer_ids
request['group_ids'] = group_ids
self.create(se... | def group_batchadd(self, buyer_ids, group_ids, session) | taobao.crm.members.group.batchadd 给一批会员添加一个分组
为一批会员添加分组,接口返回添加是否成功,如至少有一个会员的分组添加成功,接口就返回成功,否则返回失败,如果当前会员已经拥有当前分组,则直接跳过 | 5.844044 | 2.10816 | 2.772107 |
'''taobao.crm.members.increment.get 增量获取卖家会员)
增量获取会员列表,接口返回符合查询条件的所有会员。任何状态更改都会返回'''
request = TOPRequest('taobao.crm.members.increment.get')
request['current_page'] = current_page
for k, v in kwargs.iteritems():
if k not in ('grade', 'start_modify', 'end_mod... | def increment_get(self, current_page, session, **kwargs) | taobao.crm.members.increment.get 增量获取卖家会员)
增量获取会员列表,接口返回符合查询条件的所有会员。任何状态更改都会返回 | 6.556278 | 3.296909 | 1.988614 |
'''taobao.crm.members.search 获取卖家会员(高级查询))
会员列表的高级查询,接口返回符合条件的会员列表'''
request = TOPRequest('taobao.crm.members.search')
request['current_page'] = current_page
for k, v in kwargs.iteritems():
if k not in ('buyer_nick', 'grade', 'min_trade_amount', 'max_trade_a... | def search(self, current_page, session, **kwargs) | taobao.crm.members.search 获取卖家会员(高级查询))
会员列表的高级查询,接口返回符合条件的会员列表 | 5.187948 | 3.74825 | 1.384099 |
'''taobao.crm.rule.add 分组规则添加
添加分组规则,规则可用于筛选一定条件的会员。过滤条件可以选择客户来源、会员级别 、交易笔数、交易额、上次交易时间、平均客单价、宝贝件数、省份、关闭交易数等,新建规则时必须至少选择一个以上筛选条件。如果输入的规则的筛选条件不正确则不会进行处理,可以将某些分组挂在这个规则下,对被挂在该规则下的分组,系统对现有满足规则的客户都划分到这个分组(异步任务),若某些会员分组数或规则数超最大限额,则该会员不被操作,同时不影响其余会员操作,接口调用依然返回成功。每个规则可以应用到多个分组,一个用户的规则上限为5个。'''
r... | def add(self, rule_name, session, **kwargs) | taobao.crm.rule.add 分组规则添加
添加分组规则,规则可用于筛选一定条件的会员。过滤条件可以选择客户来源、会员级别 、交易笔数、交易额、上次交易时间、平均客单价、宝贝件数、省份、关闭交易数等,新建规则时必须至少选择一个以上筛选条件。如果输入的规则的筛选条件不正确则不会进行处理,可以将某些分组挂在这个规则下,对被挂在该规则下的分组,系统对现有满足规则的客户都划分到这个分组(异步任务),若某些会员分组数或规则数超最大限额,则该会员不被操作,同时不影响其余会员操作,接口调用依然返回成功。每个规则可以应用到多个分组,一个用户的规则上限为5个。 | 8.644853 | 2.053695 | 4.209414 |
'''taobao.crm.rule.delete 分组规则删除
分组规则删除'''
request = TOPRequest('taobao.crm.rule.delete')
request['rule_id'] = rule_id
self.create(self.execute(request, session))
return self.is_success | def delete(self, rule_id, session) | taobao.crm.rule.delete 分组规则删除
分组规则删除 | 7.360338 | 3.581153 | 2.055298 |
'''taobao.crm.rule.group.set 设置规则适用的分组
将规则应用或取消应用到分组上,add_groups和delete_groups,两个参数最少填写一个。'''
request = TOPRequest('taobao.crm.rule.delete')
request['rule_id'] = rule_id
if add_groups!=None: request['add_groups'] = add_groups
if delete_groups!=None: request['dele... | def group_set(self, rule_id, session, add_groups=None, delete_groups=None) | taobao.crm.rule.group.set 设置规则适用的分组
将规则应用或取消应用到分组上,add_groups和delete_groups,两个参数最少填写一个。 | 5.049732 | 2.635967 | 1.915704 |
'''taobao.crm.shopvip.cancel 卖家取消店铺vip的优惠
此接口用于取消VIP优惠'''
request = TOPRequest('taobao.crm.shopvip.cancel')
self.create(self.execute(request, session))
return self.is_success | def cancel(self, session) | taobao.crm.shopvip.cancel 卖家取消店铺vip的优惠
此接口用于取消VIP优惠 | 11.666309 | 4.037109 | 2.889768 |
'''taobao.shopcats.list.get 获取前台展示的店铺类目
此API获取淘宝面向买家的浏览导航类目 跟后台卖家商品管理的类目有差异'''
request = TOPRequest('taobao.shopcats.list.get')
if not fields:
shopCat = ShopCat()
fields = shopCat.fields
request['fields'] = fields
self.create(self.execute(... | def get(self, fields=[]) | taobao.shopcats.list.get 获取前台展示的店铺类目
此API获取淘宝面向买家的浏览导航类目 跟后台卖家商品管理的类目有差异 | 10.946692 | 2.934368 | 3.730512 |
'''taobao.sellercats.list.add 添加卖家自定义类目
此API添加卖家店铺内自定义类目 父类目parent_cid值等于0:表示此类目为店铺下的一级类目,值不等于0:表示此类目有父类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布'''
request = TOPRequest('taobao.sellercats.list.add')
request['name'] = name
if pict_url!=None: request['pict_url'... | def add(self, name, session, pict_url=None, parent_cid=None, sort_order=None) | taobao.sellercats.list.add 添加卖家自定义类目
此API添加卖家店铺内自定义类目 父类目parent_cid值等于0:表示此类目为店铺下的一级类目,值不等于0:表示此类目有父类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布 | 6.411474 | 1.678002 | 3.820897 |
'''taobao.sellercats.list.update 更新卖家自定义类目
此API更新卖家店铺内自定义类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布'''
request = TOPRequest('taobao.sellercats.list.update')
request['cid'] = cid
if name!=None: request['name'] = name
if pict_url!=None: request['pict_url... | def update(self, cid, session, name=None, pict_url=None, sort_order=None) | taobao.sellercats.list.update 更新卖家自定义类目
此API更新卖家店铺内自定义类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布 | 6.59305 | 1.924461 | 3.425921 |
'''taobao.sellercats.list.get 获取前台展示的店铺内卖家自定义商品类目
此API添加卖家店铺内自定义类目 父类目parent_cid值等于0:表示此类目为店铺下的一级类目,值不等于0:表示此类目有父类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布'''
request = TOPRequest('taobao.sellercats.list.get')
request['nick'] = nick
self.create(self.execute(re... | def get(self, nick) | taobao.sellercats.list.get 获取前台展示的店铺内卖家自定义商品类目
此API添加卖家店铺内自定义类目 父类目parent_cid值等于0:表示此类目为店铺下的一级类目,值不等于0:表示此类目有父类目 注:因为缓存的关系,添加的新类目需8个小时后才可以在淘宝页面上正常显示,但是不影响在该类目下商品发布 | 15.375032 | 1.843311 | 8.340987 |
'''taobao.shop.remainshowcase.get 获取卖家店铺剩余橱窗数量
获取卖家店铺剩余橱窗数量,已用橱窗数量,总橱窗数量(对于B卖家,后两个参数返回-1)'''
request = TOPRequest('taobao.shop.remainshowcase.get')
self.create(self.execute(request, session)['shop'])
return self | def remainshowcase_get(self, session) | taobao.shop.remainshowcase.get 获取卖家店铺剩余橱窗数量
获取卖家店铺剩余橱窗数量,已用橱窗数量,总橱窗数量(对于B卖家,后两个参数返回-1) | 7.917812 | 2.735507 | 2.894459 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.