code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
'''taobao.shop.remainshowcase.get 获取卖家店铺剩余橱窗数量
目前只支持标题、公告和描述的更新'''
request = TOPRequest('taobao.shop.remainshowcase.get')
if title!=None: request['title'] = title
if bulletin!=None: request['bulletin'] = bulletin
if desc!=None: request['desc'] = desc
self... | def update(self, session, title=None, bulletin=None, desc=None) | taobao.shop.remainshowcase.get 获取卖家店铺剩余橱窗数量
目前只支持标题、公告和描述的更新 | 6.172107 | 2.545021 | 2.42517 |
if not hasattr(self, 'queue'):
raise RuntimeError("Audio queue is not intialized.")
self.keep_listening = True
self.stream.start()
while self.keep_listening:
try:
chunk = self.queue.get(timeout=queue_timeout)
underflowed = self.stream.write(chunk)
if underflowed:
logger.debug("Buffe... | def run(self) | Initializes the stream. | 3.573264 | 3.338265 | 1.070396 |
size, unit = _split_dimension(text)
factor = _unit_lookup[unit]
return size*factor | def parse_dimension(text) | Parses the given text into one dimension and returns its
equivalent size in points.
The numbers provided can be integer or decimal, but exponents are
not supported.
The units may be inches (", in, ins, inch, inchs, inches),
millimeters (mm), points (pt, pts, point, points, or nothing), or
cent... | 7.004445 | 10.977849 | 0.638053 |
components = _dimension_separator.split(text)
if len(components) == 0:
raise DimensionError("No dimensions found in string.")
# Split each component into size and units
pairs = []
units = 0
for component in components:
value, unit = _split_dimension(component)
pairs... | def parse_dimensions(text) | Parses a set of dimensions into tuple of values representing the
sizes in points.
The dimensions that this method supports are exactly as for
parse_dimension. It supports multiple dimensions, separated by
whitespace, comma, semicolon, hyphen, or the letter x. The units
may follow each dimension (in... | 3.27595 | 3.244244 | 1.009773 |
match = _dimension_finder.match(text)
if not match:
raise DimensionError("Can't parse dimension '%s'." % text)
number = match.group(1)
unit = match.group(4)
if '.' in number:
return (float(number), unit)
else:
return (int(number), unit) | def _split_dimension(text) | Returns the number and unit from the given piece of text as a pair.
>>> _split_dimension('1pt')
(1, 'pt')
>>> _split_dimension('1 pt')
(1, 'pt')
>>> _split_dimension('1 \tpt')
(1, 'pt')
>>> _split_dimension('1 \tpt ')
(1, 'pt')
>>> _split_dimension(' 1 \tpt ')
(1, 'pt')
... | 2.730289 | 3.138986 | 0.869799 |
body = StringIO()
if boundary is None:
boundary = mimetools.choose_boundary()
for fieldname, value in fields.iteritems():
body.write('--%s\r\n' % (boundary))
if isinstance(value, tuple):
filename, data = value
writer(body).write('Content-Disposition: fo... | def encode_multipart_formdata(fields, boundary=None) | Encode a dictionary of ``fields`` using the multipart/form-data mime format.
:param fields:
Dictionary of fields. The key is treated as the field name, and the
value as the body of the form-data. If the value is a tuple of two
elements, then the first element is treated as the filename of t... | 1.689317 | 1.78023 | 0.948932 |
ignores = set(ignores or [])
ignores.add(ErrorType.Ok)
if error_type not in ignores:
raise LibError(error_type) | def maybe_raise(cls, error_type, ignores=None) | Raise an :exc:`LibError` unless the ``error_type`` is
:attr:`ErrorType.OK` or in the ``ignores`` list of error types.
Internal method. | 6.284125 | 5.433898 | 1.156467 |
if not isinstance(value, Queue):
raise TypeError("queue is not a Queue object")
self._queue = value | def queue(self, value) | Sets the audioqueue.
Parameters
----------
value : queue.Queue
The buffer from which audioframes are received. | 3.76897 | 5.150064 | 0.73183 |
size = self.element.get_minimum_size(data)
return datatypes.Point(
max(size.x, self.min_width),
max(size.y, self.min_height)
) | def get_minimum_size(self, data) | Returns the minimum size of the managed element, as long as
it is larger than any manually set minima. | 3.601973 | 3.57269 | 1.008196 |
# We can't use our get minimum size, because that enforces
# the size limits.
size = self.element.get_minimum_size(data)
# Assume we're bottom left at our natural size.
x = rect.x
y = rect.y
w = size.x
h = size.y
extra_width = rect.w - w... | def render(self, rect, data) | Draws the managed element in the correct alignment. | 2.881832 | 2.722424 | 1.058554 |
H = nx.Graph()
for i in H.nodes_iter():
H.node[i] = {}
return H | def create_copy_without_data(G) | Return a copy of the graph G with all the data removed | 4.623872 | 4.217207 | 1.09643 |
filename = os.path.normcase(filename)
dir_path = os.path.dirname(filename)
if not os.path.exists(dir_path): os.makedirs(dir_path)
with open(filename, 'wb') as f:
p = pickle.Pickler(f, protocol=protocol)
p.dump(stuff)
if verbose:
print('Written {} items to pickled binary ... | def dump(stuff, filename, verbose=True, protocol=3) | Store an object to file by pickling
Parameters
----------
stuff : object to be pickled
filename : path
verbose : bool
protocol : 1,2,3 (default = 3)
Protocol used by Pickler, higher number means more recent version of Python is needed to read the pickle
produced. Default is prot... | 2.283191 | 2.736048 | 0.834485 |
filename = os.path.normcase(filename)
try:
with open(filename, 'rb') as f:
u = pickle.Unpickler(f)
return u.load()
except IOError:
raise LogOpeningError('No file found for %s' % filename, filename) | def load(filename) | Retrieve a pickled object
Parameter
---------
filename : path
Return
------
object
Unpickled object | 3.615259 | 4.816829 | 0.750547 |
if ':' in address:
host, port = address.split(':', 1)
port = int(port)
elif re.match('^\d+$', address):
host = default[0]
port = int(address)
else:
host = address
port = default[1]
return host, port | def parse_bind_address(address, default=('localhost', 8080)) | >>> parse_bind_address('80')
('localhost', 80)
>>> parse_bind_address('0.0.0.0')
('0.0.0.0', 8080)
>>> parse_bind_address('0.0.0.0:8081')
('0.0.0.0', 8081) | 1.875066 | 2.010876 | 0.932462 |
doc = etree.fromstring(envelope)
body = get_body(doc)
queue = SignQueue()
queue.push_and_mark(body)
security_node = ensure_security_header(doc, queue)
security_token_node = create_binary_security_token(key_file)
signature_node = Signature(
xmlsec.TransformExclC14N, xmlsec.Tran... | def sign_envelope(envelope, key_file) | Sign the given soap request with the given key | 4.335439 | 4.153308 | 1.043852 |
doc = etree.fromstring(reply)
node = doc.find(".//{%s}Signature" % xmlsec.DSigNs)
if node is None:
raise CertificationError("No signature node found")
dsigCtx = xmlsec.DSigCtx()
xmlsec.addIDs(doc, ['Id'])
signKey = xmlsec.Key.load(key_file, xmlsec.KeyDataFormatPem)
signKey.name... | def verify_envelope(reply, key_file) | Verify that the given soap request is signed with the certificate | 3.905608 | 3.903812 | 1.00046 |
key_info = etree.Element(ns_id('KeyInfo', ns.dsns))
sec_token_ref = etree.SubElement(
key_info, ns_id('SecurityTokenReference', ns.wssens))
sec_token_ref.set(
ns_id('TokenType', ns.wssens), security_token.get('ValueType'))
reference = etree.SubElement(sec_token_ref, ns_id('Referen... | def create_key_info_node(security_token) | Create the KeyInfo node for WSSE.
Note that this currently only supports BinarySecurityTokens
Example of the generated XML:
<ds:KeyInfo Id="KI-24C56C5B3448F4BE9D141094243396829">
<wsse:SecurityTokenReference
wsse11:TokenType="{{ BINARY_TOKEN_TYPE }}">
<wsse... | 2.822022 | 2.618928 | 1.077549 |
node = etree.Element(
ns_id('BinarySecurityToken', ns.wssens),
nsmap={ns.wssens[0]: ns.wssens[1]})
node.set(ns_id('Id', ns.wsuns), get_unique_id())
node.set('EncodingType', ns.wssns[1] + 'Base64Binary')
node.set('ValueType', BINARY_TOKEN_TYPE)
with open(key_file) as fh:
... | def create_binary_security_token(key_file) | Create the BinarySecurityToken node containing the x509 certificate. | 3.627161 | 3.178564 | 1.141132 |
(header,) = HEADER_XPATH(envelope)
security = SECURITY_XPATH(header)
if security:
for timestamp in TIMESTAMP_XPATH(security[0]):
queue.push_and_mark(timestamp)
return security[0]
else:
nsmap = {
'wsu': ns.wsuns[1],
'wsse': ns.wssens[1],
... | def ensure_security_header(envelope, queue) | Insert a security XML node if it doesn't exist otherwise update it. | 6.662622 | 6.332791 | 1.052083 |
fin = open(filename, 'r')
line = fin.readline()
line2 = fin.readline()
fin.close()
temp = re.split('\s+', line)
temp2 = re.split('\s+', line2)
if temp[0] == '#Minor':
return groovesParameters
if temp[0] == '#Shift':
return baseStepParameters
if temp[0] == '#X... | def checkParametersInputFile(filename) | Check the do_x3dna output file and return list of parameters present in the file. | 4.491205 | 4.45083 | 1.009072 |
gotParameterList = False
param_type = None
# In case of none try to determine from file
if parameters is None:
parameters = checkParametersInputFile(filename)
if parameters is None:
raise AssertionError(" Cannot determine the parameters name from file {0}.".format(file... | def setParametersFromFile(dna, filename, parameters=None, bp=None) | Read a specific parameter from the do_x3dna output file.
It automatically load the input parameter from a file to dna object or HDF5 file.
It automatically decides from input parameter, what will be format of input file.
Parameters
----------
dna : :class:`DNA`
Input :class:`DNA` instance.
... | 3.216006 | 3.053373 | 1.053263 |
for i in range(sets):
if (len(time) != len(x[i])):
raise ValueError('\nError: number of frame in time {0} mismatched with {1} of x[{2}]!!\n' .format(
len(time), len(x[i]), i))
if not((err_type == 'block') or (err_type == 'acf')):
print('\nWarning: Method {0} is ... | def get_error(time, x, sets, err_type='block', tool='gmx analyze') | To estimate error using block averaging method
.. warning::
To calculate errors by using ``error = 'acf'`` or ``error = 'block'``,
GROMACS tool ``g_analyze`` or ``gmx analyze`` should be present in ``$PATH``.
Parameters
----------
time : 1D list or array
:attr:`DNA.time... | 2.749563 | 2.712765 | 1.013564 |
sys.stdout.write("\nReading file : %s\n" % FileName)
sys.stdout.flush()
def get_frame_data(block, parameters, bp_idx):
block = np.array(block).T
temp_data = (block[parameters, :])[:, bp_idx].copy()
return temp_data
def get_time(line):
dummy, temp_time = line.split... | def read_param_file(FileName, parameters, bp, bp_range, word=False, startBP=1) | Read parameters from do_x3dna file.
It is the main function, which is used to read and extract the parameters
values from the do_x3dna output files.
Parameters
----------
FileName : str
Parameter file produced from do_x3dna.
parameters : list
List of column indices that has to ... | 2.755246 | 2.621419 | 1.051051 |
x = np.asarray(x)
y = np.asarray(y)
angle = []
if multiple:
# Element-wise angle between arrays of vectors. Taken from following links
# http://codereview.stackexchange.com/questions/54347/calculating-element-wise-the-angles-between-two-lists-of-vectors
dot_x_y = np.einsum(... | def vector_angle(x, y, multiple=True, norm=None) | Calculate angle between two vector/s
Parameters
----------
x : 1D or 2D array
First vector or array of first vectors
y : 1D or 2D array
Second vector or array of second vectors
multiple : bool
If ``x`` and ``y`` are array of vector then use ``True`` otherwise
use ``F... | 2.2308 | 2.364008 | 0.943652 |
if self.filename is not None:
self.h5 = h5py.File(self.filename)
else:
return
if 'bp' not in self.h5:
self.h5.create_group('bp')
if 'bps' not in self.h5:
self.h5.create_group('bps')
for bp_type in ['bp', 'bps']:
... | def _openFile(self) | Open the HDF5 file for reading/writing.
This methad is called during the initialization of this class. | 1.977147 | 1.943104 | 1.01752 |
if len(self.time) == 0 :
self.time = np.array(time)
if self.h5 is not None:
self.h5.create_dataset('time', self.time.shape, dtype=self.time.dtype, data=self.time, compression="gzip", shuffle=True, scaleoffset=3)
else:
if(len(time) != len(self.... | def _set_time(self, time) | Set time in both class and hdf5 file | 4.029569 | 3.647661 | 1.104699 |
self.mask = mask.copy()
if self.h5 is not None:
if 'mask' in self.h5:
self.h5.pop('mask')
self.h5.create_dataset('mask', mask.shape, dtype=self.mask.dtype, data=mask, compression="gzip", shuffle=True) | def _set_mask(self, mask) | Set mask array in both class and hdf5 file | 2.849232 | 2.4219 | 1.176445 |
bpIndex, dum = get_idx_of_bp_parameters(bp, [], bp_range, startBP=self.startBP)
append = False
empty = False
key = 'dummy'
idx = 0
data = []
midx = []
# Masking values according to mask array
if masked and self.mask is None:
... | def get_parameters(self, parameter, bp, bp_range=True, masked=False) | To get the parameters over all frame for the given range of base pair/steps
parameters
----------
parameter : str
Input parameter name.
Parameter from following list are accepted:
* ``shear``
* ``stretch``
* ``stagger``
... | 5.587964 | 5.304805 | 1.053378 |
if not (isinstance(bp, list) or isinstance(bp, np.ndarray)):
raise AssertionError(
"type %s is not list or np.ndarray" % type(bp))
if (len(bp) > 1) and (merge == False):
raise AssertionError(
"bp %s contains more than two values, whereas ... | def time_vs_parameter(self, parameter, bp, merge=False, merge_method='mean', masked=False) | To get the parameter of either a specfic base-pair/step or a DNA segment as a function of time.
parameters
----------
parameter : str
Name of a base-pair or base-step or helical parameter.
For details about accepted keywords, see ``parameter`` in the
method :... | 2.846332 | 2.825239 | 1.007466 |
if not (isinstance(bp, list) or isinstance(bp, np.ndarray)):
raise AssertionError(
"type %s is not list or np.ndarray" % type(bp))
if (len(bp) > 1) and (merge == False):
raise AssertionError(
"bp %s contains more than two values, whereas ... | def parameter_distribution(self, parameter, bp, bins=30, merge=False, merge_method='mean', masked=False) | To get the parameter distribution of either a specific base-pair/step or a DNA segment over the MD simulation.
parameters
----------
parameter : str
Name of a base-pair or base-step or helical parameter
For details about accepted keywords, see ``parameter`` in the method... | 2.054355 | 2.067255 | 0.99376 |
if not (isinstance(bp, list) or isinstance(bp, np.ndarray)):
raise AssertionError(
"type %s is not list or np.ndarray" % type(bp))
if not ((atomname == 'P') or (atomname == 'O4*') or (atomname == 'C1*') or (atomname == 'O4\'') or (atomname == 'C1\'')):
p... | def set_helical_radius(self, filename, bp, atomname='P', full=False, bp_range=True) | To read and set local helical radius of both strand
Parameters
----------
filename : str
Input file, which is generated from do_x3dna. e.g. HelixRad_g.dat
bp : 1D list or array
base-pairs to analyze
Example: ::
bp = [6] ... | 2.987493 | 2.777352 | 1.075663 |
if (step_range):
if not isinstance(step, list):
raise AssertionError("type %s is not list" % type(step))
if (len(step) > 2):
print (
"ERROR: Range for helical axis should be list of two numbers, e.g. step=[1, 20] \n")
... | def set_helical_axis(self, filename, step_range=False, step=None) | To read and set local helical-axis positions from an input file.
Parameters
----------
filename : str
Input file, which is generated from do_x3dna. e.g. HelAxis_g.dat
step_range : bool
* ``step_range = True`` : read axis coordinates of base-steps for the given ra... | 4.123378 | 3.864267 | 1.067053 |
if (len(base_step) != 2):
raise ValueError("See, documentation for step usage!!!")
if base_step[0] > base_step[1]:
raise ValueError("See, documentation for step usage!!!")
angle = []
if cumulative:
angle_tmp = []
tangent, idx = ... | def calculate_angle_bw_tangents(self, base_step, cumulative=False, masked=False) | To calculate angle (Radian) between two tangent vectors of global helical axis.
Parameters
----------
base_step : 1D list
List of two base-steps for which angle will be calculated.
For example: **base_step** = ``[5, 50]`` either of following can be calculated.
... | 2.657126 | 2.605253 | 1.019911 |
# Check bounds
self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))
# Include alpha if necessary
if len(color_tuple) > 3:
self.alpha = self._apply_float_bounds(color_tuple[3]) | def rgb(self, color_tuple) | Used as main setter (rgb256, hls, hls256, hsv, hsv256) | 4.118828 | 4.213989 | 0.977418 |
r, g, b = self.color
hls = colorsys.rgb_to_hls(r, g, b)
hls = (int(round(hls[0] * 360)), hls[1], hls[2])
return self._append_alpha_if_necessary(hls) | def hls(self) | HLS: (Hue°, Lightness%, Saturation%)
Hue given as percent of 360, Lightness and Saturation given as percent | 3.025049 | 2.732089 | 1.10723 |
r, g, b = self.color
hsv = colorsys.rgb_to_hsv(r, g, b)
hsv = (int(round(hsv[0] * 360)), hsv[1], hsv[2])
return self._append_alpha_if_necessary(hsv) | def hsv(self) | HSV: (Hue°, Saturation%, Value%)
Hue given as percent of 360, Saturation and Value given as percent | 2.710286 | 2.654845 | 1.020883 |
r, g, b = self.color
c = 1 - r
m = 1 - g
y = 1 - b
return (c, m, y) | def cmy(self) | CMY: returned in range 0.0 - 1.0
CMY is subtractive, e.g. black: (1, 1, 1), white (0, 0, 0) | 3.005824 | 2.505528 | 1.199677 |
c, m, y = self.cmy
k = min(c, m, y)
# Handle division by zero in case of black = 1
if k != 1:
c = (c - k) / (1 - k)
m = (m - k) / (1 - k)
y = (y - k) / (1 - k)
else:
c, m, y = 1, 1, 1
cmyk = (c, m, y, k)
... | def cmyk(self) | CMYK: all returned in range 0.0 - 1.0 | 3.080286 | 2.9502 | 1.044094 |
'''taobao.item.add 添加一个商品
此接口用于新增一个商品 商品所属的卖家是当前会话的用户 商品的属性和sku的属性有包含的关系,商品的价格要位于sku的价格区间之中(例如,sku价格有5元、10元两种,那么商品的价格就需要大于等于5元,小于等于10元,否则新增商品会失败) 商品的类目和商品的价格、sku的价格都有一定的相关性(具体的关系要通过类目属性查询接口获得) 商品的运费承担方式和邮费设置有相关性,卖家承担运费不用设置邮费,买家承担运费需要设置邮费 当关键属性值选择了“其他”的时候,需要输入input_pids和input_str商品才能添加成功。'''
... | def add(self, num, price, aType, stuff_status, title, desc, location_state, location_city, cid, session, **kwargs) | taobao.item.add 添加一个商品
此接口用于新增一个商品 商品所属的卖家是当前会话的用户 商品的属性和sku的属性有包含的关系,商品的价格要位于sku的价格区间之中(例如,sku价格有5元、10元两种,那么商品的价格就需要大于等于5元,小于等于10元,否则新增商品会失败) 商品的类目和商品的价格、sku的价格都有一定的相关性(具体的关系要通过类目属性查询接口获得) 商品的运费承担方式和邮费设置有相关性,卖家承担运费不用设置邮费,买家承担运费需要设置邮费 当关键属性值选择了“其他”的时候,需要输入input_pids和input_str商品才能添加成功。 | 7.384443 | 3.049617 | 2.421433 |
'''taobao.item.update 更新商品信息
根据传入的num_iid更新对应的商品的数据 传入的num_iid所对应的商品必须属于当前会话的用户 商品的属性和sku的属性有包含的关系,商品的价格要位于sku的价格区间之中(例如,sku价格有5元、10元两种,那么商品的价格就需要大于等于5元,小于等于10元,否则更新商品会失败) 商品的类目和商品的价格、sku的价格都有一定的相关性(具体的关系要通过类目属性查询接口获得) 当关键属性值更新为“其他”的时候,需要输入input_pids和input_str商品才能更新成功。'''
request = TOPR... | def update(self, num_iid, session, **kwargs) | taobao.item.update 更新商品信息
根据传入的num_iid更新对应的商品的数据 传入的num_iid所对应的商品必须属于当前会话的用户 商品的属性和sku的属性有包含的关系,商品的价格要位于sku的价格区间之中(例如,sku价格有5元、10元两种,那么商品的价格就需要大于等于5元,小于等于10元,否则更新商品会失败) 商品的类目和商品的价格、sku的价格都有一定的相关性(具体的关系要通过类目属性查询接口获得) 当关键属性值更新为“其他”的时候,需要输入input_pids和input_str商品才能更新成功。 | 8.318959 | 3.72034 | 2.236075 |
'''taobao.item.update.delisting 商品下架
单个商品下架
输入的num_iid必须属于当前会话用户'''
request = TOPRequest('taobao.item.update.delisting')
request['num_iid'] = num_iid
self.create(self.execute(request, session)['item'])
return self | def update_delisting(self, num_iid, session) | taobao.item.update.delisting 商品下架
单个商品下架
输入的num_iid必须属于当前会话用户 | 8.016277 | 3.120639 | 2.568794 |
'''taobao.item.update.listing 一口价商品上架
单个商品上架
输入的num_iid必须属于当前会话用户'''
request = TOPRequest('taobao.item.update.listing')
request['num_iid'] = num_iid
request['num'] = num
self.create(self.execute(request, session)['item'])
return self | def update_listing(self, num_iid, num, session) | taobao.item.update.listing 一口价商品上架
单个商品上架
输入的num_iid必须属于当前会话用户 | 7.998705 | 2.903365 | 2.754977 |
'''taobao.item.quantity.update 宝贝/SKU库存修改
提供按照全量或增量形式修改宝贝/SKU库存的功能'''
request = TOPRequest('taobao.item.quantity.update')
request['num_iid'] = num_iid
request['quantity'] = quantity
if sku_id!=None:
request['sku_id'] = sku_id
if outer_id!=None... | def quantity_update(self, num_iid, quantity, session, sku_id=None, outer_id=None, aType=None) | taobao.item.quantity.update 宝贝/SKU库存修改
提供按照全量或增量形式修改宝贝/SKU库存的功能 | 3.331878 | 2.079392 | 1.602333 |
'''taobao.item.recommend.add 橱窗推荐一个商品
将当前用户指定商品设置为橱窗推荐状态 橱窗推荐需要用户有剩余橱窗位才可以顺利执行 这个Item所属卖家从传入的session中获取,需要session绑定 需要判断橱窗推荐是否已满,橱窗推荐已满停止调用橱窗推荐接口,2010年1月底开放查询剩余橱窗推荐数后可以按数量橱窗推荐商品'''
request = TOPRequest('taobao.item.recommend.add')
request['num_iid'] = num_iid
self.create... | def recommend_add(self, num_iid, session) | taobao.item.recommend.add 橱窗推荐一个商品
将当前用户指定商品设置为橱窗推荐状态 橱窗推荐需要用户有剩余橱窗位才可以顺利执行 这个Item所属卖家从传入的session中获取,需要session绑定 需要判断橱窗推荐是否已满,橱窗推荐已满停止调用橱窗推荐接口,2010年1月底开放查询剩余橱窗推荐数后可以按数量橱窗推荐商品 | 18.747185 | 1.773682 | 10.569642 |
'''taobao.item.recommend.delete 取消橱窗推荐一个商品
取消当前用户指定商品的橱窗推荐状态 这个Item所属卖家从传入的session中获取,需要session绑定'''
request = TOPRequest('taobao.item.recommend.delete')
request['num_iid'] = num_iid
self.create(self.execute(request, session)['item'])
return self | def recommend_delete(self, num_iid, session) | taobao.item.recommend.delete 取消橱窗推荐一个商品
取消当前用户指定商品的橱窗推荐状态 这个Item所属卖家从传入的session中获取,需要session绑定 | 11.989759 | 2.721975 | 4.404802 |
'''taobao.items.get 搜索商品信息
根据传入的搜索条件,获取商品列表(类似于淘宝页面上的商品搜索功能,但是只有搜索到的商品列表,不包含商品的ItemCategory列表) 只能获得商品的部分信息,商品的详细信息请通过taobao.item.get获取 如果只输入fields其他条件都不输入,系统会因为搜索条件不足而报错。 不能通过设置cid=0来查询。'''
request = TOPRequest('taobao.items.get')
if not fields:
item = Item()
... | def get(self, session, fields=[], **kwargs) | taobao.items.get 搜索商品信息
根据传入的搜索条件,获取商品列表(类似于淘宝页面上的商品搜索功能,但是只有搜索到的商品列表,不包含商品的ItemCategory列表) 只能获得商品的部分信息,商品的详细信息请通过taobao.item.get获取 如果只输入fields其他条件都不输入,系统会因为搜索条件不足而报错。 不能通过设置cid=0来查询。 | 8.185629 | 3.673682 | 2.228181 |
'''taobao.items.list.get 批量获取商品信息
查看非公开属性时需要用户登录'''
request = TOPRequest('taobao.items.list.get')
request['num_iids'] = num_iids
if not fields:
item = Item()
fields = item.fields
request['fields'] = fields
self.create(self.execute(... | def list_get(self, num_iids, fields=[], session=None) | taobao.items.list.get 批量获取商品信息
查看非公开属性时需要用户登录 | 6.496191 | 3.114396 | 2.085859 |
'''taobao.items.search 搜索商品信息
- 根据传入的搜索条件,获取商品列表和商品类目信息ItemCategory列表(类似于淘宝页面上的商品搜索功能,与 taobao.items.get的区别在于:这个方法得到的结果既有商品列表,又有类目信息列表)
- 商品列表里只能获得商品的部分信息,商品的详细信息请通过taobao.item.get获取
- 商品类目信息列表里只包含类目id和该类目下商品的数量
- 不能通过设置cid=0来查询'''
request = TOPRequest('taobao... | def search(self, fields=[], **kwargs) | taobao.items.search 搜索商品信息
- 根据传入的搜索条件,获取商品列表和商品类目信息ItemCategory列表(类似于淘宝页面上的商品搜索功能,与 taobao.items.get的区别在于:这个方法得到的结果既有商品列表,又有类目信息列表)
- 商品列表里只能获得商品的部分信息,商品的详细信息请通过taobao.item.get获取
- 商品类目信息列表里只包含类目id和该类目下商品的数量
- 不能通过设置cid=0来查询 | 7.737703 | 3.38465 | 2.286116 |
'''taobao.item.sku.add 添加SKU
新增一个sku到num_iid指定的商品中 传入的iid所对应的商品必须属于当前会话的用户'''
request = TOPRequest('taobao.item.sku.add')
request['num_iid'] = num_iid
request['properties'] = properties
request['quantity'] = quantity
request['price'] = price
if ou... | def add(self, num_iid, properties, quantity, price, session, outer_id=None, item_price=None, lang=None) | taobao.item.sku.add 添加SKU
新增一个sku到num_iid指定的商品中 传入的iid所对应的商品必须属于当前会话的用户 | 3.51431 | 1.894056 | 1.855441 |
'''taobao.item.sku.delete 删除SKU
删除一个sku的数据 需要删除的sku通过属性properties进行匹配查找'''
request = TOPRequest('taobao.item.sku.delete')
request['num_iid'] = num_iid
request['properties'] = properties
if item_num!=None:
request['item_num'] = item_num
if item... | def delete(self, num_iid, properties, session, item_price=None, item_num=None, lang=None) | taobao.item.sku.delete 删除SKU
删除一个sku的数据 需要删除的sku通过属性properties进行匹配查找 | 4.324335 | 2.161929 | 2.000221 |
'''taobao.item.sku.get 获取SKU
获取sku_id所对应的sku数据 sku_id对应的sku要属于传入的nick对应的卖家'''
request = TOPRequest('taobao.item.sku.get')
request['num_iids'] = num_iids
if not fields:
sku = Sku()
fields = sku.fields
request['fields'] = fields
self... | def get(self, num_iids, fields=[]) | taobao.item.sku.get 获取SKU
获取sku_id所对应的sku数据 sku_id对应的sku要属于传入的nick对应的卖家 | 7.788645 | 2.93304 | 2.655486 |
'''taobao.skus.custom.get 根据外部ID取商品SKU
跟据卖家设定的Sku的外部id获取商品,如果一个outer_id对应多个Sku会返回所有符合条件的sku 这个Sku所属卖家从传入的session中获取,需要session绑定(注:iid标签里是num_iid的值,可以用作num_iid使用)'''
request = TOPRequest('taobao.skus.custom.get')
request['outer_id'] = outer_id
if not fields:
i... | def custom_get(self, outer_id, session, fields=[]) | taobao.skus.custom.get 根据外部ID取商品SKU
跟据卖家设定的Sku的外部id获取商品,如果一个outer_id对应多个Sku会返回所有符合条件的sku 这个Sku所属卖家从传入的session中获取,需要session绑定(注:iid标签里是num_iid的值,可以用作num_iid使用) | 14.349162 | 2.07307 | 6.921698 |
'''taobao.item.joint.img 商品关联子图
- 关联一张商品图片到num_iid指定的商品中
- 传入的num_iid所对应的商品必须属于当前会话的用户
- 商品图片关联在卖家身份和图片来源上的限制,卖家要是B卖家或订购了多图服务才能关联图片,并且图片要来自于卖家自己的图片空间才行
- 商品图片数量有限制。不管是上传的图片还是关联的图片,他们的总数不能超过一定限额'''
request = TOPRequest('taobao.item.joint.img')
request['... | def joint_img(self, num_iid, pic_path, session, id=None, position=None, is_major=None) | taobao.item.joint.img 商品关联子图
- 关联一张商品图片到num_iid指定的商品中
- 传入的num_iid所对应的商品必须属于当前会话的用户
- 商品图片关联在卖家身份和图片来源上的限制,卖家要是B卖家或订购了多图服务才能关联图片,并且图片要来自于卖家自己的图片空间才行
- 商品图片数量有限制。不管是上传的图片还是关联的图片,他们的总数不能超过一定限额 | 8.20295 | 1.658317 | 4.946552 |
'''taobao.item.joint.propimg 商品关联属性图
- 关联一张商品属性图片到num_iid指定的商品中
- 传入的num_iid所对应的商品必须属于当前会话的用户
- 图片的属性必须要是颜色的属性,这个在前台显示的时候需要和sku进行关联的
- 商品图片关联在卖家身份和图片来源上的限制,卖家要是B卖家或订购了多图服务才能关联图片,并且图片要来自于卖家自己的图片空间才行
- 商品图片数量有限制。不管是上传的图片还是关联的图片,他们的总数不能超过一定限额,最多不能超过24张(每个颜色属性都有一... | def joint_prop(self, properties, pic_path, num_iid, session, id=None, position=None) | taobao.item.joint.propimg 商品关联属性图
- 关联一张商品属性图片到num_iid指定的商品中
- 传入的num_iid所对应的商品必须属于当前会话的用户
- 图片的属性必须要是颜色的属性,这个在前台显示的时候需要和sku进行关联的
- 商品图片关联在卖家身份和图片来源上的限制,卖家要是B卖家或订购了多图服务才能关联图片,并且图片要来自于卖家自己的图片空间才行
- 商品图片数量有限制。不管是上传的图片还是关联的图片,他们的总数不能超过一定限额,最多不能超过24张(每个颜色属性都有一张) | 11.6717 | 1.588583 | 7.347238 |
'''taobao.item.propimg.upload 添加或修改属性图片
添加一张商品属性图片到num_iid指定的商品中 传入的num_iid所对应的商品必须属于当前会话的用户 图片的属性必须要是颜色的属性,这个在前台显示的时候需要和sku进行关联的 商品属性图片只有享有服务的卖家(如:淘宝大卖家、订购了淘宝多图服务的卖家)才能上传 商品属性图片有数量和大小上的限制,最多不能超过24张(每个颜色属性都有一张)。'''
request = TOPRequest('taobao.item.propimg.upload')
request['num_... | def upload(self, num_iid, properties, session, id=None, image=None, position=None) | taobao.item.propimg.upload 添加或修改属性图片
添加一张商品属性图片到num_iid指定的商品中 传入的num_iid所对应的商品必须属于当前会话的用户 图片的属性必须要是颜色的属性,这个在前台显示的时候需要和sku进行关联的 商品属性图片只有享有服务的卖家(如:淘宝大卖家、订购了淘宝多图服务的卖家)才能上传 商品属性图片有数量和大小上的限制,最多不能超过24张(每个颜色属性都有一张)。 | 10.079 | 1.664123 | 6.056644 |
'''taobao.product.img.delete 删除产品非主图
1.传入非主图ID 2.传入产品ID 删除产品非主图'''
request = TOPRequest('taobao.product.img.delete')
request['id'] = id
request['product_id'] = product_id
self.create(self.execute(request, session)['product_img'])
return self | def delete(self, id, product_id, session) | taobao.product.img.delete 删除产品非主图
1.传入非主图ID 2.传入产品ID 删除产品非主图 | 6.618883 | 2.69166 | 2.459034 |
'''taobao.aftersale.get 查询用户售后服务模板
查询用户设置的售后服务模板,仅返回标题和id'''
request = TOPRequest('taobao.aftersale.get')
self.create(self.execute(request, session))
return self.after_sales | def get(self, session) | taobao.aftersale.get 查询用户售后服务模板
查询用户设置的售后服务模板,仅返回标题和id | 14.98536 | 4.745254 | 3.157968 |
'''taobao.product.add 上传一个产品,不包括产品非主图和属性图片
获取类目ID,必需是叶子类目ID;调用taobao.itemcats.get.v2获取 传入关键属性,结构:pid:vid;pid:vid.调用taobao.itemprops.get.v2获取pid, 调用taobao.itempropvalues.get获取vid;如果碰到用户自定义属性,请用customer_props.'''
request = TOPRequest('taobao.product.add')
request['cid'] = cid
... | def add(self, cid, price, image, name, desc, major, market_time, property_alias, session, **kwargs) | taobao.product.add 上传一个产品,不包括产品非主图和属性图片
获取类目ID,必需是叶子类目ID;调用taobao.itemcats.get.v2获取 传入关键属性,结构:pid:vid;pid:vid.调用taobao.itemprops.get.v2获取pid, 调用taobao.itempropvalues.get获取vid;如果碰到用户自定义属性,请用customer_props. | 6.21773 | 3.070616 | 2.024913 |
'''taobao.product.get 获取一个产品的信息
两种方式查看一个产品详细信息: 传入product_id来查询 传入cid和props来查询'''
request = TOPRequest('taobao.product.get')
if not fields:
fields = self.fields
request['fields'] = fields
if product_id!=None: request['product_id'] = product_id
... | def get(self, fields=[], product_id=None, cid=None, props=None) | taobao.product.get 获取一个产品的信息
两种方式查看一个产品详细信息: 传入product_id来查询 传入cid和props来查询 | 4.301767 | 2.411558 | 1.783812 |
'''taobao.products.get 获取产品列表
根据淘宝会员帐号搜索所有产品信息 注意:支持分页,每页最多返回100条,默认值为40,页码从1开始,默认为第一页'''
request = TOPRequest('taobao.products.get')
request['nick'] = nick
if not fields:
product = Product()
fields = product.fields
request['fields'] = fie... | def get(self, nick, fields=[], props=None, page_no=None, page_size=None) | taobao.products.get 获取产品列表
根据淘宝会员帐号搜索所有产品信息 注意:支持分页,每页最多返回100条,默认值为40,页码从1开始,默认为第一页 | 4.51646 | 2.21219 | 2.041624 |
'''taobao.products.search 搜索产品信息
两种方式搜索所有产品信息(二种至少传一种): 传入关键字q搜索 传入cid和props搜索 返回值支持:product_id,name,pic_path,cid,props,price,tsc 当用户指定了cid并且cid为垂直市场(3C电器城、鞋城)的类目id时,默认只返回小二确认的产品。如果用户没有指定cid,或cid为普通的类目,默认返回商家确认或小二确认的产品。如果用户自定了status字段,以指定的status类型为准'''
request = TOPRequest('taobao.produ... | def search(self, fields=[], **kwargs) | taobao.products.search 搜索产品信息
两种方式搜索所有产品信息(二种至少传一种): 传入关键字q搜索 传入cid和props搜索 返回值支持:product_id,name,pic_path,cid,props,price,tsc 当用户指定了cid并且cid为垂直市场(3C电器城、鞋城)的类目id时,默认只返回小二确认的产品。如果用户没有指定cid,或cid为普通的类目,默认返回商家确认或小二确认的产品。如果用户自定了status字段,以指定的status类型为准 | 12.894678 | 2.083819 | 6.188002 |
if not type(value) == bool:
raise TypeError("can only be True or False")
self._loop = value | def loop(self, value) | Indicates whether the playback should loop.
Parameters
----------
value : bool
True if playback should loop, False if not. | 4.044341 | 5.925654 | 0.682514 |
self.clip = None
self.loaded_file = None
self.fps = None
self.duration = None
self.status = UNINITIALIZED
self.clock.reset()
self.loop_count = 0 | def reset(self) | Resets the player and discards loaded data. | 5.894575 | 5.433693 | 1.084819 |
if not mediafile is None:
if os.path.isfile(mediafile):
self.clip = VideoFileClip(mediafile, audio=play_audio)
self.loaded_file = os.path.split(mediafile)[1]
## Timing variables
# Clip duration
self.duration = self.clip.duration
self.clock.max_duration = self.clip.duration
logger.d... | def load_media(self, mediafile, play_audio=True) | Loads a media file to decode.
If an audiostream is detected, its parameters will be stored in a
dictionary in the variable `audioformat`. This contains the fields
:nbytes: the number of bytes in the stream (2 is 16-bit sound).
:nchannels: the channels (2 for stereo, 1 for mono)
:fps: the frames per sec/sa... | 2.935377 | 2.715675 | 1.080902 |
# Check if renderfunc is indeed a function
if not func is None and not callable(func):
raise TypeError("The object passed for videorenderfunc is not a function")
self.__videorenderfunc = func | def set_videoframerender_callback(self, func) | Sets the function to call when a new frame is available.
This function is passed the frame (in the form of a numpy.ndarray) and
should take care of the rendering.
Parameters
----------
func : callable
The function to pass the new frame to once it becomes available. | 5.030907 | 5.837112 | 0.861883 |
if not hasattr(self, 'audioqueue') or self.audioqueue is None:
raise RuntimeError("No video has been loaded, or no audiostream "
"was detected.")
if not isinstance(renderer, SoundRenderer):
raise TypeError("Invalid renderer object. Not a subclass of "
"SoundRenderer")
self.soundrenderer = rendere... | def set_audiorenderer(self, renderer) | Sets the SoundRenderer object. This should take care of processing
the audioframes set in audioqueue.
Parameters
----------
renderer : soundrenderers.SoundRenderer
A subclass of soundrenderers.SoundRenderer that takes care of the
audio rendering.
Raises
------
RuntimeError
If no information ab... | 4.291375 | 3.038107 | 1.412516 |
### First do some status checks
# Make sure a file is loaded
if self.status == UNINITIALIZED or self.clip is None:
raise RuntimeError("Player uninitialized or no file loaded")
# Check if playback has already finished (rewind needs to be called first)
if self.status == EOS:
logger.debug("End of stre... | def play(self) | Start the playback of the video.
The playback loop is run in a separate thread, so this function returns
immediately. This allows one to implement things such as event handling
loops (e.g. check for key presses) elsewhere. | 5.646902 | 5.460391 | 1.034157 |
# Change playback status only if current status is PLAYING or PAUSED
# (and not READY).
logger.debug("Pausing playback")
if self.status == PAUSED:
# Recalculate audio stream position to make sure it is not out of
# sync with the video
self.__calculate_audio_frames()
self.status = PLAYING
sel... | def pause(self) | Pauses or resumes the video and/or audio stream. | 5.057965 | 4.918008 | 1.028458 |
logger.debug("Stopping playback")
# Stop the clock
self.clock.stop()
# Set plauyer status to ready
self.status = READY | def stop(self) | Stops the video stream and resets the clock. | 11.151998 | 8.95689 | 1.245075 |
# Pause the stream
self.pause()
# Make sure the movie starts at 1s as 0s gives trouble.
self.clock.time = max(0.5, value)
logger.debug("Seeking to {} seconds; frame {}".format(self.clock.time,
self.clock.current_frame))
if self.audioformat:
self.__calculate_audio_frames()
# Resume the stream
s... | def seek(self, value) | Seek to the specified time.
Parameters
----------
value : str or int
The time to seek to. Can be any of the following formats:
>>> 15.4 -> 15.4 # seconds
>>> (1,21.5) -> 81.5 # (min,sec)
>>> (1,1,2) -> 3662 # (hr, min, sec)
>>> '01:01:33.5' -> 3693.5 #(hr,min,sec)
>>> '01:01:33... | 7.477857 | 8.369421 | 0.893474 |
if self.audioformat is None:
return
start_frame = self.clock.current_frame
totalsize = int(self.clip.audio.fps*self.clip.audio.duration)
self.audio_times = list(range(0, totalsize,
self.audioformat['buffersize'])) + [totalsize]
# Remove audio segments up to the starting frame
del(self.audio_times... | def __calculate_audio_frames(self) | Aligns audio with video.
This should be called for instance after a seeking operation or resuming
from a pause. | 5.81347 | 5.204929 | 1.116916 |
# Render first frame
self.__render_videoframe()
# Start videoclock with start of this thread
self.clock.start()
logger.debug("Started rendering loop.")
# Main rendering loop
while self.status in [PLAYING,PAUSED]:
current_frame_no = self.clock.current_frame
# Check if end of clip has been reac... | def __render(self) | Main render loop.
Checks clock if new video and audio frames need to be rendered.
If so, it passes the frames to functions that take care
of rendering these frames. | 4.000595 | 3.943787 | 1.014404 |
new_videoframe = self.clip.get_frame(self.clock.time)
# Pass it to the callback function if this is set
if callable(self.__videorenderfunc):
self.__videorenderfunc(new_videoframe)
# Set current_frame to current frame (...)
self.__current_videoframe = new_videoframe | def __render_videoframe(self) | Retrieves a new videoframe from the stream.
Sets the frame as the __current_video_frame and passes it on to
__videorenderfunc() if it is set. | 5.977717 | 4.005513 | 1.492372 |
new_audioframe = None
logger.debug("Started audio rendering thread.")
while self.status in [PLAYING,PAUSED]:
# Retrieve audiochunk
if self.status == PLAYING:
if new_audioframe is None:
# Get a new frame from the audiostream, skip to the next one
# if the current one gives a problem
tr... | def __audiorender_thread(self) | Thread that takes care of the audio rendering. Do not call directly,
but only as the target of a thread. | 4.768663 | 4.762449 | 1.001305 |
"Write your forwards methods here."
for instance in orm.LocationSource.objects.all():
try:
instance.user = instance.points.all()[0].user
instance.save()
except IndexError:
# No points for this source.
instance.delete... | def forwards(self, orm) | Write your forwards methods here. | 7.936216 | 7.119314 | 1.114745 |
"Write your backwards methods here."
for instance in orm.LocationSource.objects.all():
for point in instance.points.all():
point.user = instance.user
point.save() | def backwards(self, orm) | Write your backwards methods here. | 8.779916 | 7.884045 | 1.113631 |
if not hasattr(self, 'queue'):
raise RuntimeError("Audio queue is not intialized.")
self.stream.start_stream()
self.keep_listening = True
while self.keep_listening:
try:
frame = self.queue.get(False, timeout=queue_timeout)
self.stream.write(frame)
except Empty:
continue
time.slee... | def run(self) | Initializes the stream. | 3.107748 | 2.91299 | 1.066858 |
pair = (c_int * 2)()
_pipe2(byref(pair), flags)
return pair[0], pair[1] | def pipe2(flags=0) | Wrapper around ``pipe2(2)``
:param flags:
Optional flags to set. This should almost always include O_CLOEXEC so
that the resulting code is not racy (see the discussion about O_CLOEXEC
to understand why this flag is essential). It can also include
O_NONBLOCK or O_DIRECT, depending on... | 4.434992 | 6.553145 | 0.676773 |
'''taobao.favorite.add 添加收藏夹
根据用户昵称和收藏目标的数字id以及收藏目标的类型,实现收藏行为'''
request = TOPRequest('taobao.favorite.add')
request['item_numid'] = item_numid
request['collect_type'] = collect_type
request['shared'] = shared
self.create(self.execute(request, session))
... | def add(self, item_numid, collect_type, shared, session) | taobao.favorite.add 添加收藏夹
根据用户昵称和收藏目标的数字id以及收藏目标的类型,实现收藏行为 | 5.388575 | 2.40692 | 2.238784 |
'''taobao.favorite.search 查询
查询淘宝用户收藏的商品或店铺信息.(收藏有公开和未公开两种,不入参sessionkey的只能获得公开的收藏,而入参了sessionkey的能获得未公开的收藏。)'''
request = TOPRequest('taobao.favorite.search')
request['user_nick'] = user_nick
request['collect_type'] = collect_type
request['page_no'] = page_no
... | def search(self, user_nick, collect_type, page_no, session=None) | taobao.favorite.search 查询
查询淘宝用户收藏的商品或店铺信息.(收藏有公开和未公开两种,不入参sessionkey的只能获得公开的收藏,而入参了sessionkey的能获得未公开的收藏。) | 7.012487 | 2.059973 | 3.404165 |
'''Get search results for a specific keyword'''
if type(keyword) != unicode: q = keyword.decode('utf-8')
req = self.fetch(self.search_url, {'q':q.encode('gbk')})
if not req: return None
html = req.content.decode('gbk').encode('utf-8')
soup = BeautifulSoup(html, convertEnt... | def search(self, keyword) | Get search results for a specific keyword | 4.30492 | 4.222486 | 1.019523 |
'''Get top keywords for all the categories'''
engine = models.postgres_engine()
session = models.create_session(engine)
#threadPool = ThreadPool(5)
for cat in session.query(models.Category):
if not cat.level: continue
self.cat_top_keywords(session, cat, up... | def get_top_keywords(self, up=True) | Get top keywords for all the categories | 7.288866 | 6.818711 | 1.068951 |
'''Get top keywords in a specific category'''
print 'CAT:%s, level:%s'%(str(cat), str(cat.level))
print 'OFFSET: %d'%offset
response = []
if not offsets or offset==0:
url = 'http://top.taobao.com/level3.php?cat=%s&level3=%s&show=focus&up=%s&offset=%d'%(cat.parent.cid... | def cat_top_keywords(self, session, cat, up=True, offset=0, offsets=[]) | Get top keywords in a specific category | 3.104487 | 3.110275 | 0.998139 |
'''Get top keywords categories'''
start_url = 'http://top.taobao.com/index.php?from=tbsy'
rs = self.fetch(start_url)
if not rs: return None
soup = BeautifulSoup(rs.content, convertEntities=BeautifulSoup.HTML_ENTITIES, markupMassage=hexentityMassage)
cats = [{'id':'TR_%s'%... | def get_cats(self) | Get top keywords categories | 6.369318 | 5.867653 | 1.085497 |
try:
cairo_context.save()
cairo_context.translate(0, papersize_tuple[1])
cairo_context.scale(1, -1)
layout.render(
Rectangle(0, 0, *papersize_tuple),
dict(output=CairoOutput(cairo_context))
)
finally:
cairo_context.restore() | def render_to_cairo_context(cairo_context, papersize_tuple, layout) | Renders the given layout manager on a page of the given context.
Assumes the given context has not yet been reversed in the y-direction
(i.e. it is still the default for Cairo, where y increases up
from the bottom of the page). This method performs the reversal and
resets it before it returns. | 2.672182 | 2.599083 | 1.028125 |
doc = cairo.PDFSurface(output_filename, *papersize_tuple)
c = cairo.Context(doc)
render_to_cairo_context(c, papersize_tuple, layout) | def render_to_cairo_document(output_filename, papersize_tuple, layout) | Create and save a document with contents of the given layout manager. | 2.210456 | 2.296477 | 0.962542 |
c = self.c
c.save()
c.new_path()
for x,y in zip(*[iter(pts)]*2):
c.line_to(x, y)
if close_path:
c.close_path()
self._fill_and_stroke(stroke, stroke_width, stroke_dash, fill)
c.restore() | def draw_polygon(
self,
*pts,
close_path=True,
stroke=None,
stroke_width=1,
stroke_dash=None,
fill=None
) -> None | Draws the given polygon. | 2.544097 | 2.378175 | 1.069769 |
if self.prompt_string is not None:
return self.prompt_string
if not self.color_enabled:
return (' '.join(self.command) + '>> ').encode('utf8')
color = '34'
sub_color = '37'
prompt_cmd = [
self.colorize('1;' + color, part) if part !=... | def prompt(self) | Returns the UTF-8 encoded prompt string. | 4.55562 | 4.249383 | 1.072066 |
return (u'[{}] {}>>'.format(
os.path.split(os.path.abspath('.'))[-1],
u' '.join(self.command))).encode('utf8') | def title(self) | Returns the UTF-8 encoded title | 8.611301 | 8.168469 | 1.054212 |
duration = timespec.split(':')
seconds = int(duration[-1])
minutes = 0
hours = 0
days = 0
if len(duration) > 1:
minutes = int(duration[-2])
if len(duration) > 2:
hours = int(duration[-3])
if len(duration) > 3:
days = int(duration[-4])
return datetime.ti... | def create_timedelta(timespec) | Utility function to translate DD:HH:MM:SS into a timedelta object. | 1.670786 | 1.547656 | 1.079559 |
assert event_time is None or isinstance(event_time, datetime.datetime)
assert relative_duration_before is None or isinstance(relative_duration_before, str)
assert relative_duration_after is None or isinstance(relative_duration_after, str)
if event_time is None:
# us... | def query_relative(self, query, event_time=None, relative_duration_before=None, relative_duration_after=None) | Perform the query and calculate the time range based on the relative values. | 1.924791 | 1.914597 | 1.005324 |
if self.search_results is None:
return None
result = []
for row in self.search_results['rows']:
obj = {}
for index in range(0, len(self.search_results['fields'])):
obj[self.search_results['fields'][index]] = row[index]
res... | def json(self) | Returns the search results as a list of JSON objects. | 2.552668 | 2.074335 | 1.230595 |
pass | def draw_text(self, text:str, x:float, y:float, *,
font_name:str, font_size:float, fill:Color) -> None | Draws the given text at x,y. | 56,269.730469 | 1,865.037354 | 30.170833 |
pass | def draw_line(
self, x0:float, y0:float, x1:float, y1:float, *,
stroke:Color,
stroke_width:float=1,
stroke_dash:typing.Sequence=None
) -> None | Draws the given line. | 30,427.931641 | 1,573.963135 | 19.332048 |
pass | def draw_rect(
self, x:float, y:float, w:float, h:float, *,
stroke:Color=None,
stroke_width:float=1,
stroke_dash:typing.Sequence=None,
fill:Color=None
) -> None | Draws the given rectangle. | 22,438.716797 | 1,568.427124 | 14.306509 |
pass | def draw_image(
self, img_filename:str, x:float, y:float, w:float, h:float
) -> None | Draws the given image. | 11,243.389648 | 1,374.097778 | 8.18238 |
pass | def draw_polygon(
self,
*pts,
close_path:bool=True,
stroke:Color=None,
stroke_width:float=1,
stroke_dash:typing.Sequence=None,
fill:Color=None
) -> None | Draws the given linear path. | 25,969.6875 | 1,536.823486 | 16.898289 |
pass | def clip_rect(self, x:float, y:float, w:float, h:float) -> None | Clip further output to this rect. | 47,682.367188 | 1,242.153564 | 38.386854 |
manifest_files = distutils.filelist.FileList()
for line in template_lines:
if line.strip():
manifest_files.process_template_line(line)
return manifest_files.files | def parse_manifest(template_lines) | List of file names included by the MANIFEST.in template lines. | 4.930652 | 4.466207 | 1.103991 |
cls_init = cls.__init__
cls_create = cls.Create
@functools.wraps(cls_init)
def __init__(self, *args, **kwargs):
if args or kwargs:
cls_init(self, *args, **kwargs)
else: # 2-step creation
new_self = getattr(wx, "Pre" + cls.__name__)()
for pair in ... | def _wx_two_step_creation_on_classic(cls) | Patch the wxPython Classic class to behave like a wxPython
Phoenix class on a 2-step creation process.
On wxPython Phoenix, the first step is the parameterless
``__init__``, and the second step is the ``Create`` method with
the construction parameters, e.g.::
class CustomFrame(wx.Frame):
... | 3.068377 | 2.980887 | 1.02935 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.