Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Continue the code snippet: <|code_start|> elif path.type == 'ordered':
return OrderedComparator()
elif path.type == 'uniquekey':
return UniqueKeyComparator(keys=path.keys)
class OrderedComparator:
def __init__(self):
self.DEL = []
self.SET= []
self.ADD = []
... | fillval = CmdPathRow(dict()) |
Given the code snippet: <|code_start|> '=key=value',
'=.id=value',
)
key_value_tuples = (
('key','value'),
('.id','value'),
)
@pytest.mark.parametrize("word,expected", zip(api_words,key_value_tuples))
def test_converting_api_word_to_tuple(word, expected):
assert conva... | assert parsresp(response) == (expected) |
Given snippet: <|code_start|>def test_converting_api_word_to_tuple(word, expected):
assert convattrwrd(word) == expected
@pytest.mark.parametrize("word,pair", zip(api_words,key_value_tuples))
def test_converting_tuple_to_api_word(word,pair):
assert mkattrwrd(pair) == word
@pytest.mark.parametrize("sentence,... | assert parsnt(api_sentence) == expected |
Given the code snippet: <|code_start|> (1, '1'),
(0, '0')
))
def test_casting_from_python_to_api(python_type, api_type):
assert castValToApi(python_type) == api_type
api_words = (
'=key=value',
'=.id=value',
)
key_value_tuples = (
('key','value'),
('.i... | assert set(mksnt(sentence)) == set(api_sentence) |
Predict the next line after this snippet: <|code_start|>@pytest.mark.parametrize("python_type,api_type", (
(True, 'yes'),
(False, 'no'),
(None, ''),
('string', 'string'),
('22.2', '22.2'),
(22.2, '22.2'),
(22, '22'),
(1, '1'),
(0, '0')
))
d... | assert mkattrwrd(pair) == word |
Continue the code snippet: <|code_start|> ))
def test_casting_from_api_to_python(api_type, python_type):
assert castValToPy( api_type ) == python_type
@pytest.mark.parametrize("python_type,api_type", (
(True, 'yes'),
(False, 'no'),
(None, ''),
('string', 'string'),
(... | assert convattrwrd(word) == expected |
Next line prediction: <|code_start|>
def test_trap_string_in_sentences_raises_exception():
with pytest.raises(CmdError):
trapCheck(('!trap','=key=value'))
def test_raises_when_fatal():
with pytest.raises(ConnError):
raiseIfFatal(('!fatal','connection terminated by remote hoost'))
def tes... | assert castValToPy( api_type ) == python_type |
Using the snippet: <|code_start|>def test_does_not_raise_exception_if_no_fatal_string():
raiseIfFatal( 'some string without error' )
@pytest.mark.parametrize("api_type,python_type", (
('yes', True),
('no', False),
('true', True),
('false', False),
('', None),
('stri... | assert castValToApi(python_type) == api_type |
Based on the snippet: <|code_start|># -*- coding: UTF-8 -*-
def test_trap_string_in_sentences_raises_exception():
with pytest.raises(CmdError):
trapCheck(('!trap','=key=value'))
def test_raises_when_fatal():
with pytest.raises(ConnError):
<|code_end|>
, predict the immediate next line with the he... | raiseIfFatal(('!fatal','connection terminated by remote hoost')) |
Predict the next line after this snippet: <|code_start|># -*- coding: UTF-8 -*-
def test_trap_string_in_sentences_raises_exception():
with pytest.raises(CmdError):
trapCheck(('!trap','=key=value'))
def test_raises_when_fatal():
<|code_end|>
using the current file's imports:
import pytest
from mcm.l... | with pytest.raises(ConnError): |
Continue the code snippet: <|code_start|> :param word: Attribute word.
'''
splitted = word.split( '=', 2 )
key = splitted[1]
value = splitted[2]
casted_value = castValToPy( value )
return ( key, casted_value )
def trapCheck( snts ):
'''
Check for existance of !trap word. This wor... | raise CmdError( e ) |
Given the code snippet: <|code_start|>
def trapCheck( snts ):
'''
Check for existance of !trap word. This word indicates that an error occured.
At least one !trap word in any sentence triggers an error.
Unfortunatelly mikrotik api may throw one or more errors as response.
:param snts: Iterable with... | raise ConnError( error ) |
Based on the snippet: <|code_start|>@pytest.mark.skipif( version_info > (3,2), reason='Using python >= 3.3' )
def test_module_uses_time_as_timer():
'''Assert that time.time is used when time.monotonic is not available.'''
assert timer == time
@pytest.mark.parametrize("v1,v2,oper,result", (
('4.11','3.... | with StopWatch() as st: |
Using the snippet: <|code_start|># -*- coding: UTF-8 -*-
try:
except ImportError:
@pytest.mark.skipif( version_info < (3,3), reason='Requires python >= 3.3' )
def test_module_uses_monotonic_as_timer():
'''Assert that time.monotonic is used.'''
<|code_end|>
, determine the next line of code. You have imports:
... | assert timer == monotonic |
Here is a snippet: <|code_start|>
@pytest.mark.skipif( version_info < (3,3), reason='Requires python >= 3.3' )
def test_module_uses_monotonic_as_timer():
'''Assert that time.monotonic is used.'''
assert timer == monotonic
@pytest.mark.skipif( version_info > (3,2), reason='Using python >= 3.3' )
def test_modul... | assert vcmp(v1=v1,v2=v2,op=oper) == result |
Based on the snippet: <|code_start|> ('4.10','4.1',operator.ne,True),
('4.11','4.11',operator.ne,False),
))
def test_version_comparison(v1,v2,oper,result):
assert vcmp(v1=v1,v2=v2,op=oper) == result
@patch('mcm.tools.timer', side_effect=[14705.275287508, 14711.190629636])
class Test_StopWat... | self.chained = ChainMap(self.override_dict, self.default_dict) |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: UTF-8 -*-
logger = getLogger('mcm.' + __name__)
class MasterAdapter:
def __init__(self, device):
self.device = device
def read(self, path):
content = self.device.read(path=path.absolute)
data =... | return tuple(CmdPathRow(elem) for elem in data) |
Using the snippet: <|code_start|> def __init__(self, device):
self.device = device
def read(self, path):
content = self.device.read(path=path.absolute)
data = self.assemble_data(data=content)
for row in data:
logger.debug('{path} {data}'.format(path=path.absolute, da... | except WriteError as error: |
Given snippet: <|code_start|># -*- coding: UTF-8 -*-
def validate_list(lst, allowed):
forbidden = set(lst) - set(allowed)
if forbidden:
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from mcm.exceptions import ValidateError
and context:
# Path: mcm/exceptions.py
# cla... | raise ValidateError() |
Here is a snippet: <|code_start|>
@pytest.fixture
def read_only_routeros():
return ReadOnlyRouterOS(api=MagicMock())
class StaticConfig_Tests:
def setup(self):
data = [
{'path':'test_path', 'strategy':'exact', 'rules':[ {'key':'value'} ]}
]
self.TestCls = S... | self.TestCls = RouterOsAPIDevice(api=MagicMock()) |
Continue the code snippet: <|code_start|># -*- coding: UTF-8 -*-
@pytest.fixture
def read_only_routeros():
return ReadOnlyRouterOS(api=MagicMock())
class StaticConfig_Tests:
def setup(self):
data = [
{'path':'test_path', 'strategy':'exact', 'rules':[ {'key':'value'} ]}
... | self.TestCls = StaticConfig(data=data) |
Using the snippet: <|code_start|> def setup(self):
data = [
{'path':'test_path', 'strategy':'exact', 'rules':[ {'key':'value'} ]}
]
self.TestCls = StaticConfig(data=data)
def test_read_returns_valid_rules(self):
returned = self.TestCls.read(path='test_path... | self.TestCls.api.run.side_effect = CmdError |
Given the code snippet: <|code_start|> data = [
{'path':'test_path', 'strategy':'exact', 'rules':[ {'key':'value'} ]}
]
self.TestCls = StaticConfig(data=data)
def test_read_returns_valid_rules(self):
returned = self.TestCls.read(path='test_path')
asser... | with pytest.raises(ReadError): |
Using the snippet: <|code_start|> self.TestCls.write(path=self.pathmock, action='ADD', data=None)
joinmock.assert_called_once_with(path=self.pathmock, action='ADD')
@patch.object(RouterOsAPIDevice, 'DEL')
@patch.object(RouterOsAPIDevice, 'cmd_action_join')
def test_write_calls_DEL_when_cmd_... | with self.assertRaises(WriteError): |
Based on the snippet: <|code_start|># -*- coding: UTF-8 -*-
def test_validate_list_raises_ValidateError_when_list_passed_contains_forbidden_elements():
with pytest.raises(ValidateError):
validate_list(lst=[1,2,3], allowed=[1,2] )
def test_validate_val_raises_ValidateError_when_value_passed_is_not_in_a... | validate_value(val='abc', allowed=('single', 'generic')) |
Given the code snippet: <|code_start|># -*- coding: UTF-8 -*-
def test_validate_list_raises_ValidateError_when_list_passed_contains_forbidden_elements():
with pytest.raises(ValidateError):
validate_list(lst=[1,2,3], allowed=[1,2] )
def test_validate_val_raises_ValidateError_when_value_passed_is_not_in... | validate_type(val=1, allowed=str) |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: UTF-8 -*-
def enclen( length ):
'''
Encode given length in mikrotik format.
length: Integer < 268435456.
returns: Encoded length in bytes.
'''
if length < 128:
ored_length = length
offset ... | raise ConnError( 'unable to encode length of {}' |
Given snippet: <|code_start|># -*- coding: UTF-8 -*-
@patch( 'mcm.librouteros.api.parsresp' )
@patch( 'mcm.librouteros.api.mksnt' )
@patch( 'mcm.librouteros.api.trapCheck' )
@patch( 'mcm.librouteros.api.raiseIfFatal' )
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import unit... | @patch.object( Api, '_readResponse' ) |
Predict the next line after this snippet: <|code_start|># -*- coding: UTF-8 -*-
@patch( 'mcm.librouteros.api.parsresp' )
@patch( 'mcm.librouteros.api.mksnt' )
@patch( 'mcm.librouteros.api.trapCheck' )
@patch( 'mcm.librouteros.api.raiseIfFatal' )
@patch.object( Api, '_readResponse' )
@patch.object( Api, 'close' )
c... | rwo = MagicMock( spec = ReaderWriter ) |
Given snippet: <|code_start|># -*- coding: UTF-8 -*-
class CmdPathConfigurator_Tests(TestCase):
def setUp(self):
self.addfunc = MagicMock()
self.delfunc = MagicMock()
self.setfunc = MagicMock()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from moc... | self.TestCls = CmdPathConfigurator( path=MagicMock(), configurator=MagicMock(), comparator=MagicMock(), addfunc=self.addfunc, delfunc=self.delfunc, setfunc=self.setfunc ) |
Given snippet: <|code_start|> self.TestCls.configurator.master.read.assert_called_once_with(path=self.TestCls.path)
def test_extractActionData_returns_ADD_data_when_requested(self):
data = ADD, SET, DEL = ( MagicMock(), MagicMock(), MagicMock() )
returned = self.TestCls.extartActionData(dat... | addfunc=real_action, delfunc=no_action, setfunc=real_action) |
Given the following code snippet before the placeholder: <|code_start|> self.TestCls.configurator.master.read.assert_called_once_with(path=self.TestCls.path)
def test_extractActionData_returns_ADD_data_when_requested(self):
data = ADD, SET, DEL = ( MagicMock(), MagicMock(), MagicMock() )
re... | addfunc=real_action, delfunc=no_action, setfunc=real_action) |
Next line prediction: <|code_start|> CmdPathConfigurator.with_ensure(path=self.path, configurator=self.configurator)
initmock.assert_called_once_with(path=self.path, comparator=cmpmock.return_value, configurator=self.configurator,
addfunc=real_action, delfunc=no_action, setfunc=real_actio... | self.TestCls = Configurator(master=MagicMock(), slave=MagicMock()) |
Continue the code snippet: <|code_start|>
def test_real_action_calls_slaves_write(self):
real_action(self.cls, 'ADD', self.data)
self.cls.configurator.slave.write.assert_called_once_with(data=self.data, path=self.cls.path, action='ADD')
def test_no_action_does_not_call_masters_write(self):
... | pathcfgmock.return_value.run.side_effect = ReadError |
Next line prediction: <|code_start|> def test_no_action_does_not_call_masters_write(self):
no_action(self.cls, 'ADD', self.data)
self.assertEqual( self.cls.configurator.master.write.call_count, 0 )
class Configurator_Tests(TestCase):
def setUp(self):
self.TestCls = Configurator(master... | pathcfgmock.return_value.run.side_effect = ConnError |
Here is a snippet: <|code_start|># -*- coding: UTF-8 -*-
integers = (0, 127 ,130 ,2097140 ,268435440)
encoded = (b'\x00', b'\x7f', b'\x80\x82', b'\xdf\xff\xf4', b'\xef\xff\xff\xf0')
@pytest.mark.parametrize("integer,encoded", zip(integers, encoded))
def test_encoding(integer, encoded):
<|code_end|>
. Write the ne... | assert connections.enclen(integer) == encoded |
Given the code snippet: <|code_start|># -*- coding: UTF-8 -*-
integers = (0, 127 ,130 ,2097140 ,268435440)
encoded = (b'\x00', b'\x7f', b'\x80\x82', b'\xdf\xff\xf4', b'\xef\xff\xff\xf0')
@pytest.mark.parametrize("integer,encoded", zip(integers, encoded))
def test_encoding(integer, encoded):
assert connections... | with pytest.raises(ConnError): |
Predict the next line after this snippet: <|code_start|># -*- coding: UTF-8 -*-
logger = getLogger('mcm.' + __name__)
class CmdPathConfigurator:
def __init__(self, configurator, path, comparator, addfunc, setfunc, delfunc):
self.configurator = configurator
self.path = path
self.compar... | comparator = get_comparator(path=path) |
Predict the next line for this snippet: <|code_start|>
def real_action(self, action, data):
self.configurator.slave.write(data=data, path=self.path, action=action)
def no_action(self, action, data):
pass
class Configurator:
def __init__(self, master, slave):
self.master = master
... | except ReadError as error: |
Predict the next line for this snippet: <|code_start|>
def real_action(self, action, data):
self.configurator.slave.write(data=data, path=self.path, action=action)
def no_action(self, action, data):
pass
class Configurator:
def __init__(self, master, slave):
self.master = master
s... | except ConnError as error: |
Given snippet: <|code_start|>
@patch('mcm.datastructures.MENU_PATHS')
class Test_CmdPath:
@pytest.mark.parametrize("path",("/ip/address/", "ip/address", "/ip/address"))
def test_absolute_attribute(self, paths_mock, path):
cmd_path = make_cmdpath(path, strategy=None)
assert cmd_path.absolute == ... | assert str(CmdPathRow(data)) == expected |
Predict the next line after this snippet: <|code_start|># -*- coding: UTF-8 -*-
@patch('mcm.datastructures.MENU_PATHS')
class Test_CmdPath:
@pytest.mark.parametrize("path",("/ip/address/", "ip/address", "/ip/address"))
def test_absolute_attribute(self, paths_mock, path):
<|code_end|>
using the current fil... | cmd_path = make_cmdpath(path, strategy=None) |
Given the following code snippet before the placeholder: <|code_start|>
class StaticConfig:
def __init__(self, data):
self.data = data
def read(self, path):
for section in self.data:
if section['path'] == path:
return section['rules']
def close(self):
... | except CmdError as error: |
Given the code snippet: <|code_start|>
class StaticConfig:
def __init__(self, data):
self.data = data
def read(self, path):
for section in self.data:
if section['path'] == path:
return section['rules']
def close(self):
pass
class ReadOnlyRouterOS:
... | raise ReadError(error) |
Using the snippet: <|code_start|>
def close(self):
self.api.close()
@staticmethod
def cmd_action_join(path, action):
actions = dict(ADD='add', SET='set', DEL='remove', GET='getall')
return pjoin(path, actions[action])
@staticmethod
def filter_dynamic(data):
return... | raise WriteError(error) |
Given the following code snippet before the placeholder: <|code_start|> self.comparator.ADD.append.assert_called_once_with( self.wanted )
def test_appends_to_DEL(self):
"""If there is only present element, append it to DEL."""
self.comparator.decide(wanted=None, difference=None, present=self... | self.comparator = UniqueKeyComparator( keys=('name',) ) |
Based on the snippet: <|code_start|># -*- coding: UTF-8 -*-
@pytest.fixture
def master_adapter():
return MasterAdapter(device=MagicMock())
@pytest.fixture
def slave_adapter():
<|code_end|>
, predict the immediate next line with the help of imports:
from mock import MagicMock, patch
from mcm.adapters import M... | return SlaveAdapter(device=MagicMock()) |
Here is a snippet: <|code_start|>def test_MasterAdapter_calls_assemble_data(master_adapter, path):
master_adapter.assemble_data = MagicMock()
master_adapter.read(path=path)
master_adapter.assemble_data.assert_called_once_with(data=master_adapter.device.read.return_value)
@pytest.mark.parametrize("adapter"... | slave_adapter.device.side_effect = WriteError |
Given snippet: <|code_start|>#!/usr/bin/env python
################################################################
### Jose A Espinosa. CSN/CB-CRG Group. Jan 2016 ###
################################################################
### Script creates BedTools objects from a file containing ###
### mice... | int_data = intervals.IntData(base_dir + "/sample_data/feeding_behavior/feedingBehavior_HF_mice.csv", map_dict=mapping_data.correspondence) |
Next line prediction: <|code_start|>#!/usr/bin/env python
################################################################
### Jose A Espinosa. CSN/CB-CRG Group. Jan 2016 ###
################################################################
### Script creates BedTools objects from a file containing ###
#... | int_data = intervals.IntData(base_dir + "/sample_data/feeding_behavior/feedingBehavior_HF_mice.csv", map_dict=mapping_data.correspondence) |
Next line prediction: <|code_start|>parent_parser.add_argument('-w', '--window_size', required=False, metavar="WINDOW_SIZE", type=int,
help='Window size for bedGraph intervals, default value 300')
parent_parser.add_argument('-nt', '--no_track_line', required=False, action='store_true',
... | parent_parser.add_argument('-v', '--version', action='version', version='%(prog)s {version}'.format(version=__version__)) |
Predict the next line after this snippet: <|code_start|>
tracks2merge = ""
if track_action == "join_all":
tracks2merge = tracks
elif track_action == 'join_odd':
tracks2merge = set([t for t in tracks if int(t) % 2])
elif track_action == 'join_even':
tracks2merge = set([t ... | check_path(path_color_file) |
Next line prediction: <|code_start|>parser.add_argument('-b','--behavioral_type', help='Choose whether to work with drinking or feeding mice behavioral data',
required=True, choices=_behaviors_available)
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic... | mapping_data = mapping.MappingInfo("../../sample_data/feeding_behavior/b2p.txt") |
Based on the snippet: <|code_start|>
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
print >> stderr, "Working with mice %s behavioral data" % args.behavioral_type
# Statistic to calculate
statistic = args.statistic
## Dictionary to set colors of each type of food
# food... | int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence) |
Based on the snippet: <|code_start|>
int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence)
int_data_b2 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B2.csv", map_dict=mapping_data.correspondence)
int_data_b3 = interv... | data_read_all_batches = tracks.merge_tracks (tracks.merge_tracks (tracks.merge_tracks (data_read_b1, data_read_b2), data_read_b3), data_read_b4) |
Here is a snippet: <|code_start|>parser.add_argument('-b','--behavioral_type', help='Choose whether to work with drinking or feeding mice behavioral data',
required=True, choices=_behaviors_available)
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
pr... | mapping_data = mapping.MappingInfo("../../sample_data/feeding_behavior/b2g.txt") |
Predict the next line for this snippet: <|code_start|>
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
print >> stderr, "Working with mice %s behavioral data" % args.behavioral_type
# Statistic to calculate
statistic = args.statistic
## Dictionary to set colors of each t... | int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence) |
Continue the code snippet: <|code_start|>
int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence)
int_data_b2 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B2.csv", map_dict=mapping_data.correspondence)
int_data_b3 = i... | data_read_all_batches = tracks.merge_tracks (tracks.merge_tracks (tracks.merge_tracks (data_read_b1, data_read_b2), data_read_b3), data_read_b4) |
Next line prediction: <|code_start|>#!/usr/bin/env python
################################################################
### Jose A Espinosa. CSN/CB-CRG Group. Jan 2016 ###
################################################################
### ###
### ###
### ###
### ###
### #... | int_data = intervals.IntData(base_dir + "/sample_data/feeding_behavior/feedingBehavior_HF_mice.csv", map_dict=mapping_data.correspondence) |
Predict the next line for this snippet: <|code_start|># In the cluster I use bedtools Pablo installation, because default cluster version has not map
if home == "/users/cn/jespinosa" :
pybedtools.helpers.set_bedtools_path('/users/cn/pprieto/soft/bedtools/bedtools2-2.19.1/bin')
parser = ArgumentParser(description=... | mapping_bed = mapping.MappingInfo(args.bed_mapping) |
Predict the next line for this snippet: <|code_start|> tag_file = args.tag_out
else:
tag_file = "mean_speed_i_motionDir"
print >> stderr, "Bed speed file: %s" % args.speed
print >> stderr, "Bed motion file: %s" % args.motion
print >> stderr, "Mapping bed to Pergola file: %s" % args.bed_mapping
print >> stderr, ... | int_data_speed = intervals.IntData(bed_speed_file, map_dict=mapping_bed.correspondence, header=False, |
Given the following code snippet before the placeholder: <|code_start|># In the cluster I use bedtools Pablo installation, because default cluster version has not map
if home == "/users/cn/jespinosa" :
pybedtools.helpers.set_bedtools_path('/users/cn/pprieto/soft/bedtools/bedtools2-2.19.1/bin')
parser = ArgumentPa... | mapping_bed = mapping.MappingInfo(bed_mapping) |
Predict the next line after this snippet: <|code_start|> pybedtools.helpers.set_bedtools_path('/users/cn/pprieto/soft/bedtools/bedtools2-2.19.1/bin')
parser = ArgumentParser(description='File input arguments')
parser.add_argument('-f','--forward_file', help='forward bed file', required=True)
parser.add_argument('-... | forward = intervals.IntData(forward_file, map_dict=mapping_bed.correspondence, header=False, |
Based on the snippet: <|code_start|> if window_mean:
print("@@@Pergola_rules.py: Window mean set to....................... %d" % window_mean, file=stderr)
else:
window_mean = False
if value_mean:
print("@@@Pergola_rules.py: Value mean set to....................... %d" % value_m... | intData = intervals.IntData(path, map_dict=map_file_dict.correspondence, |
Based on the snippet: <|code_start|> output_file_n = args.output_file_name + "_" + str(idx + 1)
else:
output_file_n = args.output_file_name
pergola_rules(path=input_file, map_file_path=args.mapping_file, sel_tracks=args.tracks,
list=args.list, range=args... | map_file_dict = mapping.MappingInfo(map_file_path) |
Continue the code snippet: <|code_start|>#
# Copyright (c) 2014-2019, Centre for Genomic Regulation (CRG).
# Copyright (c) 2014-2019, Jose Espinosa-Carrasco and the respective authors.
#
# This file is part of Pergola.
#
# Pergola is free software: you can redistribute it and/or modify
# it under the terms of the ... | parser_pergola_rules = ArgumentParser(parents=[parsers.parent_parser]) |
Next line prediction: <|code_start|># Pergola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the... | mapping_bed = mapping.MappingInfo(args.bed_mapping_file) |
Based on the snippet: <|code_start|># along with Pergola. If not, see <http://www.gnu.org/licenses/>.
# example execution
# ./celegans_speed_i_motion.py -p midbody.phenotypic_feature.bed -m motion.bed -b bed_map.txt -t "N2"
# Loading libraries
parser = ArgumentParser(description='File input arguments')
parser.add_... | int_data_phenotypic = intervals.IntData(bed_ph_file, map_dict=mapping_bed.correspondence, header=False, |
Predict the next line after this snippet: <|code_start|> required=True, choices=_behaviors_available)
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
print >> stderr, "Working with mice %s behavioral data" % args.behavioral_type
# Statistic to calcula... | mapping_data = mapping.MappingInfo("../../sample_data/feeding_behavior/b2g.txt") |
Based on the snippet: <|code_start|>args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
print >> stderr, "Working with mice %s behavioral data" % args.behavioral_type
# Statistic to calculate
# statistic = "count"
statistic = args.statistic
## Dictionary to set colors of eac... | int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence) |
Predict the next line for this snippet: <|code_start|>int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence)
int_data_b2 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B2.csv", map_dict=mapping_data.correspondence)
int_... | data_read_all_batches = tracks.merge_tracks (tracks.merge_tracks (tracks.merge_tracks (data_read_b1, data_read_b2), data_read_b3), data_read_b4) |
Given the following code snippet before the placeholder: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License... | mapping_bed = mapping.MappingInfo(args.bed_mapping_file) |
Given snippet: <|code_start|># along with Pergola. If not, see <http://www.gnu.org/licenses/>.
# example execution
# ./celegans_speed_i_motion.py -p midbody.phenotypic_feature.bed -m motion.bed -b bed_map.txt -t "N2"
# Loading libraries
parser = ArgumentParser(description='File input arguments')
parser.add_argumen... | int_data_phenotypic = intervals.IntData(bed_ph_file, map_dict=mapping_bed.correspondence, header=False, |
Here is a snippet: <|code_start|>parser.add_argument('-b','--behavioral_type', help='Choose whether to work with drinking or feeding mice behavioral data',
required=True, choices=_behaviors_available)
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
pr... | mapping_data = mapping.MappingInfo("../../sample_data/feeding_behavior/b2g.txt") |
Given the following code snippet before the placeholder: <|code_start|>
args = parser.parse_args()
print >> stderr, "Statistic to be calculated: %s" % args.statistic
print >> stderr, "Working with mice %s behavioral data" % args.behavioral_type
# Statistic to calculate
statistic = args.statistic
## Dictionary to set... | int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence) |
Predict the next line after this snippet: <|code_start|>
int_data_b1 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B1.csv", map_dict=mapping_data.correspondence)
int_data_b2 = intervals.IntData ("../../sample_data/feeding_beh_CB1_mice/intake_CB1_B2.csv", map_dict=mapping_data.correspondence)
... | data_read_all_batches = tracks.merge_tracks (tracks.merge_tracks (tracks.merge_tracks (data_read_b1, data_read_b2), data_read_b3), data_read_b4) |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python
"""
5 feb 2015
Script to transform Jaaba files in matlab format into pergola files
Example of how to run this file:
python jaaba2pergola_dev.py
./jaaba2pergola_dev.py
"""
# from os import getcwd
# from sys import stderr
# fro... | jaaba_parsers.jaaba_scores_to_csv(input_file='/Users/jespinosa/JAABA_MAC_0.5.1/sampledata_v0.5/Chase1_TrpA_Rig1Plate15BowlA_20120404T141155/scores_chase.mat', |
Given snippet: <|code_start|># In the cluster I use bedtools Pablo installation, because default cluster version has not map
if home == "/users/cn/jespinosa" :
pybedtools.helpers.set_bedtools_path('/users/cn/pprieto/soft/bedtools/bedtools2-2.19.1/bin')
parser = ArgumentParser(description='File input arguments')
p... | mapping_bed = mapping.MappingInfo(args.bed_mapping) |
Continue the code snippet: <|code_start|> tag_file = args.tag_out
else:
tag_file = "mean_speed_i_motionDir"
print >> stderr, "Bed speed file: %s" % args.speed
print >> stderr, "Bed motion file: %s" % args.motion
print >> stderr, "Mapping bed to Pergola file: %s" % args.bed_mapping
print >> stderr, "Output tag f... | int_data_speed = intervals.IntData(bed_speed_file, map_dict=mapping_bed.correspondence, header=False, |
Next line prediction: <|code_start|> voidp = ctypes.c_void_p
stp = ctypes.POINTER(St)
stpvoid = ctypes.POINTER(None)
arra1 = (ctypes.c_long * 4)
arra2 = (St * 4)
arra3 = (ctypes.POINTER(St) * 4)
charp = ctypes.c_char_p
string = ctypes.CString
fptr = ctypes.CFUNCTYPE(ctypes.c_int, ctyp... | ctypes = types.load_ctypes_default() |
Based on the snippet: <|code_start|> try:
# i'm lazy. Heap validation could be 10 chunks deep.
# but we validate _is_heap by looking at the mapping size
sizes = [
size for (
addr,
size) in validator.iter_user_allocations(
mapping)]
... | class LibcHeapValidator(listmodel.ListModel): |
Given snippet: <|code_start|> register_linked_list_field_and_type(struct_Items, 'list_of_items', struct_Items, 'list_of_items')
register_linked_list_field_and_type(struct_Items2, 'list_of_items', struct_Items2, 'list_of_items')
In case of a single link list:
register_single_linked_list_record_type(struct_SL... | class ListModel(basicmodel.CTypesRecordConstraintValidator): |
Predict the next line after this snippet: <|code_start|> if not isinstance(record, ctypes.Structure) and not isinstance(record, ctypes.Union):
raise TypeError('Feed me a ctypes record instance')
if max_depth <= 0:
log.debug('Maximum depth reach. Not loading any deeper members.')
... | if constraint is constraints.IgnoreMember: |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
log = logging.getLogger('testwinxpheap')
class TestWinXPHeapValidator(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._memory_handler = folder.load(zeus_1668_vmtoolsd_exe.dumpname)
cls._utils = cls._memor... | self.parser = text.RecursiveTextOutputter(self._memory_handler) |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
log = logging.getLogger('testwinxpheap')
class TestWinXPHeapValidator(unittest.TestCase):
@classmethod
def setUpClass(cls):
<|code_end|>
, determine the next line of code. You have imports:
import logging
import unittest
from... | cls._memory_handler = folder.load(zeus_1668_vmtoolsd_exe.dumpname) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for haystack.reverse.structure."""
__author__ = "Loic Jaquemet"
__copyright__ = "Copyright (C) 2012 Loic Jaquemet"
__license__ = "GPL"
__maintainer__ = "Loic Jaquemet"
__email__ = "loic.jaquemet+python@gmail... | memory_handler = folder.load('test/src/test-ctypes1.64.dump') |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests haystack.model ."""
class TestCopyModule(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.memory_handler = process.make_local_memory_handler()
cls.my_target = cls.memory_handler.get_tar... | cls.my_model = model.Model(cls.my_target.get_target_ctypes()) |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests haystack.model ."""
class TestCopyModule(unittest.TestCase):
@classmethod
def setUpClass(cls):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import logging
import unittest
from haysta... | cls.memory_handler = process.make_local_memory_handler() |
Here is a snippet: <|code_start|># Copyright (C) 2011 Loic Jaquemet loic.jaquemet+python@gmail.com
#
from __future__ import print_function
log = logging.getLogger('libdl')
class Dl_info(ctypes.Structure):
_fields_ = [
# Pathname of shared object that contains address
('dli_fname', ctypes.c_cha... | return make_process_memory_handler(me) |
Given snippet: <|code_start|> # output handling
output = api.output_to_python(memory_handler, results)
py_obj = output[0][0]
def base_argparser(program_name, description):
""" Base options shared by all console scripts """
rootparser = argparse.ArgumentParser(prog=program_name, descript... | search_parser.add_argument('--hint', type=argparse_utils.int16, |
Using the snippet: <|code_start|> # validate if required
validation = None
if args.constraints_file:
handler = constraints.ConstraintsConfigHandler()
my_constraints = handler.read(args.constraints_file.name)
validation = api.validate_record(memory_handler, result[0], my_constraints)
... | fields = ["%s: %s" % (n, t) for n, t in basicmodel.get_fields(st)] |
Predict the next line after this snippet: <|code_start|> if rtype == 'string':
ret = api.output_to_string(memory_handler, results)
elif rtype == 'python':
# useful in interactive mode
ret = api.output_to_python(memory_handler, results)
elif rtype == 'json':
ret = api.output_to... | handler = constraints.ConstraintsConfigHandler() |
Based on the snippet: <|code_start|> path = _url.path.split(':')[0]
if scheme in ['dir', 'volatility', 'rekall', 'dmp']:
if not os.path.exists(path):
raise argparse.ArgumentTypeError("Target {p} does not exists".format(p=path))
# see url.netloc for host name, frida ? live ?
re... | ret = api.output_to_string(memory_handler, results) |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Loic Jaquemet loic.jaquemet+python@gmail.com
#
try:
except ImportError as e:
"""
This module holds some basic constraint class for the Haystack model.
"""
__author__ = "Loic Jaquemet loic.jaquemet+python@gmail.com... | class ConstraintsConfigHandler(interfaces.IConstraintsConfigHandler): |
Here is a snippet: <|code_start|>b6efa000-b6f01000 r--p 00296000 08:04 3426931 /usr/lib/i386-linux-gnu/libQtCore.so.4.7.4
b6f01000-b6f04000 rw-p 0029d000 08:04 3426931 /usr/lib/i386-linux-gnu/libQtCore.so.4.7.4
'''
offset = 0xb6b3ef68 - 0xb68b1000
class Dummy():
pass
class Dl_info(ctypes.Structure):
... | return make_process_memory_handler(me) |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Test(unittest.TestCase):
def test_readable(self):
"""test the readable helper."""
invalid = '/345678ui0d9t921giv9'
<|code_end|>
, determine the next line of code. You have imports:
import logging
import unitt... | self.assertRaises(argparse.ArgumentTypeError, argparse_utils.readable, invalid) |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
log = logging.getLogger('heapwalker')
SUPPORTED_ALLOCATORS = {}
def _discover_supported_allocators():
# TODO use it in memory dump discovery. Maybe add platform selectors to Finder interface
for entry_point in p... | class HeapWalker(interfaces.IHeapWalker): |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for haystack.reverse.structure."""
log = logging.getLogger('testwin7heap')
class TestWin7Heap(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.memory_handler = folder.load(putty_1_win7.dumpname)
... | finder = win7heapwalker.Win7HeapFinder(self.memory_handler) |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for haystack.reverse.structure."""
log = logging.getLogger('testwin7heap')
class TestWin7Heap(unittest.TestCase):
@classmethod
def setUpClass(cls):
<|code_end|>
, determine the next line of code. You have imports:
im... | cls.memory_handler = folder.load(putty_1_win7.dumpname) |
Next line prediction: <|code_start|>
def tearDown(self):
if self.process is not None:
try:
self.process.kill()
except OSError as e:
pass
for f in self.tgts:
if os.path.isfile(f):
os.remove(f)
elif os.path... | out1 = memory_dumper.dump(self.process.pid, tgt1, "dir", True) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.