Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|> "properties": { "primary": {"type": "boolean"}, "classification": {"type": "string", "minLength": 1}, "name": {"type": "string", "minLength": 1}, "entity_type": { "...
"sources": sources,
Predict the next line after this snippet: <|code_start|> "primary": {"type": "boolean"}, "classification": {"type": "string", "minLength": 1}, "name": {"type": "string", "minLength": 1}, "entity_type": { "enum": ["org...
"extras": extras,
Based on the snippet: <|code_start|>""" Schema for bill objects. """ versions_or_documents = { "items": { "properties": { "note": {"type": "string", "minLength": 1}, <|code_end|> , predict the immediate next line with the help of imports: from .common import sources, extras, fuzzy_date_bl...
"date": fuzzy_date_blank,
Continue the code snippet: <|code_start|> "date": {"type": "string"}, }, "type": "object"}, "type": "array", }, "other_titles": { "items": { "properties": { "title": {"type": "string", "minLeng...
"date": fuzzy_datetime,
Continue the code snippet: <|code_start|> # a copy of the org schema without sources org_schema_no_sources = copy.deepcopy(org_schema) org_schema_no_sources['properties'].pop('sources') class Post(BaseModel, LinkMixin, ContactDetailMixin): """ A popolo-style Post """ _type = 'post' <|code_end|> . Use...
_schema = post_schema
Given the following code snippet before the placeholder: <|code_start|> 'motion_classification': {"items": {"type": "string", "minLength": 1}, "type": "array"}, 'start_date': fuzzy_datetime_blank, 'end_date': fuzzy_datetime_blank, 'result': {"type": "stri...
'sources': sources,
Based on the snippet: <|code_start|> "type": "array"}, 'start_date': fuzzy_datetime_blank, 'end_date': fuzzy_datetime_blank, 'result': {"type": "string", "enum": common.VOTE_RESULTS}, 'organization': {"type": ["string", "null"], "minLength": 1}, '...
'extras': extras,
Predict the next line after this snippet: <|code_start|> schema = { "type": "object", "properties": { 'identifier': {"type": "string"}, 'motion_text': {"type": "string", "minLength": 1}, 'motion_classification': {"items": {"type": "string", "minLength": 1}, ...
'start_date': fuzzy_datetime_blank,
Given snippet: <|code_start|> for vote in queryset: if vote.yes_count is None: report['votes_missing_yes_count'] += 1 vote.yes_count = 0 if vote.no_count is None: report['votes_missing_no_count'] += 1 vote.no_count = 0 if vote.other_count is No...
return SessionDataQualityReport(legislative_session_id=session, **report)
Given the code snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "classification": { "type": ["string", "null"], "enum": common.ORGANIZATION_CLASSIFICATIONS, ...
"links": links,
Predict the next line for this snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "classification": { "type": ["string", "null"], "enum": common.ORGANIZATION_CL...
"contact_details": contact_details,
Continue the code snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, <|code_end|> . Use current file imports: from .common import (links, contact_details, identifiers, other_names, sources, extras, fuzzy_da...
"identifiers": identifiers,
Given the following code snippet before the placeholder: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, <|code_end|> , predict the next line using imports from the current file: from .common import (links, contact_details, identifiers, other_names, sources, extras, ...
"other_names": other_names,
Given snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "classification": { "type": ["string", "null"], "enum": common.ORGANIZATION_CLASSIFICATIONS, },...
"sources": sources,
Given the code snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "classification": { "type": ["string", "null"], "enum": common.ORGANIZATION_CLASSIFICATIONS, ...
"extras": extras,
Given snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "classification": { "type": ["string", "null"], "enum": common.ORGANIZATION_CLASSIFICATIONS, },...
"founding_date": fuzzy_date_blank,
Continue the code snippet: <|code_start|> schema = { "type": "object", "properties": { "name": {"type": "string", "minLength": 1}, "url": {"type": "string", "minLength": 1}, "classification": {"type": "string", "minLength": 1}, # TODO: enum "division_id": {"type": "string", "mi...
"extras": extras,
Using the snippet: <|code_start|> schema = { "type": "object", "properties": { "name": {"type": "string", "minLength": 1}, "url": {"type": "string", "minLength": 1}, "classification": {"type": "string", "minLength": 1}, # TODO: enum "division_id": {"type": "string", "minLength"...
"start_date": fuzzy_date_blank,
Continue the code snippet: <|code_start|> class Command(BaseCommand): name = 'party' help = 'command line tool to manage parties' def add_args(self): self.add_argument('action', type=str, help='add|list') self.add_argument('party_name', type=str, nargs='?') def handle(self, args, othe...
raise CommandError('party action must be "add" or "list"')
Given the following code snippet before the placeholder: <|code_start|> def test_basics(): # id property and string j = FakeJurisdiction() assert j.jurisdiction_id == 'ocd-jurisdiction/test/government' assert j.name in str(j) def test_as_dict(): j = FakeJurisdiction() d = j.as_dict() ass...
js = JurisdictionScraper(j, '/tmp/')
Predict the next line for this snippet: <|code_start|> class FakeJurisdiction(Jurisdiction): division_id = 'ocd-division/test' classification = 'government' name = 'Test' url = 'http://example.com' def get_organizations(self): <|code_end|> with the help of current file imports: from collections ...
parent = Organization('Congress', classification='legislature')
Predict the next line after this snippet: <|code_start|> def create_jurisdictions(): Division.objects.create(id='ocd-division/country:us', name='USA') Division.objects.create(id='ocd-division/country:us/state:nc', name='NC') Jurisdiction.objects.create(id='us', division_id='ocd-division/country:us') Ju...
post = ScrapePost(label='executive', role='President',
Based on the snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "sort_name": {"type": "string"}, "family_name": {"type": "string"}, "given_name": {"type": "string"}, ...
"links": links,
Continue the code snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "sort_name": {"type": "string"}, "family_name": {"type": "string"}, "given_name": {"type": "string"...
"contact_details": contact_details,
Using the snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, <|code_end|> , determine the next line of code. You have imports: from .common import (links, contact_details, identifiers, other_names, sources, extras, ...
"identifiers": identifiers,
Given the following code snippet before the placeholder: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, <|code_end|> , predict the next line using imports from the current file: from .common import (links, contact_details, identifiers, other_names, sources, extras, ...
"other_names": other_names,
Given snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "sort_name": {"type": "string"}, "family_name": {"type": "string"}, "given_name": {"type": "string"}, "...
"sources": sources,
Using the snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "sort_name": {"type": "string"}, "family_name": {"type": "string"}, "given_name": {"type": "string"}, ...
"extras": extras,
Based on the snippet: <|code_start|> schema = { "properties": { "name": {"type": "string", "minLength": 1}, "other_names": other_names, "identifiers": identifiers, "sort_name": {"type": "string"}, "family_name": {"type": "string"}, "given_name": {"type": "string"}, ...
"birth_date": fuzzy_date_blank,
Here is a snippet: <|code_start|> schema = { "properties": { "label": {"type": "string", "minLength": 1}, "role": {"type": "string"}, "maximum_memberships": {"type": "number"}, "organization_id": {"type": "string", "minLength": 1}, "division_id": {"type": ["null", "string"], ...
"links": links,
Given the code snippet: <|code_start|> schema = { "properties": { "label": {"type": "string", "minLength": 1}, "role": {"type": "string"}, "maximum_memberships": {"type": "number"}, "organization_id": {"type": "string", "minLength": 1}, "division_id": {"type": ["null", "strin...
"contact_details": contact_details,
Next line prediction: <|code_start|> schema = { "properties": { "label": {"type": "string", "minLength": 1}, "role": {"type": "string"}, "maximum_memberships": {"type": "number"}, "organization_id": {"type": "string", "minLength": 1}, "division_id": {"type": ["null", "string"...
"extras": extras,
Predict the next line for this snippet: <|code_start|> schema = { "properties": { "label": {"type": "string", "minLength": 1}, "role": {"type": "string"}, "maximum_memberships": {"type": "number"}, "organization_id": {"type": "string", "minLength": 1}, "division_id": {"type":...
"start_date": fuzzy_date_blank,
Next line prediction: <|code_start|> i.decompose() foot = soup.find('div', style="font-family:'Helvetica Neue';font-size:14px;") next_ = soup.find('div', clas="zan-page bs-example") copy_right = soup.find('div', class_="copyright alert alert-success") ...
new_img.attrs['src'] = choice_img()
Predict the next line after this snippet: <|code_start|> if errors: r['result'].update(ExtJSWrapper.build_errors(errors)) r['result']['success'] = False else: r['result']['success'] = True r['result']['data'] = result ...
data = json.loads(key)
Predict the next line after this snippet: <|code_start|> functions = {} for cls in ('forms', 'direct'): functions[cls] = [] for fn in function_map.iterkeys(): if len(function_map[fn]['args']['all']) > 0: fnlen = 1 ...
json.dumps(result)),
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- try: has_django = True except: has_django = False __all__ = ('__features__', 'Feature', 'FeatureException', 'FeatureContentResponse') <|code_end|> with the help of current file imports: import cPickle import hashlib from simp...
class FeatureException(SAException): pass
Predict the next line after this snippet: <|code_start|> else: spins = list( range( self.spin_channels ) ) if not ions: ions = [ self.number_of_ions ] # nions+1 is the `tot` index if not orbitals: orbitals = list( range( self.number_of_projections ) ) i...
reciprocal_lattice = reciprocal_lattice * 2 * math.pi * angstrom_to_bohr
Next line prediction: <|code_start|> Args: points (list(np.array)): list of Cartesian coordinates for each point. tolerance (optional:float): the maximum triangle size for these points to be considered colinear. Default is 1e-7. Returns: (bool): True if all points fall on a straight line...
delta_e = ( eigenvalues[ 1 ] - eigenvalues[ 0 ] ) * ev_to_hartree * 2.0
Given the code snippet: <|code_start|> new_procar.sanity_check() return new_procar def parse_projections( self ): self.projection_data = projections_parser( self.read_in ) try: assert( self._number_of_bands * self._number_of_k_points == len( self.projection_data ) ) ...
self._bands = np.array( [ Band( float(i), float(e), float(o), negative_occupancies=self.negative_occupancies ) for i, e, o in band_data ] )
Given the code snippet: <|code_start|>#! /usr/bin/env python3 def parse_command_line_arguments(): # command line arguments parser = argparse.ArgumentParser( description='z-projection of a VASP (grid format) file' ) parser.add_argument( 'gridfile', help="filename of the VASP (grid format) file to be proces...
vgrid = grid.Grid()
Continue the code snippet: <|code_start|> def interpolate( i, j, x ): return( ( i * ( 1.0 - x ) ) + ( j * x) ) def trilinear_interpolation( cube, r ): return( interpolate ( interpolate( interpolate( cube[ 0, 0, 0 ], cube[ 1, 0, 0 ], r[ 0 ] ), # trilinear interpolation => h...
self.poscar = poscar.Poscar()
Next line prediction: <|code_start|> break def write_dimensions( self ): print( "\n" + ' '.join( [ str(i) for i in self.dimensions ] ) ) def read_grid( self ): grid_data = [] grid_data_lines = math.ceil( ( self.dimensions[0] * self.dimensions[1] * self.dimensions[2]...
return( self.fractional_coordinate_at_index( index ).dot( self.poscar.cell.matrix ) )
Continue the code snippet: <|code_start|> class Test_Optics(unittest.TestCase): def test_matrix_eigvals(self): matrix = np.array( [ [ 2, 0, 3 ], [ 0, 3, 0 ], [ 0, 0, 3 ] ] ) expected_eigenvalues = np.array( [ 2, 3, 3 ] ) <|code_end|> . Use c...
np.testing.assert_array_equal( matrix_eigvals( matrix ), expected_eigenvalues )
Given the code snippet: <|code_start|> class Test_Optics(unittest.TestCase): def test_matrix_eigvals(self): matrix = np.array( [ [ 2, 0, 3 ], [ 0, 3, 0 ], [ 0, 0, 3 ] ] ) expected_eigenvalues = np.array( [ 2, 3, 3 ] ) np.testing.asse...
np.testing.assert_array_equal( to_matrix( xx=1, yy=4, zz=6, xy=2, yz=5, xz=3 ),
Continue the code snippet: <|code_start|> class Test_Optics(unittest.TestCase): def test_matrix_eigvals(self): matrix = np.array( [ [ 2, 0, 3 ], [ 0, 3, 0 ], [ 0, 0, 3 ] ] ) expected_eigenvalues = np.array( [ 2, 3, 3 ] ) np.testing.a...
np.testing.assert_array_equal( parse_dielectric_data( input_data ), expected_data )
Predict the next line for this snippet: <|code_start|> class AtomTestCase( unittest.TestCase ): def test_init_atom( self ): label = 'A' r = np.array( [ 0.1, 0.2, 0.3 ] ) <|code_end|> with the help of current file imports: import unittest import numpy as np from vasppy.atom import Atom and conte...
atom = Atom( label=label, r=r )
Predict the next line after this snippet: <|code_start|> class VASPMetaTestCase( unittest.TestCase ): def test_init_vaspmeta( self ): title = 'title' description = 'description' notes = 'notes' valid_status = [ 'to-run', 'incomplete', 'finished', 'dropped' ] for s in valid_...
vaspmeta = VASPMeta( title, description, status=s, notes=notes )
Predict the next line for this snippet: <|code_start|> class BandTestCase( unittest.TestCase ): """Tests for procar.Band class""" def test_band_is_initialised( self ): """Test Band object is initialised""" index = 2 energy = 1.0 occupancy = 0.5 with patch( 'vasppy.band....
band = Band( index=index, energy=energy, occupancy=occupancy )
Given the code snippet: <|code_start|> class BandTestCase( unittest.TestCase ): """Tests for procar.Band class""" def test_band_is_initialised( self ): """Test Band object is initialised""" index = 2 energy = 1.0 occupancy = 0.5 with patch( 'vasppy.band.handle_occupancy...
handle_occupancy( 0.5, negative_occupancies='foo' )
Based on the snippet: <|code_start|>#! /usr/bin/env python3 def minimum_length( nmin ): class MinimumLength( argparse.Action ): def __call__( self, parser, args, values, option_string=None ): if not nmin <= len( values ): msg = 'argument "{f}" requires at least {nmin} arguments...
pcar = procar.Procar()
Using the snippet: <|code_start|>#! /usr/bin/env python3 def minimum_length( nmin ): class MinimumLength( argparse.Action ): def __call__( self, parser, args, values, option_string=None ): if not nmin <= len( values ): msg = 'argument "{f}" requires at least {nmin} arguments'.f...
reciprocal_lattice = reciprocal_lattice_from_outcar( 'OUTCAR' ) # Move reading the reciprocal lattice to procar.py
Predict the next line after this snippet: <|code_start|># return x_axis def orbitals_with_l( l ): to_return = { 's' : [ 0 ], 'p' : [ 1, 2, 3 ], 'd' : [ 4, 5, 6, 7, 8 ], 'f' : [ 9, 10, 11, 12, 13 ], 'all' : None } return to_return[ l ] ...
pcar = procar.Procar()
Given the code snippet: <|code_start|># x_axis.append( d + x_axis[-1] ) # x_axis = np.array( x_axis ) # else: # x_axis = np.arange( len( cartesian_k_points ) ) # return x_axis def orbitals_with_l( l ): to_return = { 's' : [ 0 ], 'p' : [ 1, 2, 3 ], ...
reciprocal_lattice = reciprocal_lattice_from_outcar( 'OUTCAR' ) # Move reading the reciprocal lattice to procar.py
Predict the next line after this snippet: <|code_start|> class OutcarTestCase( unittest.TestCase ): def test_final_energy_from_outcar( self ): example_file = """energy without entropy = -2997.63294724 energy(sigma->0) = -2997.63294724\n energy without entropy= -2997.6329...
self.assertEqual( final_energy_from_outcar(), -2997.63289805 )
Next line prediction: <|code_start|> class OutcarTestCase( unittest.TestCase ): def test_final_energy_from_outcar( self ): example_file = """energy without entropy = -2997.63294724 energy(sigma->0) = -2997.63294724\n energy without entropy= -2997.63294724 energy(sigma->...
self.assertEqual( potcar_eatom_list_from_outcar(), [ -1042.3781, -432.3788, -659.6475 ] )
Using the snippet: <|code_start|> class UtilsTestCase( unittest.TestCase ): def test_md5sum( self ): string = 'abcdefg' h = hashlib.new( 'md5' ) h.update( string.encode( 'utf-8' ) ) <|code_end|> , determine the next line of code. You have imports: import unittest import hashlib from vasppy...
self.assertEqual( md5sum( string ), h.hexdigest() )
Predict the next line for this snippet: <|code_start|> class UtilsTestCase( unittest.TestCase ): def test_md5sum( self ): string = 'abcdefg' h = hashlib.new( 'md5' ) h.update( string.encode( 'utf-8' ) ) self.assertEqual( md5sum( string ), h.hexdigest() ) def test_file_md5( self...
self.assertEqual( file_md5( m ), 'foo' )
Given the following code snippet before the placeholder: <|code_start|> class UtilsTestCase( unittest.TestCase ): def test_md5sum( self ): string = 'abcdefg' h = hashlib.new( 'md5' ) h.update( string.encode( 'utf-8' ) ) self.assertEqual( md5sum( string ), h.hexdigest() ) def te...
validate_checksum( filename='foo', md5sum='abcdef' )
Based on the snippet: <|code_start|>#! /usr/bin/env python3 def parse_command_line_arguments(): parser = argparse.ArgumentParser( description='Generate POTCAR specification based on hashing individual pseudopotential strings' ) parser.add_argument('potcar', help="filename of the VASP POTCAR to be processed", ...
for p, md5hash in potcar_spec(args.potcar, return_hashes=True).items():
Based on the snippet: <|code_start|> test_data_dir = 'test_data' test_procar_filename = os.path.join( os.path.dirname( __file__ ), test_data_dir, 'PROCAR_test' ) test_procar_spin_polarised_filename = os.path.join( os.path.dirname( __file__ ), test_data_dir, 'PROCAR_spin_polarised_test' ) class KPointTestCase( unittest...
self.k_point = procar.KPoint( index=index, frac_coords=frac_coords, weight=weight )
Predict the next line after this snippet: <|code_start|> new_poscar.atom_numbers = [ int( num * h * k * l / 2 ) for num in self.atom_numbers for __ in ( 0, 1 )] else: new_poscar.atoms = self.atoms new_poscar.atom_numbers = [ num * h * k * l for num in self.atom_numbers ] ...
config = configuration.Configuration( cell.Cell( matrix = self.cell.matrix * self.scaling ), atoms )
Given snippet: <|code_start|> new_poscar.atoms = [ label + group for label in self.atoms for group in ('a','b') ] new_poscar.atom_numbers = [ int( num * h * k * l / 2 ) for num in self.atom_numbers for __ in ( 0, 1 )] else: new_poscar.atoms = self.atoms new_poscar....
atoms = [ atom.Atom( label, coordinates ) for ( label, coordinates ) in zip( self.labels(), self.fractional_coordinates() ) ]
Predict the next line for this snippet: <|code_start|> # Ignore SIG_PIPE and don't throw exceptions on it... # http://newbebweb.blogspot.co.uk/2012/02/python-head-ioerror-errno-32-broken.html signal( SIGPIPE, SIG_DFL ) def parity( list ): return( sum( list )%2 ) def swap_axes( matrix, axes ): axes_index = {...
self.cell = cell.Cell( np.identity( 3 ) )
Given the following code snippet before the placeholder: <|code_start|> print( ''.join( [' {: .10f}'.format( element ) for element in row ] ) ) print( ' '.join( self.atoms ) ) print( ' '.join( [ str(n) for n in self.atom_numbers ] ) ) if opts.get('selective'): print( 'Se...
unit_scaling = angstrom_to_bohr
Given the following code snippet before the placeholder: <|code_start|> A Configuration object stores a single structure. """ def __init__( self, cell, atoms ): self.cell = cell self.atoms = atoms def dr( self, atom1, atom2 ): """ Calculate the distance between two ato...
return filter( lambda atom: atom.label == label, self.atoms )
Next line prediction: <|code_start|> def __init__( self, cell, atoms ): self.cell = cell self.atoms = atoms def dr( self, atom1, atom2 ): """ Calculate the distance between two atoms. Args: atom1 (vasppy.Atom): Atom 1. atom2 (vasppy.Atom): Atom ...
this_rdf = rdf.Rdf( max_r, number_of_bins )
Here is a snippet: <|code_start|> mock_potcar_string = """foo End of Dataset bar End of Dataset sds End of Dataset """ mock_potcar_data = { 'PBE': { 'A': '12', 'B': '34' }, 'PBE_52': { 'C': '01', 'D': '23' }, ...
summary = Summary()
Given snippet: <|code_start|> self.summary.meta.type = 'TYPE' self.summary.print_type() self.assertEqual( mock_stdout.getvalue(), 'type: TYPE\n' ) @patch('sys.stdout', new_callable=StringIO) def test_print_type_if_type_is_not_set( self, mock_stdout ): self.summary.meta.type = Non...
self.assertEqual( md5sum('hello\n'), 'b1946ac92492d2347c6235b4d2611184' )
Given the following code snippet before the placeholder: <|code_start|> self.assertEqual( mock_stdout.getvalue(), '' ) @patch('sys.stdout', new_callable=StringIO) def test_print_title( self, mock_stdout ): self.summary.meta.title = 'TITLE' self.summary.print_title() self.assertEq...
p_spec = potcar_spec(mock_potcar_filename)
Next line prediction: <|code_start|> @patch('vasppy.summary.VASPMeta') @patch('vasppy.summary.Summary.parse_vasprun') def test_summary_is_initialised( self, mock_parse_vasprun, MockVASPMeta ): MockVASPMeta.from_file = Mock( return_value='foo' ) summary = Summary() self.assertEqual( mo...
self.summary.meta = Mock( spec=VASPMeta )
Given snippet: <|code_start|> class AutoKPointsTestCase( unittest.TestCase ): def test_init_auto_kpoints( self ): title = 'title' subdivisions = np.array( [ 2, 2, 2 ] ) <|code_end|> , continue by predicting the next line. Consider current file imports: import unittest import numpy as np from unit...
auto_kpoints = AutoKPoints( title, subdivisions )
Given the code snippet: <|code_start|>#! /usr/bin/env python3 def parse_command_line_arguments(): # command line arguments parser = argparse.ArgumentParser() parser.add_argument( 'xdatcar' ) args = parser.parse_args() return( args ) def main(): args = parse_command_line_arguments() <|code_end...
xdatcar = Xdatcar()
Based on the snippet: <|code_start|> log = logging.getLogger(__name__) default_message = """Deployed {sha} with MkDocs version: {version}""" def _is_cwd_git_repo(): try: proc = subprocess.Popen( ['git', 'rev-parse', '--is-inside-work-tree'], stdout=subprocess.PIPE, st...
raise Abort('Deployment Aborted!')
Predict the next line after this snippet: <|code_start|> temp_dir.cleanup() def test_load_default_file_prefer_yml(self): """ test that `mkdocs.yml` will be loaded when '--config' is not set. """ temp_dir = TemporaryDirectory() config_file1 = open(os.path.join(tem...
with self.assertRaises(exceptions.ConfigurationError):
Using the snippet: <|code_start|> """ config_file = tempfile.NamedTemporaryFile('w', delete=False) try: config_file.write("site_name: MkDocs Test\n") config_file.flush() config_file.close() finally: os.remove(config_file.name) with ...
class InvalidConfigOption(BaseConfigOption):
Predict the next line for this snippet: <|code_start|> ], 'mkdocs.themes': [ 'mkdocs = mkdocs.themes.mkdocs', 'readthedocs = mkdocs.themes.readthedocs', ], 'mkdocs.plugins': [ 'search = mkdocs.contrib.search:SearchPlugin', ], }, classifi...
cmdclass=babel_cmdclass,
Given the following code snippet before the placeholder: <|code_start|> BASE_DIR = path.normpath(path.join(path.abspath(path.dirname(__file__)), '../../')) class ThemeMixinTests(unittest.TestCase): def test_dict_entry_point(self): <|code_end|> , predict the next line using imports from the current file: import...
inst = babel.ThemeMixin()
Given the code snippet: <|code_start|>#!/usr/bin/env python class LocalizationTests(unittest.TestCase): def setUp(self): self.env = unittest.mock.Mock() def test_jinja_extension_installed(self): <|code_end|> , generate the next line using the imports in this file: import unittest from mkdocs.loc...
install_translations(self.env, parse_locale('en'), [])
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python class LocalizationTests(unittest.TestCase): def setUp(self): self.env = unittest.mock.Mock() def test_jinja_extension_installed(self): <|code_end|> with the help of current file imports: import unittest from mkdocs.loca...
install_translations(self.env, parse_locale('en'), [])
Predict the next line after this snippet: <|code_start|> class LocalizationTests(unittest.TestCase): def setUp(self): self.env = unittest.mock.Mock() def test_jinja_extension_installed(self): install_translations(self.env, parse_locale('en'), []) self.env.add_extension.assert_calle...
@tempdir()
Next line prediction: <|code_start|>#!/usr/bin/env python class LocalizationTests(unittest.TestCase): def setUp(self): self.env = unittest.mock.Mock() def test_jinja_extension_installed(self): install_translations(self.env, parse_locale('en'), []) self.env.add_extension.assert_cal...
self.assertRaises(ValidationError, parse_locale, 'foo')
Given snippet: <|code_start|> def get_plugins(): """ Return a dict of all installed Plugins as {name: EntryPoint}. """ plugins = importlib_metadata.entry_points(group='mkdocs.plugins') # Allow third-party plugins to override core plugins pluginmap = {} for plugin in plugins: if plugin.name...
self.config = Config(schema=self.config_scheme, config_file_path=config_file_path)
Next line prediction: <|code_start|> def test_parse_locale_language_territory(self): locale = Locale.parse('fr_FR', '_') self.assertEqual(locale.language, 'fr') self.assertEqual(locale.territory, 'FR') self.assertEqual(str(locale), 'fr_FR') def test_parse_locale_language_territo...
with self.assertRaises(UnknownLocaleError):
Based on the snippet: <|code_start|> abs_path = os.path.abspath(os.path.dirname(__file__)) mkdocs_dir = os.path.abspath(os.path.dirname(mkdocs.__file__)) mkdocs_templates_dir = os.path.join(mkdocs_dir, 'templates') theme_dir = os.path.abspath(os.path.join(mkdocs_dir, 'themes')) def get_vars(theme): """ Return di...
theme = Theme(name='mkdocs')
Predict the next line for this snippet: <|code_start|> abs_path = os.path.abspath(os.path.dirname(__file__)) mkdocs_dir = os.path.abspath(os.path.dirname(mkdocs.__file__)) mkdocs_templates_dir = os.path.join(mkdocs_dir, 'templates') theme_dir = os.path.abspath(os.path.join(mkdocs_dir, 'themes')) def get_vars(theme):...
'locale': parse_locale('en'),
Using the snippet: <|code_start|>#!/usr/bin/env python class TableOfContentsTests(unittest.TestCase): def test_indented_toc(self): md = dedent(""" # Heading 1 ## Heading 2 ### Heading 3 """) expected = dedent(""" Heading 1 - #heading-1 Heading ...
toc = get_toc(get_markdown_toc(md))
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python class TableOfContentsTests(unittest.TestCase): def test_indented_toc(self): md = dedent(""" # Heading 1 ## Heading 2 ### Heading 3 """) expected = dedent(""" Headi...
toc = get_toc(get_markdown_toc(md))
Continue the code snippet: <|code_start|>#!/usr/bin/env python class CLITests(unittest.TestCase): def setUp(self): self.runner = CliRunner() @mock.patch('mkdocs.commands.serve.serve', autospec=True) def test_serve_default(self, mock_serve): result = self.runner.invoke( <|code_end|> ....
cli.cli, ["serve"], catch_exceptions=False)
Next line prediction: <|code_start|>#!/usr/bin/env python class NewTests(unittest.TestCase): def test_new(self): tempdir = tempfile.mkdtemp() os.chdir(tempdir) <|code_end|> . Use current file imports: (import tempfile import unittest import os from mkdocs.commands import new) and context in...
new.new("myproject")
Continue the code snippet: <|code_start|> try: has_babel = True except ImportError: # pragma: no cover has_babel = False log = logging.getLogger(__name__) base_path = os.path.dirname(os.path.abspath(__file__)) class NoBabelExtension(InternationalizationExtension): # pragma: no cover def __init__(self...
raise ValidationError(f'Invalid value for locale: {str(e)}')
Given snippet: <|code_start|> queryset = Project.objects.all() serializer_class = ProjectSerializer filter_backends = (filters.DjangoFilterBackend,) filter_fields = ('slug',) @detail_route(methods=['post']) def initialize(self, request, pk=None): project = self.get_object() if pr...
serializer_class = ModuleSerializer
Next line prediction: <|code_start|> project = self.get_object() if project.modules.exists() or project.directories.exists(): return Response('The project must be empty', status=status.HTTP_400_BAD_REQUEST) dir_tree_serializer = DirectoryTreeSerializer(data=request.data, many=True) ...
serializer_class = IssueKindSerializer
Given the following code snippet before the placeholder: <|code_start|> init_project(project, dir_tree_serializer.validated_data) return Response({'status': 'Project initialized'}) else: return Response(dir_tree_serializer.errors, status=status.HTTP_400_BAD_REQUEST) @deta...
serializer_class = IssueSerializer
Using the snippet: <|code_start|> project = self.get_object() sync_module_serializer = SyncModuleSerializer(data=request.data, many=True, context={'request': request}) if sync_module_serializer.is_valid(): sync_issues(project, sync_module_serializer.validated_data) return ...
serializer_class = DirectorySerializer
Predict the next line after this snippet: <|code_start|> class ProjectViewSet(viewsets.ModelViewSet): queryset = Project.objects.all() serializer_class = ProjectSerializer filter_backends = (filters.DjangoFilterBackend,) filter_fields = ('slug',) @detail_route(methods=['post']) def initializ...
dir_tree_serializer = DirectoryTreeSerializer(data=request.data, many=True)
Here is a snippet: <|code_start|> class ProjectViewSet(viewsets.ModelViewSet): queryset = Project.objects.all() serializer_class = ProjectSerializer filter_backends = (filters.DjangoFilterBackend,) filter_fields = ('slug',) @detail_route(methods=['post']) def initialize(self, request, pk=Non...
sync_module_serializer = SyncModuleSerializer(data=request.data, many=True, context={'request': request})
Given the code snippet: <|code_start|> class HomeView(TemplateView): template_name = 'daprojects_webapp/home.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['projects_and_maps'] = [ <|code_end|> , generate the next line using the imports in th...
(project, get_map_for_project(project)) for project in models.Project.objects.all()
Given the code snippet: <|code_start|> class DAProjectsAPI(): def __init__(self, *args, **kwargs): client = APIClient(*args, **kwargs) self.projects = Projects(client) self.modules = Modules(client) self.issue_kinds = IssueKinds(client) self.issues = Issues(client) ...
class Projects(APIResourceList):
Continue the code snippet: <|code_start|> router = routers.DefaultRouter() router.register(r'projects', ProjectViewSet) router.register(r'modules', ModuleViewSet) <|code_end|> . Use current file imports: from django.conf.urls import url, include from rest_framework import routers from .views import ProjectViewSet, Mo...
router.register(r'issue_kinds', IssueKindViewSet)