repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.colAdd
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None): """ column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error """ if pos is None: pos=len(self.co...
python
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None): """ column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error """ if pos is None: pos=len(self.co...
[ "def", "colAdd", "(", "self", ",", "name", "=", "\"\"", ",", "desc", "=", "\"\"", ",", "unit", "=", "\"\"", ",", "comment", "=", "\"\"", ",", "coltype", "=", "0", ",", "data", "=", "[", "]", ",", "pos", "=", "None", ")", ":", "if", "pos", "is...
column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error
[ "column", "types", ":", "0", ":", "Y", "1", ":", "Disregard", "2", ":", "Y", "Error", "3", ":", "X", "4", ":", "Label", "5", ":", "Z", "6", ":", "X", "Error" ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L49-L68
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.colDelete
def colDelete(self,colI=-1): """delete a column at a single index. Negative numbers count from the end.""" # print("DELETING COLUMN: [%d] %s"%(colI,self.colDesc[colI])) self.colNames.pop(colI) self.colDesc.pop(colI) self.colUnits.pop(colI) self.colComments.pop(colI) ...
python
def colDelete(self,colI=-1): """delete a column at a single index. Negative numbers count from the end.""" # print("DELETING COLUMN: [%d] %s"%(colI,self.colDesc[colI])) self.colNames.pop(colI) self.colDesc.pop(colI) self.colUnits.pop(colI) self.colComments.pop(colI) ...
[ "def", "colDelete", "(", "self", ",", "colI", "=", "-", "1", ")", ":", "# print(\"DELETING COLUMN: [%d] %s\"%(colI,self.colDesc[colI]))", "self", ".", "colNames", ".", "pop", "(", "colI", ")", "self", ".", "colDesc", ".", "pop", "(", "colI", ")", "self"...
delete a column at a single index. Negative numbers count from the end.
[ "delete", "a", "column", "at", "a", "single", "index", ".", "Negative", "numbers", "count", "from", "the", "end", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L70-L79
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.onex
def onex(self): """ delete all X columns except the first one. """ xCols=[i for i in range(self.nCols) if self.colTypes[i]==3] if len(xCols)>1: for colI in xCols[1:][::-1]: self.colDelete(colI)
python
def onex(self): """ delete all X columns except the first one. """ xCols=[i for i in range(self.nCols) if self.colTypes[i]==3] if len(xCols)>1: for colI in xCols[1:][::-1]: self.colDelete(colI)
[ "def", "onex", "(", "self", ")", ":", "xCols", "=", "[", "i", "for", "i", "in", "range", "(", "self", ".", "nCols", ")", "if", "self", ".", "colTypes", "[", "i", "]", "==", "3", "]", "if", "len", "(", "xCols", ")", ">", "1", ":", "for", "co...
delete all X columns except the first one.
[ "delete", "all", "X", "columns", "except", "the", "first", "one", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L81-L88
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.alignXY
def alignXY(self): """aligns XY pairs (or XYYY etc) by X value.""" # figure out what data we have and will align to xVals=[] xCols=[x for x in range(self.nCols) if self.colTypes[x]==3] yCols=[x for x in range(self.nCols) if self.colTypes[x]==0] xCols,yCols=np.array(xCols...
python
def alignXY(self): """aligns XY pairs (or XYYY etc) by X value.""" # figure out what data we have and will align to xVals=[] xCols=[x for x in range(self.nCols) if self.colTypes[x]==3] yCols=[x for x in range(self.nCols) if self.colTypes[x]==0] xCols,yCols=np.array(xCols...
[ "def", "alignXY", "(", "self", ")", ":", "# figure out what data we have and will align to", "xVals", "=", "[", "]", "xCols", "=", "[", "x", "for", "x", "in", "range", "(", "self", ".", "nCols", ")", "if", "self", ".", "colTypes", "[", "x", "]", "==", ...
aligns XY pairs (or XYYY etc) by X value.
[ "aligns", "XY", "pairs", "(", "or", "XYYY", "etc", ")", "by", "X", "value", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L90-L127
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.wiggle
def wiggle(self,noiseLevel=.1): """Slightly changes value of every cell in the worksheet. Used for testing.""" noise=(np.random.rand(*self.data.shape))-.5 self.data=self.data+noise*noiseLevel
python
def wiggle(self,noiseLevel=.1): """Slightly changes value of every cell in the worksheet. Used for testing.""" noise=(np.random.rand(*self.data.shape))-.5 self.data=self.data+noise*noiseLevel
[ "def", "wiggle", "(", "self", ",", "noiseLevel", "=", ".1", ")", ":", "noise", "=", "(", "np", ".", "random", ".", "rand", "(", "*", "self", ".", "data", ".", "shape", ")", ")", "-", ".5", "self", ".", "data", "=", "self", ".", "data", "+", "...
Slightly changes value of every cell in the worksheet. Used for testing.
[ "Slightly", "changes", "value", "of", "every", "cell", "in", "the", "worksheet", ".", "Used", "for", "testing", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L131-L134
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.pull
def pull(self,bookName=None,sheetName=None): """pull data into this OR.SHEET from a real book/sheet in Origin""" # tons of validation if bookName is None and self.bookName: bookName=self.bookName if sheetName is None and self.sheetName: sheetName=self.sheetName if bookName is No...
python
def pull(self,bookName=None,sheetName=None): """pull data into this OR.SHEET from a real book/sheet in Origin""" # tons of validation if bookName is None and self.bookName: bookName=self.bookName if sheetName is None and self.sheetName: sheetName=self.sheetName if bookName is No...
[ "def", "pull", "(", "self", ",", "bookName", "=", "None", ",", "sheetName", "=", "None", ")", ":", "# tons of validation", "if", "bookName", "is", "None", "and", "self", ".", "bookName", ":", "bookName", "=", "self", ".", "bookName", "if", "sheetName", "...
pull data into this OR.SHEET from a real book/sheet in Origin
[ "pull", "data", "into", "this", "OR", ".", "SHEET", "from", "a", "real", "book", "/", "sheet", "in", "Origin" ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L138-L160
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.push
def push(self,bookName=None,sheetName=None,overwrite=False): """pull this OR.SHEET into a real book/sheet in Origin""" # tons of validation if bookName: self.bookName=bookName if sheetName: self.sheetName=sheetName if not self.sheetName in OR.sheetNames(bookName): pri...
python
def push(self,bookName=None,sheetName=None,overwrite=False): """pull this OR.SHEET into a real book/sheet in Origin""" # tons of validation if bookName: self.bookName=bookName if sheetName: self.sheetName=sheetName if not self.sheetName in OR.sheetNames(bookName): pri...
[ "def", "push", "(", "self", ",", "bookName", "=", "None", ",", "sheetName", "=", "None", ",", "overwrite", "=", "False", ")", ":", "# tons of validation", "if", "bookName", ":", "self", ".", "bookName", "=", "bookName", "if", "sheetName", ":", "self", "....
pull this OR.SHEET into a real book/sheet in Origin
[ "pull", "this", "OR", ".", "SHEET", "into", "a", "real", "book", "/", "sheet", "in", "Origin" ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L162-L186
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.nRows
def nRows(self): """returns maximum number of rows based on the longest colData""" if self.nCols: return max([len(x) for x in self.colData]) else: return 0
python
def nRows(self): """returns maximum number of rows based on the longest colData""" if self.nCols: return max([len(x) for x in self.colData]) else: return 0
[ "def", "nRows", "(", "self", ")", ":", "if", "self", ".", "nCols", ":", "return", "max", "(", "[", "len", "(", "x", ")", "for", "x", "in", "self", ".", "colData", "]", ")", "else", ":", "return", "0" ]
returns maximum number of rows based on the longest colData
[ "returns", "maximum", "number", "of", "rows", "based", "on", "the", "longest", "colData" ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L191-L194
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.data
def data(self): """return all of colData as a 2D numpy array.""" data=np.empty((self.nRows,self.nCols),dtype=np.float) data[:]=np.nan # make everything nan by default for colNum,colData in enumerate(self.colData): validIs=np.where([np.isreal(v) for v in colData])[0] ...
python
def data(self): """return all of colData as a 2D numpy array.""" data=np.empty((self.nRows,self.nCols),dtype=np.float) data[:]=np.nan # make everything nan by default for colNum,colData in enumerate(self.colData): validIs=np.where([np.isreal(v) for v in colData])[0] ...
[ "def", "data", "(", "self", ")", ":", "data", "=", "np", ".", "empty", "(", "(", "self", ".", "nRows", ",", "self", ".", "nCols", ")", ",", "dtype", "=", "np", ".", "float", ")", "data", "[", ":", "]", "=", "np", ".", "nan", "# make everything ...
return all of colData as a 2D numpy array.
[ "return", "all", "of", "colData", "as", "a", "2D", "numpy", "array", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L204-L214
swharden/PyOriginTools
PyOriginTools/workbook.py
SHEET.data
def data(self,data): """Given a 2D numpy array, fill colData with it.""" assert type(data) is np.ndarray assert data.shape[1] == self.nCols for i in range(self.nCols): self.colData[i]=data[:,i].tolist()
python
def data(self,data): """Given a 2D numpy array, fill colData with it.""" assert type(data) is np.ndarray assert data.shape[1] == self.nCols for i in range(self.nCols): self.colData[i]=data[:,i].tolist()
[ "def", "data", "(", "self", ",", "data", ")", ":", "assert", "type", "(", "data", ")", "is", "np", ".", "ndarray", "assert", "data", ".", "shape", "[", "1", "]", "==", "self", ".", "nCols", "for", "i", "in", "range", "(", "self", ".", "nCols", ...
Given a 2D numpy array, fill colData with it.
[ "Given", "a", "2D", "numpy", "array", "fill", "colData", "with", "it", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L217-L222
j4321/tkColorPicker
tkcolorpicker/spinbox.py
Spinbox.focusout
def focusout(self, event): """Change style on focus out events.""" bc = self.style.lookup("TEntry", "bordercolor", ("!focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("!focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("!focus",)) self.style.configure("%s.spinbox....
python
def focusout(self, event): """Change style on focus out events.""" bc = self.style.lookup("TEntry", "bordercolor", ("!focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("!focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("!focus",)) self.style.configure("%s.spinbox....
[ "def", "focusout", "(", "self", ",", "event", ")", ":", "bc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"", ",", "\"bordercolor\"", ",", "(", "\"!focus\"", ",", ")", ")", "dc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"...
Change style on focus out events.
[ "Change", "style", "on", "focus", "out", "events", "." ]
train
https://github.com/j4321/tkColorPicker/blob/ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d/tkcolorpicker/spinbox.py#L99-L105
j4321/tkColorPicker
tkcolorpicker/spinbox.py
Spinbox.focusin
def focusin(self, event): """Change style on focus in events.""" self.old_value = self.get() bc = self.style.lookup("TEntry", "bordercolor", ("focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("focus",)) se...
python
def focusin(self, event): """Change style on focus in events.""" self.old_value = self.get() bc = self.style.lookup("TEntry", "bordercolor", ("focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("focus",)) se...
[ "def", "focusin", "(", "self", ",", "event", ")", ":", "self", ".", "old_value", "=", "self", ".", "get", "(", ")", "bc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"", ",", "\"bordercolor\"", ",", "(", "\"focus\"", ",", ")", ")", "dc...
Change style on focus in events.
[ "Change", "style", "on", "focus", "in", "events", "." ]
train
https://github.com/j4321/tkColorPicker/blob/ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d/tkcolorpicker/spinbox.py#L107-L114
xzased/lvm2py
lvm2py/lvm.py
LVM.open
def open(self): """ Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: try: ...
python
def open(self): """ Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: try: ...
[ "def", "open", "(", "self", ")", ":", "if", "not", "self", ".", "handle", ":", "try", ":", "path", "=", "self", ".", "system_dir", "except", "AttributeError", ":", "path", "=", "''", "self", ".", "__handle", "=", "lvm_init", "(", "path", ")", "if", ...
Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
[ "Obtains", "the", "lvm", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "trying", "to", "do", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L57-L73
xzased/lvm2py
lvm2py/lvm.py
LVM.close
def close(self): """ Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: q = lvm_quit(self...
python
def close(self): """ Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: q = lvm_quit(self...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "handle", ":", "q", "=", "lvm_quit", "(", "self", ".", "handle", ")", "if", "q", "!=", "0", ":", "raise", "HandleError", "(", "\"Failed to close LVM handle.\"", ")", "self", ".", "__handle", "="...
Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
[ "Closes", "the", "lvm", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "trying", "to", "do", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L75-L88
xzased/lvm2py
lvm2py/lvm.py
LVM.get_vg
def get_vg(self, name, mode="r"): """ Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open...
python
def get_vg(self, name, mode="r"): """ Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open...
[ "def", "get_vg", "(", "self", ",", "name", ",", "mode", "=", "\"r\"", ")", ":", "vg", "=", "VolumeGroup", "(", "self", ",", "name", "=", "name", ",", "mode", "=", "mode", ")", "return", "vg" ]
Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open a volume group with write permissions set the mode pa...
[ "Returns", "an", "instance", "of", "VolumeGroup", ".", "The", "name", "parameter", "should", "be", "an", "existing", "volume", "group", ".", "By", "default", "all", "volume", "groups", "are", "open", "in", "read", "mode", "::" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L130-L157
xzased/lvm2py
lvm2py/lvm.py
LVM.create_vg
def create_vg(self, name, devices): """ Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * ...
python
def create_vg(self, name, devices): """ Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * ...
[ "def", "create_vg", "(", "self", ",", "name", ",", "devices", ")", ":", "self", ".", "open", "(", ")", "vgh", "=", "lvm_vg_create", "(", "self", ".", "handle", ",", "name", ")", "if", "not", "bool", "(", "vgh", ")", ":", "self", ".", "close", "("...
Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * name (str): A volume group name. * ...
[ "Returns", "a", "new", "instance", "of", "VolumeGroup", "with", "the", "given", "name", "and", "added", "physycal", "volumes", "(", "devices", ")", "::" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L159-L198
xzased/lvm2py
lvm2py/lvm.py
LVM.remove_vg
def remove_vg(self, vg): """ Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleErro...
python
def remove_vg(self, vg): """ Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleErro...
[ "def", "remove_vg", "(", "self", ",", "vg", ")", ":", "vg", ".", "open", "(", ")", "rm", "=", "lvm_vg_remove", "(", "vg", ".", "handle", ")", "if", "rm", "!=", "0", ":", "vg", ".", "close", "(", ")", "raise", "CommitError", "(", "\"Failed to remove...
Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleError, CommitError .. note:: ...
[ "Removes", "a", "volume", "group", "::" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L200-L232
xzased/lvm2py
lvm2py/lvm.py
LVM.vgscan
def vgscan(self): """ Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError """ vg_list = [] self.open() ...
python
def vgscan(self): """ Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError """ vg_list = [] self.open() ...
[ "def", "vgscan", "(", "self", ")", ":", "vg_list", "=", "[", "]", "self", ".", "open", "(", ")", "names", "=", "lvm_list_vg_names", "(", "self", ".", "handle", ")", "if", "not", "bool", "(", "names", ")", ":", "return", "vg_list", "vgnames", "=", "...
Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError
[ "Probes", "the", "system", "for", "volume", "groups", "and", "returns", "a", "list", "of", "VolumeGroup", "instances", "::" ]
train
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L234-L266
davidmcclure/textplot
textplot/text.py
Text.from_file
def from_file(cls, path): """ Create a text from a file. Args: path (str): The file path. """ with open(path, 'r', errors='replace') as f: return cls(f.read())
python
def from_file(cls, path): """ Create a text from a file. Args: path (str): The file path. """ with open(path, 'r', errors='replace') as f: return cls(f.read())
[ "def", "from_file", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ",", "errors", "=", "'replace'", ")", "as", "f", ":", "return", "cls", "(", "f", ".", "read", "(", ")", ")" ]
Create a text from a file. Args: path (str): The file path.
[ "Create", "a", "text", "from", "a", "file", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L22-L32
davidmcclure/textplot
textplot/text.py
Text.load_stopwords
def load_stopwords(self, path): """ Load a set of stopwords. Args: path (str): The stopwords file path. """ if path: with open(path) as f: self.stopwords = set(f.read().splitlines()) else: self.stopwords = set( ...
python
def load_stopwords(self, path): """ Load a set of stopwords. Args: path (str): The stopwords file path. """ if path: with open(path) as f: self.stopwords = set(f.read().splitlines()) else: self.stopwords = set( ...
[ "def", "load_stopwords", "(", "self", ",", "path", ")", ":", "if", "path", ":", "with", "open", "(", "path", ")", "as", "f", ":", "self", ".", "stopwords", "=", "set", "(", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", ")", "else", "...
Load a set of stopwords. Args: path (str): The stopwords file path.
[ "Load", "a", "set", "of", "stopwords", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L50-L69
davidmcclure/textplot
textplot/text.py
Text.tokenize
def tokenize(self): """ Tokenize the text. """ self.tokens = [] self.terms = OrderedDict() # Generate tokens. for token in utils.tokenize(self.text): # Ignore stopwords. if token['unstemmed'] in self.stopwords: self.toke...
python
def tokenize(self): """ Tokenize the text. """ self.tokens = [] self.terms = OrderedDict() # Generate tokens. for token in utils.tokenize(self.text): # Ignore stopwords. if token['unstemmed'] in self.stopwords: self.toke...
[ "def", "tokenize", "(", "self", ")", ":", "self", ".", "tokens", "=", "[", "]", "self", ".", "terms", "=", "OrderedDict", "(", ")", "# Generate tokens.", "for", "token", "in", "utils", ".", "tokenize", "(", "self", ".", "text", ")", ":", "# Ignore stop...
Tokenize the text.
[ "Tokenize", "the", "text", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L72-L95
davidmcclure/textplot
textplot/text.py
Text.term_counts
def term_counts(self): """ Returns: OrderedDict: An ordered dictionary of term counts. """ counts = OrderedDict() for term in self.terms: counts[term] = len(self.terms[term]) return utils.sort_dict(counts)
python
def term_counts(self): """ Returns: OrderedDict: An ordered dictionary of term counts. """ counts = OrderedDict() for term in self.terms: counts[term] = len(self.terms[term]) return utils.sort_dict(counts)
[ "def", "term_counts", "(", "self", ")", ":", "counts", "=", "OrderedDict", "(", ")", "for", "term", "in", "self", ".", "terms", ":", "counts", "[", "term", "]", "=", "len", "(", "self", ".", "terms", "[", "term", "]", ")", "return", "utils", ".", ...
Returns: OrderedDict: An ordered dictionary of term counts.
[ "Returns", ":", "OrderedDict", ":", "An", "ordered", "dictionary", "of", "term", "counts", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L98-L109
davidmcclure/textplot
textplot/text.py
Text.term_count_buckets
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
python
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
[ "def", "term_count_buckets", "(", "self", ")", ":", "buckets", "=", "{", "}", "for", "term", ",", "count", "in", "self", ".", "term_counts", "(", ")", ".", "items", "(", ")", ":", "if", "count", "in", "buckets", ":", "buckets", "[", "count", "]", "...
Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text.
[ "Returns", ":", "dict", ":", "A", "dictionary", "that", "maps", "occurrence", "counts", "to", "the", "terms", "that", "appear", "that", "many", "times", "in", "the", "text", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L112-L125
davidmcclure/textplot
textplot/text.py
Text.most_frequent_terms
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
python
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
[ "def", "most_frequent_terms", "(", "self", ",", "depth", ")", ":", "counts", "=", "self", ".", "term_counts", "(", ")", "# Get the top X terms and the instance count of the last word.", "top_terms", "=", "set", "(", "list", "(", "counts", ".", "keys", "(", ")", ...
Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms.
[ "Get", "the", "X", "most", "frequent", "terms", "in", "the", "text", "and", "then", "probe", "down", "to", "get", "any", "other", "terms", "that", "have", "the", "same", "count", "as", "the", "last", "term", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L128-L152
davidmcclure/textplot
textplot/text.py
Text.unstem
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
python
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
[ "def", "unstem", "(", "self", ",", "term", ")", ":", "originals", "=", "[", "]", "for", "i", "in", "self", ".", "terms", "[", "term", "]", ":", "originals", ".", "append", "(", "self", ".", "tokens", "[", "i", "]", "[", "'unstemmed'", "]", ")", ...
Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token.
[ "Given", "a", "stemmed", "term", "get", "the", "most", "common", "unstemmed", "variant", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L155-L172
davidmcclure/textplot
textplot/text.py
Text.kde
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
python
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
[ "def", "kde", "(", "self", ",", "term", ",", "bandwidth", "=", "2000", ",", "samples", "=", "1000", ",", "kernel", "=", "'gaussian'", ")", ":", "# Get the offsets of the term instances.", "terms", "=", "np", ".", "array", "(", "self", ".", "terms", "[", ...
Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sample points. kernel (str): The kernel function. Returns: n...
[ "Estimate", "the", "kernel", "density", "of", "the", "instances", "of", "term", "in", "the", "text", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L176-L202
davidmcclure/textplot
textplot/text.py
Text.score_intersect
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
python
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
[ "def", "score_intersect", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "the", "geometric", "area", "of", "the", "overlap", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L205-L223
davidmcclure/textplot
textplot/text.py
Text.score_cosine
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
python
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
[ "def", "score_cosine", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", "k...
Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "a", "weighting", "score", "based", "on", "the", "cosine", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L226-L242
davidmcclure/textplot
textplot/text.py
Text.score_braycurtis
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
python
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
[ "def", "score_braycurtis", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "a", "weighting", "score", "based", "on", "the", "City", "Block", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L245-L261
davidmcclure/textplot
textplot/text.py
Text.plot_term_kdes
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
python
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
[ "def", "plot_term_kdes", "(", "self", ",", "words", ",", "*", "*", "kwargs", ")", ":", "stem", "=", "PorterStemmer", "(", ")", ".", "stem", "for", "word", "in", "words", ":", "kde", "=", "self", ".", "kde", "(", "stem", "(", "word", ")", ",", "*"...
Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms.
[ "Plot", "kernel", "density", "estimates", "for", "multiple", "words", "." ]
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L264-L279
stephrdev/django-mongoforms
mongoforms/fields.py
MongoFormFieldGenerator.generate
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
python
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
[ "def", "generate", "(", "self", ",", "field_name", ",", "field", ")", ":", "if", "hasattr", "(", "self", ",", "'generate_%s'", "%", "field", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ")", ":", "generator", "=", "getattr", "(", "self", ...
Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found.
[ "Tries", "to", "lookup", "a", "matching", "formfield", "generator", "(", "lowercase", "field", "-", "classname", ")", "and", "raises", "a", "NotImplementedError", "of", "no", "generator", "can", "be", "found", "." ]
train
https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/fields.py#L49-L65
twisted/axiom
axiom/sequence.py
List._fixIndex
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
python
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
[ "def", "_fixIndex", "(", "self", ",", "index", ",", "truncate", "=", "False", ")", ":", "assert", "not", "isinstance", "(", "index", ",", "slice", ")", ",", "'slices are not supported (yet)'", "if", "index", "<", "0", ":", "index", "+=", "self", ".", "le...
@param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> len(L) 5 >>> L....
[ "@param", "truncate", ":", "If", "true", "negative", "indices", "which", "go", "past", "the", "beginning", "of", "the", "list", "will", "be", "evaluated", "as", "zero", ".", "For", "example", "::" ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/sequence.py#L40-L60
twisted/axiom
axiom/queryutil.py
overlapping
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
python
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
[ "def", "overlapping", "(", "startAttribute", ",", "# X", "endAttribute", ",", "# Y", "startValue", ",", "# A", "endValue", ",", "# B", ")", ":", "assert", "startValue", "<=", "endValue", "return", "OR", "(", "AND", "(", "startAttribute", ">=", "startValue", ...
Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will constrain a query against 2 attributes for ranges which overlap with the given arguments. For a database with Items of class O which represent values in this confi...
[ "Return", "an", "L", "{", "axiom", ".", "iaxiom", ".", "IComparison", "}", "(", "an", "object", "that", "can", "be", "passed", "as", "the", "comparison", "argument", "to", "Store", ".", "query", "/", ".", "sum", "/", ".", "count", ")", "which", "will...
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L21-L88
twisted/axiom
axiom/queryutil.py
_tupleCompare
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
python
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
[ "def", "_tupleCompare", "(", "tuple1", ",", "ineq", ",", "tuple2", ",", "eq", "=", "lambda", "a", ",", "b", ":", "(", "a", "==", "b", ")", ",", "ander", "=", "AND", ",", "orer", "=", "OR", ")", ":", "orholder", "=", "[", "]", "for", "limit", ...
Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query.
[ "Compare", "two", "in", "-", "database", "tuples", ".", "Useful", "when", "sorting", "by", "a", "compound", "key", "and", "slicing", "into", "the", "middle", "of", "that", "query", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L90-L105
ubc/ubcpi
ubcpi/ubcpi.py
truncate_rationale
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
python
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
[ "def", "truncate_rationale", "(", "rationale", ",", "max_length", "=", "MAX_RATIONALE_SIZE_IN_EVENT", ")", ":", "if", "isinstance", "(", "rationale", ",", "basestring", ")", "and", "max_length", "is", "not", "None", "and", "len", "(", "rationale", ")", ">", "m...
Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value (string): the possibly truncated version of the rationale was_truncated (bool):...
[ "Truncates", "the", "rationale", "for", "analytics", "event", "emission", "if", "necessary" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L33-L49
ubc/ubcpi
ubcpi/ubcpi.py
validate_options
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
python
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
[ "def", "validate_options", "(", "options", ")", ":", "errors", "=", "[", "]", "if", "int", "(", "options", "[", "'rationale_size'", "]", "[", "'min'", "]", ")", "<", "1", ":", "errors", ".", "append", "(", "_", "(", "'Minimum Characters'", ")", ")", ...
Validate the options that course author set up and return errors in a dict if there is any
[ "Validate", "the", "options", "that", "course", "author", "set", "up", "and", "return", "errors", "in", "a", "dict", "if", "there", "is", "any" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L52-L74
ubc/ubcpi
ubcpi/ubcpi.py
MissingDataFetcherMixin.get_student_item_dict
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
python
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
[ "def", "get_student_item_dict", "(", "self", ",", "anonymous_user_id", "=", "None", ")", ":", "item_id", "=", "self", ".", "_serialize_opaque_key", "(", "self", ".", "scope_ids", ".", "usage_id", ")", "# This is not the real way course_ids should work, but this is a", "...
Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The student item associated with this XBlock instance. This ...
[ "Create", "a", "student_item_dict", "from", "our", "surrounding", "context", "." ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L87-L123
ubc/ubcpi
ubcpi/persistence.py
get_answers_for_student
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
python
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
[ "def", "get_answers_for_student", "(", "student_item", ")", ":", "submissions", "=", "sub_api", ".", "get_submissions", "(", "student_item", ")", "if", "not", "submissions", ":", "return", "Answers", "(", ")", "latest_submission", "=", "submissions", "[", "0", "...
Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the student
[ "Retrieve", "answers", "from", "backend", "for", "a", "student", "and", "question" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L25-L42
ubc/ubcpi
ubcpi/persistence.py
add_answer_for_student
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
python
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
[ "def", "add_answer_for_student", "(", "student_item", ",", "vote", ",", "rationale", ")", ":", "answers", "=", "get_answers_for_student", "(", "student_item", ")", "answers", ".", "add_answer", "(", "vote", ",", "rationale", ")", "sub_api", ".", "create_submission...
Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student voted for rationale (str): the reason why the student vote for the...
[ "Add", "an", "answer", "for", "a", "student", "to", "the", "backend" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L45-L60
ubc/ubcpi
ubcpi/persistence.py
Answers._safe_get
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
python
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
[ "def", "_safe_get", "(", "self", ",", "revision", ",", "key", ")", ":", "if", "self", ".", "has_revision", "(", "revision", ")", ":", "return", "self", ".", "raw_answers", "[", "revision", "]", ".", "get", "(", "key", ")", "else", ":", "return", "Non...
Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or RATIONALE_KEY Returns: ...
[ "Get", "an", "answer", "data", "(", "vote", "or", "rationale", ")", "by", "revision" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L77-L93
ubc/ubcpi
ubcpi/persistence.py
Answers.add_answer
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
python
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
[ "def", "add_answer", "(", "self", ",", "vote", ",", "rationale", ")", ":", "self", ".", "raw_answers", ".", "append", "(", "{", "VOTE_KEY", ":", "vote", ",", "RATIONALE_KEY", ":", "rationale", ",", "}", ")" ]
Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option
[ "Add", "an", "answer" ]
train
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L134-L145
swharden/PyOriginTools
documentation/PyOrigin-examples/examples.py
exceptionToString
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
python
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
[ "def", "exceptionToString", "(", "e", ",", "silent", "=", "False", ")", ":", "exc_type", ",", "exc_obj", ",", "exc_tb", "=", "sys", ".", "exc_info", "(", ")", "s", "=", "(", "\"\\n\"", "+", "\"=\"", "*", "50", "+", "\"\\n\"", ")", "s", "+=", "\"EXC...
when you "except Exception as e", give me the e and I'll give you a string.
[ "when", "you", "except", "Exception", "as", "e", "give", "me", "the", "e", "and", "I", "ll", "give", "you", "a", "string", "." ]
train
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/documentation/PyOrigin-examples/examples.py#L38-L51
twisted/axiom
axiom/substore.py
SubStore.createNew
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
python
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
[ "def", "createNew", "(", "cls", ",", "store", ",", "pathSegments", ")", ":", "if", "isinstance", "(", "pathSegments", ",", "basestring", ")", ":", "raise", "ValueError", "(", "'Received %r instead of a sequence'", "%", "(", "pathSegments", ",", ")", ")", "if",...
Create a new SubStore, allocating a new file space for it.
[ "Create", "a", "new", "SubStore", "allocating", "a", "new", "file", "space", "for", "it", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L25-L39
twisted/axiom
axiom/substore.py
SubStore.createStore
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
python
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
[ "def", "createStore", "(", "self", ",", "debug", ",", "journalMode", "=", "None", ")", ":", "if", "self", ".", "storepath", "is", "None", ":", "self", ".", "store", ".", "_memorySubstores", ".", "append", "(", "self", ")", "# don't fall out of cache", "if"...
Create the actual Store this Substore represents.
[ "Create", "the", "actual", "Store", "this", "Substore", "represents", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L62-L84
twisted/axiom
axiom/tags.py
upgradeCatalog1to2
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
python
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
[ "def", "upgradeCatalog1to2", "(", "oldCatalog", ")", ":", "newCatalog", "=", "oldCatalog", ".", "upgradeVersion", "(", "'tag_catalog'", ",", "1", ",", "2", ",", "tagCount", "=", "oldCatalog", ".", "tagCount", ")", "tags", "=", "newCatalog", ".", "store", "."...
Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create.
[ "Create", "_TagName", "instances", "which", "version", "2", "of", "Catalog", "automatically", "creates", "for", "use", "in", "determining", "the", "tagNames", "result", "but", "which", "version", "1", "of", "Catalog", "did", "not", "create", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L110-L122
twisted/axiom
axiom/tags.py
Catalog.tagNames
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
python
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
[ "def", "tagNames", "(", "self", ")", ":", "return", "self", ".", "store", ".", "query", "(", "_TagName", ",", "_TagName", ".", "catalog", "==", "self", ")", ".", "getColumn", "(", "\"name\"", ")" ]
Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog.
[ "Return", "an", "iterator", "of", "unicode", "strings", "-", "the", "unique", "tag", "names", "which", "have", "been", "applied", "objects", "in", "this", "catalog", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L83-L88
twisted/axiom
axiom/tags.py
Catalog.tagsOf
def tagsOf(self, obj): """ Return an iterator of unicode strings - the tag names which apply to the given object. """ return self.store.query( Tag, AND(Tag.catalog == self, Tag.object == obj)).getColumn("name")
python
def tagsOf(self, obj): """ Return an iterator of unicode strings - the tag names which apply to the given object. """ return self.store.query( Tag, AND(Tag.catalog == self, Tag.object == obj)).getColumn("name")
[ "def", "tagsOf", "(", "self", ",", "obj", ")", ":", "return", "self", ".", "store", ".", "query", "(", "Tag", ",", "AND", "(", "Tag", ".", "catalog", "==", "self", ",", "Tag", ".", "object", "==", "obj", ")", ")", ".", "getColumn", "(", "\"name\"...
Return an iterator of unicode strings - the tag names which apply to the given object.
[ "Return", "an", "iterator", "of", "unicode", "strings", "-", "the", "tag", "names", "which", "apply", "to", "the", "given", "object", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L91-L99
twisted/axiom
axiom/attributes.py
SQLAttribute.loaded
def loaded(self, oself, dbval): """ This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database v...
python
def loaded(self, oself, dbval): """ This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database v...
[ "def", "loaded", "(", "self", ",", "oself", ",", "dbval", ")", ":", "setattr", "(", "oself", ",", "self", ".", "dbunderlying", ",", "dbval", ")", "delattr", "(", "oself", ",", "self", ".", "underlying", ")" ]
This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database value which was retrieved.
[ "This", "method", "is", "invoked", "when", "the", "item", "is", "loaded", "from", "the", "database", "and", "when", "a", "transaction", "is", "reverted", "which", "restores", "this", "attribute", "s", "value", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L459-L469
twisted/axiom
axiom/attributes.py
SQLAttribute._convertPyval
def _convertPyval(self, oself, pyval): """ Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in th...
python
def _convertPyval(self, oself, pyval): """ Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in th...
[ "def", "_convertPyval", "(", "self", ",", "oself", ",", "pyval", ")", ":", "# convert to dbval later, I guess?", "if", "pyval", "is", "None", "and", "not", "self", ".", "allowNone", ":", "raise", "TypeError", "(", "\"attribute [%s.%s = %s()] must not be None\"", "%"...
Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in the database.
[ "Convert", "a", "Python", "value", "to", "a", "value", "suitable", "for", "inserting", "into", "the", "database", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L473-L487
twisted/axiom
axiom/attributes.py
SequenceComparison._queryContainer
def _queryContainer(self, store): """ Generate and cache the subselect SQL and its arguments. Return the subselect SQL. """ if self._subselectSQL is None: sql, args = self.container._sqlAndArgs('SELECT', self.contain...
python
def _queryContainer(self, store): """ Generate and cache the subselect SQL and its arguments. Return the subselect SQL. """ if self._subselectSQL is None: sql, args = self.container._sqlAndArgs('SELECT', self.contain...
[ "def", "_queryContainer", "(", "self", ",", "store", ")", ":", "if", "self", ".", "_subselectSQL", "is", "None", ":", "sql", ",", "args", "=", "self", ".", "container", ".", "_sqlAndArgs", "(", "'SELECT'", ",", "self", ".", "container", ".", "_queryTarge...
Generate and cache the subselect SQL and its arguments. Return the subselect SQL.
[ "Generate", "and", "cache", "the", "subselect", "SQL", "and", "its", "arguments", ".", "Return", "the", "subselect", "SQL", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L729-L738
twisted/axiom
axiom/attributes.py
SequenceComparison._sequenceContainer
def _sequenceContainer(self, store): """ Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like. """ if self._sequence is None: self._sequence = list(self.conta...
python
def _sequenceContainer(self, store): """ Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like. """ if self._sequence is None: self._sequence = list(self.conta...
[ "def", "_sequenceContainer", "(", "self", ",", "store", ")", ":", "if", "self", ".", "_sequence", "is", "None", ":", "self", ".", "_sequence", "=", "list", "(", "self", ".", "container", ")", "self", ".", "_clause", "=", "', '", ".", "join", "(", "["...
Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like.
[ "Smash", "whatever", "we", "got", "into", "a", "list", "and", "save", "the", "result", "in", "case", "we", "are", "executed", "multiple", "times", ".", "This", "keeps", "us", "from", "tripping", "up", "over", "generators", "and", "the", "like", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L751-L760
twisted/axiom
axiom/attributes.py
SequenceComparison._sequenceArgs
def _sequenceArgs(self, store): """ Filter each element of the data using the attribute type being tested for containment and hand back the resulting list. """ self._sequenceContainer(store) # Force _sequence to be valid return [self.attribute.infilter(pyval, None, store)...
python
def _sequenceArgs(self, store): """ Filter each element of the data using the attribute type being tested for containment and hand back the resulting list. """ self._sequenceContainer(store) # Force _sequence to be valid return [self.attribute.infilter(pyval, None, store)...
[ "def", "_sequenceArgs", "(", "self", ",", "store", ")", ":", "self", ".", "_sequenceContainer", "(", "store", ")", "# Force _sequence to be valid", "return", "[", "self", ".", "attribute", ".", "infilter", "(", "pyval", ",", "None", ",", "store", ")", "for",...
Filter each element of the data using the attribute type being tested for containment and hand back the resulting list.
[ "Filter", "each", "element", "of", "the", "data", "using", "the", "attribute", "type", "being", "tested", "for", "containment", "and", "hand", "back", "the", "resulting", "list", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L763-L769
twisted/axiom
axiom/attributes.py
path.prepareInsert
def prepareInsert(self, oself, store): """ Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname. """ if self.relative: fspath = self.__get__(osel...
python
def prepareInsert(self, oself, store): """ Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname. """ if self.relative: fspath = self.__get__(osel...
[ "def", "prepareInsert", "(", "self", ",", "oself", ",", "store", ")", ":", "if", "self", ".", "relative", ":", "fspath", "=", "self", ".", "__get__", "(", "oself", ")", "oself", ".", "__dirty__", "[", "self", ".", "attrname", "]", "=", "self", ",", ...
Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname.
[ "Prepare", "for", "insertion", "into", "the", "database", "by", "making", "the", "dbunderlying", "attribute", "of", "the", "item", "a", "relative", "pathname", "with", "respect", "to", "the", "store", "rather", "than", "an", "absolute", "pathname", "." ]
train
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L1021-L1029
upgrad/django-deletes
djangodeletes/softdeletes/models.py
SoftDeletable.restore
def restore(self, time=None): """ Undeletes the object. Returns True if undeleted, False if it was already not deleted """ if self.deleted: time = time if time else self.deleted_at if time == self.deleted_at: self.deleted = False se...
python
def restore(self, time=None): """ Undeletes the object. Returns True if undeleted, False if it was already not deleted """ if self.deleted: time = time if time else self.deleted_at if time == self.deleted_at: self.deleted = False se...
[ "def", "restore", "(", "self", ",", "time", "=", "None", ")", ":", "if", "self", ".", "deleted", ":", "time", "=", "time", "if", "time", "else", "self", ".", "deleted_at", "if", "time", "==", "self", ".", "deleted_at", ":", "self", ".", "deleted", ...
Undeletes the object. Returns True if undeleted, False if it was already not deleted
[ "Undeletes", "the", "object", ".", "Returns", "True", "if", "undeleted", "False", "if", "it", "was", "already", "not", "deleted" ]
train
https://github.com/upgrad/django-deletes/blob/05cebc3323840badc67b926ec1ba2640d6cd12be/djangodeletes/softdeletes/models.py#L97-L109
upgrad/django-deletes
djangodeletes/softdeletes/models.py
SoftDeletable.full_restore
def full_restore(self, using=None): using = using or router.db_for_write(self.__class__, instance=self) restore_counter = Counter() if self.deleted: time = self.deleted_at else: return restore_counter self.collector = models.deletion.Collector(using=using)...
python
def full_restore(self, using=None): using = using or router.db_for_write(self.__class__, instance=self) restore_counter = Counter() if self.deleted: time = self.deleted_at else: return restore_counter self.collector = models.deletion.Collector(using=using)...
[ "def", "full_restore", "(", "self", ",", "using", "=", "None", ")", ":", "using", "=", "using", "or", "router", ".", "db_for_write", "(", "self", ".", "__class__", ",", "instance", "=", "self", ")", "restore_counter", "=", "Counter", "(", ")", "if", "s...
Restores itself, as well as objects that might have been deleted along with it if cascade is the deletion strategy
[ "Restores", "itself", "as", "well", "as", "objects", "that", "might", "have", "been", "deleted", "along", "with", "it", "if", "cascade", "is", "the", "deletion", "strategy" ]
train
https://github.com/upgrad/django-deletes/blob/05cebc3323840badc67b926ec1ba2640d6cd12be/djangodeletes/softdeletes/models.py#L111-L144
skymill/automated-ebs-snapshots
automated_ebs_snapshots/connection_manager.py
connect_to_ec2
def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None): """ Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: ...
python
def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None): """ Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: ...
[ "def", "connect_to_ec2", "(", "region", "=", "'us-east-1'", ",", "access_key", "=", "None", ",", "secret_key", "=", "None", ")", ":", "if", "access_key", ":", "# Connect using supplied credentials", "logger", ".", "info", "(", "'Connecting to AWS EC2 in {}'", ".", ...
Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: boto.ec2.connection.EC2Connection -- EC2 connection
[ "Connect", "to", "AWS", "ec2" ]
train
https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/connection_manager.py#L11-L47
dmirecki/pyMorfologik
pymorfologik/parsing.py
DictParser.parse
def parse(self, output): """ Find stems for a given text. """ output = self._get_lines_with_stems(output) words = self._make_unique(output) return self._parse_for_simple_stems(words)
python
def parse(self, output): """ Find stems for a given text. """ output = self._get_lines_with_stems(output) words = self._make_unique(output) return self._parse_for_simple_stems(words)
[ "def", "parse", "(", "self", ",", "output", ")", ":", "output", "=", "self", ".", "_get_lines_with_stems", "(", "output", ")", "words", "=", "self", ".", "_make_unique", "(", "output", ")", "return", "self", ".", "_parse_for_simple_stems", "(", "words", ")...
Find stems for a given text.
[ "Find", "stems", "for", "a", "given", "text", "." ]
train
https://github.com/dmirecki/pyMorfologik/blob/e4d93a82e8b4c7a108f01e0456fbeb8024df0259/pymorfologik/parsing.py#L47-L53
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.validlocations
def validlocations(configuration=None): # type: () -> List[Dict] """ Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations ...
python
def validlocations(configuration=None): # type: () -> List[Dict] """ Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations ...
[ "def", "validlocations", "(", "configuration", "=", "None", ")", ":", "# type: () -> List[Dict]", "if", "Locations", ".", "_validlocations", "is", "None", ":", "if", "configuration", "is", "None", ":", "configuration", "=", "Configuration", ".", "read", "(", ")"...
Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations
[ "Read", "valid", "locations", "from", "HDX" ]
train
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L14-L29
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_location_from_HDX_code
def get_location_from_HDX_code(code, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[D...
python
def get_location_from_HDX_code(code, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[D...
[ "def", "get_location_from_HDX_code", "(", "code", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]", "if", "locations", "is", "None", ":", "locations", "=", "Location...
Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuratio...
[ "Get", "location", "from", "HDX", "location", "code" ]
train
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L46-L63
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_HDX_code_from_location
def get_HDX_code_from_location(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict...
python
def get_HDX_code_from_location(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict...
[ "def", "get_HDX_code_from_location", "(", "location", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]", "if", "locations", "is", "None", ":", "locations", "=", "Loca...
Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. ...
[ "Get", "HDX", "code", "for", "location" ]
train
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L66-L89
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_HDX_code_from_location_partial
def get_HDX_code_from_location_partial(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool] """Get HDX code for location Args: location (str): Location for which to get HDX code location...
python
def get_HDX_code_from_location_partial(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool] """Get HDX code for location Args: location (str): Location for which to get HDX code location...
[ "def", "get_HDX_code_from_location_partial", "(", "location", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool]", "hdx_code", "=", "Locations", ".", "get_HDX_co...
Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. ...
[ "Get", "HDX", "code", "for", "location" ]
train
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L92-L117
libyal/dtfabric
scripts/validate-definitions.py
Main
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ argument_parser = argparse.ArgumentParser( description='Validates dtFabric format definitions.') argument_parser.add_argument( 'source', nargs='?', action='store', metavar='PATH', default=None, ...
python
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ argument_parser = argparse.ArgumentParser( description='Validates dtFabric format definitions.') argument_parser.add_argument( 'source', nargs='?', action='store', metavar='PATH', default=None, ...
[ "def", "Main", "(", ")", ":", "argument_parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Validates dtFabric format definitions.'", ")", "argument_parser", ".", "add_argument", "(", "'source'", ",", "nargs", "=", "'?'", ",", "action", "="...
The main program function. Returns: bool: True if successful or False if not.
[ "The", "main", "program", "function", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L77-L130
libyal/dtfabric
scripts/validate-definitions.py
DefinitionsValidator.CheckDirectory
def CheckDirectory(self, path, extension='yaml'): """Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions. """ resul...
python
def CheckDirectory(self, path, extension='yaml'): """Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions. """ resul...
[ "def", "CheckDirectory", "(", "self", ",", "path", ",", "extension", "=", "'yaml'", ")", ":", "result", "=", "True", "if", "extension", ":", "glob_spec", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'*.{0:s}'", ".", "format", "(", "extension...
Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions.
[ "Validates", "definition", "files", "in", "a", "directory", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L22-L43
libyal/dtfabric
scripts/validate-definitions.py
DefinitionsValidator.CheckFile
def CheckFile(self, path): """Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions. """ print('Checking: {0:s}'.format(path)) definitions_registry = registry.DataTypeDefinitionsRegistry() ...
python
def CheckFile(self, path): """Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions. """ print('Checking: {0:s}'.format(path)) definitions_registry = registry.DataTypeDefinitionsRegistry() ...
[ "def", "CheckFile", "(", "self", ",", "path", ")", ":", "print", "(", "'Checking: {0:s}'", ".", "format", "(", "path", ")", ")", "definitions_registry", "=", "registry", ".", "DataTypeDefinitionsRegistry", "(", ")", "definitions_reader", "=", "reader", ".", "Y...
Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions.
[ "Validates", "the", "definition", "in", "a", "file", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L45-L74
dlanger/inlinestyler
inlinestyler/converter.py
Conversion.styleattribute
def styleattribute(self, element): """ returns css.CSSStyleDeclaration of inline styles, for html: @style """ css_text = element.get('style') if css_text: return cssutils.css.CSSStyleDeclaration(cssText=css_text) else: return None
python
def styleattribute(self, element): """ returns css.CSSStyleDeclaration of inline styles, for html: @style """ css_text = element.get('style') if css_text: return cssutils.css.CSSStyleDeclaration(cssText=css_text) else: return None
[ "def", "styleattribute", "(", "self", ",", "element", ")", ":", "css_text", "=", "element", ".", "get", "(", "'style'", ")", "if", "css_text", ":", "return", "cssutils", ".", "css", ".", "CSSStyleDeclaration", "(", "cssText", "=", "css_text", ")", "else", ...
returns css.CSSStyleDeclaration of inline styles, for html: @style
[ "returns", "css", ".", "CSSStyleDeclaration", "of", "inline", "styles", "for", "html", ":" ]
train
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/converter.py#L66-L74
skymill/automated-ebs-snapshots
automated_ebs_snapshots/config_file_parser.py
get_configuration
def get_configuration(filename): """ Read configuration file :type filename: str :param filename: Path to the configuration file """ logger.debug('Reading configuration from {}'.format(filename)) conf = SafeConfigParser() conf.read(filename) if not conf: logger.error('Configura...
python
def get_configuration(filename): """ Read configuration file :type filename: str :param filename: Path to the configuration file """ logger.debug('Reading configuration from {}'.format(filename)) conf = SafeConfigParser() conf.read(filename) if not conf: logger.error('Configura...
[ "def", "get_configuration", "(", "filename", ")", ":", "logger", ".", "debug", "(", "'Reading configuration from {}'", ".", "format", "(", "filename", ")", ")", "conf", "=", "SafeConfigParser", "(", ")", "conf", ".", "read", "(", "filename", ")", "if", "not"...
Read configuration file :type filename: str :param filename: Path to the configuration file
[ "Read", "configuration", "file" ]
train
https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/config_file_parser.py#L9-L37
dlanger/inlinestyler
inlinestyler/utils.py
inline_css
def inline_css(html_message, encoding='unicode'): """ Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including ...
python
def inline_css(html_message, encoding='unicode'): """ Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including ...
[ "def", "inline_css", "(", "html_message", ",", "encoding", "=", "'unicode'", ")", ":", "document", "=", "etree", ".", "HTML", "(", "html_message", ")", "converter", "=", "Conversion", "(", ")", "converter", ".", "perform", "(", "document", ",", "html_message...
Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including CSS
[ "Inlines", "all", "CSS", "in", "an", "HTML", "string" ]
train
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/utils.py#L4-L18
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap._CheckByteStreamSize
def _CheckByteStreamSize(self, byte_stream, byte_offset, data_type_size): """Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ...
python
def _CheckByteStreamSize(self, byte_stream, byte_offset, data_type_size): """Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ...
[ "def", "_CheckByteStreamSize", "(", "self", ",", "byte_stream", ",", "byte_offset", ",", "data_type_size", ")", ":", "try", ":", "byte_stream_size", "=", "len", "(", "byte_stream", ")", "except", "Exception", "as", "exception", ":", "raise", "errors", ".", "Ma...
Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ByteStreamTooSmallError: if the byte stream is too small. MappingError...
[ "Checks", "if", "the", "byte", "stream", "is", "large", "enough", "for", "the", "data", "type", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L149-L170
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap._GetByteStreamOperation
def _GetByteStreamOperation(self): """Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine. """ byte_order_string = self.GetStructByteOrderString() format_string = self.GetStructFormatString() # pylint: disable=assignment-fro...
python
def _GetByteStreamOperation(self): """Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine. """ byte_order_string = self.GetStructByteOrderString() format_string = self.GetStructFormatString() # pylint: disable=assignment-fro...
[ "def", "_GetByteStreamOperation", "(", "self", ")", ":", "byte_order_string", "=", "self", ".", "GetStructByteOrderString", "(", ")", "format_string", "=", "self", ".", "GetStructFormatString", "(", ")", "# pylint: disable=assignment-from-none", "if", "not", "format_str...
Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine.
[ "Retrieves", "the", "byte", "stream", "operation", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L172-L184
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap.GetStructByteOrderString
def GetStructByteOrderString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._data_type_definition: return None return self._BYTE_ORDER_STRINGS.get( ...
python
def GetStructByteOrderString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._data_type_definition: return None return self._BYTE_ORDER_STRINGS.get( ...
[ "def", "GetStructByteOrderString", "(", "self", ")", ":", "if", "not", "self", ".", "_data_type_definition", ":", "return", "None", "return", "self", ".", "_BYTE_ORDER_STRINGS", ".", "get", "(", "self", ".", "_data_type_definition", ".", "byte_order", ",", "None...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L186-L197
libyal/dtfabric
dtfabric/runtime/data_maps.py
PrimitiveDataTypeMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "value", "=", "self", ".", "FoldValue", "(", "mapped_value", ")", "return", "self", ".", "_operation", ".", "WriteTo", "(", "tuple", "(", "["...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L253-L274
libyal/dtfabric
dtfabric/runtime/data_maps.py
PrimitiveDataTypeMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "data_type_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", "self", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: MappingError: if the da...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L290-L323
libyal/dtfabric
dtfabric/runtime/data_maps.py
BooleanMap.FoldValue
def FoldValue(self, value): """Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value. """ if value is False and self._data_type_definition.false_value is n...
python
def FoldValue(self, value): """Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value. """ if value is False and self._data_type_definition.false_value is n...
[ "def", "FoldValue", "(", "self", ",", "value", ")", ":", "if", "value", "is", "False", "and", "self", ".", "_data_type_definition", ".", "false_value", "is", "not", "None", ":", "return", "self", ".", "_data_type_definition", ".", "false_value", "if", "value...
Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value.
[ "Folds", "the", "data", "type", "into", "a", "value", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L378-L396
libyal/dtfabric
dtfabric/runtime/data_maps.py
IntegerMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._data_type_definition.format == definitions.FORMAT_UNSIGNED: return self._FORMAT_STRINGS_U...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._data_type_definition.format == definitions.FORMAT_UNSIGNED: return self._FORMAT_STRINGS_U...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "self", ".", "_data_type_definition", ".", "format", "==", "definitions", ".", "FORMAT_UNSIGNED", ":", "return", "self", ".", "_FORMAT_STRINGS_UNSIGNED", ".", "get", "(", "self", ".", "_data_type_definit...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L515-L527
libyal/dtfabric
dtfabric/runtime/data_maps.py
UUIDMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "value", "=", "None", "try", ":", "if", "self", ".", "_byte_order", "==", "definitions", ".", "BYTE_ORDER_BIG_ENDIAN", ":", "value", "=", "mapped_value", "."...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L544-L571
libyal/dtfabric
dtfabric/runtime/data_maps.py
UUIDMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "data_type_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", "self", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: uuid.UUID: mapped value. Raises: MappingError: if the...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L573-L610
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._CalculateElementsDataSize
def _CalculateElementsDataSize(self, context): """Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available. """ elements_data_size = N...
python
def _CalculateElementsDataSize(self, context): """Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available. """ elements_data_size = N...
[ "def", "_CalculateElementsDataSize", "(", "self", ",", "context", ")", ":", "elements_data_size", "=", "None", "if", "self", ".", "_HasElementsDataSize", "(", ")", ":", "elements_data_size", "=", "self", ".", "_EvaluateElementsDataSize", "(", "context", ")", "elif...
Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available.
[ "Calculates", "the", "elements", "data", "size", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L636-L657
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._EvaluateElementsDataSize
def _EvaluateElementsDataSize(self, context): """Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined. """ elements_data_size = None ...
python
def _EvaluateElementsDataSize(self, context): """Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined. """ elements_data_size = None ...
[ "def", "_EvaluateElementsDataSize", "(", "self", ",", "context", ")", ":", "elements_data_size", "=", "None", "if", "self", ".", "_data_type_definition", ".", "elements_data_size", ":", "elements_data_size", "=", "self", ".", "_data_type_definition", ".", "elements_da...
Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined.
[ "Evaluates", "elements", "data", "size", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L659-L694
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._EvaluateNumberOfElements
def _EvaluateNumberOfElements(self, context): """Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined. """ number_of_elements = None ...
python
def _EvaluateNumberOfElements(self, context): """Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined. """ number_of_elements = None ...
[ "def", "_EvaluateNumberOfElements", "(", "self", ",", "context", ")", ":", "number_of_elements", "=", "None", "if", "self", ".", "_data_type_definition", ".", "number_of_elements", ":", "number_of_elements", "=", "self", ".", "_data_type_definition", ".", "number_of_e...
Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined.
[ "Evaluates", "number", "of", "elements", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L696-L731
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._GetElementDataTypeDefinition
def _GetElementDataTypeDefinition(self, data_type_definition): """Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data ty...
python
def _GetElementDataTypeDefinition(self, data_type_definition): """Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data ty...
[ "def", "_GetElementDataTypeDefinition", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "element_data_type_definition", "=", "getattr", "(", ...
Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data type cannot be determined from the data type definition.
[ "Retrieves", "the", "element", "data", "type", "definition", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L733-L755
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap.GetSizeHint
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
python
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
[ "def", "GetSizeHint", "(", "self", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "elements_data_size", "=", "self", ".", "GetByteSize", "(", ")"...
Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None.
[ "Retrieves", "a", "hint", "about", "the", "size", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L800-L833
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._CompositeMapByteStream
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
python
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
[ "def", "_CompositeMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "None", "elements_terminator", "=", "None", "number_of_elements", "...
Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Rai...
[ "Maps", "a", "sequence", "of", "composite", "data", "types", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L909-L1031
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._LinearFoldByteStream
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
python
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
[ "def", "_LinearFoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "return", "self", ".", "_operation", ".", "WriteTo", "(", "mapped_value", ")", "except", "Exception", "as", "exception", ":", "error_string"...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1033-L1053
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._LinearMapByteStream
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
python
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
[ "def", "_LinearMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", ...
Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Raises: Map...
[ "Maps", "a", "data", "type", "sequence", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1055-L1088
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._element_data_type_map: return None number_of_elements = None if self._data_t...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._element_data_type_map: return None number_of_elements = None if self._data_t...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "not", "self", ".", "_element_data_type_map", ":", "return", "None", "number_of_elements", "=", "None", "if", "self", ".", "_data_type_definition", ".", "elements_data_size", ":", "element_byte_size", "=",...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1105-L1131
libyal/dtfabric
dtfabric/runtime/data_maps.py
StreamMap.FoldByteStream
def FoldByteStream(self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the...
python
def FoldByteStream(self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "self", ".", "_CalculateElementsDataSize", "(", "context", ")", "if", "elements_data_size", "is", "not", ...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1175-L1204
libyal/dtfabric
dtfabric/runtime/data_maps.py
StreamMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "size_hints...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Raises: MappingErr...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1219-L1289
libyal/dtfabric
dtfabric/runtime/data_maps.py
PaddingMap.MapByteStream
def MapByteStream(self, byte_stream, byte_offset=0, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: i...
python
def MapByteStream(self, byte_stream, byte_offset=0, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: i...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "*", "*", "unused_kwargs", ")", ":", "return", "byte_stream", "[", "byte_offset", ":", "byte_offset", "+", "self", ".", "byte_size", "]" ]
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: if the data type definition cannot be mapped on the byte stream.
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1355-L1369
libyal/dtfabric
dtfabric/runtime/data_maps.py
StringMap.FoldByteStream
def FoldByteStream(self, mapped_value, **kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ try: ...
python
def FoldByteStream(self, mapped_value, **kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ try: ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "byte_stream", "=", "mapped_value", ".", "encode", "(", "self", ".", "_data_type_definition", ".", "encoding", ")", "except", "Exception", "as", "except...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1391-L1413
libyal/dtfabric
dtfabric/runtime/data_maps.py
StringMap.MapByteStream
def MapByteStream(self, byte_stream, byte_offset=0, **kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the dat...
python
def MapByteStream(self, byte_stream, byte_offset=0, **kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the dat...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "*", "*", "kwargs", ")", ":", "byte_stream", "=", "super", "(", "StringMap", ",", "self", ")", ".", "MapByteStream", "(", "byte_stream", ",", "byte_offset", "=", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the data type definition cannot be mapped on the byte stream.
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1415-L1458
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CheckCompositeMap
def _CheckCompositeMap(self, data_type_definition): """Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatErro...
python
def _CheckCompositeMap(self, data_type_definition): """Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatErro...
[ "def", "_CheckCompositeMap", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "members", "=", "getattr", "(", "data_type_definition", ",", ...
Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatError: if a composite map is needed cannot be determined from t...
[ "Determines", "if", "the", "data", "type", "definition", "needs", "a", "composite", "map", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1498-L1536
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CompositeFoldByteStream
def _CompositeFoldByteStream( self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: Fol...
python
def _CompositeFoldByteStream( self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: Fol...
[ "def", "_CompositeFoldByteStream", "(", "self", ",", "mapped_value", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "attribute_index", "=", "context_...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1538-L1582
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CompositeMapByteStream
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
python
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
[ "def", "_CompositeMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "...
Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: Ma...
[ "Maps", "a", "sequence", "of", "composite", "data", "types", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1584-L1686
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._GetAttributeNames
def _GetAttributeNames(self, data_type_definition): """Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determin...
python
def _GetAttributeNames(self, data_type_definition): """Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determin...
[ "def", "_GetAttributeNames", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "attribute_names", "=", "[", "]", "for", "member_definition", ...
Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determined from the data type definition.
[ "Determines", "the", "attribute", "(", "or", "field", ")", "names", "of", "the", "members", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1688-L1708
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._GetMemberDataTypeMaps
def _GetMemberDataTypeMaps(self, data_type_definition, data_type_map_cache): """Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: mem...
python
def _GetMemberDataTypeMaps(self, data_type_definition, data_type_map_cache): """Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: mem...
[ "def", "_GetMemberDataTypeMaps", "(", "self", ",", "data_type_definition", ",", "data_type_map_cache", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "members", "=", "getattr", "("...
Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: member data type maps. Raises: FormatError: if the data type maps cannot be ...
[ "Retrieves", "the", "member", "data", "type", "maps", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1710-L1771
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._LinearFoldByteStream
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
python
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
[ "def", "_LinearFoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "attribute_values", "=", "[", "getattr", "(", "mapped_value", ",", "attribute_name", ",", "None", ")", "for", "attribute_name", "in", "self"...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1773-L1798
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._LinearMapByteStream
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
python
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
[ "def", "_LinearMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "members_data_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", ...
Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: MappingError: if...
[ "Maps", "a", "data", "type", "sequence", "on", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1800-L1849
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap.GetSizeHint
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
python
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
[ "def", "GetSizeHint", "(", "self", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "subcontext", "=", "context_state", ".", "get", "(", "'context'...
Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None.
[ "Retrieves", "a", "hint", "about", "the", "size", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1874-L1900
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._format_string is None and self._data_type_maps: format_strings = [] for member_data...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._format_string is None and self._data_type_maps: format_strings = [] for member_data...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "self", ".", "_format_string", "is", "None", "and", "self", ".", "_data_type_maps", ":", "format_strings", "=", "[", "]", "for", "member_data_type_map", "in", "self", ".", "_data_type_maps", ":", "if...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1902-L1923
libyal/dtfabric
dtfabric/runtime/data_maps.py
SemanticDataTypeMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded int...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded int...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "# pylint: disable=redundant-returns-doc", "raise", "errors", ".", "FoldingError", "(", "'Unable to fold {0:s} data type into byte stream'", ".", "format", "(", "self", ...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
train
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1944-L1959