Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Next line prediction: <|code_start|># Purpose: blocks section
# Created: 09.08.2012, taken from my package ezdxf
# Copyright (C) 2011, Manfred Moitzi
# License: MIT-License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class BlocksSection(object):
name = 'blocks'
... | for group in TagGroups(islice(tags, 2, len(tags)-1)):
|
Predict the next line for this snippet: <|code_start|># Purpose: blocks section
# Created: 09.08.2012, taken from my package ezdxf
# Copyright (C) 2011, Manfred Moitzi
# License: MIT-License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
class BlocksSection(object):
name ... | entities = build_entities(groups)
|
Using the snippet: <|code_start|> ole = Import_IPT.checkVersion(filename)
if (ole):
if (Import_IPT.read(ole)):
return Import_IPT
elif (ext == '.ipn'):
ole = Import_IPT.checkVersion(filename)
if (ole):
if (Import_IPT.read(ole)):
return Import_IPT
elif (ext == '.idw'):
ole = Import_IPT.... | return canImport()
|
Given snippet: <|code_start|> if (FreeCAD.GuiUp):
# adjust camara position and orientation
g = FreeCADGui.getDocument(doc.Name)
v = g.ActiveView
c = v.getCameraNode()
p = coin.SbVec3f(1, 1, 1)
o = coin.SbVec3f(0, 0, 0)
u = coin.SbVec3f(0, 1, 0)
c.position.setValue(p)
c.pointAt( o, u )
Free... | logInfo(u"DONE!")
|
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
'''
importer.py:
Collection of 3D Mesh importers
'''
__author__ = "Jens M. Plonka"
__copyright__ = 'Copyright 2018, Germany'
__url__ = "https://www.github.com/jmplonka/InventorLoader"
def decode(name):
"decodes encoded strings"
dec... | logWarning(" Couldn't determine character encoding for filename - using unencoded!\n")
|
Predict the next line for this snippet: <|code_start|> if (importerSAT.readText(filename)):
return importerSAT
elif (ext in ['.sab', '.smb', '.smbh']):
if (importerSAT.readBinary(filename)):
return importerSAT
elif (ext == '.dxf'):
if (importerDXF.read(filename)):
return importerDXF
elif (ext =... | logError(u"File doesn't exists (%s)!", os.path.abspath(filename))
|
Continue the code snippet: <|code_start|> if (not isOleFile(filename)):
logError(u"ERROR> '%s' is not a valid Autodesk Inventor file!", filename)
return False
return canImport()
def releaseMemory():
setThumbnail(None)
Acis.releaseMemory()
importerClasses.releaseModel()
def adjustView(doc):
if (... | logAlways(u"Importing: %s", filename)
|
Predict the next line after this snippet: <|code_start|> c.pointAt( o, u )
FreeCADGui.SendMsgToActiveView("ViewFit")
def insert(filename, docname, skip = [], only = [], root = None):
'''
opens an Autodesk Inventor file in the current document
'''
doc = FreeCAD.listDocuments().get(docname)
if (doc):
... | doc.CreatedBy = getAuthor()
|
Given the code snippet: <|code_start|>
def insert(filename, docname, skip = [], only = [], root = None):
'''
opens an Autodesk Inventor file in the current document
'''
doc = FreeCAD.listDocuments().get(docname)
if (doc):
if (isFileValid(filename)):
logAlways(u"Importing: %s", filename)
reader = r... | doc.Comment = getComment()
|
Given snippet: <|code_start|> FreeCADGui.SendMsgToActiveView("ViewFit")
def insert(filename, docname, skip = [], only = [], root = None):
'''
opens an Autodesk Inventor file in the current document
'''
doc = FreeCAD.listDocuments().get(docname)
if (doc):
if (isFileValid(filename)):
logAlways(u"Impo... | doc.LastModifiedBy = getLastModifiedBy()
|
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
'''
importer.py:
Collection of 3D Mesh importers
'''
__author__ = "Jens M. Plonka"
__copyright__ = 'Copyright 2018, Germany'
__url__ = "https://www.github.com/jmplonka/InventorLoader"
def decode(name):
"decodes encoded strings"
dec... | setThumbnail(None)
|
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
'''
importer.py:
Collection of 3D Mesh importers
'''
__author__ = "Jens M. Plonka"
__copyright__ = 'Copyright 2018, Germany'
__url__ = "https://www.github.com/jmplonka/InventorLoader"
def decode(na... | root = createGroup('_%s' %(grpName))
|
Given the code snippet: <|code_start|># Purpose: handle tables section
# Created: 21.07.2012, taken from my ezdxf project
# Copyright (C) 2012, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
TABLENAMES = {
'layer' : 'layers',
... | 'LAYER': LayerTable,
|
Predict the next line after this snippet: <|code_start|>
class EntitySection(object):
name = 'entities'
def __init__(self):
self._entities = list()
@classmethod
def from_tags(cls, tags, drawing):
entity_section = cls()
entity_section._build(tags)
return e... | groups = TagGroups(islice(tags, 2, len(tags)-1))
|
Given snippet: <|code_start|> @classmethod
def from_tags(cls, tags, drawing):
entity_section = cls()
entity_section._build(tags)
return entity_section
def get_entities(self):
return self._entities
def __len__(self):
return len(self._entities)
def... | entity = entity_factory(Tags(group))
|
Continue the code snippet: <|code_start|> @classmethod
def from_tags(cls, tags, drawing):
entity_section = cls()
entity_section._build(tags)
return entity_section
def get_entities(self):
return self._entities
def __len__(self):
return len(self._entities... | entity = entity_factory(Tags(group))
|
Next line prediction: <|code_start|> self.desc = desc
def _getParameters(self):
return super(GROUP, self)._getParameters() + [self.desc]
#############################################################
# Global functions
#############################################################
def export(filename, satHe... | path = getDumpFolder().replace('\\', '/')
|
Using the snippet: <|code_start|> path, f = os.path.split(filename)
name, x = os.path.splitext(f)
path = getDumpFolder().replace('\\', '/')
stepfile = "%s/%s.step" %(path, name)
step = u"ISO-10303-21;\n"
step += u"HEADER;\n"
step += u"FILE_DESCRIPTION(('FreeCAD Model'),'2;1');\n"
step += u"FILE_NAME('%s... | logInfo(u"STEP file written to '%s'.", stepfile)
|
Predict the next line after this snippet: <|code_start|> torus.placement = _createAxis2Placement3D('', center, 'Origin', axis, 'center_axis', ref, 'ref_axis')
if (minor < 0.0): return torus, (sense != 'forward')
return torus, (sense == 'forward')
def _createSurfaceFaceShape(acisFace, shape):
surface = acisFace... | logWarning("Can't export surface '%s.%s'!" %(shape.__class__.__module__, shape.__class__.__name__))
|
Here is a snippet: <|code_start|> def getAttribute(self):
l = [_obj2str(p) for p in self._getParameters()]
return "%s(%s)" %(self._getClassName(), ",".join(l))
def toString(self):
l = [_obj2str(p) for p in self._getParameters()]
return "%s(%s)" %(self._getClassName(), ",".join(l))
def __str__(self):
... | logError(traceback.format_exc())
|
Given the code snippet: <|code_start|> except:
ec = EDGE_CURVE('', p1, p2, curve, sense)
_edgeCurves[key] = ec
return ec
def _exportList_(a):
step = ''
for i in a:
if (isinstance(i, ExportEntity)):
step += i.exportSTEP()
elif (type(i) == list):
step += _exportList_(i)
elif (type(i) == tu... | if (isEqual1D(acisCurve.ratio, 1.0)):
|
Continue the code snippet: <|code_start|> super(GEOMETRIC_REPRESENTATION_ITEM, self).__init__()
class SURFACE(ReferencedEntity):
def __init__(self):
super(SURFACE, self).__init__()
class RATIONAL_B_SPLINE_SURFACE(ReferencedEntity):
def __init__(self, weights):
super(RATIONAL_B_SPLINE_SURFACE, self).__i... | user = getAuthor()
|
Given the following code snippet before the placeholder: <|code_start|>
class SURFACE(ReferencedEntity):
def __init__(self):
super(SURFACE, self).__init__()
class RATIONAL_B_SPLINE_SURFACE(ReferencedEntity):
def __init__(self, weights):
super(RATIONAL_B_SPLINE_SURFACE, self).__init__()
self.weights = w... | desc = getDescription()
|
Given the following code snippet before the placeholder: <|code_start|> return u"(%s)" %(",".join([_obj2str(i) for i in l]))
def _obj2str(o):
if (o is None): return _str2str(o)
if (type(o) == int): return u"%d" %(o)
if (sys.version_info.major < 3):
if (type(o) == long): ... | color = getColorDefault()
|
Continue the code snippet: <|code_start|> if (curve is not None):
oe = ORIENTED_EDGE((acisCoEdge.sense == 'forward'))
p1 = _createVertexPoint(acisEdge.getStart())
p2 = _createVertexPoint(acisEdge.getEnd())
e = _createEdgeCurve(p1, p2, curve, (acisEdge.sense == 'forward'))
oe.edge = e
r... | return DIR_X.cross(axis) # any perpendicular vector to normal?!?
|
Using the snippet: <|code_start|> acisEdge = acisCoEdge.getEdge()
curve = _createCurve(acisEdge.getCurve())
if (curve is not None):
oe = ORIENTED_EDGE((acisCoEdge.sense == 'forward'))
p1 = _createVertexPoint(acisEdge.getStart())
p2 = _createVertexPoint(acisEdge.getEnd())
e = _createEd... | if (isEqual1D(axis.x, 1.0)): return DIR_Y
|
Next line prediction: <|code_start|> self.sec2 = None
self.set = None
self.exp = None
def __str__(self): return "[%s], %s, '%s', [%s]" %(IntArr2Str(self.a1, 4), self.size, self.a2, IntArr2Str(self.a3, 2))
class UFRxAppendix(UFRxObject):
def __init__(self):
self.p1 = ()
self.p2 = 0
class UFRxBOM... | v = VersionInfo() # [00 00 18 40 00 00 A0 41]
|
Predict the next line after this snippet: <|code_start|> self.label = u''
self.orgPath = u''
self.fmtId = None
self.dataPath = u''
self.dataLen = 0
self.data = []
self.orgPathW = u''
self.labelW = u''
self.defPathW = u''
def __repr__(self): return str(... | self.header, i = getUInt16(data, i)# get flag1, typically a hardcoded value of 02 00
|
Continue the code snippet: <|code_start|> self.header = None
self.label = u''
self.orgPath = u''
self.fmtId = None
self.dataPath = u''
self.dataLen = 0
self.data = []
self.orgPathW = u''
self.labelW = u''
self.defPathW = u''
def __repr__(self):... | self.size, i = getUInt32(data, 0)
|
Predict the next line after this snippet: <|code_start|> self.dataLen = 0
self.data = []
self.orgPathW = u''
self.labelW = u''
self.defPathW = u''
def __repr__(self): return str(self.getDict())
def getDict(self):
"""populate temp dict that stores configurations"""
return... | self.dataPath, i = getLen32Text8(data, i)
|
Predict the next line for this snippet: <|code_start|>
def __repr__(self): return str(self.getDict())
def getDict(self):
"""populate temp dict that stores configurations"""
return {
"size": self.size,
"header": self.header,
"label": self.label,
"orgPath": ... | self.orgPathW, i = getLen32Text16(data, i) # command16
|
Based on the snippet: <|code_start|> The zero based offset of the UID.
Returns:
The UID at offset.
The new position in the 'stream'.
'''
end = offset + 16
val = UID(bytes_le=data[offset:end])
return val, end
def getDateTime(data, offset):
'''
Returns a timestamp (datetime).
Args:
data
... | txt = data[i: end].decode(ENCODING_FS)
|
Given the following code snippet before the placeholder: <|code_start|>def getParameterization(pts, fac, closed):
# Computes a knot Sequence for a set of points
# fac (0-1) : parameterization factor
# 0 -> Uniform
# 0.5 -> Centripetal
# 1.0 -> Chord-Length
... | self.parameters = (MIN_0, MAX_2PI)
|
Predict the next line for this snippet: <|code_start|> tol11, i = getLength(chunks, i)
if (not chunks[i].tag in [TAG_UTF8_U8, TAG_IDENT, TAG_SUBIDENT]):
i += 1 # newer Inventor versions (>2017
p13, i = readBS2Curve(chunks, i)
else:
raise AssertionError("wrong singularity %s" %(singularity))
t... | angle, i = getInterval(chunks, index, MIN_PI, MAX_PI, 1.0)
|
Given snippet: <|code_start|> self.normal = DIR_Z
self.uvorigin = CENTER
self.sensev = 'forward_v'
self.urange = Interval(Range('I', MIN_INF), Range('I', MAX_INF))
self.vrange = Interval(Range('I', MIN_INF), Range('I', MAX_INF))
def getSatTextGeometry(self, index): return "%s %s %s %s %s %s #" %... | self.vrange = Interval(Range('I', MIN_PI2), Range('I', MAX_PI2))
|
Given the following code snippet before the placeholder: <|code_start|>
def readBS3Surface(chunks, index):
nbs, degreeU, degreeV, i = getDimensionSurface(chunks, index)
if (nbs == 'nullbs'):
return None, i
if (nbs in ('nubs', 'nurbs')):
closureU, closureV, singularityU, singularityV, countU, countV, i = ge... | rngU, i = getInterval(chunks, i, MIN_INF, MAX_INF, 1.0)
|
Given the following code snippet before the placeholder: <|code_start|>def getParameterization(pts, fac, closed):
# Computes a knot Sequence for a set of points
# fac (0-1) : parameterization factor
# 0 -> Uniform
# 0.5 -> Centripetal
# 1.0 -> Chord-Length
... | self.parameters = (MIN_0, MAX_2PI)
|
Given snippet: <|code_start|> tol11, i = getLength(chunks, i)
if (not chunks[i].tag in [TAG_UTF8_U8, TAG_IDENT, TAG_SUBIDENT]):
i += 1 # newer Inventor versions (>2017
p13, i = readBS2Curve(chunks, i)
else:
raise AssertionError("wrong singularity %s" %(singularity))
t21, i = getValue(chunks, ... | angle, i = getInterval(chunks, index, MIN_PI, MAX_PI, 1.0)
|
Here is a snippet: <|code_start|> self.normal = DIR_Z
self.uvorigin = CENTER
self.sensev = 'forward_v'
self.urange = Interval(Range('I', MIN_INF), Range('I', MAX_INF))
self.vrange = Interval(Range('I', MIN_INF), Range('I', MAX_INF))
def getSatTextGeometry(self, index): return "%s %s %s %s %s %s ... | self.vrange = Interval(Range('I', MIN_PI2), Range('I', MAX_PI2))
|
Given the following code snippet before the placeholder: <|code_start|>
def readBS3Surface(chunks, index):
nbs, degreeU, degreeV, i = getDimensionSurface(chunks, index)
if (nbs == 'nullbs'):
return None, i
if (nbs in ('nubs', 'nurbs')):
closureU, closureV, singularityU, singularityV, countU, countV, i = ge... | rngU, i = getInterval(chunks, i, MIN_INF, MAX_INF, 1.0)
|
Continue the code snippet: <|code_start|> if (not chunks[i].tag in [TAG_UTF8_U8, TAG_IDENT, TAG_SUBIDENT]):
i += 1 # newer Inventor versions (>2017
p13, i = readBS2Curve(chunks, i)
else:
raise AssertionError("wrong singularity %s" %(singularity))
t21, i = getValue(chunks, i)
s21, i = readSurfa... | dime1, i = getInterval(chunks, i, -MAX_LEN, MAX_LEN, getScale())
|
Continue the code snippet: <|code_start|> logError(traceback.format_exc())
raise Exception("Unknown surface-type '%s'!" % (subtype))
return surface, i
#FIXME: this is a dirty hack :(
if (chunk.tag == TAG_DOUBLE):
a, i = getFloats(chunks, index, 5)
return None, i
if (chunk.tag in [TAG_POSITION, TAG... | shape.rotate(PLC(CENTER, axis, angle))
|
Here is a snippet: <|code_start|> except:
logError(traceback.format_exc())
raise Exception("Unknown surface-type '%s'!" % (subtype))
return surface, i
#FIXME: this is a dirty hack :(
if (chunk.tag == TAG_DOUBLE):
a, i = getFloats(chunks, index, 5)
return None, i
if (chunk.tag in [TAG_POSITION, ... | axis = DIR_Z.cross(dir) if angle != 180 else DIR_X
|
Continue the code snippet: <|code_start|> self.weights = [[]] # sequence of sequence float
self.vMults = () # tuple of int, ref. umults
self.vKnots = () # tuple of float
self.vPeriodic = vPeriodic # boolean
self.vDegree = vDegree # int
def readPoints3DMap(self, count... | self.dirMinor = DIR_Y
|
Given the code snippet: <|code_start|> if (surface is not None):
i = surface.setSubtype(chunks, i)
except:
logError(traceback.format_exc())
raise Exception("Unknown surface-type '%s'!" % (subtype))
return surface, i
#FIXME: this is a dirty hack :(
if (chunk.tag == TAG_DOUBLE):
a, i = getFlo... | angle = degrees(DIR_Z.getAngle(dir))
|
Based on the snippet: <|code_start|>TOKEN_TRANSLATIONS = {
'0x0a': TAG_TRUE,
'0x0A': TAG_TRUE,
'0x0b': TAG_FALSE,
'0x0B': TAG_FALSE,
'{': TAG_SUBTYPE_OPEN,
'}': TAG_SUBTYPE_CLOSE,
'#': TAG_TERMINATOR
}
_reader = None
_getSLong = getSInt32
_getULong ... | txt = txt.encode(ENCODING_FS).decode("utf8")
|
Based on the snippet: <|code_start|>class Table(object):
def __init__(self):
self._table_entries = dict()
def get(self, name, default=KeyError):
try:
return self._table_entries[name]
except KeyError:
if default is KeyError:
raise
... | groups = TagGroups(tags)
|
Predict the next line for this snippet: <|code_start|>
def get(self, name, default=KeyError):
try:
return self._table_entries[name]
except KeyError:
if default is KeyError:
raise
else:
return default
def __getitem__(s... | yield Tags(entrytags)
|
Given the following code snippet before the placeholder: <|code_start|>
__author__ = 'Jens M. Plonka'
__copyright__ = 'Copyright 2018, Germany'
__url__ = "https://www.github.com/jmplonka/InventorLoader"
class Transformation2D(object):
def __init__(self):
self.a0 = 0x00000000
self.m = [[1,0,0]... | value, i = getFloat64(data, i)
|
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
'''
importerTransformation.py:
Importer for the Document's components
Simple approach to read/analyse Autodesk (R) Invetor (R) part file's (IPT) browser view data.
The importer can read files from Autodesk (R) Invetor (R) Inventro V2010 on. Older versions ... | self.a0, i = getUInt32(data, offset)
|
Using the snippet: <|code_start|> if (d1 & b):
mask += '-' if (d2 & b) else '0'
else:
mask += '+' if (d2 & b) else 'x'
if (((j+1) % 3) == 0): mask += '|'
return u' transformation={a0=%s m=%s}' %(mask, m)
def __repr__(self):
m0 = self.__m2s__(0)
m1 = self.__m2s__(1)
m2 = self.__m2s__(... | d1, i = getUInt16(data, i)
|
Given snippet: <|code_start|> def __init__(self, menuText = None, toolTip = None, pixmap = None, accel=None):
self.resources = {}
self.addResource('MenuText', menuText)
self.addResource('ToolTip', toolTip)
self.addResource('Pixmap', pixmap)
self.addResource('Accel', accel)
def addResource(self, r... | super(_CmdSketch2D, self).__init__(menuText="&2D Sketch", toolTip="Creates an 2D sketch", pixmap=getIconPath("Sketch2D.png"), accel="I, 2")
|
Given the code snippet: <|code_start|>class _ViewProvider(object):
def __init__(self, vp):
vp.Proxy = self
def attach(self, vp):
self.ViewObject = vp
self.Object = vp.Object
def onChanged(self, vp, prop): return
def setEdit(self, vp, mode): return False
def unsetEdit(self, vp, mode): return
def... | return getIconPath('FxBoundaryPatch.xpm') |
Based on the snippet: <|code_start|> def __init__(self, vp):
super(_ViewProviderSketch3D, self).__init__(vp)
def claimChildren(self):
return []
def getIcon(self):
return getIconPath("Sketch3D.xpm")
def makeSketch3D(name = u"Sketch3D"):
fp = createPartFeature("Part::FeaturePython", name)
sketch3D = _Sketch... | header = getTableValue(table, 'A', row) |
Predict the next line after this snippet: <|code_start|> row += 1
header = getTableValue(table, 'A', row)
return headers
def _updateMapping_(self, fp):
if (fp.Values is None): return False
if (fp.Parameters is None): return False
fp.Mapping.clear()
FreeCAD.ActiveDocument.recompute()
parameter = se... | setTableValue(fp.Parameters, 'B', fp.Mapping[col], val) |
Given snippet: <|code_start|> if (obj.TypeId == 'Sketcher::SketchObject'):
for c, constraint in enumerate(obj.Constraints):
if (constraint.Type in DIM_CONSTRAINTS):
prp = 'Constraints[%d]' %(c)
value = getExpression(obj, prp)
if (value is None):
value = constraint.Value
if (co... | logWarning("Spreadsheet 'Parameters' doesn't meet layout constraints to serve as parameters table!") |
Based on the snippet: <|code_start|> QObject.connect(self.form.btnParamAdd, SIGNAL("clicked()"), self.addParam)
QObject.connect(self.form.btnParamDel, SIGNAL("clicked()"), self.delParam)
VariantTableModel(table, fp.Values)
self.fp = fp
def getParameters(self):
parameters = []
table = self.fp.Parameters
r... | logError("Failed to insert row %d", row) |
Continue the code snippet: <|code_start|> value = value.Value
values.append([False, obj.Name, prp, 'd_%d' %(len(values)), str(value), XPR_PROPERTIES[obj.getTypeIdOfProperty(prp)]])
return values
def getParametersValues(doc):
table = None
for t in doc.getObjectsByLabel('Parameters'):
if (t.TypeId == ... | unit = table.get(getCellRef('B', row)) |
Using the snippet: <|code_start|> else:
unit = None
source = None
if (hasSource):
source = getTableValue(table, 'D', row)
property = None
if (hasProperty):
property = getTableValue(table, 'E', row)
values.append([False, source, property, name, value, unit])
row += 1
return table, values, False
... | table.setAlias(u"B%d" %(row), calcAliasname(name)) |
Given snippet: <|code_start|>
def createIPartParameters(doc, values):
table = doc.addObject('Spreadsheet::Sheet', 'Parameters')
table.set('A1', 'Parameter')
table.set('B1', 'Value')
table.set('C1', 'Unit')
table.set('D1', 'Source')
table.set('E1', 'Property')
for row, data in enumerate(values, 2):
(add, source... | ParameterTableModel(form.tableView, values) |
Predict the next line after this snippet: <|code_start|> def __init__(self, vp):
super(_ViewProviderTrim, self).__init__(vp)
def claimChildren(self):
return self.Object.Patches
def getIcon(self):
return getIconPath('FxBoundaryPatch.xpm')
def makeTrim(name = u"Trim", faces = None):
if (faces == None):
sele... | fp.addProperty("App::PropertyVector" , "Axis" , "Coil", "The direction of the coil's axis").Axis = DIR_Z
|
Given the code snippet: <|code_start|> section = cls()
self._sections[section.name] = section
def _setup_sections(self, tagreader, drawing):
def name(section):
return section[1].value
for section in iterchunks(tagreader, stoptag='EOF', endofchunk='ENDSEC')... | 'TABLES' : TablesSection,
|
Here is a snippet: <|code_start|> self._sections[section.name] = section
def _setup_sections(self, tagreader, drawing):
def name(section):
return section[1].value
for section in iterchunks(tagreader, stoptag='EOF', endofchunk='ENDSEC'):
if name(section) ==... | 'ENTITIES': EntitySection,
|
Here is a snippet: <|code_start|>
def _setup_sections(self, tagreader, drawing):
def name(section):
return section[1].value
for section in iterchunks(tagreader, stoptag='EOF', endofchunk='ENDSEC'):
if name(section) == 'HEADER':
new_section = HeaderSect... | 'OBJECTS' : ObjectsSection,
|
Predict the next line for this snippet: <|code_start|> def _setup_sections(self, tagreader, drawing):
def name(section):
return section[1].value
for section in iterchunks(tagreader, stoptag='EOF', endofchunk='ENDSEC'):
if name(section) == 'HEADER':
new_s... | 'BLOCKS' : BlocksSection,
|
Here is a snippet: <|code_start|>"""unset a default setting
unset config
unset target
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'unset' verb"""
if len(args) > 0 :
noun = args[0]
settings.unset(proj_dir, ... | log.error("expected noun: {}".format(', '.join(valid_nouns))) |
Using the snippet: <|code_start|>"""unset a default setting
unset config
unset target
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'unset' verb"""
if len(args) > 0 :
noun = args[0]
<|code_end|>
, determine the next... | settings.unset(proj_dir, noun) |
Given the following code snippet before the placeholder: <|code_start|>"""
wasi-sdk installation and maintenance
"""
def run(fips_dir, proj_dir, args):
if len(args) > 0:
cmd = args[0]
if cmd == 'install':
wasisdk.install(fips_dir)
elif cmd == 'uninstall':
wasisdk... | log.error("unknown subcommand '{}' (run './fips help wasisdk')".format(cmd)) |
Given the following code snippet before the placeholder: <|code_start|>"""
wasi-sdk installation and maintenance
"""
def run(fips_dir, proj_dir, args):
if len(args) > 0:
cmd = args[0]
if cmd == 'install':
<|code_end|>
, predict the next line using imports from the current file:
from mod import... | wasisdk.install(fips_dir) |
Using the snippet: <|code_start|> return util.get_workspace_dir(fips_dir) + '/fips-sdks/android'
#-------------------------------------------------------------------------------
def check_exists(fips_dir) :
"""check if the android sdk has been installed"""
return os.path.isdir(get_sdk_dir(fips_dir))
#-----... | log.colored(log.BLUE, '>>> install Android SDK package: {}'.format(pkg)) |
Given snippet: <|code_start|>"""Android SDK support"""
if sys.version_info[0] >= 3:
else:
tools_urls = {
'win': 'https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip',
'osx': 'https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip',
'linux': 'https://dl.goog... | return util.get_workspace_dir(fips_dir) + '/fips-sdks/android' |
Next line prediction: <|code_start|> subprocess.call('unzip {}'.format(path), cwd=get_sdk_dir(fips_dir), shell=True)
else:
with zipfile.ZipFile(path, 'r') as archive:
archive.extractall(get_sdk_dir(fips_dir))
#------------------------------------------------------------------------------... | if not java.check_exists(fips_dir) or not javac.check_exists(fips_dir) : |
Given the following code snippet before the placeholder: <|code_start|> subprocess.call('unzip {}'.format(path), cwd=get_sdk_dir(fips_dir), shell=True)
else:
with zipfile.ZipFile(path, 'r') as archive:
archive.extractall(get_sdk_dir(fips_dir))
#-------------------------------------------... | if not java.check_exists(fips_dir) or not javac.check_exists(fips_dir) : |
Using the snippet: <|code_start|>"""helper verb for VSCode support
vscode clean -- removes all .vscode directories in all dependencies
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
if not util.is_valid_project_dir(proj_dir) :
<|code_end... | log.error('must be run in a project directory') |
Given the code snippet: <|code_start|>"""helper verb for VSCode support
vscode clean -- removes all .vscode directories in all dependencies
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
if not util.is_valid_project_dir(proj_dir) :
... | vscode.cleanup(fips_dir, proj_dir) |
Given the following code snippet before the placeholder: <|code_start|>"""update dependencies (only if no local changes)
update -- update all dependencies
update [proj] -- update a specific dependency
update fips -- update fips itself
"""
#--------------------------------------------------------------... | log.warn(" '{}' has local changes, skipping...".format(fips_dir)) |
Using the snippet: <|code_start|>"""update dependencies (only if no local changes)
update -- update all dependencies
update [proj] -- update a specific dependency
update fips -- update fips itself
"""
#-------------------------------------------------------------------------------
def run(fips_dir, pr... | proj_dir = util.get_project_dir(fips_dir, proj_name) |
Based on the snippet: <|code_start|>"""update dependencies (only if no local changes)
update -- update all dependencies
update [proj] -- update a specific dependency
update fips -- update fips itself
"""
#-------------------------------------------------------------------------------
def run(fips_dir,... | dep.update_imports(fips_dir, proj_dir) |
Using the snippet: <|code_start|>"""update dependencies (only if no local changes)
update -- update all dependencies
update [proj] -- update a specific dependency
update fips -- update fips itself
"""
#-------------------------------------------------------------------------------
def run(fips_dir, pr... | if git.has_local_changes(fips_dir) : |
Given the following code snippet before the placeholder: <|code_start|>"""
emscripten SDK installation and maintenance
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args):
if len(args) > 0:
cmd = args[0]
if cmd == 'install':
... | log.error("emscripten SDK version expected (run './fips emsdk list')") |
Next line prediction: <|code_start|>"""
emscripten SDK installation and maintenance
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args):
if len(args) > 0:
cmd = args[0]
if cmd == 'install':
emsdk_version = None
... | emsdk.install(fips_dir, emsdk_version) |
Predict the next line after this snippet: <|code_start|>"""'setup' verb to setup platform SDKs
setup emscripten
setup android
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'setup' verb"""
sdk_name = None
if len(args) > ... | log.error("invalid SDK name (must be 'emscripten' or 'android')") |
Predict the next line after this snippet: <|code_start|>"""'setup' verb to setup platform SDKs
setup emscripten
setup android
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'setup' verb"""
sdk_name = None
if len(args) > ... | emsdk.install(fips_dir, None) |
Next line prediction: <|code_start|>"""'setup' verb to setup platform SDKs
setup emscripten
setup android
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'setup' verb"""
sdk_name = None
if len(args) > 0 :
sdk_name... | android.setup(fips_dir) |
Predict the next line for this snippet: <|code_start|>"""'setup' verb to setup platform SDKs
setup emscripten
setup android
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'setup' verb"""
sdk_name = None
if len(args) > 0 ... | wasisdk.setup(fips_dir) |
Given the code snippet: <|code_start|>"""run built exes
run [target]
run [target] [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run fips project build targets"""
if not util.is_valid_project_dir(proj_dir) :
<|code_end|>
, ... | log.error('must be run in a project directory') |
Given snippet: <|code_start|>"""run built exes
run [target]
run [target] [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run fips project build targets"""
<|code_end|>
, continue by predicting the next line. Consider current fil... | if not util.is_valid_project_dir(proj_dir) : |
Given the code snippet: <|code_start|>"""run built exes
run [target]
run [target] [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run fips project build targets"""
if not util.is_valid_project_dir(proj_dir) :
log.err... | retcode = project.run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd) |
Using the snippet: <|code_start|>"""run built exes
run [target]
run [target] [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run fips project build targets"""
if not util.is_valid_project_dir(proj_dir) :
log.error('m... | cfg_name = settings.get(proj_dir, 'config') |
Predict the next line for this snippet: <|code_start|>"""implement the 'open' verb
open
open [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'open' verb (opens project in IDE)"""
if not util.is_valid_project_dir(pro... | log.error('must be run in a project directory') |
Next line prediction: <|code_start|>"""implement the 'open' verb
open
open [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'open' verb (opens project in IDE)"""
<|code_end|>
. Use current file imports:
(import os
impor... | if not util.is_valid_project_dir(proj_dir) : |
Given the code snippet: <|code_start|>"""build fips project
build
build [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""build fips project"""
if not util.is_valid_project_dir(proj_dir) :
<|code_end|>
, generate the next line... | log.error('must be run in a project directory') |
Predict the next line for this snippet: <|code_start|>"""build fips project
build
build [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""build fips project"""
<|code_end|>
with the help of current file imports:
from mod import ... | if not util.is_valid_project_dir(proj_dir) : |
Here is a snippet: <|code_start|>"""build fips project
build
build [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""build fips project"""
if not util.is_valid_project_dir(proj_dir) :
log.error('must be run in a projec... | project.build(fips_dir, proj_dir, cfg_name, None, build_tool_args) |
Next line prediction: <|code_start|>"""build fips project
build
build [config]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""build fips project"""
if not util.is_valid_project_dir(proj_dir) :
log.error('must be run in a pro... | cfg_name = settings.get(proj_dir, 'config') |
Based on the snippet: <|code_start|>"""wrapper for cmake tool"""
name = 'cmake'
platforms = ['linux', 'osx', 'win']
optional = False
not_found = 'please install cmake 2.8 or newer'
#------------------------------------------------------------------------------
def check_exists(fips_dir, major=2, minor=8) :
"""te... | log.info('{}NOTE{}: cmake must be at least version {}.{} (found: {}.{}.{})'.format( |
Given the code snippet: <|code_start|>"""set a default config or target
set config [config-name]
set target [target-name]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'set' verb"""
# FIXME: thos shouldn't be as hardwired ... | log.error('expected config name') |
Predict the next line for this snippet: <|code_start|>"""set a default config or target
set config [config-name]
set target [target-name]
"""
#-------------------------------------------------------------------------------
def run(fips_dir, proj_dir, args) :
"""run the 'set' verb"""
# FIXME: thos shouldn't ... | settings.set(proj_dir, 'config', cfg_name) |
Based on the snippet: <|code_start|> subprocess.check_output([exe_name, '--version'])
return True
except (OSError, subprocess.CalledProcessError):
return False
#------------------------------------------------------------------------------
def exe_name():
if try_exists('code'):
... | proj_name = util.get_project_name_from_dir(proj_dir) |
Predict the next line for this snippet: <|code_start|>
#------------------------------------------------------------------------------
def exe_name():
if try_exists('code'):
return 'code'
else:
# open source version on RaspberryPi
return 'code-oss'
#-------------------------------------... | log.error("Failed to run Visual Studio Code as '{}'".format(exe)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.