labNo
float64
1
10
taskNo
float64
0
4
questioner
stringclasses
2 values
question
stringlengths
9
201
code
stringlengths
18
30.3k
startLine
float64
0
192
endLine
float64
0
196
questionType
stringclasses
4 values
answer
stringlengths
2
905
src
stringclasses
3 values
code_processed
stringlengths
12
28.3k
id
stringlengths
2
5
raw_code
stringlengths
20
30.3k
raw_comment
stringlengths
10
242
comment
stringlengths
9
207
q_code
stringlengths
66
30.3k
null
null
null
What does the code ensure if host - block - list is changed to none ?
def test_config_change(config_stub, basedir, download_stub, data_tmpdir, tmpdir): filtered_blocked_hosts = BLOCKLIST_HOSTS[1:] blocklist = QUrl(create_blocklist(tmpdir, blocked_hosts=filtered_blocked_hosts, name='blocked-hosts', line_format='one_per_line')) config_stub.data = {'content': {'host-block-lists': [blocklist], 'host-blocking-enabled': True, 'host-blocking-whitelist': None}} host_blocker = adblock.HostBlocker() host_blocker.read_hosts() config_stub.set('content', 'host-block-lists', None) host_blocker.read_hosts() for str_url in URLS_TO_CHECK: assert (not host_blocker.is_blocked(QUrl(str_url)))
null
null
null
blocked - hosts resets
codeqa
def test config change config stub basedir download stub data tmpdir tmpdir filtered blocked hosts BLOCKLIST HOSTS[ 1 ]blocklist Q Url create blocklist tmpdir blocked hosts filtered blocked hosts name 'blocked-hosts' line format 'one per line' config stub data {'content' {'host-block-lists' [blocklist] 'host-blocking-enabled' True 'host-blocking-whitelist' None}}host blocker adblock Host Blocker host blocker read hosts config stub set 'content' 'host-block-lists' None host blocker read hosts for str url in URLS TO CHECK assert not host blocker is blocked Q Url str url
null
null
null
null
Question: What does the code ensure if host - block - list is changed to none ? Code: def test_config_change(config_stub, basedir, download_stub, data_tmpdir, tmpdir): filtered_blocked_hosts = BLOCKLIST_HOSTS[1:] blocklist = QUrl(create_blocklist(tmpdir, blocked_hosts=filtered_blocked_hosts, name='blocked-hosts', line_format='one_per_line')) config_stub.data = {'content': {'host-block-lists': [blocklist], 'host-blocking-enabled': True, 'host-blocking-whitelist': None}} host_blocker = adblock.HostBlocker() host_blocker.read_hosts() config_stub.set('content', 'host-block-lists', None) host_blocker.read_hosts() for str_url in URLS_TO_CHECK: assert (not host_blocker.is_blocked(QUrl(str_url)))
null
null
null
How must all passed bags have the same number of partitions ?
def bag_zip(*bags): npartitions = bags[0].npartitions assert all(((bag.npartitions == npartitions) for bag in bags)) name = ('zip-' + tokenize(*bags)) dsk = dict((((name, i), (reify, ((zip,) + tuple(((bag.name, i) for bag in bags))))) for i in range(npartitions))) bags_dsk = merge(*(bag.dask for bag in bags)) return Bag(merge(bags_dsk, dsk), name, npartitions)
null
null
null
partition - wise bag
codeqa
def bag zip *bags npartitions bags[ 0 ] npartitionsassert all bag npartitions npartitions for bag in bags name 'zip-' + tokenize *bags dsk dict name i reify zip + tuple bag name i for bag in bags for i in range npartitions bags dsk merge * bag dask for bag in bags return Bag merge bags dsk dsk name npartitions
null
null
null
null
Question: How must all passed bags have the same number of partitions ? Code: def bag_zip(*bags): npartitions = bags[0].npartitions assert all(((bag.npartitions == npartitions) for bag in bags)) name = ('zip-' + tokenize(*bags)) dsk = dict((((name, i), (reify, ((zip,) + tuple(((bag.name, i) for bag in bags))))) for i in range(npartitions))) bags_dsk = merge(*(bag.dask for bag in bags)) return Bag(merge(bags_dsk, dsk), name, npartitions)
null
null
null
What must all passed bags have partition - wise bag ?
def bag_zip(*bags): npartitions = bags[0].npartitions assert all(((bag.npartitions == npartitions) for bag in bags)) name = ('zip-' + tokenize(*bags)) dsk = dict((((name, i), (reify, ((zip,) + tuple(((bag.name, i) for bag in bags))))) for i in range(npartitions))) bags_dsk = merge(*(bag.dask for bag in bags)) return Bag(merge(bags_dsk, dsk), name, npartitions)
null
null
null
the same number of partitions
codeqa
def bag zip *bags npartitions bags[ 0 ] npartitionsassert all bag npartitions npartitions for bag in bags name 'zip-' + tokenize *bags dsk dict name i reify zip + tuple bag name i for bag in bags for i in range npartitions bags dsk merge * bag dask for bag in bags return Bag merge bags dsk dsk name npartitions
null
null
null
null
Question: What must all passed bags have partition - wise bag ? Code: def bag_zip(*bags): npartitions = bags[0].npartitions assert all(((bag.npartitions == npartitions) for bag in bags)) name = ('zip-' + tokenize(*bags)) dsk = dict((((name, i), (reify, ((zip,) + tuple(((bag.name, i) for bag in bags))))) for i in range(npartitions))) bags_dsk = merge(*(bag.dask for bag in bags)) return Bag(merge(bags_dsk, dsk), name, npartitions)
null
null
null
What needs a newline explicitly at the end ?
def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
the python grammar
codeqa
def test end newlines def test source end pos module Parser With Recovery load grammar u source moduleassert module get code source assert module end pos end pos test 'a' 1 1 test 'a\n' 2 0 test 'a\nb' 2 1 test 'a\n#comment\n' 3 0 test 'a\n#comment' 2 8 test 'a#comment' 1 9 test 'defa \npass' 2 5 test 'defa ' 1 6
null
null
null
null
Question: What needs a newline explicitly at the end ? Code: def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
How does the python grammar need a newline at the end ?
def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
explicitly
codeqa
def test end newlines def test source end pos module Parser With Recovery load grammar u source moduleassert module get code source assert module end pos end pos test 'a' 1 1 test 'a\n' 2 0 test 'a\nb' 2 1 test 'a\n#comment\n' 3 0 test 'a\n#comment' 2 8 test 'a#comment' 1 9 test 'defa \npass' 2 5 test 'defa ' 1 6
null
null
null
null
Question: How does the python grammar need a newline at the end ? Code: def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
What does the python grammar need explicitly at the end ?
def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
a newline
codeqa
def test end newlines def test source end pos module Parser With Recovery load grammar u source moduleassert module get code source assert module end pos end pos test 'a' 1 1 test 'a\n' 2 0 test 'a\nb' 2 1 test 'a\n#comment\n' 3 0 test 'a\n#comment' 2 8 test 'a#comment' 1 9 test 'defa \npass' 2 5 test 'defa ' 1 6
null
null
null
null
Question: What does the python grammar need explicitly at the end ? Code: def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
When does the python grammar need a newline explicitly ?
def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
at the end
codeqa
def test end newlines def test source end pos module Parser With Recovery load grammar u source moduleassert module get code source assert module end pos end pos test 'a' 1 1 test 'a\n' 2 0 test 'a\nb' 2 1 test 'a\n#comment\n' 3 0 test 'a\n#comment' 2 8 test 'a#comment' 1 9 test 'defa \npass' 2 5 test 'defa ' 1 6
null
null
null
null
Question: When does the python grammar need a newline explicitly ? Code: def test_end_newlines(): def test(source, end_pos): module = ParserWithRecovery(load_grammar(), u(source)).module assert (module.get_code() == source) assert (module.end_pos == end_pos) test('a', (1, 1)) test('a\n', (2, 0)) test('a\nb', (2, 1)) test('a\n#comment\n', (3, 0)) test('a\n#comment', (2, 8)) test('a#comment', (1, 9)) test('def a():\n pass', (2, 5)) test('def a(', (1, 6))
null
null
null
What does the code handle ?
def find_again(text): return _setup(text).find_again(text)
null
null
null
the editor edit menu item and corresponding event
codeqa
def find again text return setup text find again text
null
null
null
null
Question: What does the code handle ? Code: def find_again(text): return _setup(text).find_again(text)
null
null
null
How do data_files return ?
def get_data_files(): if sys.platform.startswith('linux'): if PY3: data_files = [('share/applications', ['scripts/spyder3.desktop']), ('share/pixmaps', ['img_src/spyder3.png'])] else: data_files = [('share/applications', ['scripts/spyder.desktop']), ('share/pixmaps', ['img_src/spyder.png'])] elif (os.name == 'nt'): data_files = [('scripts', ['img_src/spyder.ico', 'img_src/spyder_reset.ico'])] else: data_files = [] return data_files
null
null
null
in a platform dependent manner
codeqa
def get data files if sys platform startswith 'linux' if PY 3 data files [ 'share/applications' ['scripts/spyder 3 desktop'] 'share/pixmaps' ['img src/spyder 3 png'] ]else data files [ 'share/applications' ['scripts/spyder desktop'] 'share/pixmaps' ['img src/spyder png'] ]elif os name 'nt' data files [ 'scripts' ['img src/spyder ico' 'img src/spyder reset ico'] ]else data files []return data files
null
null
null
null
Question: How do data_files return ? Code: def get_data_files(): if sys.platform.startswith('linux'): if PY3: data_files = [('share/applications', ['scripts/spyder3.desktop']), ('share/pixmaps', ['img_src/spyder3.png'])] else: data_files = [('share/applications', ['scripts/spyder.desktop']), ('share/pixmaps', ['img_src/spyder.png'])] elif (os.name == 'nt'): data_files = [('scripts', ['img_src/spyder.ico', 'img_src/spyder_reset.ico'])] else: data_files = [] return data_files
null
null
null
What did the code set using the necessary platform - dependent calls ?
def set_term_title(title): if ignore_termtitle: return _set_term_title(title)
null
null
null
terminal title
codeqa
def set term title title if ignore termtitle return set term title title
null
null
null
null
Question: What did the code set using the necessary platform - dependent calls ? Code: def set_term_title(title): if ignore_termtitle: return _set_term_title(title)
null
null
null
How did the code set terminal title ?
def set_term_title(title): if ignore_termtitle: return _set_term_title(title)
null
null
null
using the necessary platform - dependent calls
codeqa
def set term title title if ignore termtitle return set term title title
null
null
null
null
Question: How did the code set terminal title ? Code: def set_term_title(title): if ignore_termtitle: return _set_term_title(title)
null
null
null
What does the code select ?
def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
the server that allocates value using a binary search
codeqa
def Bisect Hash List ls left right value if right < left return Noneif left right return ls[left]middle left + right - left / 2 middleval ls[middle]start middleval interval startend middleval interval endif start < value < end return middlevalif value > end return Bisect Hash List ls middle + 1 right value if value < start return Bisect Hash List ls left middle - 1 value
null
null
null
null
Question: What does the code select ? Code: def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
What does the server allocate using a binary search ?
def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
value
codeqa
def Bisect Hash List ls left right value if right < left return Noneif left right return ls[left]middle left + right - left / 2 middleval ls[middle]start middleval interval startend middleval interval endif start < value < end return middlevalif value > end return Bisect Hash List ls middle + 1 right value if value < start return Bisect Hash List ls left middle - 1 value
null
null
null
null
Question: What does the server allocate using a binary search ? Code: def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
What allocates value using a binary search ?
def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
the server
codeqa
def Bisect Hash List ls left right value if right < left return Noneif left right return ls[left]middle left + right - left / 2 middleval ls[middle]start middleval interval startend middleval interval endif start < value < end return middlevalif value > end return Bisect Hash List ls middle + 1 right value if value < start return Bisect Hash List ls left middle - 1 value
null
null
null
null
Question: What allocates value using a binary search ? Code: def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
How does the server allocate value ?
def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
using a binary search
codeqa
def Bisect Hash List ls left right value if right < left return Noneif left right return ls[left]middle left + right - left / 2 middleval ls[middle]start middleval interval startend middleval interval endif start < value < end return middlevalif value > end return Bisect Hash List ls middle + 1 right value if value < start return Bisect Hash List ls left middle - 1 value
null
null
null
null
Question: How does the server allocate value ? Code: def _BisectHashList(ls, left, right, value): if (right < left): return None if (left == right): return ls[left] middle = (left + ((right - left) / 2)) middleval = ls[middle] start = middleval.interval.start end = middleval.interval.end if (start <= value < end): return middleval if (value >= end): return _BisectHashList(ls, (middle + 1), right, value) if (value < start): return _BisectHashList(ls, left, (middle - 1), value)
null
null
null
What does standard tool function return ?
def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
a dictionary containing the big
codeqa
def image get resized images base 64 source return big False return medium True return small True big name 'image' medium name 'image medium' small name 'image small' avoid resize big True avoid resize medium False avoid resize small False return dict dict if return big return dict[big name] image resize image big base 64 source avoid if small avoid resize big if return medium return dict[medium name] image resize image medium base 64 source avoid if small avoid resize medium if return small return dict[small name] image resize image small base 64 source avoid if small avoid resize small return return dict
null
null
null
null
Question: What does standard tool function return ? Code: def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
What returns a dictionary containing the big ?
def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
standard tool function
codeqa
def image get resized images base 64 source return big False return medium True return small True big name 'image' medium name 'image medium' small name 'image small' avoid resize big True avoid resize medium False avoid resize small False return dict dict if return big return dict[big name] image resize image big base 64 source avoid if small avoid resize big if return medium return dict[medium name] image resize image medium base 64 source avoid if small avoid resize medium if return small return dict[small name] image resize image small base 64 source avoid if small avoid resize small return return dict
null
null
null
null
Question: What returns a dictionary containing the big ? Code: def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
What is containing the big ?
def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
a dictionary
codeqa
def image get resized images base 64 source return big False return medium True return small True big name 'image' medium name 'image medium' small name 'image small' avoid resize big True avoid resize medium False avoid resize small False return dict dict if return big return dict[big name] image resize image big base 64 source avoid if small avoid resize big if return medium return dict[medium name] image resize image medium base 64 source avoid if small avoid resize medium if return small return dict[small name] image resize image small base 64 source avoid if small avoid resize small return return dict
null
null
null
null
Question: What is containing the big ? Code: def image_get_resized_images(base64_source, return_big=False, return_medium=True, return_small=True, big_name='image', medium_name='image_medium', small_name='image_small', avoid_resize_big=True, avoid_resize_medium=False, avoid_resize_small=False): return_dict = dict() if return_big: return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big) if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source, avoid_if_small=avoid_resize_medium) if return_small: return_dict[small_name] = image_resize_image_small(base64_source, avoid_if_small=avoid_resize_small) return return_dict
null
null
null
When do a native path return ?
def npath(path): if (six.PY2 and (not isinstance(path, bytes))): return path.encode(fs_encoding) return path
null
null
null
always
codeqa
def npath path if six PY 2 and not isinstance path bytes return path encode fs encoding return path
null
null
null
null
Question: When do a native path return ? Code: def npath(path): if (six.PY2 and (not isinstance(path, bytes))): return path.encode(fs_encoding) return path
null
null
null
What does the code write ?
def write(domain, key, value, type='string', user=None): if ((type == 'bool') or (type == 'boolean')): if (value is True): value = 'TRUE' elif (value is False): value = 'FALSE' cmd = 'defaults write "{0}" "{1}" -{2} "{3}"'.format(domain, key, type, value) return __salt__['cmd.run_all'](cmd, runas=user)
null
null
null
a default to the system
codeqa
def write domain key value type 'string' user None if type 'bool' or type 'boolean' if value is True value 'TRUE'elif value is False value 'FALSE'cmd 'defaultswrite"{ 0 }""{ 1 }"-{ 2 }"{ 3 }"' format domain key type value return salt ['cmd run all'] cmd runas user
null
null
null
null
Question: What does the code write ? Code: def write(domain, key, value, type='string', user=None): if ((type == 'bool') or (type == 'boolean')): if (value is True): value = 'TRUE' elif (value is False): value = 'FALSE' cmd = 'defaults write "{0}" "{1}" -{2} "{3}"'.format(domain, key, type, value) return __salt__['cmd.run_all'](cmd, runas=user)
null
null
null
What does the code convert to its source directory form ?
def Sourceify(path): if ('$(' in path): return path if os.path.isabs(path): return path return (srcdir_prefix + path)
null
null
null
a path
codeqa
def Sourceify path if '$ ' in path return pathif os path isabs path return pathreturn srcdir prefix + path
null
null
null
null
Question: What does the code convert to its source directory form ? Code: def Sourceify(path): if ('$(' in path): return path if os.path.isabs(path): return path return (srcdir_prefix + path)
null
null
null
What did the code read ?
def _read_double(fid, n=1): return np.fromfile(fid, '>f8', n)
null
null
null
a double
codeqa
def read double fid n 1 return np fromfile fid '>f 8 ' n
null
null
null
null
Question: What did the code read ? Code: def _read_double(fid, n=1): return np.fromfile(fid, '>f8', n)
null
null
null
What does the code get ?
def getTranslateMatrixTetragrid(prefix, xmlElement): translation = getCumulativeVector3Remove(prefix, Vector3(), xmlElement) if translation.getIsDefault(): return None return [[1.0, 0.0, 0.0, translation.x], [0.0, 1.0, 0.0, translation.y], [0.0, 0.0, 1.0, translation.z], [0.0, 0.0, 0.0, 1.0]]
null
null
null
translate matrix
codeqa
def get Translate Matrix Tetragrid prefix xml Element translation get Cumulative Vector 3 Remove prefix Vector 3 xml Element if translation get Is Default return Nonereturn [[ 1 0 0 0 0 0 translation x] [0 0 1 0 0 0 translation y] [0 0 0 0 1 0 translation z] [0 0 0 0 0 0 1 0]]
null
null
null
null
Question: What does the code get ? Code: def getTranslateMatrixTetragrid(prefix, xmlElement): translation = getCumulativeVector3Remove(prefix, Vector3(), xmlElement) if translation.getIsDefault(): return None return [[1.0, 0.0, 0.0, translation.x], [0.0, 1.0, 0.0, translation.y], [0.0, 0.0, 1.0, translation.z], [0.0, 0.0, 0.0, 1.0]]
null
null
null
What does the code fetch ?
def _fetch_templates(src): templates = [] log.debug('Listing contents of {0}'.format(src)) for item in os.listdir(src): s = os.path.join(src, item) if os.path.isdir(s): template_path = os.path.join(s, TEMPLATE_FILE_NAME) if os.path.isfile(template_path): templates.append(_get_template(template_path, item)) else: log.debug('Directory does not contain {1} {0}'.format(template_path, TEMPLATE_FILE_NAME)) return templates
null
null
null
all of the templates in the src directory
codeqa
def fetch templates src templates []log debug ' Listingcontentsof{ 0 }' format src for item in os listdir src s os path join src item if os path isdir s template path os path join s TEMPLATE FILE NAME if os path isfile template path templates append get template template path item else log debug ' Directorydoesnotcontain{ 1 }{ 0 }' format template path TEMPLATE FILE NAME return templates
null
null
null
null
Question: What does the code fetch ? Code: def _fetch_templates(src): templates = [] log.debug('Listing contents of {0}'.format(src)) for item in os.listdir(src): s = os.path.join(src, item) if os.path.isdir(s): template_path = os.path.join(s, TEMPLATE_FILE_NAME) if os.path.isfile(template_path): templates.append(_get_template(template_path, item)) else: log.debug('Directory does not contain {1} {0}'.format(template_path, TEMPLATE_FILE_NAME)) return templates
null
null
null
In which direction does an empty request send to the configured end - point ?
def MaybeInvokeAuthentication(): datastore_stub = apiproxy_stub_map.apiproxy.GetStub('datastore_v3') if isinstance(datastore_stub, RemoteStub): datastore_stub._server.Send(datastore_stub._path, payload=None) else: raise ConfigurationError('remote_api is not configured.')
null
null
null
through
codeqa
def Maybe Invoke Authentication datastore stub apiproxy stub map apiproxy Get Stub 'datastore v3 ' if isinstance datastore stub Remote Stub datastore stub server Send datastore stub path payload None else raise Configuration Error 'remote apiisnotconfigured '
null
null
null
null
Question: In which direction does an empty request send to the configured end - point ? Code: def MaybeInvokeAuthentication(): datastore_stub = apiproxy_stub_map.apiproxy.GetStub('datastore_v3') if isinstance(datastore_stub, RemoteStub): datastore_stub._server.Send(datastore_stub._path, payload=None) else: raise ConfigurationError('remote_api is not configured.')
null
null
null
How will a middleware function be called ?
def request_middleware(api=None): def decorator(middleware_method): apply_to_api = (hug.API(api) if api else hug.api.from_object(middleware_method)) class MiddlewareRouter(object, ): __slots__ = () def process_request(self, request, response): return middleware_method(request, response) apply_to_api.http.add_middleware(MiddlewareRouter()) return middleware_method return decorator
null
null
null
on every request
codeqa
def request middleware api None def decorator middleware method apply to api hug API api if api else hug api from object middleware method class Middleware Router object slots def process request self request response return middleware method request response apply to api http add middleware Middleware Router return middleware methodreturn decorator
null
null
null
null
Question: How will a middleware function be called ? Code: def request_middleware(api=None): def decorator(middleware_method): apply_to_api = (hug.API(api) if api else hug.api.from_object(middleware_method)) class MiddlewareRouter(object, ): __slots__ = () def process_request(self, request, response): return middleware_method(request, response) apply_to_api.http.add_middleware(MiddlewareRouter()) return middleware_method return decorator
null
null
null
What do import require ?
def enable(config): config_filename = ('/etc/nginx/sites-available/%s' % config) link_filename = ('/etc/nginx/sites-enabled/%s' % config) if (not is_link(link_filename)): run_as_root(('ln -s %(config_filename)s %(link_filename)s' % {'config_filename': quote(config_filename), 'link_filename': quote(link_filename)}))
null
null
null
require
codeqa
def enable config config filename '/etc/nginx/sites-available/%s' % config link filename '/etc/nginx/sites-enabled/%s' % config if not is link link filename run as root 'ln-s% config filename s% link filename s' % {'config filename' quote config filename 'link filename' quote link filename }
null
null
null
null
Question: What do import require ? Code: def enable(config): config_filename = ('/etc/nginx/sites-available/%s' % config) link_filename = ('/etc/nginx/sites-enabled/%s' % config) if (not is_link(link_filename)): run_as_root(('ln -s %(config_filename)s %(link_filename)s' % {'config_filename': quote(config_filename), 'link_filename': quote(link_filename)}))
null
null
null
What does the code delete ?
def delete_config(key): path = ((os.path.expanduser('~') + os.sep) + '.rainbow_config.json') try: data = load_config(path) except: raise Exception('Config file is messed up.') if ((key in data) and (key in c)): data.pop(key) c.pop(key) try: data[key] = c[key] = get_default_config(key) except: pass else: raise Exception('No such config key.') with open(path, 'w') as out: json.dump(data, out, indent=4) os.system(('chmod 777 ' + path))
null
null
null
a config key
codeqa
def delete config key path os path expanduser '~' + os sep + ' rainbow config json' try data load config path except raise Exception ' Configfileismessedup ' if key in data and key in c data pop key c pop key try data[key] c[key] get default config key except passelse raise Exception ' Nosuchconfigkey ' with open path 'w' as out json dump data out indent 4 os system 'chmod 777 ' + path
null
null
null
null
Question: What does the code delete ? Code: def delete_config(key): path = ((os.path.expanduser('~') + os.sep) + '.rainbow_config.json') try: data = load_config(path) except: raise Exception('Config file is messed up.') if ((key in data) and (key in c)): data.pop(key) c.pop(key) try: data[key] = c[key] = get_default_config(key) except: pass else: raise Exception('No such config key.') with open(path, 'w') as out: json.dump(data, out, indent=4) os.system(('chmod 777 ' + path))
null
null
null
How does the code flatten the given event ?
def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
by pre - associating format fields with specific objects
codeqa
def flatten Event event if event get 'log format' None is None returnif 'log flattened' in event fields event['log flattened']else fields {}key Flattener Key Flattener for literal Text field Name format Spec conversion in a Formatter parse event['log format'] if field Name is None continueif conversion 'r' conversion 's'flattened Key key Flattener flat Key field Name format Spec conversion structured Key key Flattener flat Key field Name format Spec '' if flattened Key in fields continueif field Name endswith u' ' field Name field Name[ -2 ]callit Trueelse callit Falsefield a Formatter get field field Name event field Value field[ 0 ]if conversion 'r' conversion Function reprelse conversion Function unicodeif callit field Value field Value flattened Value conversion Function field Value fields[flattened Key] flattened Valuefields[structured Key] field Valueif fields event['log flattened'] fields
null
null
null
null
Question: How does the code flatten the given event ? Code: def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
How do format fields associate with specific objects ?
def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
pre
codeqa
def flatten Event event if event get 'log format' None is None returnif 'log flattened' in event fields event['log flattened']else fields {}key Flattener Key Flattener for literal Text field Name format Spec conversion in a Formatter parse event['log format'] if field Name is None continueif conversion 'r' conversion 's'flattened Key key Flattener flat Key field Name format Spec conversion structured Key key Flattener flat Key field Name format Spec '' if flattened Key in fields continueif field Name endswith u' ' field Name field Name[ -2 ]callit Trueelse callit Falsefield a Formatter get field field Name event field Value field[ 0 ]if conversion 'r' conversion Function reprelse conversion Function unicodeif callit field Value field Value flattened Value conversion Function field Value fields[flattened Key] flattened Valuefields[structured Key] field Valueif fields event['log flattened'] fields
null
null
null
null
Question: How do format fields associate with specific objects ? Code: def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
What does the code flatten by pre - associating format fields with specific objects ?
def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
the given event
codeqa
def flatten Event event if event get 'log format' None is None returnif 'log flattened' in event fields event['log flattened']else fields {}key Flattener Key Flattener for literal Text field Name format Spec conversion in a Formatter parse event['log format'] if field Name is None continueif conversion 'r' conversion 's'flattened Key key Flattener flat Key field Name format Spec conversion structured Key key Flattener flat Key field Name format Spec '' if flattened Key in fields continueif field Name endswith u' ' field Name field Name[ -2 ]callit Trueelse callit Falsefield a Formatter get field field Name event field Value field[ 0 ]if conversion 'r' conversion Function reprelse conversion Function unicodeif callit field Value field Value flattened Value conversion Function field Value fields[flattened Key] flattened Valuefields[structured Key] field Valueif fields event['log flattened'] fields
null
null
null
null
Question: What does the code flatten by pre - associating format fields with specific objects ? Code: def flattenEvent(event): if (event.get('log_format', None) is None): return if ('log_flattened' in event): fields = event['log_flattened'] else: fields = {} keyFlattener = KeyFlattener() for (literalText, fieldName, formatSpec, conversion) in aFormatter.parse(event['log_format']): if (fieldName is None): continue if (conversion != 'r'): conversion = 's' flattenedKey = keyFlattener.flatKey(fieldName, formatSpec, conversion) structuredKey = keyFlattener.flatKey(fieldName, formatSpec, '') if (flattenedKey in fields): continue if fieldName.endswith(u'()'): fieldName = fieldName[:(-2)] callit = True else: callit = False field = aFormatter.get_field(fieldName, (), event) fieldValue = field[0] if (conversion == 'r'): conversionFunction = repr else: conversionFunction = unicode if callit: fieldValue = fieldValue() flattenedValue = conversionFunction(fieldValue) fields[flattenedKey] = flattenedValue fields[structuredKey] = fieldValue if fields: event['log_flattened'] = fields
null
null
null
Where did the bug report ?
def fix_IE_for_vary(request, response): useragent = request.META.get('HTTP_USER_AGENT', '').upper() if (('MSIE' not in useragent) and ('CHROMEFRAME' not in useragent)): return response safe_mime_types = ('text/html', 'text/plain', 'text/sgml') mime_type = response.get('Content-Type', '').partition(';')[0] if (mime_type not in safe_mime_types): try: del response['Vary'] except KeyError: pass return response
null
null
null
at URL
codeqa
def fix IE for vary request response useragent request META get 'HTTP USER AGENT' '' upper if 'MSIE' not in useragent and 'CHROMEFRAME' not in useragent return responsesafe mime types 'text/html' 'text/plain' 'text/sgml' mime type response get ' Content- Type' '' partition ' ' [0 ]if mime type not in safe mime types try del response[' Vary']except Key Error passreturn response
null
null
null
null
Question: Where did the bug report ? Code: def fix_IE_for_vary(request, response): useragent = request.META.get('HTTP_USER_AGENT', '').upper() if (('MSIE' not in useragent) and ('CHROMEFRAME' not in useragent)): return response safe_mime_types = ('text/html', 'text/plain', 'text/sgml') mime_type = response.get('Content-Type', '').partition(';')[0] if (mime_type not in safe_mime_types): try: del response['Vary'] except KeyError: pass return response
null
null
null
What reported at URL ?
def fix_IE_for_vary(request, response): useragent = request.META.get('HTTP_USER_AGENT', '').upper() if (('MSIE' not in useragent) and ('CHROMEFRAME' not in useragent)): return response safe_mime_types = ('text/html', 'text/plain', 'text/sgml') mime_type = response.get('Content-Type', '').partition(';')[0] if (mime_type not in safe_mime_types): try: del response['Vary'] except KeyError: pass return response
null
null
null
the bug
codeqa
def fix IE for vary request response useragent request META get 'HTTP USER AGENT' '' upper if 'MSIE' not in useragent and 'CHROMEFRAME' not in useragent return responsesafe mime types 'text/html' 'text/plain' 'text/sgml' mime type response get ' Content- Type' '' partition ' ' [0 ]if mime type not in safe mime types try del response[' Vary']except Key Error passreturn response
null
null
null
null
Question: What reported at URL ? Code: def fix_IE_for_vary(request, response): useragent = request.META.get('HTTP_USER_AGENT', '').upper() if (('MSIE' not in useragent) and ('CHROMEFRAME' not in useragent)): return response safe_mime_types = ('text/html', 'text/plain', 'text/sgml') mime_type = response.get('Content-Type', '').partition(';')[0] if (mime_type not in safe_mime_types): try: del response['Vary'] except KeyError: pass return response
null
null
null
When do time return ?
def delta_t(): ts = time() while True: t = time() (dt, ts) = ((t - ts), t) (yield dt)
null
null
null
between each call
codeqa
def delta t ts time while True t time dt ts t - ts t yield dt
null
null
null
null
Question: When do time return ? Code: def delta_t(): ts = time() while True: t = time() (dt, ts) = ((t - ts), t) (yield dt)
null
null
null
What does the code dump to a saved on - disk representation ?
def save_obj(obj, save_path): if ((save_path is None) or (len(save_path) == 0)): return save_path = os.path.expandvars(os.path.expanduser(save_path)) logger.debug('serializing object to: %s', save_path) ensure_dirs_exist(save_path) pickle.dump(obj, open(save_path, 'wb'), 2)
null
null
null
a python data structure
codeqa
def save obj obj save path if save path is None or len save path 0 returnsave path os path expandvars os path expanduser save path logger debug 'serializingobjectto %s' save path ensure dirs exist save path pickle dump obj open save path 'wb' 2
null
null
null
null
Question: What does the code dump to a saved on - disk representation ? Code: def save_obj(obj, save_path): if ((save_path is None) or (len(save_path) == 0)): return save_path = os.path.expandvars(os.path.expanduser(save_path)) logger.debug('serializing object to: %s', save_path) ensure_dirs_exist(save_path) pickle.dump(obj, open(save_path, 'wb'), 2)
null
null
null
Where does the code normalize a collection of points so that last row = 1 ?
def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
in homogeneous coordinates
codeqa
def normalize points for row in points row / points[ -1 ]return points
null
null
null
null
Question: Where does the code normalize a collection of points so that last row = 1 ? Code: def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
For what purpose does the code normalize a collection of points in homogeneous coordinates ?
def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
so that last row = 1
codeqa
def normalize points for row in points row / points[ -1 ]return points
null
null
null
null
Question: For what purpose does the code normalize a collection of points in homogeneous coordinates ? Code: def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
What does the code normalize in homogeneous coordinates so that last row = 1 ?
def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
a collection of points
codeqa
def normalize points for row in points row / points[ -1 ]return points
null
null
null
null
Question: What does the code normalize in homogeneous coordinates so that last row = 1 ? Code: def normalize(points): for row in points: row /= points[(-1)] return points
null
null
null
What did the code cast to a strictly positive integer ?
def strict_positive_int(integer_string, cutoff=None): ret = int(integer_string) if (ret <= 0): raise ValueError() if cutoff: ret = min(ret, cutoff) return ret
null
null
null
a string
codeqa
def strict positive int integer string cutoff None ret int integer string if ret < 0 raise Value Error if cutoff ret min ret cutoff return ret
null
null
null
null
Question: What did the code cast to a strictly positive integer ? Code: def strict_positive_int(integer_string, cutoff=None): ret = int(integer_string) if (ret <= 0): raise ValueError() if cutoff: ret = min(ret, cutoff) return ret
null
null
null
What does the code return ?
def read_pid_file(filename): try: (pid, port) = open(filename, 'r').readlines() (pid, port) = (int(pid), int(port)) except ValueError: try: (pid, port) = (int(open(filename, 'r').read()), None) except ValueError: (pid, port) = (None, None) return (pid, port)
null
null
null
the contents
codeqa
def read pid file filename try pid port open filename 'r' readlines pid port int pid int port except Value Error try pid port int open filename 'r' read None except Value Error pid port None None return pid port
null
null
null
null
Question: What does the code return ? Code: def read_pid_file(filename): try: (pid, port) = open(filename, 'r').readlines() (pid, port) = (int(pid), int(port)) except ValueError: try: (pid, port) = (int(open(filename, 'r').read()), None) except ValueError: (pid, port) = (None, None) return (pid, port)
null
null
null
What does the code add to outputs ?
def addSymmetricXPath(outputs, path, x): vertexes = [] loops = [getSymmetricXLoop(path, vertexes, (- x)), getSymmetricXLoop(path, vertexes, x)] outputs.append(getPillarOutput(loops))
null
null
null
x path output
codeqa
def add Symmetric X Path outputs path x vertexes []loops [get Symmetric X Loop path vertexes - x get Symmetric X Loop path vertexes x ]outputs append get Pillar Output loops
null
null
null
null
Question: What does the code add to outputs ? Code: def addSymmetricXPath(outputs, path, x): vertexes = [] loops = [getSymmetricXLoop(path, vertexes, (- x)), getSymmetricXLoop(path, vertexes, x)] outputs.append(getPillarOutput(loops))
null
null
null
What does the code decorate ?
def steps(steps_class): if hasattr(steps_class, '__init__'): _init_ = getattr(steps_class, '__init__') def init(self, *args, **kwargs): _init_(self, *args, **kwargs) STEP_REGISTRY.load_steps(self) else: def init(self, *args, **kwargs): STEP_REGISTRY.load_steps(self) setattr(steps_class, '__init__', init) return steps_class
null
null
null
a class
codeqa
def steps steps class if hasattr steps class ' init ' init getattr steps class ' init ' def init self *args **kwargs init self *args **kwargs STEP REGISTRY load steps self else def init self *args **kwargs STEP REGISTRY load steps self setattr steps class ' init ' init return steps class
null
null
null
null
Question: What does the code decorate ? Code: def steps(steps_class): if hasattr(steps_class, '__init__'): _init_ = getattr(steps_class, '__init__') def init(self, *args, **kwargs): _init_(self, *args, **kwargs) STEP_REGISTRY.load_steps(self) else: def init(self, *args, **kwargs): STEP_REGISTRY.load_steps(self) setattr(steps_class, '__init__', init) return steps_class
null
null
null
What does the code make from start to end ?
def linear_gradient(start, end, nbins, eps=1e-10): start = array(start) end = array(end) result = [] n_minus_1 = max(float((nbins - 1)), eps) for i in range(nbins): result.append(list((((start * (n_minus_1 - i)) / n_minus_1) + (end * (i / n_minus_1))))) return result
null
null
null
linear color gradient
codeqa
def linear gradient start end nbins eps 1e- 10 start array start end array end result []n minus 1 max float nbins - 1 eps for i in range nbins result append list start * n minus 1 - i / n minus 1 + end * i / n minus 1 return result
null
null
null
null
Question: What does the code make from start to end ? Code: def linear_gradient(start, end, nbins, eps=1e-10): start = array(start) end = array(end) result = [] n_minus_1 = max(float((nbins - 1)), eps) for i in range(nbins): result.append(list((((start * (n_minus_1 - i)) / n_minus_1) + (end * (i / n_minus_1))))) return result
null
null
null
What does the code extract ?
def scan_postfix_submission_line(date, log, collector): m = re.match('([A-Z0-9]+): client=(\\S+), sasl_method=PLAIN, sasl_username=(\\S+)', log) if m: collector['activity-by-hour']['smtp-sends'][date.hour] += 1
null
null
null
interesting data
codeqa
def scan postfix submission line date log collector m re match ' [A-Z 0 - 9 ]+ client \\S+ sasl method PLAIN sasl username \\S+ ' log if m collector['activity-by-hour']['smtp-sends'][date hour] + 1
null
null
null
null
Question: What does the code extract ? Code: def scan_postfix_submission_line(date, log, collector): m = re.match('([A-Z0-9]+): client=(\\S+), sasl_method=PLAIN, sasl_username=(\\S+)', log) if m: collector['activity-by-hour']['smtp-sends'][date.hour] += 1
null
null
null
What did the code read ?
def read_cz_lsm_time_stamps(fh): (size, count) = struct.unpack('<ii', fh.read(8)) if (size != (8 + (8 * count))): raise ValueError('lsm_time_stamps block is too short') return fh.read_array('<f8', count=count)
null
null
null
lsm time stamps
codeqa
def read cz lsm time stamps fh size count struct unpack '<ii' fh read 8 if size 8 + 8 * count raise Value Error 'lsm time stampsblockistooshort' return fh read array '<f 8 ' count count
null
null
null
null
Question: What did the code read ? Code: def read_cz_lsm_time_stamps(fh): (size, count) = struct.unpack('<ii', fh.read(8)) if (size != (8 + (8 * count))): raise ValueError('lsm_time_stamps block is too short') return fh.read_array('<f8', count=count)
null
null
null
What does the code decode ?
def urlsafe_b64decode(s): return b64decode(s.translate(_urlsafe_decode_translation))
null
null
null
a string encoded with the standard base64 alphabet
codeqa
def urlsafe b64 decode s return b64 decode s translate urlsafe decode translation
null
null
null
null
Question: What does the code decode ? Code: def urlsafe_b64decode(s): return b64decode(s.translate(_urlsafe_decode_translation))
null
null
null
How did a string encode ?
def urlsafe_b64decode(s): return b64decode(s.translate(_urlsafe_decode_translation))
null
null
null
with the standard base64 alphabet
codeqa
def urlsafe b64 decode s return b64 decode s translate urlsafe decode translation
null
null
null
null
Question: How did a string encode ? Code: def urlsafe_b64decode(s): return b64decode(s.translate(_urlsafe_decode_translation))
null
null
null
What does the code fail if given object is ?
def assert_none(obj, msg=None, values=True): _msg = ('%r is not None' % obj) if (obj is not None): if (msg is None): msg = _msg elif (values is True): msg = ('%s: %s' % (msg, _msg)) _report_failure(msg)
null
null
null
the test
codeqa
def assert none obj msg None values True msg '%risnot None' % obj if obj is not None if msg is None msg msgelif values is True msg '%s %s' % msg msg report failure msg
null
null
null
null
Question: What does the code fail if given object is ? Code: def assert_none(obj, msg=None, values=True): _msg = ('%r is not None' % obj) if (obj is not None): if (msg is None): msg = _msg elif (values is True): msg = ('%s: %s' % (msg, _msg)) _report_failure(msg)
null
null
null
What dumps the environment ?
def test_app(environ, start_response): req = Request(environ, populate_request=False) if (req.args.get('resource') == 'logo'): response = logo else: response = Response(render_testapp(req), mimetype='text/html') return response(environ, start_response)
null
null
null
simple test application
codeqa
def test app environ start response req Request environ populate request False if req args get 'resource' 'logo' response logoelse response Response render testapp req mimetype 'text/html' return response environ start response
null
null
null
null
Question: What dumps the environment ? Code: def test_app(environ, start_response): req = Request(environ, populate_request=False) if (req.args.get('resource') == 'logo'): response = logo else: response = Response(render_testapp(req), mimetype='text/html') return response(environ, start_response)
null
null
null
What does simple test application dump ?
def test_app(environ, start_response): req = Request(environ, populate_request=False) if (req.args.get('resource') == 'logo'): response = logo else: response = Response(render_testapp(req), mimetype='text/html') return response(environ, start_response)
null
null
null
the environment
codeqa
def test app environ start response req Request environ populate request False if req args get 'resource' 'logo' response logoelse response Response render testapp req mimetype 'text/html' return response environ start response
null
null
null
null
Question: What does simple test application dump ? Code: def test_app(environ, start_response): req = Request(environ, populate_request=False) if (req.args.get('resource') == 'logo'): response = logo else: response = Response(render_testapp(req), mimetype='text/html') return response(environ, start_response)
null
null
null
What do resource formats contain ?
@logic.validate(logic.schema.default_autocomplete_schema) def format_autocomplete(context, data_dict): model = context['model'] session = context['session'] _check_access('format_autocomplete', context, data_dict) q = data_dict['q'] limit = data_dict.get('limit', 5) like_q = ((u'%' + q) + u'%') query = session.query(model.Resource.format, _func.count(model.Resource.format).label('total')).filter(_and_((model.Resource.state == 'active'))).filter(model.Resource.format.ilike(like_q)).group_by(model.Resource.format).order_by('total DESC').limit(limit) return [resource.format.lower() for resource in query]
null
null
null
a string
codeqa
@logic validate logic schema default autocomplete schema def format autocomplete context data dict model context['model']session context['session'] check access 'format autocomplete' context data dict q data dict['q']limit data dict get 'limit' 5 like q u'%' + q + u'%' query session query model Resource format func count model Resource format label 'total' filter and model Resource state 'active' filter model Resource format ilike like q group by model Resource format order by 'total DESC' limit limit return [resource format lower for resource in query]
null
null
null
null
Question: What do resource formats contain ? Code: @logic.validate(logic.schema.default_autocomplete_schema) def format_autocomplete(context, data_dict): model = context['model'] session = context['session'] _check_access('format_autocomplete', context, data_dict) q = data_dict['q'] limit = data_dict.get('limit', 5) like_q = ((u'%' + q) + u'%') query = session.query(model.Resource.format, _func.count(model.Resource.format).label('total')).filter(_and_((model.Resource.state == 'active'))).filter(model.Resource.format.ilike(like_q)).group_by(model.Resource.format).order_by('total DESC').limit(limit) return [resource.format.lower() for resource in query]
null
null
null
What contain a string ?
@logic.validate(logic.schema.default_autocomplete_schema) def format_autocomplete(context, data_dict): model = context['model'] session = context['session'] _check_access('format_autocomplete', context, data_dict) q = data_dict['q'] limit = data_dict.get('limit', 5) like_q = ((u'%' + q) + u'%') query = session.query(model.Resource.format, _func.count(model.Resource.format).label('total')).filter(_and_((model.Resource.state == 'active'))).filter(model.Resource.format.ilike(like_q)).group_by(model.Resource.format).order_by('total DESC').limit(limit) return [resource.format.lower() for resource in query]
null
null
null
resource formats
codeqa
@logic validate logic schema default autocomplete schema def format autocomplete context data dict model context['model']session context['session'] check access 'format autocomplete' context data dict q data dict['q']limit data dict get 'limit' 5 like q u'%' + q + u'%' query session query model Resource format func count model Resource format label 'total' filter and model Resource state 'active' filter model Resource format ilike like q group by model Resource format order by 'total DESC' limit limit return [resource format lower for resource in query]
null
null
null
null
Question: What contain a string ? Code: @logic.validate(logic.schema.default_autocomplete_schema) def format_autocomplete(context, data_dict): model = context['model'] session = context['session'] _check_access('format_autocomplete', context, data_dict) q = data_dict['q'] limit = data_dict.get('limit', 5) like_q = ((u'%' + q) + u'%') query = session.query(model.Resource.format, _func.count(model.Resource.format).label('total')).filter(_and_((model.Resource.state == 'active'))).filter(model.Resource.format.ilike(like_q)).group_by(model.Resource.format).order_by('total DESC').limit(limit) return [resource.format.lower() for resource in query]
null
null
null
What does the code add ?
@web.app.route('/content-length') def total_content_length(): return ('Total content-length recieved: %i' % stats['content-length'])
null
null
null
a route to the locust web app
codeqa
@web app route '/content-length' def total content length return ' Totalcontent-lengthrecieved %i' % stats['content-length']
null
null
null
null
Question: What does the code add ? Code: @web.app.route('/content-length') def total_content_length(): return ('Total content-length recieved: %i' % stats['content-length'])
null
null
null
What archives on an update operation ?
@receiver(pre_save, sender=Microsite) def on_microsite_updated(sender, instance, **kwargs): if instance.id: original = Microsite.objects.get(id=instance.id) _make_archive_copy(original)
null
null
null
the microsite
codeqa
@receiver pre save sender Microsite def on microsite updated sender instance **kwargs if instance id original Microsite objects get id instance id make archive copy original
null
null
null
null
Question: What archives on an update operation ? Code: @receiver(pre_save, sender=Microsite) def on_microsite_updated(sender, instance, **kwargs): if instance.id: original = Microsite.objects.get(id=instance.id) _make_archive_copy(original)
null
null
null
What limited to the given type in the course ?
def query_for_course(course_key, category=None): if getattr(course_key, 'deprecated', False): prefix = '_id' else: prefix = 'content_son' dbkey = SON([('{}.tag'.format(prefix), XASSET_LOCATION_TAG), ('{}.org'.format(prefix), course_key.org), ('{}.course'.format(prefix), course_key.course)]) if category: dbkey['{}.category'.format(prefix)] = category if getattr(course_key, 'deprecated', False): dbkey['{}.run'.format(prefix)] = {'$exists': False} else: dbkey['{}.run'.format(prefix)] = course_key.run return dbkey
null
null
null
all assets
codeqa
def query for course course key category None if getattr course key 'deprecated' False prefix ' id'else prefix 'content son'dbkey SON [ '{} tag' format prefix XASSET LOCATION TAG '{} org' format prefix course key org '{} course' format prefix course key course ] if category dbkey['{} category' format prefix ] categoryif getattr course key 'deprecated' False dbkey['{} run' format prefix ] {'$exists' False}else dbkey['{} run' format prefix ] course key runreturn dbkey
null
null
null
null
Question: What limited to the given type in the course ? Code: def query_for_course(course_key, category=None): if getattr(course_key, 'deprecated', False): prefix = '_id' else: prefix = 'content_son' dbkey = SON([('{}.tag'.format(prefix), XASSET_LOCATION_TAG), ('{}.org'.format(prefix), course_key.org), ('{}.course'.format(prefix), course_key.course)]) if category: dbkey['{}.category'.format(prefix)] = category if getattr(course_key, 'deprecated', False): dbkey['{}.run'.format(prefix)] = {'$exists': False} else: dbkey['{}.run'.format(prefix)] = course_key.run return dbkey
null
null
null
What does the code get from epochs ?
def _get_data(inst, return_itc): from ..epochs import BaseEpochs from ..evoked import Evoked if (not isinstance(inst, (BaseEpochs, Evoked))): raise TypeError('inst must be Epochs or Evoked') if isinstance(inst, BaseEpochs): data = inst.get_data() else: if return_itc: raise ValueError('return_itc must be False for evoked data') data = inst.data[np.newaxis, ...].copy() return data
null
null
null
data
codeqa
def get data inst return itc from epochs import Base Epochsfrom evoked import Evokedif not isinstance inst Base Epochs Evoked raise Type Error 'instmustbe Epochsor Evoked' if isinstance inst Base Epochs data inst get data else if return itc raise Value Error 'return itcmustbe Falseforevokeddata' data inst data[np newaxis ] copy return data
null
null
null
null
Question: What does the code get from epochs ? Code: def _get_data(inst, return_itc): from ..epochs import BaseEpochs from ..evoked import Evoked if (not isinstance(inst, (BaseEpochs, Evoked))): raise TypeError('inst must be Epochs or Evoked') if isinstance(inst, BaseEpochs): data = inst.get_data() else: if return_itc: raise ValueError('return_itc must be False for evoked data') data = inst.data[np.newaxis, ...].copy() return data
null
null
null
How did server delete ?
@utils.arg('server', metavar='<server>', help='Name or ID of server.') def do_restore(cs, args): utils.find_resource(cs.servers, args.server, deleted=True).restore()
null
null
null
soft
codeqa
@utils arg 'server' metavar '<server>' help ' Nameor I Dofserver ' def do restore cs args utils find resource cs servers args server deleted True restore
null
null
null
null
Question: How did server delete ? Code: @utils.arg('server', metavar='<server>', help='Name or ID of server.') def do_restore(cs, args): utils.find_resource(cs.servers, args.server, deleted=True).restore()
null
null
null
What does the code restore ?
@utils.arg('server', metavar='<server>', help='Name or ID of server.') def do_restore(cs, args): utils.find_resource(cs.servers, args.server, deleted=True).restore()
null
null
null
a soft - deleted server
codeqa
@utils arg 'server' metavar '<server>' help ' Nameor I Dofserver ' def do restore cs args utils find resource cs servers args server deleted True restore
null
null
null
null
Question: What does the code restore ? Code: @utils.arg('server', metavar='<server>', help='Name or ID of server.') def do_restore(cs, args): utils.find_resource(cs.servers, args.server, deleted=True).restore()
null
null
null
What does the code create from ?
def dict2str(data): result = '' for k in data: if (data[k] is not None): result += ('%s %s\n' % (str(k), str(data[k]))) else: result += ('%s\n' % str(k)) return result
null
null
null
a string with a whitespace and newline delimited text
codeqa
def dict 2 str data result ''for k in data if data[k] is not None result + '%s%s\n' % str k str data[k] else result + '%s\n' % str k return result
null
null
null
null
Question: What does the code create from ? Code: def dict2str(data): result = '' for k in data: if (data[k] is not None): result += ('%s %s\n' % (str(k), str(data[k]))) else: result += ('%s\n' % str(k)) return result
null
null
null
What does the code get ?
def getNewMouseTool(): return ViewpointRotate()
null
null
null
a new mouse tool
codeqa
def get New Mouse Tool return Viewpoint Rotate
null
null
null
null
Question: What does the code get ? Code: def getNewMouseTool(): return ViewpointRotate()
null
null
null
How did a vector field compute symbols of the given frame ?
def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
wrt the coordinate
codeqa
def divergence vect frame check vector vect if vect 0 return S 0 vect express vect frame variables True vectx vect dot frame x vecty vect dot frame y vectz vect dot frame z out S 0 out + diff vectx frame[ 0 ] out + diff vecty frame[ 1 ] out + diff vectz frame[ 2 ] return out
null
null
null
null
Question: How did a vector field compute symbols of the given frame ? Code: def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
What computed symbols of the given frame ?
def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
a vector field
codeqa
def divergence vect frame check vector vect if vect 0 return S 0 vect express vect frame variables True vectx vect dot frame x vecty vect dot frame y vectz vect dot frame z out S 0 out + diff vectx frame[ 0 ] out + diff vecty frame[ 1 ] out + diff vectz frame[ 2 ] return out
null
null
null
null
Question: What computed symbols of the given frame ? Code: def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
Where did a vector field compute wrt the coordinate ?
def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
symbols of the given frame
codeqa
def divergence vect frame check vector vect if vect 0 return S 0 vect express vect frame variables True vectx vect dot frame x vecty vect dot frame y vectz vect dot frame z out S 0 out + diff vectx frame[ 0 ] out + diff vecty frame[ 1 ] out + diff vectz frame[ 2 ] return out
null
null
null
null
Question: Where did a vector field compute wrt the coordinate ? Code: def divergence(vect, frame): _check_vector(vect) if (vect == 0): return S(0) vect = express(vect, frame, variables=True) vectx = vect.dot(frame.x) vecty = vect.dot(frame.y) vectz = vect.dot(frame.z) out = S(0) out += diff(vectx, frame[0]) out += diff(vecty, frame[1]) out += diff(vectz, frame[2]) return out
null
null
null
How do a test skip ?
def skip(reason): def decorator(test_item): if (not (isinstance(test_item, type) and issubclass(test_item, TestCase))): @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): raise SkipTest(reason) test_item = skip_wrapper test_item.__unittest_skip__ = True test_item.__unittest_skip_why__ = reason return test_item return decorator
null
null
null
unconditionally
codeqa
def skip reason def decorator test item if not isinstance test item type and issubclass test item Test Case @functools wraps test item def skip wrapper *args **kwargs raise Skip Test reason test item skip wrappertest item unittest skip Truetest item unittest skip why reasonreturn test itemreturn decorator
null
null
null
null
Question: How do a test skip ? Code: def skip(reason): def decorator(test_item): if (not (isinstance(test_item, type) and issubclass(test_item, TestCase))): @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): raise SkipTest(reason) test_item = skip_wrapper test_item.__unittest_skip__ = True test_item.__unittest_skip_why__ = reason return test_item return decorator
null
null
null
How did a string save ?
def pixmap_to_data(pixmap, format='JPEG', quality=90): ba = QByteArray() buf = QBuffer(ba) buf.open(QBuffer.WriteOnly) pixmap.save(buf, format, quality=quality) return bytes(ba.data())
null
null
null
in the specified format
codeqa
def pixmap to data pixmap format 'JPEG' quality 90 ba Q Byte Array buf Q Buffer ba buf open Q Buffer Write Only pixmap save buf format quality quality return bytes ba data
null
null
null
null
Question: How did a string save ? Code: def pixmap_to_data(pixmap, format='JPEG', quality=90): ba = QByteArray() buf = QBuffer(ba) buf.open(QBuffer.WriteOnly) pixmap.save(buf, format, quality=quality) return bytes(ba.data())
null
null
null
For what purpose do bytes convert ?
def to_unit(value, unit): return (value / (1024 ** BYTE_SIZES.index(unit)))
null
null
null
to give unit
codeqa
def to unit value unit return value / 1024 ** BYTE SIZES index unit
null
null
null
null
Question: For what purpose do bytes convert ? Code: def to_unit(value, unit): return (value / (1024 ** BYTE_SIZES.index(unit)))
null
null
null
What does the code get ?
def get_telemetry_data(request, indent=None): admin_user = User.objects.first() data_dict = {'daily_data': get_daily_data(now()), 'apps': settings.INSTALLED_APPS, 'debug': settings.DEBUG, 'host': (request.get_host() if request else None), 'key': get_installation_key(), 'machine': platform.machine(), 'admin_user': (admin_user.email if admin_user else None), 'last_login': (admin_user.last_login if admin_user else None), 'platform': platform.platform(), 'python_version': sys.version, 'shuup_version': shuup.__version__} return safe_json(data_dict, indent)
null
null
null
the telemetry data that would be sent
codeqa
def get telemetry data request indent None admin user User objects first data dict {'daily data' get daily data now 'apps' settings INSTALLED APPS 'debug' settings DEBUG 'host' request get host if request else None 'key' get installation key 'machine' platform machine 'admin user' admin user email if admin user else None 'last login' admin user last login if admin user else None 'platform' platform platform 'python version' sys version 'shuup version' shuup version }return safe json data dict indent
null
null
null
null
Question: What does the code get ? Code: def get_telemetry_data(request, indent=None): admin_user = User.objects.first() data_dict = {'daily_data': get_daily_data(now()), 'apps': settings.INSTALLED_APPS, 'debug': settings.DEBUG, 'host': (request.get_host() if request else None), 'key': get_installation_key(), 'machine': platform.machine(), 'admin_user': (admin_user.email if admin_user else None), 'last_login': (admin_user.last_login if admin_user else None), 'platform': platform.platform(), 'python_version': sys.version, 'shuup_version': shuup.__version__} return safe_json(data_dict, indent)
null
null
null
which organization preview of posts ?
@require_POST @login_required def preview_async(request): statsd.incr('forums.preview') m = OutboxMessage(sender=request.user, message=request.POST.get('content', '')) return render(request, 'messages/includes/message_preview.html', {'message': m})
null
null
null
ajax
codeqa
@require POST@login requireddef preview async request statsd incr 'forums preview' m Outbox Message sender request user message request POST get 'content' '' return render request 'messages/includes/message preview html' {'message' m}
null
null
null
null
Question: which organization preview of posts ? Code: @require_POST @login_required def preview_async(request): statsd.incr('forums.preview') m = OutboxMessage(sender=request.user, message=request.POST.get('content', '')) return render(request, 'messages/includes/message_preview.html', {'message': m})
null
null
null
What does the code save ?
@should_dump_processes def stop_process_dump(): cancel_thread(SAVE_PROCESS_PTR) dump_processes()
null
null
null
profiling information
codeqa
@should dump processesdef stop process dump cancel thread SAVE PROCESS PTR dump processes
null
null
null
null
Question: What does the code save ? Code: @should_dump_processes def stop_process_dump(): cancel_thread(SAVE_PROCESS_PTR) dump_processes()
null
null
null
What used to sort top 250/bottom 10 rank ?
def _cmpBottom(a, b): return _cmpTop(a, b, what='bottom 10 rank')
null
null
null
function
codeqa
def cmp Bottom a b return cmp Top a b what 'bottom 10 rank'
null
null
null
null
Question: What used to sort top 250/bottom 10 rank ? Code: def _cmpBottom(a, b): return _cmpTop(a, b, what='bottom 10 rank')
null
null
null
What did function use ?
def _cmpBottom(a, b): return _cmpTop(a, b, what='bottom 10 rank')
null
null
null
to sort top 250/bottom 10 rank
codeqa
def cmp Bottom a b return cmp Top a b what 'bottom 10 rank'
null
null
null
null
Question: What did function use ? Code: def _cmpBottom(a, b): return _cmpTop(a, b, what='bottom 10 rank')
null
null
null
What is containing msg ?
def email(to_email, msg, from_email=None): assert (_smtp is not None), 'Either gmail_login or smtp_login must be called to setup an smtplib.SMTP instance.' from_email_ = '' if (from_email is not None): from_email_ = from_email elif (_email_from is not None): from_email_ = _email_from headers = [('To: %s' % to_email), ('From: %s' % from_email_), 'Subject: nflgame alert'] full_msg = ('%s\r\n\r\n%s' % ('\r\n'.join(headers), msg)) _send_email(from_email_, to_email, full_msg)
null
null
null
a message
codeqa
def email to email msg from email None assert smtp is not None ' Eithergmail loginorsmtp loginmustbecalledtosetupansmtplib SMT Pinstance 'from email ''if from email is not None from email from emailelif email from is not None from email email fromheaders [ ' To %s' % to email ' From %s' % from email ' Subject nflgamealert']full msg '%s\r\n\r\n%s' % '\r\n' join headers msg send email from email to email full msg
null
null
null
null
Question: What is containing msg ? Code: def email(to_email, msg, from_email=None): assert (_smtp is not None), 'Either gmail_login or smtp_login must be called to setup an smtplib.SMTP instance.' from_email_ = '' if (from_email is not None): from_email_ = from_email elif (_email_from is not None): from_email_ = _email_from headers = [('To: %s' % to_email), ('From: %s' % from_email_), 'Subject: nflgame alert'] full_msg = ('%s\r\n\r\n%s' % ('\r\n'.join(headers), msg)) _send_email(from_email_, to_email, full_msg)
null
null
null
What does an email send with a message containing msg ?
def email(to_email, msg, from_email=None): assert (_smtp is not None), 'Either gmail_login or smtp_login must be called to setup an smtplib.SMTP instance.' from_email_ = '' if (from_email is not None): from_email_ = from_email elif (_email_from is not None): from_email_ = _email_from headers = [('To: %s' % to_email), ('From: %s' % from_email_), 'Subject: nflgame alert'] full_msg = ('%s\r\n\r\n%s' % ('\r\n'.join(headers), msg)) _send_email(from_email_, to_email, full_msg)
null
null
null
to to_email
codeqa
def email to email msg from email None assert smtp is not None ' Eithergmail loginorsmtp loginmustbecalledtosetupansmtplib SMT Pinstance 'from email ''if from email is not None from email from emailelif email from is not None from email email fromheaders [ ' To %s' % to email ' From %s' % from email ' Subject nflgamealert']full msg '%s\r\n\r\n%s' % '\r\n' join headers msg send email from email to email full msg
null
null
null
null
Question: What does an email send with a message containing msg ? Code: def email(to_email, msg, from_email=None): assert (_smtp is not None), 'Either gmail_login or smtp_login must be called to setup an smtplib.SMTP instance.' from_email_ = '' if (from_email is not None): from_email_ = from_email elif (_email_from is not None): from_email_ = _email_from headers = [('To: %s' % to_email), ('From: %s' % from_email_), 'Subject: nflgame alert'] full_msg = ('%s\r\n\r\n%s' % ('\r\n'.join(headers), msg)) _send_email(from_email_, to_email, full_msg)
null
null
null
What generates on all images ?
def imdb_proposals(net, imdb): _t = Timer() imdb_boxes = [[] for _ in xrange(imdb.num_images)] for i in xrange(imdb.num_images): im = cv2.imread(imdb.image_path_at(i)) _t.tic() (imdb_boxes[i], scores) = im_proposals(net, im) _t.toc() print 'im_proposals: {:d}/{:d} {:.3f}s'.format((i + 1), imdb.num_images, _t.average_time) if 0: dets = np.hstack((imdb_boxes[i], scores)) _vis_proposals(im, dets[:3, :], thresh=0.9) plt.show() return imdb_boxes
null
null
null
rpn proposals
codeqa
def imdb proposals net imdb t Timer imdb boxes [[] for in xrange imdb num images ]for i in xrange imdb num images im cv 2 imread imdb image path at i t tic imdb boxes[i] scores im proposals net im t toc print 'im proposals { d}/{ d}{ 3f}s' format i + 1 imdb num images t average time if 0 dets np hstack imdb boxes[i] scores vis proposals im dets[ 3 ] thresh 0 9 plt show return imdb boxes
null
null
null
null
Question: What generates on all images ? Code: def imdb_proposals(net, imdb): _t = Timer() imdb_boxes = [[] for _ in xrange(imdb.num_images)] for i in xrange(imdb.num_images): im = cv2.imread(imdb.image_path_at(i)) _t.tic() (imdb_boxes[i], scores) = im_proposals(net, im) _t.toc() print 'im_proposals: {:d}/{:d} {:.3f}s'.format((i + 1), imdb.num_images, _t.average_time) if 0: dets = np.hstack((imdb_boxes[i], scores)) _vis_proposals(im, dets[:3, :], thresh=0.9) plt.show() return imdb_boxes
null
null
null
For what purpose do string trim ?
def trim(s): return (s if (len(s) <= 80) else (s[:77] + '...'))
null
null
null
to fit on terminal
codeqa
def trim s return s if len s < 80 else s[ 77 ] + ' '
null
null
null
null
Question: For what purpose do string trim ? Code: def trim(s): return (s if (len(s) <= 80) else (s[:77] + '...'))
null
null
null
What is a dictionary of all the parameters for the media range the ?
def parse_media_range(range): (type, subtype, params) = parse_mime_type(range) try: if (not (0 <= float(params['q']) <= 1)): raise ValueError except (KeyError, ValueError): params['q'] = '1' return (type, subtype, params)
null
null
null
params
codeqa
def parse media range range type subtype params parse mime type range try if not 0 < float params['q'] < 1 raise Value Errorexcept Key Error Value Error params['q'] '1 'return type subtype params
null
null
null
null
Question: What is a dictionary of all the parameters for the media range the ? Code: def parse_media_range(range): (type, subtype, params) = parse_mime_type(range) try: if (not (0 <= float(params['q']) <= 1)): raise ValueError except (KeyError, ValueError): params['q'] = '1' return (type, subtype, params)
null
null
null
How does the code build a sequential tower starting from inputs ?
def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
by using an op repeatedly
codeqa
def repeat op repetitions inputs op *args **kwargs scope kwargs pop 'scope' None with tf variable scope scope ' Repeat Op' [inputs] tower inputsfor in range repetitions tower op tower *args **kwargs return tower
null
null
null
null
Question: How does the code build a sequential tower starting from inputs ? Code: def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
When do an op use ?
def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
repeatedly
codeqa
def repeat op repetitions inputs op *args **kwargs scope kwargs pop 'scope' None with tf variable scope scope ' Repeat Op' [inputs] tower inputsfor in range repetitions tower op tower *args **kwargs return tower
null
null
null
null
Question: When do an op use ? Code: def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
What does the code build starting from inputs by using an op repeatedly ?
def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
a sequential tower
codeqa
def repeat op repetitions inputs op *args **kwargs scope kwargs pop 'scope' None with tf variable scope scope ' Repeat Op' [inputs] tower inputsfor in range repetitions tower op tower *args **kwargs return tower
null
null
null
null
Question: What does the code build starting from inputs by using an op repeatedly ? Code: def repeat_op(repetitions, inputs, op, *args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope, 'RepeatOp', [inputs]): tower = inputs for _ in range(repetitions): tower = op(tower, *args, **kwargs) return tower
null
null
null
Where does the code expand ~ ?
def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
in paths
codeqa
def finish common config encoding common config encoding encoding lower default top theme get default theme encoding startswith u'utf' or encoding startswith u'ucs' common config common config copy common config setdefault u'default top theme' default top theme common config setdefault u'paths' [] common config setdefault u'watcher' u'auto' common config setdefault u'log level' u'WARNING' common config setdefault u'log format' u'% asctime s % levelname s % message s' common config setdefault u'term truecolor' False common config setdefault u'term escape style' u'auto' common config setdefault u'ambiwidth' 1 common config setdefault u'additional escapes' None common config setdefault u'reload config' True common config setdefault u'interval' None common config setdefault u'log file' [ None] if not isinstance common config[u'log file'] list common config[u'log file'] [common config[u'log file']]common config[u'paths'] [os path expanduser path for path in common config[u'paths']]return common config
null
null
null
null
Question: Where does the code expand ~ ? Code: def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
What does the code add to common config ?
def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
default values
codeqa
def finish common config encoding common config encoding encoding lower default top theme get default theme encoding startswith u'utf' or encoding startswith u'ucs' common config common config copy common config setdefault u'default top theme' default top theme common config setdefault u'paths' [] common config setdefault u'watcher' u'auto' common config setdefault u'log level' u'WARNING' common config setdefault u'log format' u'% asctime s % levelname s % message s' common config setdefault u'term truecolor' False common config setdefault u'term escape style' u'auto' common config setdefault u'ambiwidth' 1 common config setdefault u'additional escapes' None common config setdefault u'reload config' True common config setdefault u'interval' None common config setdefault u'log file' [ None] if not isinstance common config[u'log file'] list common config[u'log file'] [common config[u'log file']]common config[u'paths'] [os path expanduser path for path in common config[u'paths']]return common config
null
null
null
null
Question: What does the code add to common config ? Code: def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
In which direction does the code expand in paths ?
def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
~
codeqa
def finish common config encoding common config encoding encoding lower default top theme get default theme encoding startswith u'utf' or encoding startswith u'ucs' common config common config copy common config setdefault u'default top theme' default top theme common config setdefault u'paths' [] common config setdefault u'watcher' u'auto' common config setdefault u'log level' u'WARNING' common config setdefault u'log format' u'% asctime s % levelname s % message s' common config setdefault u'term truecolor' False common config setdefault u'term escape style' u'auto' common config setdefault u'ambiwidth' 1 common config setdefault u'additional escapes' None common config setdefault u'reload config' True common config setdefault u'interval' None common config setdefault u'log file' [ None] if not isinstance common config[u'log file'] list common config[u'log file'] [common config[u'log file']]common config[u'paths'] [os path expanduser path for path in common config[u'paths']]return common config
null
null
null
null
Question: In which direction does the code expand in paths ? Code: def finish_common_config(encoding, common_config): encoding = encoding.lower() default_top_theme = get_default_theme((encoding.startswith(u'utf') or encoding.startswith(u'ucs'))) common_config = common_config.copy() common_config.setdefault(u'default_top_theme', default_top_theme) common_config.setdefault(u'paths', []) common_config.setdefault(u'watcher', u'auto') common_config.setdefault(u'log_level', u'WARNING') common_config.setdefault(u'log_format', u'%(asctime)s:%(levelname)s:%(message)s') common_config.setdefault(u'term_truecolor', False) common_config.setdefault(u'term_escape_style', u'auto') common_config.setdefault(u'ambiwidth', 1) common_config.setdefault(u'additional_escapes', None) common_config.setdefault(u'reload_config', True) common_config.setdefault(u'interval', None) common_config.setdefault(u'log_file', [None]) if (not isinstance(common_config[u'log_file'], list)): common_config[u'log_file'] = [common_config[u'log_file']] common_config[u'paths'] = [os.path.expanduser(path) for path in common_config[u'paths']] return common_config
null
null
null
When do a denoising autoencoder train code ?
def test_dae_yaml(): limited_epoch_train(os.path.join(pylearn2.__path__[0], 'scripts/autoencoder_example/dae.yaml'))
null
null
null
for a single epoch
codeqa
def test dae yaml limited epoch train os path join pylearn 2 path [0 ] 'scripts/autoencoder example/dae yaml'
null
null
null
null
Question: When do a denoising autoencoder train code ? Code: def test_dae_yaml(): limited_epoch_train(os.path.join(pylearn2.__path__[0], 'scripts/autoencoder_example/dae.yaml'))
null
null
null
What does the code get ?
def getEndGeometryXMLString(output): addEndXMLTag('fabmetheus', 0, output) return output.getvalue()
null
null
null
the string representation of this object info
codeqa
def get End Geometry XML String output add End XML Tag 'fabmetheus' 0 output return output getvalue
null
null
null
null
Question: What does the code get ? Code: def getEndGeometryXMLString(output): addEndXMLTag('fabmetheus', 0, output) return output.getvalue()
null
null
null
What does the code get ?
def _get_index(names, key): if _is_int(key): indx = int(key) elif isinstance(key, string_types): try: indx = names.index(key.rstrip()) except ValueError: _key = key.lower().rstrip() names = [n.lower().rstrip() for n in names] count = names.count(_key) if (count == 1): indx = names.index(_key) elif (count == 0): raise KeyError("Key '{}' does not exist.".format(key)) else: raise KeyError("Ambiguous key name '{}'.".format(key)) else: raise KeyError("Illegal key '{}'.".format(repr(key))) return indx
null
null
null
the index of the key in the names list
codeqa
def get index names key if is int key indx int key elif isinstance key string types try indx names index key rstrip except Value Error key key lower rstrip names [n lower rstrip for n in names]count names count key if count 1 indx names index key elif count 0 raise Key Error " Key'{}'doesnotexist " format key else raise Key Error " Ambiguouskeyname'{}' " format key else raise Key Error " Illegalkey'{}' " format repr key return indx
null
null
null
null
Question: What does the code get ? Code: def _get_index(names, key): if _is_int(key): indx = int(key) elif isinstance(key, string_types): try: indx = names.index(key.rstrip()) except ValueError: _key = key.lower().rstrip() names = [n.lower().rstrip() for n in names] count = names.count(_key) if (count == 1): indx = names.index(_key) elif (count == 0): raise KeyError("Key '{}' does not exist.".format(key)) else: raise KeyError("Ambiguous key name '{}'.".format(key)) else: raise KeyError("Illegal key '{}'.".format(repr(key))) return indx
null
null
null
What do you handle at the level of the root logger ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
logging yourself
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: What do you handle at the level of the root logger ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
Where do you handle logging yourself ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
at the level of the root logger
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: Where do you handle logging yourself ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
What are you embedding in a larger application ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
our library
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: What are you embedding in a larger application ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
Where do you log yourself ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
at the level of the root logger
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: Where do you log yourself ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
What do you wish ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
to handle logging yourself at the level of the root logger
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: What do you wish ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
What do you log at the level of the root logger ?
def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
yourself
codeqa
def restore defaults top level logger logging get Logger name split ' ' [0 ] top level logger propagate Truetop level logger set Level logging NOTSET while top level logger handlers top level logger handlers pop
null
null
null
null
Question: What do you log at the level of the root logger ? Code: def restore_defaults(): top_level_logger = logging.getLogger(__name__.split('.')[0]) top_level_logger.propagate = True top_level_logger.setLevel(logging.NOTSET) while top_level_logger.handlers: top_level_logger.handlers.pop()
null
null
null
What does the code ensure ?
def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
that the marathon app with the given i d is present and is configured to match the given config values
codeqa
def config name config ret {'name' name 'changes' {} 'result' False 'comment' ''}existing config Noneif salt ['marathon has app'] name existing config salt ['marathon app'] name ['app']if existing config update config copy deepcopy existing config salt utils configcomparer compare and update config config update config ret['changes'] else ret['changes']['app'] {'new' config 'old' None}update config configif ret['changes'] if opts ['test'] ret['result'] Noneret['comment'] ' Marathonapp{ 0 }issettobeupdated' format name return retupdate result salt ['marathon update app'] name update config if 'exception' in update result ret['result'] Falseret['comment'] ' Failedtoupdateappconfigfor{ 0 } {1 }' format name update result['exception'] return retelse ret['result'] Trueret['comment'] ' Updatedappconfigfor{ 0 }' format name return retret['result'] Trueret['comment'] ' Marathonapp{ 0 }configuredcorrectly' format name return ret
null
null
null
null
Question: What does the code ensure ? Code: def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
What is the marathon app configured ?
def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
to match the given config values
codeqa
def config name config ret {'name' name 'changes' {} 'result' False 'comment' ''}existing config Noneif salt ['marathon has app'] name existing config salt ['marathon app'] name ['app']if existing config update config copy deepcopy existing config salt utils configcomparer compare and update config config update config ret['changes'] else ret['changes']['app'] {'new' config 'old' None}update config configif ret['changes'] if opts ['test'] ret['result'] Noneret['comment'] ' Marathonapp{ 0 }issettobeupdated' format name return retupdate result salt ['marathon update app'] name update config if 'exception' in update result ret['result'] Falseret['comment'] ' Failedtoupdateappconfigfor{ 0 } {1 }' format name update result['exception'] return retelse ret['result'] Trueret['comment'] ' Updatedappconfigfor{ 0 }' format name return retret['result'] Trueret['comment'] ' Marathonapp{ 0 }configuredcorrectly' format name return ret
null
null
null
null
Question: What is the marathon app configured ? Code: def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
What is configured to match the given config values ?
def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
the marathon app
codeqa
def config name config ret {'name' name 'changes' {} 'result' False 'comment' ''}existing config Noneif salt ['marathon has app'] name existing config salt ['marathon app'] name ['app']if existing config update config copy deepcopy existing config salt utils configcomparer compare and update config config update config ret['changes'] else ret['changes']['app'] {'new' config 'old' None}update config configif ret['changes'] if opts ['test'] ret['result'] Noneret['comment'] ' Marathonapp{ 0 }issettobeupdated' format name return retupdate result salt ['marathon update app'] name update config if 'exception' in update result ret['result'] Falseret['comment'] ' Failedtoupdateappconfigfor{ 0 } {1 }' format name update result['exception'] return retelse ret['result'] Trueret['comment'] ' Updatedappconfigfor{ 0 }' format name return retret['result'] Trueret['comment'] ' Marathonapp{ 0 }configuredcorrectly' format name return ret
null
null
null
null
Question: What is configured to match the given config values ? Code: def config(name, config): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} existing_config = None if __salt__['marathon.has_app'](name): existing_config = __salt__['marathon.app'](name)['app'] if existing_config: update_config = copy.deepcopy(existing_config) salt.utils.configcomparer.compare_and_update_config(config, update_config, ret['changes']) else: ret['changes']['app'] = {'new': config, 'old': None} update_config = config if ret['changes']: if __opts__['test']: ret['result'] = None ret['comment'] = 'Marathon app {0} is set to be updated'.format(name) return ret update_result = __salt__['marathon.update_app'](name, update_config) if ('exception' in update_result): ret['result'] = False ret['comment'] = 'Failed to update app config for {0}: {1}'.format(name, update_result['exception']) return ret else: ret['result'] = True ret['comment'] = 'Updated app config for {0}'.format(name) return ret ret['result'] = True ret['comment'] = 'Marathon app {0} configured correctly'.format(name) return ret
null
null
null
How did the code give ?
def remove_repeating_from_task(task_name, s): module = (str(task_name).rpartition(u'.')[0] + u'.') return remove_repeating(module, s)
null
null
null
task name
codeqa
def remove repeating from task task name s module str task name rpartition u' ' [0 ] + u' ' return remove repeating module s
null
null
null
null
Question: How did the code give ? Code: def remove_repeating_from_task(task_name, s): module = (str(task_name).rpartition(u'.')[0] + u'.') return remove_repeating(module, s)
null
null
null
What does the code generate ?
def menu_prompt(model, prompt=' > ', rows=None, header=None, theading=None, footer=None, force=0): content = '' for x in (header, theading, rows, footer): if isinstance(x, list): for line in x: content += (line + '\n') elif isinstance(x, str): content += (x + '\n') g.content = content screen.update() choice = input(prompt) if (choice in model): return model[choice] elif force: return menu_prompt(model, prompt, rows, header, theading, footer, force) elif (not choice.strip()): return (False, False) else: return (False, 'abort')
null
null
null
a list of choice
codeqa
def menu prompt model prompt '>' rows None header None theading None footer None force 0 content ''for x in header theading rows footer if isinstance x list for line in x content + line + '\n' elif isinstance x str content + x + '\n' g content contentscreen update choice input prompt if choice in model return model[choice]elif force return menu prompt model prompt rows header theading footer force elif not choice strip return False False else return False 'abort'
null
null
null
null
Question: What does the code generate ? Code: def menu_prompt(model, prompt=' > ', rows=None, header=None, theading=None, footer=None, force=0): content = '' for x in (header, theading, rows, footer): if isinstance(x, list): for line in x: content += (line + '\n') elif isinstance(x, str): content += (x + '\n') g.content = content screen.update() choice = input(prompt) if (choice in model): return model[choice] elif force: return menu_prompt(model, prompt, rows, header, theading, footer, force) elif (not choice.strip()): return (False, False) else: return (False, 'abort')
null
null
null
What does the code get ?
def one(s): return next(iter(s))
null
null
null
one element of a set
codeqa
def one s return next iter s
null
null
null
null
Question: What does the code get ? Code: def one(s): return next(iter(s))
null
null
null
What does the code remove from a file name ?
def demangle_name(name, mode): if name.endswith('.bupl'): return (name[:(-5)], BUP_NORMAL) elif name.endswith('.bup'): return (name[:(-4)], BUP_CHUNKED) elif name.endswith('.bupm'): return (name[:(-5)], (BUP_CHUNKED if stat.S_ISDIR(mode) else BUP_NORMAL)) else: return (name, BUP_NORMAL)
null
null
null
name mangling
codeqa
def demangle name name mode if name endswith ' bupl' return name[ -5 ] BUP NORMAL elif name endswith ' bup' return name[ -4 ] BUP CHUNKED elif name endswith ' bupm' return name[ -5 ] BUP CHUNKED if stat S ISDIR mode else BUP NORMAL else return name BUP NORMAL
null
null
null
null
Question: What does the code remove from a file name ? Code: def demangle_name(name, mode): if name.endswith('.bupl'): return (name[:(-5)], BUP_NORMAL) elif name.endswith('.bup'): return (name[:(-4)], BUP_CHUNKED) elif name.endswith('.bupm'): return (name[:(-5)], (BUP_CHUNKED if stat.S_ISDIR(mode) else BUP_NORMAL)) else: return (name, BUP_NORMAL)
null
null
null
What do you enable ?
@pytest.fixture(scope=u'session') def celery_enable_logging(): return False
null
null
null
logging
codeqa
@pytest fixture scope u'session' def celery enable logging return False
null
null
null
null
Question: What do you enable ? Code: @pytest.fixture(scope=u'session') def celery_enable_logging(): return False
null
null
null
For what purpose can you override this fixture ?
@pytest.fixture(scope=u'session') def celery_enable_logging(): return False
null
null
null
to enable logging
codeqa
@pytest fixture scope u'session' def celery enable logging return False
null
null
null
null
Question: For what purpose can you override this fixture ? Code: @pytest.fixture(scope=u'session') def celery_enable_logging(): return False