repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/baseFeatureWriter.py
BaseFeatureWriter.compileGSUB
def compileGSUB(self): """Compile a temporary GSUB table from the current feature file. """ from ufo2ft.util import compileGSUB compiler = self.context.compiler if compiler is not None: # The result is cached in the compiler instance, so if another # writ...
python
def compileGSUB(self): """Compile a temporary GSUB table from the current feature file. """ from ufo2ft.util import compileGSUB compiler = self.context.compiler if compiler is not None: # The result is cached in the compiler instance, so if another # writ...
[ "def", "compileGSUB", "(", "self", ")", ":", "from", "ufo2ft", ".", "util", "import", "compileGSUB", "compiler", "=", "self", ".", "context", ".", "compiler", "if", "compiler", "is", "not", "None", ":", "# The result is cached in the compiler instance, so if another...
Compile a temporary GSUB table from the current feature file.
[ "Compile", "a", "temporary", "GSUB", "table", "from", "the", "current", "feature", "file", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/baseFeatureWriter.py#L163-L185
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.compile
def compile(self): """ Compile the OpenType binary. """ self.otf = TTFont(sfntVersion=self.sfntVersion) # only compile vertical metrics tables if vhea metrics a defined vertical_metrics = [ "openTypeVheaVertTypoAscender", "openTypeVheaVertTypoDesc...
python
def compile(self): """ Compile the OpenType binary. """ self.otf = TTFont(sfntVersion=self.sfntVersion) # only compile vertical metrics tables if vhea metrics a defined vertical_metrics = [ "openTypeVheaVertTypoAscender", "openTypeVheaVertTypoDesc...
[ "def", "compile", "(", "self", ")", ":", "self", ".", "otf", "=", "TTFont", "(", "sfntVersion", "=", "self", ".", "sfntVersion", ")", "# only compile vertical metrics tables if vhea metrics a defined", "vertical_metrics", "=", "[", "\"openTypeVheaVertTypoAscender\"", ",...
Compile the OpenType binary.
[ "Compile", "the", "OpenType", "binary", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L94-L132
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.makeFontBoundingBox
def makeFontBoundingBox(self): """ Make a bounding box for the font. **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired. """ if not hasattr(self, "glyphBoundingBoxes"): ...
python
def makeFontBoundingBox(self): """ Make a bounding box for the font. **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired. """ if not hasattr(self, "glyphBoundingBoxes"): ...
[ "def", "makeFontBoundingBox", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"glyphBoundingBoxes\"", ")", ":", "self", ".", "glyphBoundingBoxes", "=", "self", ".", "makeGlyphsBoundingBoxes", "(", ")", "fontBox", "=", "None", "for", "glyphNa...
Make a bounding box for the font. **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired.
[ "Make", "a", "bounding", "box", "for", "the", "font", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L164-L184
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.makeMissingRequiredGlyphs
def makeMissingRequiredGlyphs(font, glyphSet): """ Add .notdef to the glyph set if it is not present. **This should not be called externally.** Subclasses may override this method to handle the glyph creation in a different way if desired. """ if ".notdef" in gly...
python
def makeMissingRequiredGlyphs(font, glyphSet): """ Add .notdef to the glyph set if it is not present. **This should not be called externally.** Subclasses may override this method to handle the glyph creation in a different way if desired. """ if ".notdef" in gly...
[ "def", "makeMissingRequiredGlyphs", "(", "font", ",", "glyphSet", ")", ":", "if", "\".notdef\"", "in", "glyphSet", ":", "return", "unitsPerEm", "=", "otRound", "(", "getAttrWithFallback", "(", "font", ".", "info", ",", "\"unitsPerEm\"", ")", ")", "ascender", "...
Add .notdef to the glyph set if it is not present. **This should not be called externally.** Subclasses may override this method to handle the glyph creation in a different way if desired.
[ "Add", ".", "notdef", "to", "the", "glyph", "set", "if", "it", "is", "not", "present", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L197-L216
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_head
def setupTable_head(self): """ Make the head table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "head" not in self.tables: return ...
python
def setupTable_head(self): """ Make the head table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "head" not in self.tables: return ...
[ "def", "setupTable_head", "(", "self", ")", ":", "if", "\"head\"", "not", "in", "self", ".", "tables", ":", "return", "self", ".", "otf", "[", "\"head\"", "]", "=", "head", "=", "newTable", "(", "\"head\"", ")", "font", "=", "self", ".", "ufo", "head...
Make the head table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "head", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L245-L305
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_name
def setupTable_name(self): """ Make the name table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "name" not in self.tables: return ...
python
def setupTable_name(self): """ Make the name table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "name" not in self.tables: return ...
[ "def", "setupTable_name", "(", "self", ")", ":", "if", "\"name\"", "not", "in", "self", ".", "tables", ":", "return", "font", "=", "self", ".", "ufo", "self", ".", "otf", "[", "\"name\"", "]", "=", "name", "=", "newTable", "(", "\"name\"", ")", "name...
Make the name table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "name", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L307-L386
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_cmap
def setupTable_cmap(self): """ Make the cmap table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "cmap" not in self.tables: return ...
python
def setupTable_cmap(self): """ Make the cmap table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "cmap" not in self.tables: return ...
[ "def", "setupTable_cmap", "(", "self", ")", ":", "if", "\"cmap\"", "not", "in", "self", ".", "tables", ":", "return", "from", "fontTools", ".", "ttLib", ".", "tables", ".", "_c_m_a_p", "import", "cmap_format_4", "nonBMP", "=", "dict", "(", "(", "k", ",",...
Make the cmap table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "cmap", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L398-L450
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_hmtx
def setupTable_hmtx(self): """ Make the hmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "hmtx" not in self.tables: return ...
python
def setupTable_hmtx(self): """ Make the hmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "hmtx" not in self.tables: return ...
[ "def", "setupTable_hmtx", "(", "self", ")", ":", "if", "\"hmtx\"", "not", "in", "self", ".", "tables", ":", "return", "self", ".", "otf", "[", "\"hmtx\"", "]", "=", "hmtx", "=", "newTable", "(", "\"hmtx\"", ")", "hmtx", ".", "metrics", "=", "{", "}",...
Make the hmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "hmtx", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L613-L633
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler._setupTable_hhea_or_vhea
def _setupTable_hhea_or_vhea(self, tag): """ Make the hhea table or the vhea table. This assume the hmtx or the vmtx were respectively made first. """ if tag not in self.tables: return if tag == "hhea": isHhea = True else: isHh...
python
def _setupTable_hhea_or_vhea(self, tag): """ Make the hhea table or the vhea table. This assume the hmtx or the vmtx were respectively made first. """ if tag not in self.tables: return if tag == "hhea": isHhea = True else: isHh...
[ "def", "_setupTable_hhea_or_vhea", "(", "self", ",", "tag", ")", ":", "if", "tag", "not", "in", "self", ".", "tables", ":", "return", "if", "tag", "==", "\"hhea\"", ":", "isHhea", "=", "True", "else", ":", "isHhea", "=", "False", "self", ".", "otf", ...
Make the hhea table or the vhea table. This assume the hmtx or the vmtx were respectively made first.
[ "Make", "the", "hhea", "table", "or", "the", "vhea", "table", ".", "This", "assume", "the", "hmtx", "or", "the", "vmtx", "were", "respectively", "made", "first", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L635-L727
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_vmtx
def setupTable_vmtx(self): """ Make the vmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "vmtx" not in self.tables: return ...
python
def setupTable_vmtx(self): """ Make the vmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "vmtx" not in self.tables: return ...
[ "def", "setupTable_vmtx", "(", "self", ")", ":", "if", "\"vmtx\"", "not", "in", "self", ".", "tables", ":", "return", "self", ".", "otf", "[", "\"vmtx\"", "]", "=", "vmtx", "=", "newTable", "(", "\"vmtx\"", ")", "vmtx", ".", "metrics", "=", "{", "}",...
Make the vmtx table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "vmtx", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L739-L760
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_VORG
def setupTable_VORG(self): """ Make the VORG table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "VORG" not in self.tables: return ...
python
def setupTable_VORG(self): """ Make the VORG table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "VORG" not in self.tables: return ...
[ "def", "setupTable_VORG", "(", "self", ")", ":", "if", "\"VORG\"", "not", "in", "self", ".", "tables", ":", "return", "self", ".", "otf", "[", "\"VORG\"", "]", "=", "vorg", "=", "newTable", "(", "\"VORG\"", ")", "vorg", ".", "majorVersion", "=", "1", ...
Make the VORG table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "VORG", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L762-L785
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.setupTable_post
def setupTable_post(self): """ Make the post table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "post" not in self.tables: return ...
python
def setupTable_post(self): """ Make the post table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired. """ if "post" not in self.tables: return ...
[ "def", "setupTable_post", "(", "self", ")", ":", "if", "\"post\"", "not", "in", "self", ".", "tables", ":", "return", "self", ".", "otf", "[", "\"post\"", "]", "=", "post", "=", "newTable", "(", "\"post\"", ")", "font", "=", "self", ".", "ufo", "post...
Make the post table. **This should not be called externally.** Subclasses may override or supplement this method to handle the table creation in a different way if desired.
[ "Make", "the", "post", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L798-L825
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
BaseOutlineCompiler.importTTX
def importTTX(self): """ Merge TTX files from data directory "com.github.fonttools.ttx" **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired. """ import os import re ...
python
def importTTX(self): """ Merge TTX files from data directory "com.github.fonttools.ttx" **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired. """ import os import re ...
[ "def", "importTTX", "(", "self", ")", ":", "import", "os", "import", "re", "prefix", "=", "\"com.github.fonttools.ttx\"", "sfntVersionRE", "=", "re", ".", "compile", "(", "'(^<ttFont\\s+)(sfntVersion=\".*\"\\s+)(.*>$)'", ",", "flags", "=", "re", ".", "MULTILINE", ...
Merge TTX files from data directory "com.github.fonttools.ttx" **This should not be called externally.** Subclasses may override this method to handle the bounds creation in a different way if desired.
[ "Merge", "TTX", "files", "from", "data", "directory", "com", ".", "github", ".", "fonttools", ".", "ttx" ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L837-L863
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
OutlineTTFCompiler.setupTable_post
def setupTable_post(self): """Make a format 2 post table with the compiler's glyph order.""" super(OutlineTTFCompiler, self).setupTable_post() if "post" not in self.otf: return post = self.otf["post"] post.formatType = 2.0 post.extraNames = [] post.ma...
python
def setupTable_post(self): """Make a format 2 post table with the compiler's glyph order.""" super(OutlineTTFCompiler, self).setupTable_post() if "post" not in self.otf: return post = self.otf["post"] post.formatType = 2.0 post.extraNames = [] post.ma...
[ "def", "setupTable_post", "(", "self", ")", ":", "super", "(", "OutlineTTFCompiler", ",", "self", ")", ".", "setupTable_post", "(", ")", "if", "\"post\"", "not", "in", "self", ".", "otf", ":", "return", "post", "=", "self", ".", "otf", "[", "\"post\"", ...
Make a format 2 post table with the compiler's glyph order.
[ "Make", "a", "format", "2", "post", "table", "with", "the", "compiler", "s", "glyph", "order", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L1143-L1153
train
googlefonts/ufo2ft
Lib/ufo2ft/outlineCompiler.py
OutlineTTFCompiler.setupTable_glyf
def setupTable_glyf(self): """Make the glyf table.""" if not {"glyf", "loca"}.issubset(self.tables): return self.otf["loca"] = newTable("loca") self.otf["glyf"] = glyf = newTable("glyf") glyf.glyphs = {} glyf.glyphOrder = self.glyphOrder hmtx = self....
python
def setupTable_glyf(self): """Make the glyf table.""" if not {"glyf", "loca"}.issubset(self.tables): return self.otf["loca"] = newTable("loca") self.otf["glyf"] = glyf = newTable("glyf") glyf.glyphs = {} glyf.glyphOrder = self.glyphOrder hmtx = self....
[ "def", "setupTable_glyf", "(", "self", ")", ":", "if", "not", "{", "\"glyf\"", ",", "\"loca\"", "}", ".", "issubset", "(", "self", ".", "tables", ")", ":", "return", "self", ".", "otf", "[", "\"loca\"", "]", "=", "newTable", "(", "\"loca\"", ")", "se...
Make the glyf table.
[ "Make", "the", "glyf", "table", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/outlineCompiler.py#L1160-L1188
train
quadrismegistus/prosodic
prosodic/dicts/en/syllabify.py
loadLanguage
def loadLanguage(filename) : '''This function loads up a language configuration file and returns the configuration to be passed to the syllabify function.''' L = { "consonants" : [], "vowels" : [], "onsets" : [] } f = open(filename, "r") section = None for line in f : line = line.strip() if line in ("[cons...
python
def loadLanguage(filename) : '''This function loads up a language configuration file and returns the configuration to be passed to the syllabify function.''' L = { "consonants" : [], "vowels" : [], "onsets" : [] } f = open(filename, "r") section = None for line in f : line = line.strip() if line in ("[cons...
[ "def", "loadLanguage", "(", "filename", ")", ":", "L", "=", "{", "\"consonants\"", ":", "[", "]", ",", "\"vowels\"", ":", "[", "]", ",", "\"onsets\"", ":", "[", "]", "}", "f", "=", "open", "(", "filename", ",", "\"r\"", ")", "section", "=", "None",...
This function loads up a language configuration file and returns the configuration to be passed to the syllabify function.
[ "This", "function", "loads", "up", "a", "language", "configuration", "file", "and", "returns", "the", "configuration", "to", "be", "passed", "to", "the", "syllabify", "function", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/dicts/en/syllabify.py#L56-L79
train
quadrismegistus/prosodic
prosodic/dicts/en/syllabify.py
stringify
def stringify(syllables) : '''This function takes a syllabification returned by syllabify and turns it into a string, with phonemes spearated by spaces and syllables spearated by periods.''' ret = [] for syl in syllables : stress, onset, nucleus, coda = syl if stress != None and len(nucleus) != 0 : nu...
python
def stringify(syllables) : '''This function takes a syllabification returned by syllabify and turns it into a string, with phonemes spearated by spaces and syllables spearated by periods.''' ret = [] for syl in syllables : stress, onset, nucleus, coda = syl if stress != None and len(nucleus) != 0 : nu...
[ "def", "stringify", "(", "syllables", ")", ":", "ret", "=", "[", "]", "for", "syl", "in", "syllables", ":", "stress", ",", "onset", ",", "nucleus", ",", "coda", "=", "syl", "if", "stress", "!=", "None", "and", "len", "(", "nucleus", ")", "!=", "0",...
This function takes a syllabification returned by syllabify and turns it into a string, with phonemes spearated by spaces and syllables spearated by periods.
[ "This", "function", "takes", "a", "syllabification", "returned", "by", "syllabify", "and", "turns", "it", "into", "a", "string", "with", "phonemes", "spearated", "by", "spaces", "and", "syllables", "spearated", "by", "periods", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/dicts/en/syllabify.py#L158-L168
train
quadrismegistus/prosodic
prosodic/tools.py
slice
def slice(l,num_slices=None,slice_length=None,runts=True,random=False): """ Returns a new list of n evenly-sized segments of the original list """ if random: import random random.shuffle(l) if not num_slices and not slice_length: return l if not slice_length: slice_length=int(len(l)/num_slices) newlist=[l[i:...
python
def slice(l,num_slices=None,slice_length=None,runts=True,random=False): """ Returns a new list of n evenly-sized segments of the original list """ if random: import random random.shuffle(l) if not num_slices and not slice_length: return l if not slice_length: slice_length=int(len(l)/num_slices) newlist=[l[i:...
[ "def", "slice", "(", "l", ",", "num_slices", "=", "None", ",", "slice_length", "=", "None", ",", "runts", "=", "True", ",", "random", "=", "False", ")", ":", "if", "random", ":", "import", "random", "random", ".", "shuffle", "(", "l", ")", "if", "n...
Returns a new list of n evenly-sized segments of the original list
[ "Returns", "a", "new", "list", "of", "n", "evenly", "-", "sized", "segments", "of", "the", "original", "list" ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/tools.py#L3-L14
train
quadrismegistus/prosodic
prosodic/entity.py
entity.u2s
def u2s(self,u): """Returns an ASCII representation of the Unicode string 'u'.""" try: return u.encode('utf-8',errors='ignore') except (UnicodeDecodeError,AttributeError) as e: try: return str(u) except UnicodeEncodeError: return unicode(u).encode('utf-8',errors='ignore')
python
def u2s(self,u): """Returns an ASCII representation of the Unicode string 'u'.""" try: return u.encode('utf-8',errors='ignore') except (UnicodeDecodeError,AttributeError) as e: try: return str(u) except UnicodeEncodeError: return unicode(u).encode('utf-8',errors='ignore')
[ "def", "u2s", "(", "self", ",", "u", ")", ":", "try", ":", "return", "u", ".", "encode", "(", "'utf-8'", ",", "errors", "=", "'ignore'", ")", "except", "(", "UnicodeDecodeError", ",", "AttributeError", ")", "as", "e", ":", "try", ":", "return", "str"...
Returns an ASCII representation of the Unicode string 'u'.
[ "Returns", "an", "ASCII", "representation", "of", "the", "Unicode", "string", "u", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L217-L226
train
quadrismegistus/prosodic
prosodic/entity.py
entity.wordtokens
def wordtokens(self,include_punct=True): """Returns a list of this object's Words in order of their appearance. Set flattenList to False to receive a list of lists of Words.""" ws=self.ents('WordToken') if not include_punct: return [w for w in ws if not w.is_punct] return ws
python
def wordtokens(self,include_punct=True): """Returns a list of this object's Words in order of their appearance. Set flattenList to False to receive a list of lists of Words.""" ws=self.ents('WordToken') if not include_punct: return [w for w in ws if not w.is_punct] return ws
[ "def", "wordtokens", "(", "self", ",", "include_punct", "=", "True", ")", ":", "ws", "=", "self", ".", "ents", "(", "'WordToken'", ")", "if", "not", "include_punct", ":", "return", "[", "w", "for", "w", "in", "ws", "if", "not", "w", ".", "is_punct", ...
Returns a list of this object's Words in order of their appearance. Set flattenList to False to receive a list of lists of Words.
[ "Returns", "a", "list", "of", "this", "object", "s", "Words", "in", "order", "of", "their", "appearance", ".", "Set", "flattenList", "to", "False", "to", "receive", "a", "list", "of", "lists", "of", "Words", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L387-L392
train
quadrismegistus/prosodic
prosodic/entity.py
entity.dir
def dir(self,methods=True,showall=True): """Show this object's attributes and methods.""" import inspect #print "[attributes]" for k,v in sorted(self.__dict__.items()): if k.startswith("_"): continue print makeminlength("."+k,being.linelen),"\t",v if not methods: return entmethods=dir(entity) ...
python
def dir(self,methods=True,showall=True): """Show this object's attributes and methods.""" import inspect #print "[attributes]" for k,v in sorted(self.__dict__.items()): if k.startswith("_"): continue print makeminlength("."+k,being.linelen),"\t",v if not methods: return entmethods=dir(entity) ...
[ "def", "dir", "(", "self", ",", "methods", "=", "True", ",", "showall", "=", "True", ")", ":", "import", "inspect", "#print \"[attributes]\"", "for", "k", ",", "v", "in", "sorted", "(", "self", ".", "__dict__", ".", "items", "(", ")", ")", ":", "if",...
Show this object's attributes and methods.
[ "Show", "this", "object", "s", "attributes", "and", "methods", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L433-L472
train
quadrismegistus/prosodic
prosodic/entity.py
entity.makeBubbleChart
def makeBubbleChart(self,posdict,name,stattup=None): """Returns HTML for a bubble chart of the positin dictionary.""" xname=[x for x in name.split(".") if x.startswith("X_")][0] yname=[x for x in name.split(".") if x.startswith("Y_")][0] #elsename=name.replace(xname,'').replace(yname,'').replace('..','.').repl...
python
def makeBubbleChart(self,posdict,name,stattup=None): """Returns HTML for a bubble chart of the positin dictionary.""" xname=[x for x in name.split(".") if x.startswith("X_")][0] yname=[x for x in name.split(".") if x.startswith("Y_")][0] #elsename=name.replace(xname,'').replace(yname,'').replace('..','.').repl...
[ "def", "makeBubbleChart", "(", "self", ",", "posdict", ",", "name", ",", "stattup", "=", "None", ")", ":", "xname", "=", "[", "x", "for", "x", "in", "name", ".", "split", "(", "\".\"", ")", "if", "x", ".", "startswith", "(", "\"X_\"", ")", "]", "...
Returns HTML for a bubble chart of the positin dictionary.
[ "Returns", "HTML", "for", "a", "bubble", "chart", "of", "the", "positin", "dictionary", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L790-L816
train
quadrismegistus/prosodic
prosodic/entity.py
entity.getName
def getName(self): """Return a Name string for this object.""" name=self.findattr('name') if not name: name="_directinput_" if self.classname().lower()=="line": name+="."+str(self).replace(" ","_").lower() else: name=name.replace('.txt','') while name.startswith("."): name=name[1:] return...
python
def getName(self): """Return a Name string for this object.""" name=self.findattr('name') if not name: name="_directinput_" if self.classname().lower()=="line": name+="."+str(self).replace(" ","_").lower() else: name=name.replace('.txt','') while name.startswith("."): name=name[1:] return...
[ "def", "getName", "(", "self", ")", ":", "name", "=", "self", ".", "findattr", "(", "'name'", ")", "if", "not", "name", ":", "name", "=", "\"_directinput_\"", "if", "self", ".", "classname", "(", ")", ".", "lower", "(", ")", "==", "\"line\"", ":", ...
Return a Name string for this object.
[ "Return", "a", "Name", "string", "for", "this", "object", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L956-L970
train
quadrismegistus/prosodic
prosodic/entity.py
entity.scansion_prepare
def scansion_prepare(self,meter=None,conscious=False): """Print out header column for line-scansions for a given meter. """ import prosodic config=prosodic.config if not meter: if not hasattr(self,'_Text__bestparses'): return x=getattr(self,'_Text__bestparses') if not x.keys(): return meter=x.keys(...
python
def scansion_prepare(self,meter=None,conscious=False): """Print out header column for line-scansions for a given meter. """ import prosodic config=prosodic.config if not meter: if not hasattr(self,'_Text__bestparses'): return x=getattr(self,'_Text__bestparses') if not x.keys(): return meter=x.keys(...
[ "def", "scansion_prepare", "(", "self", ",", "meter", "=", "None", ",", "conscious", "=", "False", ")", ":", "import", "prosodic", "config", "=", "prosodic", ".", "config", "if", "not", "meter", ":", "if", "not", "hasattr", "(", "self", ",", "'_Text__bes...
Print out header column for line-scansions for a given meter.
[ "Print", "out", "header", "column", "for", "line", "-", "scansions", "for", "a", "given", "meter", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L1138-L1150
train
quadrismegistus/prosodic
prosodic/entity.py
entity.report
def report(self,meter=None,include_bounded=False,reverse=True): """ Print all parses and their violations in a structured format. """ ReportStr = '' if not meter: from Meter import Meter meter=Meter.genDefault() if (hasattr(self,'allParses')): self.om(unicode(self)) allparses=self.allParses(meter=m...
python
def report(self,meter=None,include_bounded=False,reverse=True): """ Print all parses and their violations in a structured format. """ ReportStr = '' if not meter: from Meter import Meter meter=Meter.genDefault() if (hasattr(self,'allParses')): self.om(unicode(self)) allparses=self.allParses(meter=m...
[ "def", "report", "(", "self", ",", "meter", "=", "None", ",", "include_bounded", "=", "False", ",", "reverse", "=", "True", ")", ":", "ReportStr", "=", "''", "if", "not", "meter", ":", "from", "Meter", "import", "Meter", "meter", "=", "Meter", ".", "...
Print all parses and their violations in a structured format.
[ "Print", "all", "parses", "and", "their", "violations", "in", "a", "structured", "format", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L1168-L1191
train
quadrismegistus/prosodic
prosodic/entity.py
entity.tree
def tree(self,offset=0,prefix_inherited="",nofeatsplease=['Phoneme']): """Print a tree-structure of this object's phonological representation.""" tree = "" numchild=0 for child in self.children: if type(child)==type([]): child=child[0] numchild+=1 classname=child.classname() if classname=="Wor...
python
def tree(self,offset=0,prefix_inherited="",nofeatsplease=['Phoneme']): """Print a tree-structure of this object's phonological representation.""" tree = "" numchild=0 for child in self.children: if type(child)==type([]): child=child[0] numchild+=1 classname=child.classname() if classname=="Wor...
[ "def", "tree", "(", "self", ",", "offset", "=", "0", ",", "prefix_inherited", "=", "\"\"", ",", "nofeatsplease", "=", "[", "'Phoneme'", "]", ")", ":", "tree", "=", "\"\"", "numchild", "=", "0", "for", "child", "in", "self", ".", "children", ":", "if"...
Print a tree-structure of this object's phonological representation.
[ "Print", "a", "tree", "-", "structure", "of", "this", "object", "s", "phonological", "representation", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L1212-L1278
train
quadrismegistus/prosodic
prosodic/entity.py
entity.search
def search(self, searchTerm): """Returns objects matching the query.""" if type(searchTerm)==type(''): searchTerm=SearchTerm(searchTerm) if searchTerm not in self.featpaths: matches = None if searchTerm.type != None and searchTerm.type != self.classname(): matches = self._searchInChildren(searchTerm...
python
def search(self, searchTerm): """Returns objects matching the query.""" if type(searchTerm)==type(''): searchTerm=SearchTerm(searchTerm) if searchTerm not in self.featpaths: matches = None if searchTerm.type != None and searchTerm.type != self.classname(): matches = self._searchInChildren(searchTerm...
[ "def", "search", "(", "self", ",", "searchTerm", ")", ":", "if", "type", "(", "searchTerm", ")", "==", "type", "(", "''", ")", ":", "searchTerm", "=", "SearchTerm", "(", "searchTerm", ")", "if", "searchTerm", "not", "in", "self", ".", "featpaths", ":",...
Returns objects matching the query.
[ "Returns", "objects", "matching", "the", "query", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L1501-L1520
train
quadrismegistus/prosodic
prosodic/Text.py
Text.stats_positions
def stats_positions(self,meter=None,all_parses=False): """Produce statistics from the parser""" """Positions All feats of slots All constraint violations """ parses = self.allParses(meter=meter) if all_parses else [[parse] for parse in self.bestParses(meter=meter)] dx={} for parselist in parses: ...
python
def stats_positions(self,meter=None,all_parses=False): """Produce statistics from the parser""" """Positions All feats of slots All constraint violations """ parses = self.allParses(meter=meter) if all_parses else [[parse] for parse in self.bestParses(meter=meter)] dx={} for parselist in parses: ...
[ "def", "stats_positions", "(", "self", ",", "meter", "=", "None", ",", "all_parses", "=", "False", ")", ":", "\"\"\"Positions\n\t\tAll feats of slots\n\t\tAll constraint violations\n\n\n\t\t\"\"\"", "parses", "=", "self", ".", "allParses", "(", "meter", "=", "meter", ...
Produce statistics from the parser
[ "Produce", "statistics", "from", "the", "parser" ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L191-L256
train
quadrismegistus/prosodic
prosodic/Text.py
Text.iparse
def iparse(self,meter=None,num_processes=1,arbiter='Line',line_lim=None): """Parse this text metrically, yielding it line by line.""" from Meter import Meter,genDefault,parse_ent,parse_ent_mp import multiprocessing as mp meter=self.get_meter(meter) # set internal attributes self.__parses[meter.id]=[] sel...
python
def iparse(self,meter=None,num_processes=1,arbiter='Line',line_lim=None): """Parse this text metrically, yielding it line by line.""" from Meter import Meter,genDefault,parse_ent,parse_ent_mp import multiprocessing as mp meter=self.get_meter(meter) # set internal attributes self.__parses[meter.id]=[] sel...
[ "def", "iparse", "(", "self", ",", "meter", "=", "None", ",", "num_processes", "=", "1", ",", "arbiter", "=", "'Line'", ",", "line_lim", "=", "None", ")", ":", "from", "Meter", "import", "Meter", ",", "genDefault", ",", "parse_ent", ",", "parse_ent_mp", ...
Parse this text metrically, yielding it line by line.
[ "Parse", "this", "text", "metrically", "yielding", "it", "line", "by", "line", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L468-L523
train
quadrismegistus/prosodic
prosodic/Text.py
Text.scansion
def scansion(self,meter=None,conscious=False): """Print out the parses and their violations in scansion format.""" meter=self.get_meter(meter) self.scansion_prepare(meter=meter,conscious=conscious) for line in self.lines(): try: line.scansion(meter=meter,conscious=conscious) except AttributeError: ...
python
def scansion(self,meter=None,conscious=False): """Print out the parses and their violations in scansion format.""" meter=self.get_meter(meter) self.scansion_prepare(meter=meter,conscious=conscious) for line in self.lines(): try: line.scansion(meter=meter,conscious=conscious) except AttributeError: ...
[ "def", "scansion", "(", "self", ",", "meter", "=", "None", ",", "conscious", "=", "False", ")", ":", "meter", "=", "self", ".", "get_meter", "(", "meter", ")", "self", ".", "scansion_prepare", "(", "meter", "=", "meter", ",", "conscious", "=", "conscio...
Print out the parses and their violations in scansion format.
[ "Print", "out", "the", "parses", "and", "their", "violations", "in", "scansion", "format", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L610-L621
train
quadrismegistus/prosodic
prosodic/Text.py
Text.allParses
def allParses(self,meter=None,include_bounded=False,one_per_meter=True): """Return a list of lists of parses.""" meter=self.get_meter(meter) try: parses=self.__parses[meter.id] if one_per_meter: toreturn=[] for _parses in parses: sofar=set() _parses2=[] for _p in _parses: _pm=...
python
def allParses(self,meter=None,include_bounded=False,one_per_meter=True): """Return a list of lists of parses.""" meter=self.get_meter(meter) try: parses=self.__parses[meter.id] if one_per_meter: toreturn=[] for _parses in parses: sofar=set() _parses2=[] for _p in _parses: _pm=...
[ "def", "allParses", "(", "self", ",", "meter", "=", "None", ",", "include_bounded", "=", "False", ",", "one_per_meter", "=", "True", ")", ":", "meter", "=", "self", ".", "get_meter", "(", "meter", ")", "try", ":", "parses", "=", "self", ".", "__parses"...
Return a list of lists of parses.
[ "Return", "a", "list", "of", "lists", "of", "parses", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L628-L658
train
quadrismegistus/prosodic
prosodic/Text.py
Text.validlines
def validlines(self): """Return all lines within which Prosodic understood all words.""" return [ln for ln in self.lines() if (not ln.isBroken() and not ln.ignoreMe)]
python
def validlines(self): """Return all lines within which Prosodic understood all words.""" return [ln for ln in self.lines() if (not ln.isBroken() and not ln.ignoreMe)]
[ "def", "validlines", "(", "self", ")", ":", "return", "[", "ln", "for", "ln", "in", "self", ".", "lines", "(", ")", "if", "(", "not", "ln", ".", "isBroken", "(", ")", "and", "not", "ln", ".", "ignoreMe", ")", "]" ]
Return all lines within which Prosodic understood all words.
[ "Return", "all", "lines", "within", "which", "Prosodic", "understood", "all", "words", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L843-L846
train
bartTC/django-markup
django_markup/markup.py
MarkupFormatter.choices
def choices(self): """ Returns the filter list as a tuple. Useful for model choices. """ choice_list = getattr( settings, 'MARKUP_CHOICES', DEFAULT_MARKUP_CHOICES ) return [(f, self._get_filter_title(f)) for f in choice_list]
python
def choices(self): """ Returns the filter list as a tuple. Useful for model choices. """ choice_list = getattr( settings, 'MARKUP_CHOICES', DEFAULT_MARKUP_CHOICES ) return [(f, self._get_filter_title(f)) for f in choice_list]
[ "def", "choices", "(", "self", ")", ":", "choice_list", "=", "getattr", "(", "settings", ",", "'MARKUP_CHOICES'", ",", "DEFAULT_MARKUP_CHOICES", ")", "return", "[", "(", "f", ",", "self", ".", "_get_filter_title", "(", "f", ")", ")", "for", "f", "in", "c...
Returns the filter list as a tuple. Useful for model choices.
[ "Returns", "the", "filter", "list", "as", "a", "tuple", ".", "Useful", "for", "model", "choices", "." ]
1c9c0b46373cc5350282407cec82114af80b8ea3
https://github.com/bartTC/django-markup/blob/1c9c0b46373cc5350282407cec82114af80b8ea3/django_markup/markup.py#L38-L45
train
bartTC/django-markup
django_markup/markup.py
MarkupFormatter.unregister
def unregister(self, filter_name): """ Unregister a filter from the filter list """ if filter_name in self.filter_list: self.filter_list.pop(filter_name)
python
def unregister(self, filter_name): """ Unregister a filter from the filter list """ if filter_name in self.filter_list: self.filter_list.pop(filter_name)
[ "def", "unregister", "(", "self", ",", "filter_name", ")", ":", "if", "filter_name", "in", "self", ".", "filter_list", ":", "self", ".", "filter_list", ".", "pop", "(", "filter_name", ")" ]
Unregister a filter from the filter list
[ "Unregister", "a", "filter", "from", "the", "filter", "list" ]
1c9c0b46373cc5350282407cec82114af80b8ea3
https://github.com/bartTC/django-markup/blob/1c9c0b46373cc5350282407cec82114af80b8ea3/django_markup/markup.py#L59-L64
train
quadrismegistus/prosodic
metricaltree/metricaltree.py
MetricalTree.convert
def convert(cls, tree): """ Convert a tree between different subtypes of Tree. ``cls`` determines which class will be used to encode the new tree. :type tree: Tree :param tree: The tree that should be converted. :return: The new Tree. """ if isinstance(...
python
def convert(cls, tree): """ Convert a tree between different subtypes of Tree. ``cls`` determines which class will be used to encode the new tree. :type tree: Tree :param tree: The tree that should be converted. :return: The new Tree. """ if isinstance(...
[ "def", "convert", "(", "cls", ",", "tree", ")", ":", "if", "isinstance", "(", "tree", ",", "Tree", ")", ":", "children", "=", "[", "cls", ".", "convert", "(", "child", ")", "for", "child", "in", "tree", "]", "if", "isinstance", "(", "tree", ",", ...
Convert a tree between different subtypes of Tree. ``cls`` determines which class will be used to encode the new tree. :type tree: Tree :param tree: The tree that should be converted. :return: The new Tree.
[ "Convert", "a", "tree", "between", "different", "subtypes", "of", "Tree", ".", "cls", "determines", "which", "class", "will", "be", "used", "to", "encode", "the", "new", "tree", "." ]
8af66ed9be40c922d03a0b09bc11c87d2061b618
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/metricaltree/metricaltree.py#L377-L396
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/models/runtime_raw_extension.py
RuntimeRawExtension.raw
def raw(self, raw): """Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. # noqa: E501 :param raw: The raw of this RuntimeRawExtension. # noqa: E501 :type: str """ if raw is None: raise ValueError("Invalid value f...
python
def raw(self, raw): """Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. # noqa: E501 :param raw: The raw of this RuntimeRawExtension. # noqa: E501 :type: str """ if raw is None: raise ValueError("Invalid value f...
[ "def", "raw", "(", "self", ",", "raw", ")", ":", "if", "raw", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `raw`, must not be `None`\"", ")", "# noqa: E501", "if", "raw", "is", "not", "None", "and", "not", "re", ".", "search", "(", "...
Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. # noqa: E501 :param raw: The raw of this RuntimeRawExtension. # noqa: E501 :type: str
[ "Sets", "the", "raw", "of", "this", "RuntimeRawExtension", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/models/runtime_raw_extension.py#L61-L74
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/watch/watch.py
Watch.unmarshal_event
def unmarshal_event(self, data: str, response_type): """Return the K8s response `data` in JSON format. """ js = json.loads(data) # Make a copy of the original object and save it under the # `raw_object` key because we will replace the data under `object` with # a Python...
python
def unmarshal_event(self, data: str, response_type): """Return the K8s response `data` in JSON format. """ js = json.loads(data) # Make a copy of the original object and save it under the # `raw_object` key because we will replace the data under `object` with # a Python...
[ "def", "unmarshal_event", "(", "self", ",", "data", ":", "str", ",", "response_type", ")", ":", "js", "=", "json", ".", "loads", "(", "data", ")", "# Make a copy of the original object and save it under the", "# `raw_object` key because we will replace the data under `objec...
Return the K8s response `data` in JSON format.
[ "Return", "the", "K8s", "response", "data", "in", "JSON", "format", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/watch/watch.py#L67-L105
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/watch/watch.py
Watch.stream
def stream(self, func, *args, **kwargs): """Watch an API resource and stream the result back via a generator. :param func: The API function pointer. Any parameter to the function can be passed after this parameter. :return: Event object with these keys: ...
python
def stream(self, func, *args, **kwargs): """Watch an API resource and stream the result back via a generator. :param func: The API function pointer. Any parameter to the function can be passed after this parameter. :return: Event object with these keys: ...
[ "def", "stream", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "close", "(", ")", "self", ".", "_stop", "=", "False", "self", ".", "return_type", "=", "self", ".", "get_return_type", "(", "func", ")", ...
Watch an API resource and stream the result back via a generator. :param func: The API function pointer. Any parameter to the function can be passed after this parameter. :return: Event object with these keys: 'type': The type of event such as "ADDED", "DELETED"...
[ "Watch", "an", "API", "resource", "and", "stream", "the", "result", "back", "via", "a", "generator", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/watch/watch.py#L152-L185
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/rest.py
RESTResponse.getheader
def getheader(self, name, default=None): """Returns a given response header.""" return self.aiohttp_response.headers.get(name, default)
python
def getheader(self, name, default=None): """Returns a given response header.""" return self.aiohttp_response.headers.get(name, default)
[ "def", "getheader", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "return", "self", ".", "aiohttp_response", ".", "headers", ".", "get", "(", "name", ",", "default", ")" ]
Returns a given response header.
[ "Returns", "a", "given", "response", "header", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/rest.py#L40-L42
train
swistakm/graceful
src/graceful/authorization.py
authentication_required
def authentication_required(req, resp, resource, uri_kwargs): """Ensure that user is authenticated otherwise return ``401 Unauthorized``. If request fails to authenticate this authorization hook will also include list of ``WWW-Athenticate`` challenges. Args: req (falcon.Request): the request o...
python
def authentication_required(req, resp, resource, uri_kwargs): """Ensure that user is authenticated otherwise return ``401 Unauthorized``. If request fails to authenticate this authorization hook will also include list of ``WWW-Athenticate`` challenges. Args: req (falcon.Request): the request o...
[ "def", "authentication_required", "(", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "if", "'user'", "not", "in", "req", ".", "context", ":", "args", "=", "[", "\"Unauthorized\"", ",", "\"This resource requires authentication\"", "]", "# comp...
Ensure that user is authenticated otherwise return ``401 Unauthorized``. If request fails to authenticate this authorization hook will also include list of ``WWW-Athenticate`` challenges. Args: req (falcon.Request): the request object. resp (falcon.Response): the response object. r...
[ "Ensure", "that", "user", "is", "authenticated", "otherwise", "return", "401", "Unauthorized", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authorization.py#L22-L43
train
swistakm/graceful
src/graceful/fields.py
BaseField.describe
def describe(self, **kwargs): """ Describe this field instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items ...
python
def describe(self, **kwargs): """ Describe this field instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items ...
[ "def", "describe", "(", "self", ",", "*", "*", "kwargs", ")", ":", "description", "=", "{", "'label'", ":", "self", ".", "label", ",", "'details'", ":", "inspect", ".", "cleandoc", "(", "self", ".", "details", ")", ",", "'type'", ":", "\"list of {}\"",...
Describe this field instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items Suggested way for overriding description fie...
[ "Describe", "this", "field", "instance", "for", "purpose", "of", "self", "-", "documentation", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/fields.py#L134-L166
train
swistakm/graceful
src/graceful/fields.py
BoolField.from_representation
def from_representation(self, data): """Convert representation value to ``bool`` if it has expected form.""" if data in self._TRUE_VALUES: return True elif data in self._FALSE_VALUES: return False else: raise ValueError( "{type} type va...
python
def from_representation(self, data): """Convert representation value to ``bool`` if it has expected form.""" if data in self._TRUE_VALUES: return True elif data in self._FALSE_VALUES: return False else: raise ValueError( "{type} type va...
[ "def", "from_representation", "(", "self", ",", "data", ")", ":", "if", "data", "in", "self", ".", "_TRUE_VALUES", ":", "return", "True", "elif", "data", "in", "self", ".", "_FALSE_VALUES", ":", "return", "False", "else", ":", "raise", "ValueError", "(", ...
Convert representation value to ``bool`` if it has expected form.
[ "Convert", "representation", "value", "to", "bool", "if", "it", "has", "expected", "form", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/fields.py#L280-L292
train
swistakm/graceful
src/graceful/serializers.py
MetaSerializer._get_fields
def _get_fields(mcs, bases, namespace): """Create fields dictionary to be used in resource class namespace. Pop all field objects from attributes dict (namespace) and store them under _field_storage_key atrribute. Also collect all fields from base classes in order that ensures fields ca...
python
def _get_fields(mcs, bases, namespace): """Create fields dictionary to be used in resource class namespace. Pop all field objects from attributes dict (namespace) and store them under _field_storage_key atrribute. Also collect all fields from base classes in order that ensures fields ca...
[ "def", "_get_fields", "(", "mcs", ",", "bases", ",", "namespace", ")", ":", "fields", "=", "[", "(", "name", ",", "namespace", ".", "pop", "(", "name", ")", ")", "for", "name", ",", "attribute", "in", "list", "(", "namespace", ".", "items", "(", ")...
Create fields dictionary to be used in resource class namespace. Pop all field objects from attributes dict (namespace) and store them under _field_storage_key atrribute. Also collect all fields from base classes in order that ensures fields can be overriden. Args: bases: a...
[ "Create", "fields", "dictionary", "to", "be", "used", "in", "resource", "class", "namespace", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L41-L66
train
swistakm/graceful
src/graceful/serializers.py
BaseSerializer.to_representation
def to_representation(self, obj): """Convert given internal object instance into representation dict. Representation dict may be later serialized to the content-type of choice in the resource HTTP method handler. This loops over all fields and retrieves source keys/attributes as ...
python
def to_representation(self, obj): """Convert given internal object instance into representation dict. Representation dict may be later serialized to the content-type of choice in the resource HTTP method handler. This loops over all fields and retrieves source keys/attributes as ...
[ "def", "to_representation", "(", "self", ",", "obj", ")", ":", "representation", "=", "{", "}", "for", "name", ",", "field", "in", "self", ".", "fields", ".", "items", "(", ")", ":", "if", "field", ".", "write_only", ":", "continue", "# note fields do no...
Convert given internal object instance into representation dict. Representation dict may be later serialized to the content-type of choice in the resource HTTP method handler. This loops over all fields and retrieves source keys/attributes as field values with respect to optional field...
[ "Convert", "given", "internal", "object", "instance", "into", "representation", "dict", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L101-L138
train
swistakm/graceful
src/graceful/serializers.py
BaseSerializer.from_representation
def from_representation(self, representation): """Convert given representation dict into internal object. Internal object is simply a dictionary of values with respect to field sources. This does not check if all required fields exist or values are valid in terms of value valid...
python
def from_representation(self, representation): """Convert given representation dict into internal object. Internal object is simply a dictionary of values with respect to field sources. This does not check if all required fields exist or values are valid in terms of value valid...
[ "def", "from_representation", "(", "self", ",", "representation", ")", ":", "object_dict", "=", "{", "}", "failed", "=", "{", "}", "for", "name", ",", "field", "in", "self", ".", "fields", ".", "items", "(", ")", ":", "if", "name", "not", "in", "repr...
Convert given representation dict into internal object. Internal object is simply a dictionary of values with respect to field sources. This does not check if all required fields exist or values are valid in terms of value validation (see: :meth:`BaseField.validate()`) but stil...
[ "Convert", "given", "representation", "dict", "into", "internal", "object", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L140-L218
train
swistakm/graceful
src/graceful/serializers.py
BaseSerializer.get_attribute
def get_attribute(self, obj, attr): """Get attribute of given object instance. Reason for existence of this method is the fact that 'attribute' can be also object's key from if is a dict or any other kind of mapping. Note: it will return None if attribute key does not exist A...
python
def get_attribute(self, obj, attr): """Get attribute of given object instance. Reason for existence of this method is the fact that 'attribute' can be also object's key from if is a dict or any other kind of mapping. Note: it will return None if attribute key does not exist A...
[ "def", "get_attribute", "(", "self", ",", "obj", ",", "attr", ")", ":", "# '*' is a special wildcard character that means whole object", "# is passed", "if", "attr", "==", "'*'", ":", "return", "obj", "# if this is any mapping then instead of attributes use keys", "if", "is...
Get attribute of given object instance. Reason for existence of this method is the fact that 'attribute' can be also object's key from if is a dict or any other kind of mapping. Note: it will return None if attribute key does not exist Args: obj (object): internal object ...
[ "Get", "attribute", "of", "given", "object", "instance", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L299-L323
train
swistakm/graceful
src/graceful/serializers.py
BaseSerializer.set_attribute
def set_attribute(self, obj, attr, value): """Set value of attribute in given object instance. Reason for existence of this method is the fact that 'attribute' can be also a object's key if it is a dict or any other kind of mapping. Args: obj (object): object instance to mo...
python
def set_attribute(self, obj, attr, value): """Set value of attribute in given object instance. Reason for existence of this method is the fact that 'attribute' can be also a object's key if it is a dict or any other kind of mapping. Args: obj (object): object instance to mo...
[ "def", "set_attribute", "(", "self", ",", "obj", ",", "attr", ",", "value", ")", ":", "# if this is any mutable mapping then instead of attributes use keys", "if", "isinstance", "(", "obj", ",", "MutableMapping", ")", ":", "obj", "[", "attr", "]", "=", "value", ...
Set value of attribute in given object instance. Reason for existence of this method is the fact that 'attribute' can be also a object's key if it is a dict or any other kind of mapping. Args: obj (object): object instance to modify attr (str): attribute (or key) to cha...
[ "Set", "value", "of", "attribute", "in", "given", "object", "instance", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L325-L341
train
swistakm/graceful
src/graceful/serializers.py
BaseSerializer.describe
def describe(self): """Describe all serialized fields. It returns dictionary of all fields description defined for this serializer using their own ``describe()`` methods with respect to order in which they are defined as class attributes. Returns: OrderedDict: seria...
python
def describe(self): """Describe all serialized fields. It returns dictionary of all fields description defined for this serializer using their own ``describe()`` methods with respect to order in which they are defined as class attributes. Returns: OrderedDict: seria...
[ "def", "describe", "(", "self", ")", ":", "return", "OrderedDict", "(", "[", "(", "name", ",", "field", ".", "describe", "(", ")", ")", "for", "name", ",", "field", "in", "self", ".", "fields", ".", "items", "(", ")", "]", ")" ]
Describe all serialized fields. It returns dictionary of all fields description defined for this serializer using their own ``describe()`` methods with respect to order in which they are defined as class attributes. Returns: OrderedDict: serializer description
[ "Describe", "all", "serialized", "fields", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/serializers.py#L343-L357
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/config/incluster_config.py
_join_host_port
def _join_host_port(host, port): """Adapted golang's net.JoinHostPort""" template = "%s:%s" host_requires_bracketing = ':' in host or '%' in host if host_requires_bracketing: template = "[%s]:%s" return template % (host, port)
python
def _join_host_port(host, port): """Adapted golang's net.JoinHostPort""" template = "%s:%s" host_requires_bracketing = ':' in host or '%' in host if host_requires_bracketing: template = "[%s]:%s" return template % (host, port)
[ "def", "_join_host_port", "(", "host", ",", "port", ")", ":", "template", "=", "\"%s:%s\"", "host_requires_bracketing", "=", "':'", "in", "host", "or", "'%'", "in", "host", "if", "host_requires_bracketing", ":", "template", "=", "\"[%s]:%s\"", "return", "templat...
Adapted golang's net.JoinHostPort
[ "Adapted", "golang", "s", "net", ".", "JoinHostPort" ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/config/incluster_config.py#L27-L33
train
swistakm/graceful
src/graceful/resources/mixins.py
BaseMixin.handle
def handle(self, handler, req, resp, **kwargs): """Handle given resource manipulation flow in consistent manner. This mixin is intended to be used only as a base class in new flow mixin classes. It ensures that regardless of resource manunipulation semantics (retrieve, get, delete etc.)...
python
def handle(self, handler, req, resp, **kwargs): """Handle given resource manipulation flow in consistent manner. This mixin is intended to be used only as a base class in new flow mixin classes. It ensures that regardless of resource manunipulation semantics (retrieve, get, delete etc.)...
[ "def", "handle", "(", "self", ",", "handler", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")", ":", "params", "=", "self", ".", "require_params", "(", "req", ")", "# future: remove in 1.x", "if", "getattr", "(", "self", ",", "'_with_context'", ",",...
Handle given resource manipulation flow in consistent manner. This mixin is intended to be used only as a base class in new flow mixin classes. It ensures that regardless of resource manunipulation semantics (retrieve, get, delete etc.) the flow is always the same: 1. Decode and valida...
[ "Handle", "given", "resource", "manipulation", "flow", "in", "consistent", "manner", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L11-L45
train
swistakm/graceful
src/graceful/resources/mixins.py
RetrieveMixin.on_get
def on_get(self, req, resp, handler=None, **kwargs): """Respond on GET HTTP request assuming resource retrieval flow. This request handler assumes that GET requests are associated with single resource instance retrieval. Thus default flow for such requests is: * Retrieve single...
python
def on_get(self, req, resp, handler=None, **kwargs): """Respond on GET HTTP request assuming resource retrieval flow. This request handler assumes that GET requests are associated with single resource instance retrieval. Thus default flow for such requests is: * Retrieve single...
[ "def", "on_get", "(", "self", ",", "req", ",", "resp", ",", "handler", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle", "(", "handler", "or", "self", ".", "retrieve", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")" ]
Respond on GET HTTP request assuming resource retrieval flow. This request handler assumes that GET requests are associated with single resource instance retrieval. Thus default flow for such requests is: * Retrieve single resource instance of prepare its representation by ca...
[ "Respond", "on", "GET", "HTTP", "request", "assuming", "resource", "retrieval", "flow", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L75-L94
train
swistakm/graceful
src/graceful/resources/mixins.py
ListMixin.on_get
def on_get(self, req, resp, handler=None, **kwargs): """Respond on GET HTTP request assuming resource list retrieval flow. This request handler assumes that GET requests are associated with resource list retrieval. Thus default flow for such requests is: * Retrieve list of existing res...
python
def on_get(self, req, resp, handler=None, **kwargs): """Respond on GET HTTP request assuming resource list retrieval flow. This request handler assumes that GET requests are associated with resource list retrieval. Thus default flow for such requests is: * Retrieve list of existing res...
[ "def", "on_get", "(", "self", ",", "req", ",", "resp", ",", "handler", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle", "(", "handler", "or", "self", ".", "list", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")" ]
Respond on GET HTTP request assuming resource list retrieval flow. This request handler assumes that GET requests are associated with resource list retrieval. Thus default flow for such requests is: * Retrieve list of existing resource instances and prepare their representations by c...
[ "Respond", "on", "GET", "HTTP", "request", "assuming", "resource", "list", "retrieval", "flow", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L124-L142
train
swistakm/graceful
src/graceful/resources/mixins.py
DeleteMixin.on_delete
def on_delete(self, req, resp, handler=None, **kwargs): """Respond on DELETE HTTP request assuming resource deletion flow. This request handler assumes that DELETE requests are associated with resource deletion. Thus default flow for such requests is: * Delete existing resource instanc...
python
def on_delete(self, req, resp, handler=None, **kwargs): """Respond on DELETE HTTP request assuming resource deletion flow. This request handler assumes that DELETE requests are associated with resource deletion. Thus default flow for such requests is: * Delete existing resource instanc...
[ "def", "on_delete", "(", "self", ",", "req", ",", "resp", ",", "handler", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle", "(", "handler", "or", "self", ".", "delete", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")", ...
Respond on DELETE HTTP request assuming resource deletion flow. This request handler assumes that DELETE requests are associated with resource deletion. Thus default flow for such requests is: * Delete existing resource instance. * Set response status code to ``202 Accepted``. ...
[ "Respond", "on", "DELETE", "HTTP", "request", "assuming", "resource", "deletion", "flow", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L168-L188
train
swistakm/graceful
src/graceful/resources/mixins.py
UpdateMixin.on_put
def on_put(self, req, resp, handler=None, **kwargs): """Respond on PUT HTTP request assuming resource update flow. This request handler assumes that PUT requests are associated with resource update/modification. Thus default flow for such requests is: * Modify existing resource instanc...
python
def on_put(self, req, resp, handler=None, **kwargs): """Respond on PUT HTTP request assuming resource update flow. This request handler assumes that PUT requests are associated with resource update/modification. Thus default flow for such requests is: * Modify existing resource instanc...
[ "def", "on_put", "(", "self", ",", "req", ",", "resp", ",", "handler", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle", "(", "handler", "or", "self", ".", "update", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")", "r...
Respond on PUT HTTP request assuming resource update flow. This request handler assumes that PUT requests are associated with resource update/modification. Thus default flow for such requests is: * Modify existing resource instance and prepare its representation by calling its update...
[ "Respond", "on", "PUT", "HTTP", "request", "assuming", "resource", "update", "flow", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L217-L237
train
swistakm/graceful
src/graceful/resources/mixins.py
PaginatedMixin.add_pagination_meta
def add_pagination_meta(self, params, meta): """Extend default meta dictionary value with pagination hints. Note: This method handler attaches values to ``meta`` dictionary without changing it's reference. This means that you should never replace ``meta`` dictionary ...
python
def add_pagination_meta(self, params, meta): """Extend default meta dictionary value with pagination hints. Note: This method handler attaches values to ``meta`` dictionary without changing it's reference. This means that you should never replace ``meta`` dictionary ...
[ "def", "add_pagination_meta", "(", "self", ",", "params", ",", "meta", ")", ":", "meta", "[", "'page_size'", "]", "=", "params", "[", "'page_size'", "]", "meta", "[", "'page'", "]", "=", "params", "[", "'page'", "]", "meta", "[", "'prev'", "]", "=", ...
Extend default meta dictionary value with pagination hints. Note: This method handler attaches values to ``meta`` dictionary without changing it's reference. This means that you should never replace ``meta`` dictionary with any other dict instance but simply modify ...
[ "Extend", "default", "meta", "dictionary", "value", "with", "pagination", "hints", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/mixins.py#L396-L418
train
swistakm/graceful
src/graceful/resources/base.py
MetaResource._get_params
def _get_params(mcs, bases, namespace): """Create params dictionary to be used in resource class namespace. Pop all parameter objects from attributes dict (namespace) and store them under _params_storage_key atrribute. Also collect all params from base classes in order that ensures ...
python
def _get_params(mcs, bases, namespace): """Create params dictionary to be used in resource class namespace. Pop all parameter objects from attributes dict (namespace) and store them under _params_storage_key atrribute. Also collect all params from base classes in order that ensures ...
[ "def", "_get_params", "(", "mcs", ",", "bases", ",", "namespace", ")", ":", "params", "=", "[", "(", "name", ",", "namespace", ".", "pop", "(", "name", ")", ")", "for", "name", ",", "attribute", "in", "list", "(", "namespace", ".", "items", "(", ")...
Create params dictionary to be used in resource class namespace. Pop all parameter objects from attributes dict (namespace) and store them under _params_storage_key atrribute. Also collect all params from base classes in order that ensures params can be overriden. Args: ...
[ "Create", "params", "dictionary", "to", "be", "used", "in", "resource", "class", "namespace", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L35-L61
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.make_body
def make_body(self, resp, params, meta, content): """Construct response body in ``resp`` object using JSON serialization. Args: resp (falcon.Response): response object where to include serialized body params (dict): dictionary of parsed parameters met...
python
def make_body(self, resp, params, meta, content): """Construct response body in ``resp`` object using JSON serialization. Args: resp (falcon.Response): response object where to include serialized body params (dict): dictionary of parsed parameters met...
[ "def", "make_body", "(", "self", ",", "resp", ",", "params", ",", "meta", ",", "content", ")", ":", "response", "=", "{", "'meta'", ":", "meta", ",", "'content'", ":", "content", "}", "resp", ".", "content_type", "=", "'application/json'", "resp", ".", ...
Construct response body in ``resp`` object using JSON serialization. Args: resp (falcon.Response): response object where to include serialized body params (dict): dictionary of parsed parameters meta (dict): dictionary of metadata to be included in 'meta' ...
[ "Construct", "response", "body", "in", "resp", "object", "using", "JSON", "serialization", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L153-L177
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.allowed_methods
def allowed_methods(self): """Return list of allowed HTTP methods on this resource. This is only for purpose of making resource description. Returns: list: list of allowed HTTP method names (uppercase) """ return [ method for method, allowed...
python
def allowed_methods(self): """Return list of allowed HTTP methods on this resource. This is only for purpose of making resource description. Returns: list: list of allowed HTTP method names (uppercase) """ return [ method for method, allowed...
[ "def", "allowed_methods", "(", "self", ")", ":", "return", "[", "method", "for", "method", ",", "allowed", "in", "(", "(", "'GET'", ",", "hasattr", "(", "self", ",", "'on_get'", ")", ")", ",", "(", "'POST'", ",", "hasattr", "(", "self", ",", "'on_pos...
Return list of allowed HTTP methods on this resource. This is only for purpose of making resource description. Returns: list: list of allowed HTTP method names (uppercase)
[ "Return", "list", "of", "allowed", "HTTP", "methods", "on", "this", "resource", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L179-L199
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.describe
def describe(self, req=None, resp=None, **kwargs): """Describe API resource using resource introspection. Additional description on derrived resource class can be added using keyword arguments and calling ``super().decribe()`` method call like following: .. code-block:: python ...
python
def describe(self, req=None, resp=None, **kwargs): """Describe API resource using resource introspection. Additional description on derrived resource class can be added using keyword arguments and calling ``super().decribe()`` method call like following: .. code-block:: python ...
[ "def", "describe", "(", "self", ",", "req", "=", "None", ",", "resp", "=", "None", ",", "*", "*", "kwargs", ")", ":", "description", "=", "{", "'params'", ":", "OrderedDict", "(", "[", "(", "name", ",", "param", ".", "describe", "(", ")", ")", "f...
Describe API resource using resource introspection. Additional description on derrived resource class can be added using keyword arguments and calling ``super().decribe()`` method call like following: .. code-block:: python class SomeResource(BaseResource): ...
[ "Describe", "API", "resource", "using", "resource", "introspection", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L201-L248
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.on_options
def on_options(self, req, resp, **kwargs): """Respond with JSON formatted resource description on OPTIONS request. Args: req (falcon.Request): Optional request object. Defaults to None. resp (falcon.Response): Optional response object. Defaults to None. kwargs (dict)...
python
def on_options(self, req, resp, **kwargs): """Respond with JSON formatted resource description on OPTIONS request. Args: req (falcon.Request): Optional request object. Defaults to None. resp (falcon.Response): Optional response object. Defaults to None. kwargs (dict)...
[ "def", "on_options", "(", "self", ",", "req", ",", "resp", ",", "*", "*", "kwargs", ")", ":", "resp", ".", "set_header", "(", "'Allow'", ",", "', '", ".", "join", "(", "self", ".", "allowed_methods", "(", ")", ")", ")", "resp", ".", "body", "=", ...
Respond with JSON formatted resource description on OPTIONS request. Args: req (falcon.Request): Optional request object. Defaults to None. resp (falcon.Response): Optional response object. Defaults to None. kwargs (dict): Dictionary of values created by falcon from ...
[ "Respond", "with", "JSON", "formatted", "resource", "description", "on", "OPTIONS", "request", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L250-L269
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.require_params
def require_params(self, req): """Require all defined parameters from request query string. Raises ``falcon.errors.HTTPMissingParam`` exception if any of required parameters is missing and ``falcon.errors.HTTPInvalidParam`` if any of parameters could not be understood (wrong format). ...
python
def require_params(self, req): """Require all defined parameters from request query string. Raises ``falcon.errors.HTTPMissingParam`` exception if any of required parameters is missing and ``falcon.errors.HTTPInvalidParam`` if any of parameters could not be understood (wrong format). ...
[ "def", "require_params", "(", "self", ",", "req", ")", ":", "params", "=", "{", "}", "for", "name", ",", "param", "in", "self", ".", "params", ".", "items", "(", ")", ":", "if", "name", "not", "in", "req", ".", "params", "and", "param", ".", "req...
Require all defined parameters from request query string. Raises ``falcon.errors.HTTPMissingParam`` exception if any of required parameters is missing and ``falcon.errors.HTTPInvalidParam`` if any of parameters could not be understood (wrong format). Args: req (falcon.Reque...
[ "Require", "all", "defined", "parameters", "from", "request", "query", "string", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L271-L335
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.require_meta_and_content
def require_meta_and_content(self, content_handler, params, **kwargs): """Require 'meta' and 'content' dictionaries using proper hander. Args: content_handler (callable): function that accepts ``params, meta, **kwargs`` argument and returns dictionary for ``c...
python
def require_meta_and_content(self, content_handler, params, **kwargs): """Require 'meta' and 'content' dictionaries using proper hander. Args: content_handler (callable): function that accepts ``params, meta, **kwargs`` argument and returns dictionary for ``c...
[ "def", "require_meta_and_content", "(", "self", ",", "content_handler", ",", "params", ",", "*", "*", "kwargs", ")", ":", "meta", "=", "{", "'params'", ":", "params", "}", "content", "=", "content_handler", "(", "params", ",", "meta", ",", "*", "*", "kwa...
Require 'meta' and 'content' dictionaries using proper hander. Args: content_handler (callable): function that accepts ``params, meta, **kwargs`` argument and returns dictionary for ``content`` response section params (dict): dictionary of parsed resource...
[ "Require", "meta", "and", "content", "dictionaries", "using", "proper", "hander", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L337-L358
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.require_representation
def require_representation(self, req): """Require raw representation dictionary from falcon request object. This does not perform any field parsing or validation but only uses allowed content-encoding handler to decode content body. Note: Currently only JSON is allowed as c...
python
def require_representation(self, req): """Require raw representation dictionary from falcon request object. This does not perform any field parsing or validation but only uses allowed content-encoding handler to decode content body. Note: Currently only JSON is allowed as c...
[ "def", "require_representation", "(", "self", ",", "req", ")", ":", "try", ":", "type_", ",", "subtype", ",", "_", "=", "parse_mime_type", "(", "req", ".", "content_type", ")", "content_type", "=", "'/'", ".", "join", "(", "(", "type_", ",", "subtype", ...
Require raw representation dictionary from falcon request object. This does not perform any field parsing or validation but only uses allowed content-encoding handler to decode content body. Note: Currently only JSON is allowed as content type. Args: req (falco...
[ "Require", "raw", "representation", "dictionary", "from", "falcon", "request", "object", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L360-L392
train
swistakm/graceful
src/graceful/resources/base.py
BaseResource.require_validated
def require_validated(self, req, partial=False, bulk=False): """Require fully validated internal object dictionary. Internal object dictionary creation is based on content-decoded representation retrieved from request body. Internal object validation is performed using resource serializ...
python
def require_validated(self, req, partial=False, bulk=False): """Require fully validated internal object dictionary. Internal object dictionary creation is based on content-decoded representation retrieved from request body. Internal object validation is performed using resource serializ...
[ "def", "require_validated", "(", "self", ",", "req", ",", "partial", "=", "False", ",", "bulk", "=", "False", ")", ":", "representations", "=", "[", "self", ".", "require_representation", "(", "req", ")", "]", "if", "not", "bulk", "else", "self", ".", ...
Require fully validated internal object dictionary. Internal object dictionary creation is based on content-decoded representation retrieved from request body. Internal object validation is performed using resource serializer. Args: req (falcon.Request): request object ...
[ "Require", "fully", "validated", "internal", "object", "dictionary", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/base.py#L394-L443
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/models/admissionregistration_v1beta1_webhook_client_config.py
AdmissionregistrationV1beta1WebhookClientConfig.ca_bundle
def ca_bundle(self, ca_bundle): """Sets the ca_bundle of this AdmissionregistrationV1beta1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. # noqa: E501 :par...
python
def ca_bundle(self, ca_bundle): """Sets the ca_bundle of this AdmissionregistrationV1beta1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. # noqa: E501 :par...
[ "def", "ca_bundle", "(", "self", ",", "ca_bundle", ")", ":", "if", "ca_bundle", "is", "not", "None", "and", "not", "re", ".", "search", "(", "r'^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$'", ",", "ca_bundle", ")", ":", "# noqa: E501", "rai...
Sets the ca_bundle of this AdmissionregistrationV1beta1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. # noqa: E501 :param ca_bundle: The ca_bundle of this Admissi...
[ "Sets", "the", "ca_bundle", "of", "this", "AdmissionregistrationV1beta1WebhookClientConfig", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/models/admissionregistration_v1beta1_webhook_client_config.py#L72-L83
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/models/v1beta1_certificate_signing_request_status.py
V1beta1CertificateSigningRequestStatus.certificate
def certificate(self, certificate): """Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. # noqa: E501 :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. # noqa:...
python
def certificate(self, certificate): """Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. # noqa: E501 :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. # noqa:...
[ "def", "certificate", "(", "self", ",", "certificate", ")", ":", "if", "certificate", "is", "not", "None", "and", "not", "re", ".", "search", "(", "r'^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$'", ",", "certificate", ")", ":", "# noqa: E501"...
Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. # noqa: E501 :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. # noqa: E501 :type: str
[ "Sets", "the", "certificate", "of", "this", "V1beta1CertificateSigningRequestStatus", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/models/v1beta1_certificate_signing_request_status.py#L67-L78
train
swistakm/graceful
src/graceful/resources/generic.py
ListAPI.describe
def describe(self, req=None, resp=None, **kwargs): """Extend default endpoint description with serializer description.""" return super().describe( req, resp, type='list', fields=self.serializer.describe() if self.serializer else None, **kwargs )
python
def describe(self, req=None, resp=None, **kwargs): """Extend default endpoint description with serializer description.""" return super().describe( req, resp, type='list', fields=self.serializer.describe() if self.serializer else None, **kwargs )
[ "def", "describe", "(", "self", ",", "req", "=", "None", ",", "resp", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", ")", ".", "describe", "(", "req", ",", "resp", ",", "type", "=", "'list'", ",", "fields", "=", "self", ...
Extend default endpoint description with serializer description.
[ "Extend", "default", "endpoint", "description", "with", "serializer", "description", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/resources/generic.py#L163-L170
train
swistakm/graceful
src/graceful/authentication.py
DummyUserStorage.get_user
def get_user( self, identified_with, identifier, req, resp, resource, uri_kwargs ): """Return default user object.""" return self.user
python
def get_user( self, identified_with, identifier, req, resp, resource, uri_kwargs ): """Return default user object.""" return self.user
[ "def", "get_user", "(", "self", ",", "identified_with", ",", "identifier", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "return", "self", ".", "user" ]
Return default user object.
[ "Return", "default", "user", "object", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L77-L81
train
swistakm/graceful
src/graceful/authentication.py
KeyValueUserStorage._get_storage_key
def _get_storage_key(self, identified_with, identifier): """Get key string for given user identifier in consistent manner.""" return ':'.join(( self.key_prefix, identified_with.name, self.hash_identifier(identified_with, identifier), ))
python
def _get_storage_key(self, identified_with, identifier): """Get key string for given user identifier in consistent manner.""" return ':'.join(( self.key_prefix, identified_with.name, self.hash_identifier(identified_with, identifier), ))
[ "def", "_get_storage_key", "(", "self", ",", "identified_with", ",", "identifier", ")", ":", "return", "':'", ".", "join", "(", "(", "self", ".", "key_prefix", ",", "identified_with", ".", "name", ",", "self", ".", "hash_identifier", "(", "identified_with", ...
Get key string for given user identifier in consistent manner.
[ "Get", "key", "string", "for", "given", "user", "identifier", "in", "consistent", "manner", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L166-L171
train
swistakm/graceful
src/graceful/authentication.py
KeyValueUserStorage.get_user
def get_user( self, identified_with, identifier, req, resp, resource, uri_kwargs ): """Get user object for given identifier. Args: identified_with (object): authentication middleware used to identify the user. identifier: middleware specifix user iden...
python
def get_user( self, identified_with, identifier, req, resp, resource, uri_kwargs ): """Get user object for given identifier. Args: identified_with (object): authentication middleware used to identify the user. identifier: middleware specifix user iden...
[ "def", "get_user", "(", "self", ",", "identified_with", ",", "identifier", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "stored_value", "=", "self", ".", "kv_store", ".", "get", "(", "self", ".", "_get_storage_key", "(", "identifi...
Get user object for given identifier. Args: identified_with (object): authentication middleware used to identify the user. identifier: middleware specifix user identifier (string or tuple in case of all built in authentication middleware classes). ...
[ "Get", "user", "object", "for", "given", "identifier", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L209-L231
train
swistakm/graceful
src/graceful/authentication.py
KeyValueUserStorage.register
def register(self, identified_with, identifier, user): """Register new key for given client identifier. This is only a helper method that allows to register new user objects for client identities (keys, tokens, addresses etc.). Args: identified_with (object): authentication...
python
def register(self, identified_with, identifier, user): """Register new key for given client identifier. This is only a helper method that allows to register new user objects for client identities (keys, tokens, addresses etc.). Args: identified_with (object): authentication...
[ "def", "register", "(", "self", ",", "identified_with", ",", "identifier", ",", "user", ")", ":", "self", ".", "kv_store", ".", "set", "(", "self", ".", "_get_storage_key", "(", "identified_with", ",", "identifier", ")", ",", "self", ".", "serialization", ...
Register new key for given client identifier. This is only a helper method that allows to register new user objects for client identities (keys, tokens, addresses etc.). Args: identified_with (object): authentication middleware used to identify the user. ...
[ "Register", "new", "key", "for", "given", "client", "identifier", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L233-L248
train
swistakm/graceful
src/graceful/authentication.py
BaseAuthenticationMiddleware.process_resource
def process_resource(self, req, resp, resource, uri_kwargs=None): """Process resource after routing to it. This is basic falcon middleware handler. Args: req (falcon.Request): request object resp (falcon.Response): response object resource (object): resource...
python
def process_resource(self, req, resp, resource, uri_kwargs=None): """Process resource after routing to it. This is basic falcon middleware handler. Args: req (falcon.Request): request object resp (falcon.Response): response object resource (object): resource...
[ "def", "process_resource", "(", "self", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", "=", "None", ")", ":", "if", "'user'", "in", "req", ".", "context", ":", "return", "identifier", "=", "self", ".", "identify", "(", "req", ",", "resp",...
Process resource after routing to it. This is basic falcon middleware handler. Args: req (falcon.Request): request object resp (falcon.Response): response object resource (object): resource object matched by falcon router uri_kwargs (dict): additional ke...
[ "Process", "resource", "after", "routing", "to", "it", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L288-L314
train
swistakm/graceful
src/graceful/authentication.py
BaseAuthenticationMiddleware.try_storage
def try_storage(self, identifier, req, resp, resource, uri_kwargs): """Try to find user in configured user storage object. Args: identifier: User identifier. Returns: user object. """ if identifier is None: user = None # note: if use...
python
def try_storage(self, identifier, req, resp, resource, uri_kwargs): """Try to find user in configured user storage object. Args: identifier: User identifier. Returns: user object. """ if identifier is None: user = None # note: if use...
[ "def", "try_storage", "(", "self", ",", "identifier", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "if", "identifier", "is", "None", ":", "user", "=", "None", "# note: if user_storage is defined, always use it in order to", "# authent...
Try to find user in configured user storage object. Args: identifier: User identifier. Returns: user object.
[ "Try", "to", "find", "user", "in", "configured", "user", "storage", "object", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L331-L365
train
swistakm/graceful
src/graceful/authentication.py
Basic.identify
def identify(self, req, resp, resource, uri_kwargs): """Identify user using Authenticate header with Basic auth.""" header = req.get_header("Authorization", False) auth = header.split(" ") if header else None if auth is None or auth[0].lower() != 'basic': return None ...
python
def identify(self, req, resp, resource, uri_kwargs): """Identify user using Authenticate header with Basic auth.""" header = req.get_header("Authorization", False) auth = header.split(" ") if header else None if auth is None or auth[0].lower() != 'basic': return None ...
[ "def", "identify", "(", "self", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "header", "=", "req", ".", "get_header", "(", "\"Authorization\"", ",", "False", ")", "auth", "=", "header", ".", "split", "(", "\" \"", ")", "if", ...
Identify user using Authenticate header with Basic auth.
[ "Identify", "user", "using", "Authenticate", "header", "with", "Basic", "auth", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L426-L453
train
swistakm/graceful
src/graceful/authentication.py
XAPIKey.identify
def identify(self, req, resp, resource, uri_kwargs): """Initialize X-Api-Key authentication middleware.""" try: return req.get_header('X-Api-Key', True) except (KeyError, HTTPMissingHeader): pass
python
def identify(self, req, resp, resource, uri_kwargs): """Initialize X-Api-Key authentication middleware.""" try: return req.get_header('X-Api-Key', True) except (KeyError, HTTPMissingHeader): pass
[ "def", "identify", "(", "self", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "try", ":", "return", "req", ".", "get_header", "(", "'X-Api-Key'", ",", "True", ")", "except", "(", "KeyError", ",", "HTTPMissingHeader", ")", ":", ...
Initialize X-Api-Key authentication middleware.
[ "Initialize", "X", "-", "Api", "-", "Key", "authentication", "middleware", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L490-L495
train
swistakm/graceful
src/graceful/authentication.py
Token.identify
def identify(self, req, resp, resource, uri_kwargs): """Identify user using Authenticate header with Token auth.""" header = req.get_header('Authorization', False) auth = header.split(' ') if header else None if auth is None or auth[0].lower() != 'token': return None ...
python
def identify(self, req, resp, resource, uri_kwargs): """Identify user using Authenticate header with Token auth.""" header = req.get_header('Authorization', False) auth = header.split(' ') if header else None if auth is None or auth[0].lower() != 'token': return None ...
[ "def", "identify", "(", "self", ",", "req", ",", "resp", ",", "resource", ",", "uri_kwargs", ")", ":", "header", "=", "req", ".", "get_header", "(", "'Authorization'", ",", "False", ")", "auth", "=", "header", ".", "split", "(", "' '", ")", "if", "he...
Identify user using Authenticate header with Token auth.
[ "Identify", "user", "using", "Authenticate", "header", "with", "Token", "auth", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L524-L539
train
swistakm/graceful
src/graceful/authentication.py
XForwardedFor._get_client_address
def _get_client_address(self, req): """Get address from ``X-Forwarded-For`` header or use remote address. Remote address is used if the ``X-Forwarded-For`` header is not available. Note that this may not be safe to depend on both without proper authorization backend. Args: ...
python
def _get_client_address(self, req): """Get address from ``X-Forwarded-For`` header or use remote address. Remote address is used if the ``X-Forwarded-For`` header is not available. Note that this may not be safe to depend on both without proper authorization backend. Args: ...
[ "def", "_get_client_address", "(", "self", ",", "req", ")", ":", "try", ":", "forwarded_for", "=", "req", ".", "get_header", "(", "'X-Forwarded-For'", ",", "True", ")", "return", "forwarded_for", ".", "split", "(", "','", ")", "[", "0", "]", ".", "strip"...
Get address from ``X-Forwarded-For`` header or use remote address. Remote address is used if the ``X-Forwarded-For`` header is not available. Note that this may not be safe to depend on both without proper authorization backend. Args: req (falcon.Request): falcon.Request ob...
[ "Get", "address", "from", "X", "-", "Forwarded", "-", "For", "header", "or", "use", "remote", "address", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L595-L615
train
swistakm/graceful
src/graceful/errors.py
DeserializationError._get_description
def _get_description(self): """Return human readable description error description. This description should explain everything that went wrong during deserialization. """ return ", ".join([ part for part in [ "missing: {}".format(self.missing) if sel...
python
def _get_description(self): """Return human readable description error description. This description should explain everything that went wrong during deserialization. """ return ", ".join([ part for part in [ "missing: {}".format(self.missing) if sel...
[ "def", "_get_description", "(", "self", ")", ":", "return", "\", \"", ".", "join", "(", "[", "part", "for", "part", "in", "[", "\"missing: {}\"", ".", "format", "(", "self", ".", "missing", ")", "if", "self", ".", "missing", "else", "\"\"", ",", "(", ...
Return human readable description error description. This description should explain everything that went wrong during deserialization.
[ "Return", "human", "readable", "description", "error", "description", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/errors.py#L23-L43
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/config/kube_config.py
load_kube_config
async def load_kube_config(config_file=None, context=None, client_configuration=None, persist_config=True): """Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration. :param config_file: Nam...
python
async def load_kube_config(config_file=None, context=None, client_configuration=None, persist_config=True): """Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration. :param config_file: Nam...
[ "async", "def", "load_kube_config", "(", "config_file", "=", "None", ",", "context", "=", "None", ",", "client_configuration", "=", "None", ",", "persist_config", "=", "True", ")", ":", "if", "config_file", "is", "None", ":", "config_file", "=", "KUBE_CONFIG_D...
Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration. :param config_file: Name of the kube-config file. :param context: set the active context. If is set to None, current_context from config file will be used. :param client_config...
[ "Loads", "authentication", "and", "cluster", "information", "from", "kube", "-", "config", "file", "and", "stores", "them", "in", "kubernetes", ".", "client", ".", "configuration", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/config/kube_config.py#L533-L561
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/config/kube_config.py
refresh_token
async def refresh_token(loader, client_configuration=None, interval=60): """Refresh token if necessary, updates the token in client configurarion :param loader: KubeConfigLoader returned by load_kube_config :param client_configuration: The kubernetes.client.Configuration to set configs to. ...
python
async def refresh_token(loader, client_configuration=None, interval=60): """Refresh token if necessary, updates the token in client configurarion :param loader: KubeConfigLoader returned by load_kube_config :param client_configuration: The kubernetes.client.Configuration to set configs to. ...
[ "async", "def", "refresh_token", "(", "loader", ",", "client_configuration", "=", "None", ",", "interval", "=", "60", ")", ":", "if", "loader", ".", "provider", "!=", "'gcp'", ":", "return", "if", "client_configuration", "is", "None", ":", "client_configuratio...
Refresh token if necessary, updates the token in client configurarion :param loader: KubeConfigLoader returned by load_kube_config :param client_configuration: The kubernetes.client.Configuration to set configs to. :param interval: how often check if token is up-to-date
[ "Refresh", "token", "if", "necessary", "updates", "the", "token", "in", "client", "configurarion" ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/config/kube_config.py#L564-L582
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/config/kube_config.py
new_client_from_config
async def new_client_from_config(config_file=None, context=None, persist_config=True): """Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.""" client_config = type.__call__(Con...
python
async def new_client_from_config(config_file=None, context=None, persist_config=True): """Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.""" client_config = type.__call__(Con...
[ "async", "def", "new_client_from_config", "(", "config_file", "=", "None", ",", "context", "=", "None", ",", "persist_config", "=", "True", ")", ":", "client_config", "=", "type", ".", "__call__", "(", "Configuration", ")", "await", "load_kube_config", "(", "c...
Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.
[ "Loads", "configuration", "the", "same", "as", "load_kube_config", "but", "returns", "an", "ApiClient", "to", "be", "used", "with", "any", "API", "object", ".", "This", "will", "allow", "the", "caller", "to", "concurrently", "talk", "with", "multiple", "cluste...
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/config/kube_config.py#L585-L595
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/config/kube_config.py
KubeConfigLoader._load_authentication
async def _load_authentication(self): """Read authentication from kube-config user section if exists. This function goes through various authentication methods in user section of kube-config and stops if it finds a valid authentication method. The order of authentication methods is: ...
python
async def _load_authentication(self): """Read authentication from kube-config user section if exists. This function goes through various authentication methods in user section of kube-config and stops if it finds a valid authentication method. The order of authentication methods is: ...
[ "async", "def", "_load_authentication", "(", "self", ")", ":", "if", "not", "self", ".", "_user", ":", "logging", ".", "debug", "(", "'No user section in current context.'", ")", "return", "if", "self", ".", "provider", "==", "'gcp'", ":", "await", "self", "...
Read authentication from kube-config user section if exists. This function goes through various authentication methods in user section of kube-config and stops if it finds a valid authentication method. The order of authentication methods is: 1. GCP auth-provider 2. tok...
[ "Read", "authentication", "from", "kube", "-", "config", "user", "section", "if", "exists", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/config/kube_config.py#L178-L215
train
swistakm/graceful
src/graceful/validators.py
min_validator
def min_validator(min_value): """Return validator function that ensures lower bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check Args: min_value: minimal value for new validator """ def valida...
python
def min_validator(min_value): """Return validator function that ensures lower bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check Args: min_value: minimal value for new validator """ def valida...
[ "def", "min_validator", "(", "min_value", ")", ":", "def", "validator", "(", "value", ")", ":", "if", "value", "<", "min_value", ":", "raise", "ValidationError", "(", "\"{} is not >= {}\"", ".", "format", "(", "value", ",", "min_value", ")", ")", "return", ...
Return validator function that ensures lower bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check Args: min_value: minimal value for new validator
[ "Return", "validator", "function", "that", "ensures", "lower", "bound", "of", "a", "number", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/validators.py#L14-L28
train
swistakm/graceful
src/graceful/validators.py
max_validator
def max_validator(max_value): """Return validator function that ensures upper bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check. Args: max_value: maximum value for new validator """ def valid...
python
def max_validator(max_value): """Return validator function that ensures upper bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check. Args: max_value: maximum value for new validator """ def valid...
[ "def", "max_validator", "(", "max_value", ")", ":", "def", "validator", "(", "value", ")", ":", "if", "value", ">", "max_value", ":", "raise", "ValidationError", "(", "\"{} is not <= {}\"", ".", "format", "(", "value", ",", "max_value", ")", ")", "return", ...
Return validator function that ensures upper bound of a number. Result validation function will validate the internal value of resource instance field with the ``value >= min_value`` check. Args: max_value: maximum value for new validator
[ "Return", "validator", "function", "that", "ensures", "upper", "bound", "of", "a", "number", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/validators.py#L31-L45
train
swistakm/graceful
src/graceful/validators.py
choices_validator
def choices_validator(choices): """Return validator function that will check if ``value in choices``. Args: max_value (list, set, tuple): allowed choices for new validator """ def validator(value): if value not in choices: # note: make it a list for consistent representatio...
python
def choices_validator(choices): """Return validator function that will check if ``value in choices``. Args: max_value (list, set, tuple): allowed choices for new validator """ def validator(value): if value not in choices: # note: make it a list for consistent representatio...
[ "def", "choices_validator", "(", "choices", ")", ":", "def", "validator", "(", "value", ")", ":", "if", "value", "not", "in", "choices", ":", "# note: make it a list for consistent representation", "raise", "ValidationError", "(", "\"{} is not in {}\"", ".", "format",...
Return validator function that will check if ``value in choices``. Args: max_value (list, set, tuple): allowed choices for new validator
[ "Return", "validator", "function", "that", "will", "check", "if", "value", "in", "choices", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/validators.py#L48-L62
train
swistakm/graceful
src/graceful/validators.py
match_validator
def match_validator(expression): """Return validator function that will check if matches given expression. Args: match: if string then this will be converted to regular expression using ``re.compile``. Can be also any object that has ``match()`` method like already compiled regula...
python
def match_validator(expression): """Return validator function that will check if matches given expression. Args: match: if string then this will be converted to regular expression using ``re.compile``. Can be also any object that has ``match()`` method like already compiled regula...
[ "def", "match_validator", "(", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "str", ")", ":", "compiled", "=", "re", ".", "compile", "(", "expression", ")", "elif", "hasattr", "(", "expression", ",", "'match'", ")", ":", "# check it e...
Return validator function that will check if matches given expression. Args: match: if string then this will be converted to regular expression using ``re.compile``. Can be also any object that has ``match()`` method like already compiled regular regular expression or custom ...
[ "Return", "validator", "function", "that", "will", "check", "if", "matches", "given", "expression", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/validators.py#L65-L98
train
swistakm/graceful
src/graceful/parameters.py
BaseParam.validated_value
def validated_value(self, raw_value): """Return parsed parameter value and run validation handlers. Error message included in exception will be included in http error response Args: value: raw parameter value to parse validate Returns: None Not...
python
def validated_value(self, raw_value): """Return parsed parameter value and run validation handlers. Error message included in exception will be included in http error response Args: value: raw parameter value to parse validate Returns: None Not...
[ "def", "validated_value", "(", "self", ",", "raw_value", ")", ":", "value", "=", "self", ".", "value", "(", "raw_value", ")", "try", ":", "for", "validator", "in", "self", ".", "validators", ":", "validator", "(", "value", ")", "except", ":", "raise", ...
Return parsed parameter value and run validation handlers. Error message included in exception will be included in http error response Args: value: raw parameter value to parse validate Returns: None Note: Concept of validation for params i...
[ "Return", "parsed", "parameter", "value", "and", "run", "validation", "handlers", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/parameters.py#L122-L149
train
swistakm/graceful
src/graceful/parameters.py
BaseParam.describe
def describe(self, **kwargs): """Describe this parameter instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items ...
python
def describe(self, **kwargs): """Describe this parameter instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items ...
[ "def", "describe", "(", "self", ",", "*", "*", "kwargs", ")", ":", "description", "=", "{", "'label'", ":", "self", ".", "label", ",", "# note: details are expected to be large so it should", "# be reformatted", "'details'", ":", "inspect", ".", "cleandoc", ...
Describe this parameter instance for purpose of self-documentation. Args: kwargs (dict): dictionary of additional description items for extending default description Returns: dict: dictionary of description items Suggested way for overriding descriptio...
[ "Describe", "this", "parameter", "instance", "for", "purpose", "of", "self", "-", "documentation", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/parameters.py#L164-L199
train
swistakm/graceful
src/graceful/parameters.py
Base64EncodedParam.value
def value(self, raw_value): """Decode param with Base64.""" try: return base64.b64decode(bytes(raw_value, 'utf-8')).decode('utf-8') except binascii.Error as err: raise ValueError(str(err))
python
def value(self, raw_value): """Decode param with Base64.""" try: return base64.b64decode(bytes(raw_value, 'utf-8')).decode('utf-8') except binascii.Error as err: raise ValueError(str(err))
[ "def", "value", "(", "self", ",", "raw_value", ")", ":", "try", ":", "return", "base64", ".", "b64decode", "(", "bytes", "(", "raw_value", ",", "'utf-8'", ")", ")", ".", "decode", "(", "'utf-8'", ")", "except", "binascii", ".", "Error", "as", "err", ...
Decode param with Base64.
[ "Decode", "param", "with", "Base64", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/parameters.py#L237-L242
train
swistakm/graceful
src/graceful/parameters.py
DecimalParam.value
def value(self, raw_value): """Decode param as decimal value.""" try: return decimal.Decimal(raw_value) except decimal.InvalidOperation: raise ValueError( "Could not parse '{}' value as decimal".format(raw_value) )
python
def value(self, raw_value): """Decode param as decimal value.""" try: return decimal.Decimal(raw_value) except decimal.InvalidOperation: raise ValueError( "Could not parse '{}' value as decimal".format(raw_value) )
[ "def", "value", "(", "self", ",", "raw_value", ")", ":", "try", ":", "return", "decimal", ".", "Decimal", "(", "raw_value", ")", "except", "decimal", ".", "InvalidOperation", ":", "raise", "ValueError", "(", "\"Could not parse '{}' value as decimal\"", ".", "for...
Decode param as decimal value.
[ "Decode", "param", "as", "decimal", "value", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/parameters.py#L270-L277
train
swistakm/graceful
src/graceful/parameters.py
BoolParam.value
def value(self, raw_value): """Decode param as bool value.""" if raw_value in self._FALSE_VALUES: return False elif raw_value in self._TRUE_VALUES: return True else: raise ValueError( "Could not parse '{}' value as boolean".format(raw_v...
python
def value(self, raw_value): """Decode param as bool value.""" if raw_value in self._FALSE_VALUES: return False elif raw_value in self._TRUE_VALUES: return True else: raise ValueError( "Could not parse '{}' value as boolean".format(raw_v...
[ "def", "value", "(", "self", ",", "raw_value", ")", ":", "if", "raw_value", "in", "self", ".", "_FALSE_VALUES", ":", "return", "False", "elif", "raw_value", "in", "self", ".", "_TRUE_VALUES", ":", "return", "True", "else", ":", "raise", "ValueError", "(", ...
Decode param as bool value.
[ "Decode", "param", "as", "bool", "value", "." ]
d4678cb6349a5c843a5e58002fc80140821609e4
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/parameters.py#L300-L309
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/models/v1beta1_certificate_signing_request_spec.py
V1beta1CertificateSigningRequestSpec.request
def request(self, request): """Sets the request of this V1beta1CertificateSigningRequestSpec. Base64-encoded PKCS#10 CSR data # noqa: E501 :param request: The request of this V1beta1CertificateSigningRequestSpec. # noqa: E501 :type: str """ if request is None: ...
python
def request(self, request): """Sets the request of this V1beta1CertificateSigningRequestSpec. Base64-encoded PKCS#10 CSR data # noqa: E501 :param request: The request of this V1beta1CertificateSigningRequestSpec. # noqa: E501 :type: str """ if request is None: ...
[ "def", "request", "(", "self", ",", "request", ")", ":", "if", "request", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `request`, must not be `None`\"", ")", "# noqa: E501", "if", "request", "is", "not", "None", "and", "not", "re", ".", ...
Sets the request of this V1beta1CertificateSigningRequestSpec. Base64-encoded PKCS#10 CSR data # noqa: E501 :param request: The request of this V1beta1CertificateSigningRequestSpec. # noqa: E501 :type: str
[ "Sets", "the", "request", "of", "this", "V1beta1CertificateSigningRequestSpec", "." ]
f9ab15317ec921409714c7afef11aeb0f579985d
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/models/v1beta1_certificate_signing_request_spec.py#L132-L145
train
CLARIAH/grlc
src/projection.py
project
def project(dataIn, projectionScript): '''Programs may make use of data in the `dataIn` variable and should produce data on the `dataOut` variable.''' # We don't really need to initialize it, but we do it to avoid linter errors dataOut = {} try: projectionScript = str(projectionScript) ...
python
def project(dataIn, projectionScript): '''Programs may make use of data in the `dataIn` variable and should produce data on the `dataOut` variable.''' # We don't really need to initialize it, but we do it to avoid linter errors dataOut = {} try: projectionScript = str(projectionScript) ...
[ "def", "project", "(", "dataIn", ",", "projectionScript", ")", ":", "# We don't really need to initialize it, but we do it to avoid linter errors", "dataOut", "=", "{", "}", "try", ":", "projectionScript", "=", "str", "(", "projectionScript", ")", "program", "=", "makeP...
Programs may make use of data in the `dataIn` variable and should produce data on the `dataOut` variable.
[ "Programs", "may", "make", "use", "of", "data", "in", "the", "dataIn", "variable", "and", "should", "produce", "data", "on", "the", "dataOut", "variable", "." ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/projection.py#L7-L33
train
CLARIAH/grlc
src/prov.py
grlcPROV.init_prov_graph
def init_prov_graph(self): """ Initialize PROV graph with all we know at the start of the recording """ try: # Use git2prov to get prov on the repo repo_prov = check_output( ['node_modules/git2prov/bin/git2prov', 'https://github.com/{}/{}/'.format...
python
def init_prov_graph(self): """ Initialize PROV graph with all we know at the start of the recording """ try: # Use git2prov to get prov on the repo repo_prov = check_output( ['node_modules/git2prov/bin/git2prov', 'https://github.com/{}/{}/'.format...
[ "def", "init_prov_graph", "(", "self", ")", ":", "try", ":", "# Use git2prov to get prov on the repo", "repo_prov", "=", "check_output", "(", "[", "'node_modules/git2prov/bin/git2prov'", ",", "'https://github.com/{}/{}/'", ".", "format", "(", "self", ".", "user", ",", ...
Initialize PROV graph with all we know at the start of the recording
[ "Initialize", "PROV", "graph", "with", "all", "we", "know", "at", "the", "start", "of", "the", "recording" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/prov.py#L35-L68
train
CLARIAH/grlc
src/prov.py
grlcPROV.add_used_entity
def add_used_entity(self, entity_uri): """ Add the provided URI as a used entity by the logged activity """ entity_o = URIRef(entity_uri) self.prov_g.add((entity_o, RDF.type, self.prov.Entity)) self.prov_g.add((self.activity, self.prov.used, entity_o))
python
def add_used_entity(self, entity_uri): """ Add the provided URI as a used entity by the logged activity """ entity_o = URIRef(entity_uri) self.prov_g.add((entity_o, RDF.type, self.prov.Entity)) self.prov_g.add((self.activity, self.prov.used, entity_o))
[ "def", "add_used_entity", "(", "self", ",", "entity_uri", ")", ":", "entity_o", "=", "URIRef", "(", "entity_uri", ")", "self", ".", "prov_g", ".", "add", "(", "(", "entity_o", ",", "RDF", ".", "type", ",", "self", ".", "prov", ".", "Entity", ")", ")"...
Add the provided URI as a used entity by the logged activity
[ "Add", "the", "provided", "URI", "as", "a", "used", "entity", "by", "the", "logged", "activity" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/prov.py#L72-L78
train
CLARIAH/grlc
src/prov.py
grlcPROV.end_prov_graph
def end_prov_graph(self): """ Finalize prov recording with end time """ endTime = Literal(datetime.now()) self.prov_g.add((self.entity_d, self.prov.generatedAtTime, endTime)) self.prov_g.add((self.activity, self.prov.endedAtTime, endTime))
python
def end_prov_graph(self): """ Finalize prov recording with end time """ endTime = Literal(datetime.now()) self.prov_g.add((self.entity_d, self.prov.generatedAtTime, endTime)) self.prov_g.add((self.activity, self.prov.endedAtTime, endTime))
[ "def", "end_prov_graph", "(", "self", ")", ":", "endTime", "=", "Literal", "(", "datetime", ".", "now", "(", ")", ")", "self", ".", "prov_g", ".", "add", "(", "(", "self", ".", "entity_d", ",", "self", ".", "prov", ".", "generatedAtTime", ",", "endTi...
Finalize prov recording with end time
[ "Finalize", "prov", "recording", "with", "end", "time" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/prov.py#L80-L86
train
CLARIAH/grlc
src/prov.py
grlcPROV.log_prov_graph
def log_prov_graph(self): """ Log provenance graph so far """ glogger.debug("Spec generation provenance graph:") glogger.debug(self.prov_g.serialize(format='turtle'))
python
def log_prov_graph(self): """ Log provenance graph so far """ glogger.debug("Spec generation provenance graph:") glogger.debug(self.prov_g.serialize(format='turtle'))
[ "def", "log_prov_graph", "(", "self", ")", ":", "glogger", ".", "debug", "(", "\"Spec generation provenance graph:\"", ")", "glogger", ".", "debug", "(", "self", ".", "prov_g", ".", "serialize", "(", "format", "=", "'turtle'", ")", ")" ]
Log provenance graph so far
[ "Log", "provenance", "graph", "so", "far" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/prov.py#L88-L93
train
CLARIAH/grlc
src/prov.py
grlcPROV.serialize
def serialize(self, format): """ Serialize provenance graph in the specified format """ if PY3: return self.prov_g.serialize(format=format).decode('utf-8') else: return self.prov_g.serialize(format=format)
python
def serialize(self, format): """ Serialize provenance graph in the specified format """ if PY3: return self.prov_g.serialize(format=format).decode('utf-8') else: return self.prov_g.serialize(format=format)
[ "def", "serialize", "(", "self", ",", "format", ")", ":", "if", "PY3", ":", "return", "self", ".", "prov_g", ".", "serialize", "(", "format", "=", "format", ")", ".", "decode", "(", "'utf-8'", ")", "else", ":", "return", "self", ".", "prov_g", ".", ...
Serialize provenance graph in the specified format
[ "Serialize", "provenance", "graph", "in", "the", "specified", "format" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/prov.py#L95-L102
train
CLARIAH/grlc
src/gquery.py
get_defaults
def get_defaults(rq, v, metadata): """ Returns the default value for a parameter or None """ glogger.debug("Metadata with defaults: {}".format(metadata)) if 'defaults' not in metadata: return None defaultsDict = _getDictWithKey(v, metadata['defaults']) if defaultsDict: return...
python
def get_defaults(rq, v, metadata): """ Returns the default value for a parameter or None """ glogger.debug("Metadata with defaults: {}".format(metadata)) if 'defaults' not in metadata: return None defaultsDict = _getDictWithKey(v, metadata['defaults']) if defaultsDict: return...
[ "def", "get_defaults", "(", "rq", ",", "v", ",", "metadata", ")", ":", "glogger", ".", "debug", "(", "\"Metadata with defaults: {}\"", ".", "format", "(", "metadata", ")", ")", "if", "'defaults'", "not", "in", "metadata", ":", "return", "None", "defaultsDict...
Returns the default value for a parameter or None
[ "Returns", "the", "default", "value", "for", "a", "parameter", "or", "None" ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/gquery.py#L183-L193
train
CLARIAH/grlc
src/fileLoaders.py
LocalLoader.fetchFiles
def fetchFiles(self): """Returns a list of file items contained on the local repo.""" print("Fetching files from {}".format(self.baseDir)) files = glob(path.join(self.baseDir, '*')) filesDef = [] for f in files: print("Found SPARQL file {}".format(f)) rela...
python
def fetchFiles(self): """Returns a list of file items contained on the local repo.""" print("Fetching files from {}".format(self.baseDir)) files = glob(path.join(self.baseDir, '*')) filesDef = [] for f in files: print("Found SPARQL file {}".format(f)) rela...
[ "def", "fetchFiles", "(", "self", ")", ":", "print", "(", "\"Fetching files from {}\"", ".", "format", "(", "self", ".", "baseDir", ")", ")", "files", "=", "glob", "(", "path", ".", "join", "(", "self", ".", "baseDir", ",", "'*'", ")", ")", "filesDef",...
Returns a list of file items contained on the local repo.
[ "Returns", "a", "list", "of", "file", "items", "contained", "on", "the", "local", "repo", "." ]
f5664e34f039010c00ef8ebb69917c05e8ce75d7
https://github.com/CLARIAH/grlc/blob/f5664e34f039010c00ef8ebb69917c05e8ce75d7/src/fileLoaders.py#L125-L137
train