text stringlengths 0 828 |
|---|
>>> thread = api.update_product_by_id(product_id, product, async=True) |
>>> result = thread.get() |
:param async bool |
:param str product_id: ID of product to update. (required) |
:param Product product: Attributes of product to update. (required) |
:return: Product |
If the method is called asynchronously, |
returns the request thread. |
"""""" |
kwargs['_return_http_data_only'] = True |
if kwargs.get('async'): |
return cls._update_product_by_id_with_http_info(product_id, product, **kwargs) |
else: |
(data) = cls._update_product_by_id_with_http_info(product_id, product, **kwargs) |
return data" |
4103,"def asserts(input_value, rule, message=''): |
"""""" this function allows you to write asserts in generators since there are |
moments where you actually want the program to halt when certain values |
are seen. |
"""""" |
assert callable(rule) or type(rule)==bool, 'asserts needs rule to be a callable function or a test boolean' |
assert isinstance(message, str), 'asserts needs message to be a string' |
# if the message is empty and rule is callable, fill message with rule's source code |
if len(message)==0 and callable(rule): |
try: |
s = getsource(rule).splitlines()[0].strip() |
except: |
s = repr(rule).strip() |
message = 'illegal input of {} breaks - {}'.format(input_value, s) |
if callable(rule): |
# if rule is a function, run the function and assign it to rule |
rule = rule(input_value) |
# now, assert the rule and return the input value |
assert rule, message |
return input_value" |
4104,"def print(*a): |
"""""" print just one that returns what you give it instead of None """""" |
try: |
_print(*a) |
return a[0] if len(a) == 1 else a |
except: |
_print(*a)" |
4105,"def pattern2re(pattern): |
""""""Makes a unicode regular expression from a pattern. |
Returns ``(start, full_re, int_re)`` where: |
* `start` is either empty or the subdirectory in which to start searching, |
* `full_re` is a regular expression object that matches the requested |
files, i.e. a translation of the pattern |
* `int_re` is either None of a regular expression object that matches |
the requested paths or their ancestors (i.e. if a path doesn't match |
`int_re`, no path under it will match `full_re`) |
This uses extended patterns, where: |
* a slash '/' always represents the path separator |
* a backslash '\' escapes other special characters |
* an initial slash '/' anchors the match at the beginning of the |
(relative) path |
* a trailing '/' suffix is removed |
* an asterisk '*' matches a sequence of any length (including 0) of any |
characters (except the path separator) |
* a '?' matches exactly one character (except the path separator) |
* '[abc]' matches characters 'a', 'b' or 'c' |
* two asterisks '**' matches one or more path components (might match '/' |
characters) |
"""""" |
pattern_segs = filter(None, pattern.split('/')) |
# This anchors the first component either at the start of the string or at |
# the start of a path component |
if not pattern: |
return '', re.compile(''), None |
elif '/' in pattern: |
full_regex = '^' # Start at beginning of path |
int_regex = [] |
int_regex_done = False |
start_dir = [] |
start_dir_done = False |
else: |
full_regex = '(?:^|/)' # Skip any number of full components |
int_regex = None |
int_regex_done = True |
start_dir = [] |
start_dir_done = True |
# Handles each component |
for pnum, pat in enumerate(pattern_segs): |
comp = patterncomp2re(pat) |
# The first component is already anchored |
if pnum > 0: |
full_regex += '/' |
full_regex += comp |
if not int_regex_done: |
if pat == '**': |
int_regex_done = True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.