id
int32
0
252k
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
52,700
winstonwolff/expectorant
expectorant/expector.py
change
def change(subject, evaluator, by=_NOT_SET, frm=_NOT_SET, to=_NOT_SET): ''' Calls function `evaluator` before and after a call function `subject`. Output of `evaluator` should change. >>> expect = Expector([]) >>> a = [1, 2, 3] >>> expect(a.clear).to(change, lambda: len(a)) (True, 'expect chang...
python
def change(subject, evaluator, by=_NOT_SET, frm=_NOT_SET, to=_NOT_SET): ''' Calls function `evaluator` before and after a call function `subject`. Output of `evaluator` should change. >>> expect = Expector([]) >>> a = [1, 2, 3] >>> expect(a.clear).to(change, lambda: len(a)) (True, 'expect chang...
[ "def", "change", "(", "subject", ",", "evaluator", ",", "by", "=", "_NOT_SET", ",", "frm", "=", "_NOT_SET", ",", "to", "=", "_NOT_SET", ")", ":", "output_before", "=", "evaluator", "(", ")", "subject", "(", ")", "output_after", "=", "evaluator", "(", "...
Calls function `evaluator` before and after a call function `subject`. Output of `evaluator` should change. >>> expect = Expector([]) >>> a = [1, 2, 3] >>> expect(a.clear).to(change, lambda: len(a)) (True, 'expect change: actual from=3 to=0') >>> a = [1, 2, 3] >>> expect(a.clear).to(change, la...
[ "Calls", "function", "evaluator", "before", "and", "after", "a", "call", "function", "subject", ".", "Output", "of", "evaluator", "should", "change", "." ]
cb9e4c1656d7c1f4394f0b0fbeb968a833030031
https://github.com/winstonwolff/expectorant/blob/cb9e4c1656d7c1f4394f0b0fbeb968a833030031/expectorant/expector.py#L143-L183
52,701
Pixelapse/pyglass
pyglass/pdf/api.py
stitch_pdfs
def stitch_pdfs(pdf_list): ''' Merges a series of single page pdfs into one multi-page doc ''' pdf_merger = PdfFileMerger() for pdf in pdf_list: pdf_merger.append(pdf) with NamedTemporaryFile(prefix='pyglass', suffix='.pdf', delete=False) as tempfileobj: dest_path = tempfileobj.name pdf_merger.write...
python
def stitch_pdfs(pdf_list): ''' Merges a series of single page pdfs into one multi-page doc ''' pdf_merger = PdfFileMerger() for pdf in pdf_list: pdf_merger.append(pdf) with NamedTemporaryFile(prefix='pyglass', suffix='.pdf', delete=False) as tempfileobj: dest_path = tempfileobj.name pdf_merger.write...
[ "def", "stitch_pdfs", "(", "pdf_list", ")", ":", "pdf_merger", "=", "PdfFileMerger", "(", ")", "for", "pdf", "in", "pdf_list", ":", "pdf_merger", ".", "append", "(", "pdf", ")", "with", "NamedTemporaryFile", "(", "prefix", "=", "'pyglass'", ",", "suffix", ...
Merges a series of single page pdfs into one multi-page doc
[ "Merges", "a", "series", "of", "single", "page", "pdfs", "into", "one", "multi", "-", "page", "doc" ]
83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/pdf/api.py#L16-L27
52,702
Pixelapse/pyglass
pyglass/pdf/api.py
split_pdf
def split_pdf(pdf_path): ''' Splits a multi-page pdf into a list of single page pdfs ''' pdf = PdfFileReader(pdf_path) pdf_list = [] for page_num in range(pdf.numPages): page = pdf.getPage(page_num) pdf_writer = PdfFileWriter() pdf_writer.addPage(page) with NamedTemporaryFile(prefix='pyglass'...
python
def split_pdf(pdf_path): ''' Splits a multi-page pdf into a list of single page pdfs ''' pdf = PdfFileReader(pdf_path) pdf_list = [] for page_num in range(pdf.numPages): page = pdf.getPage(page_num) pdf_writer = PdfFileWriter() pdf_writer.addPage(page) with NamedTemporaryFile(prefix='pyglass'...
[ "def", "split_pdf", "(", "pdf_path", ")", ":", "pdf", "=", "PdfFileReader", "(", "pdf_path", ")", "pdf_list", "=", "[", "]", "for", "page_num", "in", "range", "(", "pdf", ".", "numPages", ")", ":", "page", "=", "pdf", ".", "getPage", "(", "page_num", ...
Splits a multi-page pdf into a list of single page pdfs
[ "Splits", "a", "multi", "-", "page", "pdf", "into", "a", "list", "of", "single", "page", "pdfs" ]
83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/pdf/api.py#L30-L47
52,703
pcx/shoot
shoot/server.py
ShootServer.send_head
def send_head(self): """Builds response headers and in process renders templates, if any. This method overrides SimpleHTTPRequestHandlet.send_head() """ path = self.translate_path(self.path) f = None to_render = False if os.path.isdir(path): if not se...
python
def send_head(self): """Builds response headers and in process renders templates, if any. This method overrides SimpleHTTPRequestHandlet.send_head() """ path = self.translate_path(self.path) f = None to_render = False if os.path.isdir(path): if not se...
[ "def", "send_head", "(", "self", ")", ":", "path", "=", "self", ".", "translate_path", "(", "self", ".", "path", ")", "f", "=", "None", "to_render", "=", "False", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "not", "self", ...
Builds response headers and in process renders templates, if any. This method overrides SimpleHTTPRequestHandlet.send_head()
[ "Builds", "response", "headers", "and", "in", "process", "renders", "templates", "if", "any", "." ]
25a8295bec2dd167cc5662312039ba4fd29a8836
https://github.com/pcx/shoot/blob/25a8295bec2dd167cc5662312039ba4fd29a8836/shoot/server.py#L20-L82
52,704
decryptus/sonicprobe
sonicprobe/libs/urisup.py
pct_decode
def pct_decode(s): """ Return the percent-decoded version of string s. >>> pct_decode('%43%6F%75%63%6F%75%2C%20%6A%65%20%73%75%69%73%20%63%6F%6E%76%69%76%69%61%6C') 'Coucou, je suis convivial' >>> pct_decode('') '' >>> pct_decode('%2525') '%25' """ if s is None: return N...
python
def pct_decode(s): """ Return the percent-decoded version of string s. >>> pct_decode('%43%6F%75%63%6F%75%2C%20%6A%65%20%73%75%69%73%20%63%6F%6E%76%69%76%69%61%6C') 'Coucou, je suis convivial' >>> pct_decode('') '' >>> pct_decode('%2525') '%25' """ if s is None: return N...
[ "def", "pct_decode", "(", "s", ")", ":", "if", "s", "is", "None", ":", "return", "None", "elif", "not", "isinstance", "(", "s", ",", "unicode", ")", ":", "s", "=", "str", "(", "s", ")", "else", ":", "s", "=", "s", ".", "encode", "(", "'utf8'", ...
Return the percent-decoded version of string s. >>> pct_decode('%43%6F%75%63%6F%75%2C%20%6A%65%20%73%75%69%73%20%63%6F%6E%76%69%76%69%61%6C') 'Coucou, je suis convivial' >>> pct_decode('') '' >>> pct_decode('%2525') '%25'
[ "Return", "the", "percent", "-", "decoded", "version", "of", "string", "s", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L216-L234
52,705
decryptus/sonicprobe
sonicprobe/libs/urisup.py
pct_encode
def pct_encode(s, encdct): """ Return a translated version of s where each character is mapped to a string thanks to the encdct dictionary. Use the encdct parameter to construct a string from parameter s where each character k from s is replaced by the value corresponding to key k in encdct. I...
python
def pct_encode(s, encdct): """ Return a translated version of s where each character is mapped to a string thanks to the encdct dictionary. Use the encdct parameter to construct a string from parameter s where each character k from s is replaced by the value corresponding to key k in encdct. I...
[ "def", "pct_encode", "(", "s", ",", "encdct", ")", ":", "if", "s", "is", "None", ":", "return", "None", "elif", "not", "isinstance", "(", "s", ",", "unicode", ")", ":", "s", "=", "str", "(", "s", ")", "else", ":", "s", "=", "s", ".", "encode", ...
Return a translated version of s where each character is mapped to a string thanks to the encdct dictionary. Use the encdct parameter to construct a string from parameter s where each character k from s is replaced by the value corresponding to key k in encdct. It happens that callers use dictionaries...
[ "Return", "a", "translated", "version", "of", "s", "where", "each", "character", "is", "mapped", "to", "a", "string", "thanks", "to", "the", "encdct", "dictionary", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L236-L254
52,706
decryptus/sonicprobe
sonicprobe/libs/urisup.py
split_authority
def split_authority(authority): """ Split authority into component parts. This function supports IP-literal as defined in RFC 3986. >>> split_authority("user:passwd@host:port") ('user', 'passwd', 'host', 'port') >>> split_authority("user:@host:port") ('user', None, 'host', 'port') >>> ...
python
def split_authority(authority): """ Split authority into component parts. This function supports IP-literal as defined in RFC 3986. >>> split_authority("user:passwd@host:port") ('user', 'passwd', 'host', 'port') >>> split_authority("user:@host:port") ('user', None, 'host', 'port') >>> ...
[ "def", "split_authority", "(", "authority", ")", ":", "if", "'@'", "in", "authority", ":", "userinfo", ",", "hostport", "=", "authority", ".", "split", "(", "'@'", ",", "1", ")", "if", "userinfo", "and", "':'", "in", "userinfo", ":", "user", ",", "pass...
Split authority into component parts. This function supports IP-literal as defined in RFC 3986. >>> split_authority("user:passwd@host:port") ('user', 'passwd', 'host', 'port') >>> split_authority("user:@host:port") ('user', None, 'host', 'port') >>> split_authority("user@host:port") ('user...
[ "Split", "authority", "into", "component", "parts", ".", "This", "function", "supports", "IP", "-", "literal", "as", "defined", "in", "RFC", "3986", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L313-L368
52,707
decryptus/sonicprobe
sonicprobe/libs/urisup.py
basic_urisplit
def basic_urisplit(uri): """ Basic URI Parser according to RFC 3986 >>> basic_urisplit("scheme://authority/path?query#fragment") ('scheme', 'authority', '/path', 'query', 'fragment') """ p = RFC3986_MATCHER(uri).groups() return (p[1], p[3], p[4], p[6], p[8])
python
def basic_urisplit(uri): """ Basic URI Parser according to RFC 3986 >>> basic_urisplit("scheme://authority/path?query#fragment") ('scheme', 'authority', '/path', 'query', 'fragment') """ p = RFC3986_MATCHER(uri).groups() return (p[1], p[3], p[4], p[6], p[8])
[ "def", "basic_urisplit", "(", "uri", ")", ":", "p", "=", "RFC3986_MATCHER", "(", "uri", ")", ".", "groups", "(", ")", "return", "(", "p", "[", "1", "]", ",", "p", "[", "3", "]", ",", "p", "[", "4", "]", ",", "p", "[", "6", "]", ",", "p", ...
Basic URI Parser according to RFC 3986 >>> basic_urisplit("scheme://authority/path?query#fragment") ('scheme', 'authority', '/path', 'query', 'fragment')
[ "Basic", "URI", "Parser", "according", "to", "RFC", "3986" ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L402-L410
52,708
decryptus/sonicprobe
sonicprobe/libs/urisup.py
uri_tree_normalize
def uri_tree_normalize(uri_tree): """ Transform an URI tree so that adjacent all-empty fields are coalesced into a single None at parent level. The return value can be used for validation. As a result, no distinction is made between empty and absent fields. It is believed that this limitation is...
python
def uri_tree_normalize(uri_tree): """ Transform an URI tree so that adjacent all-empty fields are coalesced into a single None at parent level. The return value can be used for validation. As a result, no distinction is made between empty and absent fields. It is believed that this limitation is...
[ "def", "uri_tree_normalize", "(", "uri_tree", ")", ":", "scheme", ",", "authority", ",", "path", ",", "query", ",", "fragment", "=", "uri_tree", "if", "authority", "and", "(", "filter", "(", "bool", ",", "authority", ")", "==", "(", ")", ")", ":", "aut...
Transform an URI tree so that adjacent all-empty fields are coalesced into a single None at parent level. The return value can be used for validation. As a result, no distinction is made between empty and absent fields. It is believed that this limitation is harmless because this is the behavior of ...
[ "Transform", "an", "URI", "tree", "so", "that", "adjacent", "all", "-", "empty", "fields", "are", "coalesced", "into", "a", "single", "None", "at", "parent", "level", ".", "The", "return", "value", "can", "be", "used", "for", "validation", ".", "As", "a"...
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L434-L462
52,709
decryptus/sonicprobe
sonicprobe/libs/urisup.py
uri_tree_precode_check
def uri_tree_precode_check(uri_tree, type_host = HOST_REG_NAME): """ Call this function to validate a raw URI tree before trying to encode it. """ scheme, authority, path, query, fragment = uri_tree # pylint: disable-msg=W0612 if scheme: if not valid_scheme(scheme): raise Inv...
python
def uri_tree_precode_check(uri_tree, type_host = HOST_REG_NAME): """ Call this function to validate a raw URI tree before trying to encode it. """ scheme, authority, path, query, fragment = uri_tree # pylint: disable-msg=W0612 if scheme: if not valid_scheme(scheme): raise Inv...
[ "def", "uri_tree_precode_check", "(", "uri_tree", ",", "type_host", "=", "HOST_REG_NAME", ")", ":", "scheme", ",", "authority", ",", "path", ",", "query", ",", "fragment", "=", "uri_tree", "# pylint: disable-msg=W0612", "if", "scheme", ":", "if", "not", "valid_s...
Call this function to validate a raw URI tree before trying to encode it.
[ "Call", "this", "function", "to", "validate", "a", "raw", "URI", "tree", "before", "trying", "to", "encode", "it", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L565-L587
52,710
MinchinWeb/minchin.releaser
minchin/releaser/util.py
check_configuration
def check_configuration(ctx, base_key, needed_keys): """ Confrim a valid configuration. Args: ctx (invoke.context): base_key (str): the base configuration key everything is under. needed_keys (list): sub-keys of the base key that are checked to make sure they exist. ...
python
def check_configuration(ctx, base_key, needed_keys): """ Confrim a valid configuration. Args: ctx (invoke.context): base_key (str): the base configuration key everything is under. needed_keys (list): sub-keys of the base key that are checked to make sure they exist. ...
[ "def", "check_configuration", "(", "ctx", ",", "base_key", ",", "needed_keys", ")", ":", "# check for valid configuration", "if", "base_key", "not", "in", "ctx", ".", "keys", "(", ")", ":", "exit", "(", "\"[{}ERROR{}] missing configuration for '{}'\"", ".", "format"...
Confrim a valid configuration. Args: ctx (invoke.context): base_key (str): the base configuration key everything is under. needed_keys (list): sub-keys of the base key that are checked to make sure they exist.
[ "Confrim", "a", "valid", "configuration", "." ]
cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4
https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/util.py#L7-L32
52,711
MinchinWeb/minchin.releaser
minchin/releaser/util.py
check_existence
def check_existence(to_check, name, config_key=None, relative_to=None, allow_undefined=False, allow_not_existing=False, base_key='releaser'): """Determine whether a file or folder actually exists.""" if allow_undefined and (to_check is None or to_check.lower() == 'none'):...
python
def check_existence(to_check, name, config_key=None, relative_to=None, allow_undefined=False, allow_not_existing=False, base_key='releaser'): """Determine whether a file or folder actually exists.""" if allow_undefined and (to_check is None or to_check.lower() == 'none'):...
[ "def", "check_existence", "(", "to_check", ",", "name", ",", "config_key", "=", "None", ",", "relative_to", "=", "None", ",", "allow_undefined", "=", "False", ",", "allow_not_existing", "=", "False", ",", "base_key", "=", "'releaser'", ")", ":", "if", "allow...
Determine whether a file or folder actually exists.
[ "Determine", "whether", "a", "file", "or", "folder", "actually", "exists", "." ]
cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4
https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/util.py#L35-L61
52,712
MatiasSM/fcb
fcb/processing/transformations/ToImage.py
_determine_dimensions
def _determine_dimensions(num_of_pixels): """ Given a number of pixels, determines the largest width and height that define a rectangle with such an area """ for x in xrange(int(math.sqrt(num_of_pixels)) + 1, 1, -1): if num_of_pixels % x == 0: return num_of_pixels // x, x r...
python
def _determine_dimensions(num_of_pixels): """ Given a number of pixels, determines the largest width and height that define a rectangle with such an area """ for x in xrange(int(math.sqrt(num_of_pixels)) + 1, 1, -1): if num_of_pixels % x == 0: return num_of_pixels // x, x r...
[ "def", "_determine_dimensions", "(", "num_of_pixels", ")", ":", "for", "x", "in", "xrange", "(", "int", "(", "math", ".", "sqrt", "(", "num_of_pixels", ")", ")", "+", "1", ",", "1", ",", "-", "1", ")", ":", "if", "num_of_pixels", "%", "x", "==", "0...
Given a number of pixels, determines the largest width and height that define a rectangle with such an area
[ "Given", "a", "number", "of", "pixels", "determines", "the", "largest", "width", "and", "height", "that", "define", "a", "rectangle", "with", "such", "an", "area" ]
92a6c535287ea1c1ef986954a5d66e7905fb6221
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/transformations/ToImage.py#L15-L23
52,713
MatiasSM/fcb
fcb/processing/transformations/ToImage.py
from_image_to_file
def from_image_to_file(img_path, file_path): """ Expects images created by from_from_file_to_image """ img = Image.open(img_path) data = numpy.array(img) data = numpy.reshape(data, len(img.getdata()) * 3) to_remove = data[len(data) - 1] data = numpy.delete(data, xrange(len(data) - to_rem...
python
def from_image_to_file(img_path, file_path): """ Expects images created by from_from_file_to_image """ img = Image.open(img_path) data = numpy.array(img) data = numpy.reshape(data, len(img.getdata()) * 3) to_remove = data[len(data) - 1] data = numpy.delete(data, xrange(len(data) - to_rem...
[ "def", "from_image_to_file", "(", "img_path", ",", "file_path", ")", ":", "img", "=", "Image", ".", "open", "(", "img_path", ")", "data", "=", "numpy", ".", "array", "(", "img", ")", "data", "=", "numpy", ".", "reshape", "(", "data", ",", "len", "(",...
Expects images created by from_from_file_to_image
[ "Expects", "images", "created", "by", "from_from_file_to_image" ]
92a6c535287ea1c1ef986954a5d66e7905fb6221
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/transformations/ToImage.py#L58-L67
52,714
lvh/txeasymail
txeasymail/html.py
textFromHTML
def textFromHTML(html): """ Cleans and parses text from the given HTML. """ cleaner = lxml.html.clean.Cleaner(scripts=True) cleaned = cleaner.clean_html(html) return lxml.html.fromstring(cleaned).text_content()
python
def textFromHTML(html): """ Cleans and parses text from the given HTML. """ cleaner = lxml.html.clean.Cleaner(scripts=True) cleaned = cleaner.clean_html(html) return lxml.html.fromstring(cleaned).text_content()
[ "def", "textFromHTML", "(", "html", ")", ":", "cleaner", "=", "lxml", ".", "html", ".", "clean", ".", "Cleaner", "(", "scripts", "=", "True", ")", "cleaned", "=", "cleaner", ".", "clean_html", "(", "html", ")", "return", "lxml", ".", "html", ".", "fr...
Cleans and parses text from the given HTML.
[ "Cleans", "and", "parses", "text", "from", "the", "given", "HTML", "." ]
7b845a5238b1371824854468646d54653a426f09
https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/html.py#L27-L33
52,715
lvh/txeasymail
txeasymail/html.py
UnsafeHTMLTemplate.evaluate
def evaluate(self, context): """ Interpolates the HTML source with the context, then returns that HTML and the text extracted from that html. """ html = self._source.format(**context) parts = {"text/html": html, "text/plain": textFromHTML(html)} return {}, parts
python
def evaluate(self, context): """ Interpolates the HTML source with the context, then returns that HTML and the text extracted from that html. """ html = self._source.format(**context) parts = {"text/html": html, "text/plain": textFromHTML(html)} return {}, parts
[ "def", "evaluate", "(", "self", ",", "context", ")", ":", "html", "=", "self", ".", "_source", ".", "format", "(", "*", "*", "context", ")", "parts", "=", "{", "\"text/html\"", ":", "html", ",", "\"text/plain\"", ":", "textFromHTML", "(", "html", ")", ...
Interpolates the HTML source with the context, then returns that HTML and the text extracted from that html.
[ "Interpolates", "the", "HTML", "source", "with", "the", "context", "then", "returns", "that", "HTML", "and", "the", "text", "extracted", "from", "that", "html", "." ]
7b845a5238b1371824854468646d54653a426f09
https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/html.py#L16-L23
52,716
GaretJax/coolfig
setup.py
Setup.get_files
def get_files(*bases): """ List all files in a data directory. """ for base in bases: basedir, _ = base.split(".", 1) base = os.path.join(os.path.dirname(__file__), *base.split(".")) rem = len(os.path.dirname(base)) + len(basedir) + 2 for...
python
def get_files(*bases): """ List all files in a data directory. """ for base in bases: basedir, _ = base.split(".", 1) base = os.path.join(os.path.dirname(__file__), *base.split(".")) rem = len(os.path.dirname(base)) + len(basedir) + 2 for...
[ "def", "get_files", "(", "*", "bases", ")", ":", "for", "base", "in", "bases", ":", "basedir", ",", "_", "=", "base", ".", "split", "(", "\".\"", ",", "1", ")", "base", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname"...
List all files in a data directory.
[ "List", "all", "files", "in", "a", "data", "directory", "." ]
6952aabc6ad2c9684d5d98dc470313f8f13fe636
https://github.com/GaretJax/coolfig/blob/6952aabc6ad2c9684d5d98dc470313f8f13fe636/setup.py#L48-L60
52,717
dcaune/perseus-lib-python-common
majormode/perseus/model/geolocation.py
GeoPoint.equirectangular_distance
def equirectangular_distance(self, other): """ Return the approximate equirectangular when the location is close to the center of the cluster. For small distances, Pythagoras’ theorem can be used on an equirectangular projection. Equirectangular formula:: x...
python
def equirectangular_distance(self, other): """ Return the approximate equirectangular when the location is close to the center of the cluster. For small distances, Pythagoras’ theorem can be used on an equirectangular projection. Equirectangular formula:: x...
[ "def", "equirectangular_distance", "(", "self", ",", "other", ")", ":", "x", "=", "math", ".", "radians", "(", "other", ".", "longitude", "-", "self", ".", "longitude", ")", "*", "math", ".", "cos", "(", "math", ".", "radians", "(", "other", ".", "la...
Return the approximate equirectangular when the location is close to the center of the cluster. For small distances, Pythagoras’ theorem can be used on an equirectangular projection. Equirectangular formula:: x = Δλ ⋅ cos φm y = Δφ d = R ⋅ √(x² + y)...
[ "Return", "the", "approximate", "equirectangular", "when", "the", "location", "is", "close", "to", "the", "center", "of", "the", "cluster", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/geolocation.py#L140-L202
52,718
dcaune/perseus-lib-python-common
majormode/perseus/model/geolocation.py
GeoPoint.from_json
def from_json(payload): """ Build a ``GeoPoint`` instance from the specified JSON object. @param payload: JSON representation of a geographic location:: { "accuracy": decimal, "altitude": decimal, "bearing": decimal, ...
python
def from_json(payload): """ Build a ``GeoPoint`` instance from the specified JSON object. @param payload: JSON representation of a geographic location:: { "accuracy": decimal, "altitude": decimal, "bearing": decimal, ...
[ "def", "from_json", "(", "payload", ")", ":", "return", "payload", "and", "GeoPoint", "(", "payload", "[", "'longitude'", "]", ",", "payload", "[", "'latitude'", "]", ",", "accuracy", "=", "payload", ".", "get", "(", "'accuracy'", ")", ",", "altitude", "...
Build a ``GeoPoint`` instance from the specified JSON object. @param payload: JSON representation of a geographic location:: { "accuracy": decimal, "altitude": decimal, "bearing": decimal, "longitude": decimal, ...
[ "Build", "a", "GeoPoint", "instance", "from", "the", "specified", "JSON", "object", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/geolocation.py#L238-L299
52,719
ronhanson/python-jobmanager-common
jobmanager/common/__init__.py
change_keys
def change_keys(obj, convert): """ Recursively goes through the dictionary obj and replaces keys with the convert function. """ if isinstance(obj, (str, int, float)): return obj if isinstance(obj, dict): new = obj.__class__() for k, v in obj.items(): new[convert(k...
python
def change_keys(obj, convert): """ Recursively goes through the dictionary obj and replaces keys with the convert function. """ if isinstance(obj, (str, int, float)): return obj if isinstance(obj, dict): new = obj.__class__() for k, v in obj.items(): new[convert(k...
[ "def", "change_keys", "(", "obj", ",", "convert", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "str", ",", "int", ",", "float", ")", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "new", "=", "obj", ".", ...
Recursively goes through the dictionary obj and replaces keys with the convert function.
[ "Recursively", "goes", "through", "the", "dictionary", "obj", "and", "replaces", "keys", "with", "the", "convert", "function", "." ]
a61fadcdfcfe111bc0bf3b195c9accc0293f2888
https://github.com/ronhanson/python-jobmanager-common/blob/a61fadcdfcfe111bc0bf3b195c9accc0293f2888/jobmanager/common/__init__.py#L56-L70
52,720
dcaune/perseus-lib-python-common
majormode/perseus/utils/rdbms.py
RdbmsConnection._expand_placeholder_value
def _expand_placeholder_value(value): """ Return the SQL string representation of the specified placeholder's value. @param value: the value of a placeholder such as a simple element, a list, or a tuple of one string. @note: by convention, a tuple of one string in...
python
def _expand_placeholder_value(value): """ Return the SQL string representation of the specified placeholder's value. @param value: the value of a placeholder such as a simple element, a list, or a tuple of one string. @note: by convention, a tuple of one string in...
[ "def", "_expand_placeholder_value", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "set", ")", ")", "or", "(", "isinstance", "(", "value", ",", "tuple", ")", "and", "len", "(", "value", ")", "!=", "1", ")", ":", "s...
Return the SQL string representation of the specified placeholder's value. @param value: the value of a placeholder such as a simple element, a list, or a tuple of one string. @note: by convention, a tuple of one string indicates that this string MUST not be quoted as...
[ "Return", "the", "SQL", "string", "representation", "of", "the", "specified", "placeholder", "s", "value", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L596-L629
52,721
dcaune/perseus-lib-python-common
majormode/perseus/utils/rdbms.py
RdbmsConnection._get_placeholders
def _get_placeholders(sql_statement, parameters): """ Retrieve the list of placeholders and their type defined in an SQL statement. @param sql_statement: a parameterized statement. @param parameters: the list of parameters used in the SQL statement. @return: a dictio...
python
def _get_placeholders(sql_statement, parameters): """ Retrieve the list of placeholders and their type defined in an SQL statement. @param sql_statement: a parameterized statement. @param parameters: the list of parameters used in the SQL statement. @return: a dictio...
[ "def", "_get_placeholders", "(", "sql_statement", ",", "parameters", ")", ":", "# Find the list of placeholders, and their type, defined in the SQL", "# statement.", "placeholders", "=", "{", "}", "try", ":", "for", "match", "in", "REGEX_PATTERN_SQL_PLACEHOLDERS", ".", "fin...
Retrieve the list of placeholders and their type defined in an SQL statement. @param sql_statement: a parameterized statement. @param parameters: the list of parameters used in the SQL statement. @return: a dictionary of placeholders where the key represents the name of ...
[ "Retrieve", "the", "list", "of", "placeholders", "and", "their", "type", "defined", "in", "an", "SQL", "statement", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L632-L685
52,722
dcaune/perseus-lib-python-common
majormode/perseus/utils/rdbms.py
RdbmsConnection._prepare_statement
def _prepare_statement(sql_statement, parameters): """ Prepare the specified SQL statement, replacing the placeholders by the value of the given parameters @param sql_statement: the string expression of a SQL statement. @param parameters: a dictionary of parameters where the ke...
python
def _prepare_statement(sql_statement, parameters): """ Prepare the specified SQL statement, replacing the placeholders by the value of the given parameters @param sql_statement: the string expression of a SQL statement. @param parameters: a dictionary of parameters where the ke...
[ "def", "_prepare_statement", "(", "sql_statement", ",", "parameters", ")", ":", "placehoolders", "=", "RdbmsConnection", ".", "_get_placeholders", "(", "sql_statement", ",", "parameters", ")", "for", "(", "variable_name", ",", "(", "variable_type", ",", "variable_va...
Prepare the specified SQL statement, replacing the placeholders by the value of the given parameters @param sql_statement: the string expression of a SQL statement. @param parameters: a dictionary of parameters where the key represents the name of a parameter and the value represen...
[ "Prepare", "the", "specified", "SQL", "statement", "replacing", "the", "placeholders", "by", "the", "value", "of", "the", "given", "parameters" ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L688-L716
52,723
dcaune/perseus-lib-python-common
majormode/perseus/utils/rdbms.py
RdbmsConnection._replace_placeholder
def _replace_placeholder(sql_statement, variable): """ Return the string obtained by replacing the specified placeholders by its corresponding value. @param sql_statement: the string expression of a SQL statement to replace placeholders with their corresponding values. ...
python
def _replace_placeholder(sql_statement, variable): """ Return the string obtained by replacing the specified placeholders by its corresponding value. @param sql_statement: the string expression of a SQL statement to replace placeholders with their corresponding values. ...
[ "def", "_replace_placeholder", "(", "sql_statement", ",", "variable", ")", ":", "(", "variable_name", ",", "variable_type", ",", "variable_value", ")", "=", "variable", "sql_value", "=", "RdbmsConnection", ".", "_expand_placeholder_value", "(", "variable_value", ")", ...
Return the string obtained by replacing the specified placeholders by its corresponding value. @param sql_statement: the string expression of a SQL statement to replace placeholders with their corresponding values. @param variable: the variable to use to replace the corresponding ...
[ "Return", "the", "string", "obtained", "by", "replacing", "the", "specified", "placeholders", "by", "its", "corresponding", "value", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L719-L748
52,724
dcaune/perseus-lib-python-common
majormode/perseus/utils/rdbms.py
RdbmsConnection._to_sql_value
def _to_sql_value(value, noquote=False): """ Return the SQL string representation of the specified value. @param value: a value to convert into its SQL string representation. @param noquote: indicate whether to quote or not the specified value. @return: a SQL string represen...
python
def _to_sql_value(value, noquote=False): """ Return the SQL string representation of the specified value. @param value: a value to convert into its SQL string representation. @param noquote: indicate whether to quote or not the specified value. @return: a SQL string represen...
[ "def", "_to_sql_value", "(", "value", ",", "noquote", "=", "False", ")", ":", "# Convert to string the values that the database adapter can't adapt", "# to a SQL type.", "# [http://initd.org/psycopg/docs/usage.html#query-parameters]", "if", "not", "isinstance", "(", "value", ",",...
Return the SQL string representation of the specified value. @param value: a value to convert into its SQL string representation. @param noquote: indicate whether to quote or not the specified value. @return: a SQL string representation of the specified value.
[ "Return", "the", "SQL", "string", "representation", "of", "the", "specified", "value", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/rdbms.py#L751-L782
52,725
tuxpiper/cloudcast
cloudcast/elements.py
EC2Instance.standalone_from_launchable
def standalone_from_launchable(cls, launch): """ Given a launchable resource, create a definition of a standalone instance, which doesn't depend on or contain references to other elements. """ attrs = copy.copy(launch.el_attrs) # Remove attributes we overwrite / d...
python
def standalone_from_launchable(cls, launch): """ Given a launchable resource, create a definition of a standalone instance, which doesn't depend on or contain references to other elements. """ attrs = copy.copy(launch.el_attrs) # Remove attributes we overwrite / d...
[ "def", "standalone_from_launchable", "(", "cls", ",", "launch", ")", ":", "attrs", "=", "copy", ".", "copy", "(", "launch", ".", "el_attrs", ")", "# Remove attributes we overwrite / don't need", "del", "attrs", "[", "\"Type\"", "]", "if", "attrs", ".", "has_key"...
Given a launchable resource, create a definition of a standalone instance, which doesn't depend on or contain references to other elements.
[ "Given", "a", "launchable", "resource", "create", "a", "definition", "of", "a", "standalone", "instance", "which", "doesn", "t", "depend", "on", "or", "contain", "references", "to", "other", "elements", "." ]
06ca62045c483e9c3e7ee960ba70d90ea6a13776
https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/elements.py#L310-L332
52,726
gpagliuca/pyfas
build/lib/pyfas/ppl.py
Ppl.filter_data
def filter_data(self, pattern=''): """ Filter available varaibles """ filtered_profiles = {} with open(self.abspath) as fobj: for idx, line in enumerate(fobj): if 'TIME SERIES' in line: break if pattern in l...
python
def filter_data(self, pattern=''): """ Filter available varaibles """ filtered_profiles = {} with open(self.abspath) as fobj: for idx, line in enumerate(fobj): if 'TIME SERIES' in line: break if pattern in l...
[ "def", "filter_data", "(", "self", ",", "pattern", "=", "''", ")", ":", "filtered_profiles", "=", "{", "}", "with", "open", "(", "self", ".", "abspath", ")", "as", "fobj", ":", "for", "idx", ",", "line", "in", "enumerate", "(", "fobj", ")", ":", "i...
Filter available varaibles
[ "Filter", "available", "varaibles" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/ppl.py#L64-L75
52,727
gpagliuca/pyfas
build/lib/pyfas/ppl.py
Ppl.extract
def extract(self, variable_idx): """ Extract a specific varaible """ branch = self._define_branch(variable_idx) label = self.profiles[variable_idx].replace("\n", "") self.label[variable_idx] = label self.data[variable_idx] = [[], []] with open(self...
python
def extract(self, variable_idx): """ Extract a specific varaible """ branch = self._define_branch(variable_idx) label = self.profiles[variable_idx].replace("\n", "") self.label[variable_idx] = label self.data[variable_idx] = [[], []] with open(self...
[ "def", "extract", "(", "self", ",", "variable_idx", ")", ":", "branch", "=", "self", ".", "_define_branch", "(", "variable_idx", ")", "label", "=", "self", ".", "profiles", "[", "variable_idx", "]", ".", "replace", "(", "\"\\n\"", ",", "\"\"", ")", "self...
Extract a specific varaible
[ "Extract", "a", "specific", "varaible" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/ppl.py#L101-L125
52,728
abhishek-ram/pyas2-lib
pyas2lib/utils.py
canonicalize
def canonicalize(message): """ Function to convert an email Message to standard format string :param message: email.Message to be converted to standard string :return: the standard representation of the email message in bytes """ if message.is_multipart() \ or message.get('Content-...
python
def canonicalize(message): """ Function to convert an email Message to standard format string :param message: email.Message to be converted to standard string :return: the standard representation of the email message in bytes """ if message.is_multipart() \ or message.get('Content-...
[ "def", "canonicalize", "(", "message", ")", ":", "if", "message", ".", "is_multipart", "(", ")", "or", "message", ".", "get", "(", "'Content-Transfer-Encoding'", ")", "!=", "'binary'", ":", "return", "mime_to_bytes", "(", "message", ",", "0", ")", ".", "re...
Function to convert an email Message to standard format string :param message: email.Message to be converted to standard string :return: the standard representation of the email message in bytes
[ "Function", "to", "convert", "an", "email", "Message", "to", "standard", "format", "string" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/utils.py#L48-L67
52,729
abhishek-ram/pyas2-lib
pyas2lib/utils.py
extract_first_part
def extract_first_part(message, boundary): """ Function to extract the first part of a multipart message""" first_message = message.split(boundary)[1].lstrip() if first_message.endswith(b'\r\n'): first_message = first_message[:-2] else: first_message = first_message[:-1] return first...
python
def extract_first_part(message, boundary): """ Function to extract the first part of a multipart message""" first_message = message.split(boundary)[1].lstrip() if first_message.endswith(b'\r\n'): first_message = first_message[:-2] else: first_message = first_message[:-1] return first...
[ "def", "extract_first_part", "(", "message", ",", "boundary", ")", ":", "first_message", "=", "message", ".", "split", "(", "boundary", ")", "[", "1", "]", ".", "lstrip", "(", ")", "if", "first_message", ".", "endswith", "(", "b'\\r\\n'", ")", ":", "firs...
Function to extract the first part of a multipart message
[ "Function", "to", "extract", "the", "first", "part", "of", "a", "multipart", "message" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/utils.py#L92-L99
52,730
abhishek-ram/pyas2-lib
pyas2lib/utils.py
pem_to_der
def pem_to_der(cert, return_multiple=True): """ Converts a given certificate or list to PEM format""" # initialize the certificate array cert_list = [] # If certificate is in DER then un-armour it if pem.detect(cert): for _, _, der_bytes in pem.unarmor(cert, multiple=True): cer...
python
def pem_to_der(cert, return_multiple=True): """ Converts a given certificate or list to PEM format""" # initialize the certificate array cert_list = [] # If certificate is in DER then un-armour it if pem.detect(cert): for _, _, der_bytes in pem.unarmor(cert, multiple=True): cer...
[ "def", "pem_to_der", "(", "cert", ",", "return_multiple", "=", "True", ")", ":", "# initialize the certificate array", "cert_list", "=", "[", "]", "# If certificate is in DER then un-armour it", "if", "pem", ".", "detect", "(", "cert", ")", ":", "for", "_", ",", ...
Converts a given certificate or list to PEM format
[ "Converts", "a", "given", "certificate", "or", "list", "to", "PEM", "format" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/utils.py#L102-L119
52,731
abhishek-ram/pyas2-lib
pyas2lib/utils.py
verify_certificate_chain
def verify_certificate_chain(cert_str, trusted_certs, ignore_self_signed=True): """ Verify a given certificate against a trust store""" # Load the certificate certificate = crypto.load_certificate(crypto.FILETYPE_ASN1, cert_str) # Create a certificate store and add your trusted certs try: ...
python
def verify_certificate_chain(cert_str, trusted_certs, ignore_self_signed=True): """ Verify a given certificate against a trust store""" # Load the certificate certificate = crypto.load_certificate(crypto.FILETYPE_ASN1, cert_str) # Create a certificate store and add your trusted certs try: ...
[ "def", "verify_certificate_chain", "(", "cert_str", ",", "trusted_certs", ",", "ignore_self_signed", "=", "True", ")", ":", "# Load the certificate", "certificate", "=", "crypto", ".", "load_certificate", "(", "crypto", ".", "FILETYPE_ASN1", ",", "cert_str", ")", "#...
Verify a given certificate against a trust store
[ "Verify", "a", "given", "certificate", "against", "a", "trust", "store" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/utils.py#L148-L175
52,732
lpomfrey/django-debreach
debreach/context_processors.py
csrf
def csrf(request): """ Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if it has not been provided by either a view decorator or the middleware """ def _get_val(): token = get_token(request) if token is None: # In order to be able to provide debu...
python
def csrf(request): """ Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if it has not been provided by either a view decorator or the middleware """ def _get_val(): token = get_token(request) if token is None: # In order to be able to provide debu...
[ "def", "csrf", "(", "request", ")", ":", "def", "_get_val", "(", ")", ":", "token", "=", "get_token", "(", "request", ")", "if", "token", "is", "None", ":", "# In order to be able to provide debugging info in the", "# case of misconfiguration, we use a sentinel value", ...
Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if it has not been provided by either a view decorator or the middleware
[ "Context", "processor", "that", "provides", "a", "CSRF", "token", "or", "the", "string", "NOTPROVIDED", "if", "it", "has", "not", "been", "provided", "by", "either", "a", "view", "decorator", "or", "the", "middleware" ]
b425bb719ea5de583fae7db5b7419e5fed569cb0
https://github.com/lpomfrey/django-debreach/blob/b425bb719ea5de583fae7db5b7419e5fed569cb0/debreach/context_processors.py#L14-L36
52,733
taskcluster/taskcluster-lib-urls
taskcluster_urls/__init__.py
api
def api(root_url, service, version, path): """Generate URL for path in a Taskcluster service.""" root_url = root_url.rstrip('/') path = path.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://{}.taskcluster.net/{}/{}'.format(service, version, path) else: return '{}/api/{}/{}/{}...
python
def api(root_url, service, version, path): """Generate URL for path in a Taskcluster service.""" root_url = root_url.rstrip('/') path = path.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://{}.taskcluster.net/{}/{}'.format(service, version, path) else: return '{}/api/{}/{}/{}...
[ "def", "api", "(", "root_url", ",", "service", ",", "version", ",", "path", ")", ":", "root_url", "=", "root_url", ".", "rstrip", "(", "'/'", ")", "path", "=", "path", ".", "lstrip", "(", "'/'", ")", "if", "root_url", "==", "OLD_ROOT_URL", ":", "retu...
Generate URL for path in a Taskcluster service.
[ "Generate", "URL", "for", "path", "in", "a", "Taskcluster", "service", "." ]
998aee4b8cd7fcbd9c02de16b3849391431e3c9b
https://github.com/taskcluster/taskcluster-lib-urls/blob/998aee4b8cd7fcbd9c02de16b3849391431e3c9b/taskcluster_urls/__init__.py#L3-L10
52,734
taskcluster/taskcluster-lib-urls
taskcluster_urls/__init__.py
api_reference
def api_reference(root_url, service, version): """Generate URL for a Taskcluster api reference.""" root_url = root_url.rstrip('/') if root_url == OLD_ROOT_URL: return 'https://references.taskcluster.net/{}/{}/api.json'.format(service, version) else: return '{}/references/{}/{}/api.json'....
python
def api_reference(root_url, service, version): """Generate URL for a Taskcluster api reference.""" root_url = root_url.rstrip('/') if root_url == OLD_ROOT_URL: return 'https://references.taskcluster.net/{}/{}/api.json'.format(service, version) else: return '{}/references/{}/{}/api.json'....
[ "def", "api_reference", "(", "root_url", ",", "service", ",", "version", ")", ":", "root_url", "=", "root_url", ".", "rstrip", "(", "'/'", ")", "if", "root_url", "==", "OLD_ROOT_URL", ":", "return", "'https://references.taskcluster.net/{}/{}/api.json'", ".", "form...
Generate URL for a Taskcluster api reference.
[ "Generate", "URL", "for", "a", "Taskcluster", "api", "reference", "." ]
998aee4b8cd7fcbd9c02de16b3849391431e3c9b
https://github.com/taskcluster/taskcluster-lib-urls/blob/998aee4b8cd7fcbd9c02de16b3849391431e3c9b/taskcluster_urls/__init__.py#L12-L18
52,735
taskcluster/taskcluster-lib-urls
taskcluster_urls/__init__.py
docs
def docs(root_url, path): """Generate URL for path in the Taskcluster docs.""" root_url = root_url.rstrip('/') path = path.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://docs.taskcluster.net/{}'.format(path) else: return '{}/docs/{}'.format(root_url, path)
python
def docs(root_url, path): """Generate URL for path in the Taskcluster docs.""" root_url = root_url.rstrip('/') path = path.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://docs.taskcluster.net/{}'.format(path) else: return '{}/docs/{}'.format(root_url, path)
[ "def", "docs", "(", "root_url", ",", "path", ")", ":", "root_url", "=", "root_url", ".", "rstrip", "(", "'/'", ")", "path", "=", "path", ".", "lstrip", "(", "'/'", ")", "if", "root_url", "==", "OLD_ROOT_URL", ":", "return", "'https://docs.taskcluster.net/{...
Generate URL for path in the Taskcluster docs.
[ "Generate", "URL", "for", "path", "in", "the", "Taskcluster", "docs", "." ]
998aee4b8cd7fcbd9c02de16b3849391431e3c9b
https://github.com/taskcluster/taskcluster-lib-urls/blob/998aee4b8cd7fcbd9c02de16b3849391431e3c9b/taskcluster_urls/__init__.py#L20-L27
52,736
taskcluster/taskcluster-lib-urls
taskcluster_urls/__init__.py
exchange_reference
def exchange_reference(root_url, service, version): """Generate URL for a Taskcluster exchange reference.""" root_url = root_url.rstrip('/') if root_url == OLD_ROOT_URL: return 'https://references.taskcluster.net/{}/{}/exchanges.json'.format(service, version) else: return '{}/references/...
python
def exchange_reference(root_url, service, version): """Generate URL for a Taskcluster exchange reference.""" root_url = root_url.rstrip('/') if root_url == OLD_ROOT_URL: return 'https://references.taskcluster.net/{}/{}/exchanges.json'.format(service, version) else: return '{}/references/...
[ "def", "exchange_reference", "(", "root_url", ",", "service", ",", "version", ")", ":", "root_url", "=", "root_url", ".", "rstrip", "(", "'/'", ")", "if", "root_url", "==", "OLD_ROOT_URL", ":", "return", "'https://references.taskcluster.net/{}/{}/exchanges.json'", "...
Generate URL for a Taskcluster exchange reference.
[ "Generate", "URL", "for", "a", "Taskcluster", "exchange", "reference", "." ]
998aee4b8cd7fcbd9c02de16b3849391431e3c9b
https://github.com/taskcluster/taskcluster-lib-urls/blob/998aee4b8cd7fcbd9c02de16b3849391431e3c9b/taskcluster_urls/__init__.py#L29-L35
52,737
taskcluster/taskcluster-lib-urls
taskcluster_urls/__init__.py
schema
def schema(root_url, service, name): """Generate URL for a schema in a Taskcluster service.""" root_url = root_url.rstrip('/') name = name.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://schemas.taskcluster.net/{}/{}'.format(service, name) else: return '{}/schemas/{}/{}'.for...
python
def schema(root_url, service, name): """Generate URL for a schema in a Taskcluster service.""" root_url = root_url.rstrip('/') name = name.lstrip('/') if root_url == OLD_ROOT_URL: return 'https://schemas.taskcluster.net/{}/{}'.format(service, name) else: return '{}/schemas/{}/{}'.for...
[ "def", "schema", "(", "root_url", ",", "service", ",", "name", ")", ":", "root_url", "=", "root_url", ".", "rstrip", "(", "'/'", ")", "name", "=", "name", ".", "lstrip", "(", "'/'", ")", "if", "root_url", "==", "OLD_ROOT_URL", ":", "return", "'https://...
Generate URL for a schema in a Taskcluster service.
[ "Generate", "URL", "for", "a", "schema", "in", "a", "Taskcluster", "service", "." ]
998aee4b8cd7fcbd9c02de16b3849391431e3c9b
https://github.com/taskcluster/taskcluster-lib-urls/blob/998aee4b8cd7fcbd9c02de16b3849391431e3c9b/taskcluster_urls/__init__.py#L37-L44
52,738
ionelmc/python-fields
src/fields/extras.py
regex_validation_sealer
def regex_validation_sealer(fields, defaults, RegexType=type(re.compile(""))): """ Example sealer that just does regex-based validation. """ required = set(fields) - set(defaults) if required: raise TypeError( "regex_validation_sealer doesn't support required arguments. Fields th...
python
def regex_validation_sealer(fields, defaults, RegexType=type(re.compile(""))): """ Example sealer that just does regex-based validation. """ required = set(fields) - set(defaults) if required: raise TypeError( "regex_validation_sealer doesn't support required arguments. Fields th...
[ "def", "regex_validation_sealer", "(", "fields", ",", "defaults", ",", "RegexType", "=", "type", "(", "re", ".", "compile", "(", "\"\"", ")", ")", ")", ":", "required", "=", "set", "(", "fields", ")", "-", "set", "(", "defaults", ")", "if", "required",...
Example sealer that just does regex-based validation.
[ "Example", "sealer", "that", "just", "does", "regex", "-", "based", "validation", "." ]
91e13560173abcc42cc1a95cbe2956b307126416
https://github.com/ionelmc/python-fields/blob/91e13560173abcc42cc1a95cbe2956b307126416/src/fields/extras.py#L12-L47
52,739
gpagliuca/pyfas
build/lib/pyfas/pilink.py
PI_read
def PI_read(server, tag, start=None, end=None, frequency=None): """ Read function for PI server. It has to be executed by python 32 bit. """ pisdk = Dispatch('PISDK.PISDK') my_server = pisdk.Servers(server) # Not sure if/when the login is necessary #con = Dispatch('PISDKDlg.Connections') ...
python
def PI_read(server, tag, start=None, end=None, frequency=None): """ Read function for PI server. It has to be executed by python 32 bit. """ pisdk = Dispatch('PISDK.PISDK') my_server = pisdk.Servers(server) # Not sure if/when the login is necessary #con = Dispatch('PISDKDlg.Connections') ...
[ "def", "PI_read", "(", "server", ",", "tag", ",", "start", "=", "None", ",", "end", "=", "None", ",", "frequency", "=", "None", ")", ":", "pisdk", "=", "Dispatch", "(", "'PISDK.PISDK'", ")", "my_server", "=", "pisdk", ".", "Servers", "(", "server", "...
Read function for PI server. It has to be executed by python 32 bit.
[ "Read", "function", "for", "PI", "server", ".", "It", "has", "to", "be", "executed", "by", "python", "32", "bit", "." ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/pilink.py#L6-L40
52,740
gpagliuca/pyfas
build/lib/pyfas/usc.py
unisim_csv_formatting
def unisim_csv_formatting(path, fname): """ Remove some useless stuff from the head of a csv file generated by unisim and returns a pandas dataframe """ with open(path+fname, 'r') as fobj: data = fobj.readlines() header = data[9].split(",")[:-1] unit_of_measures = data[10].sp...
python
def unisim_csv_formatting(path, fname): """ Remove some useless stuff from the head of a csv file generated by unisim and returns a pandas dataframe """ with open(path+fname, 'r') as fobj: data = fobj.readlines() header = data[9].split(",")[:-1] unit_of_measures = data[10].sp...
[ "def", "unisim_csv_formatting", "(", "path", ",", "fname", ")", ":", "with", "open", "(", "path", "+", "fname", ",", "'r'", ")", "as", "fobj", ":", "data", "=", "fobj", ".", "readlines", "(", ")", "header", "=", "data", "[", "9", "]", ".", "split",...
Remove some useless stuff from the head of a csv file generated by unisim and returns a pandas dataframe
[ "Remove", "some", "useless", "stuff", "from", "the", "head", "of", "a", "csv", "file", "generated", "by", "unisim", "and", "returns", "a", "pandas", "dataframe" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L37-L54
52,741
gpagliuca/pyfas
build/lib/pyfas/usc.py
Usc.extract_stripchart
def extract_stripchart(self, stripchart='overall', expose_data=True): """ Extract a specific stripchard and exposes the data in the namespace """ csv_fname = self.fname.split(os.sep)[-1].replace(".usc", ".csv") scp_fname = self.fname.split(os.sep)[-1].replace(".usc", ".SCP") ...
python
def extract_stripchart(self, stripchart='overall', expose_data=True): """ Extract a specific stripchard and exposes the data in the namespace """ csv_fname = self.fname.split(os.sep)[-1].replace(".usc", ".csv") scp_fname = self.fname.split(os.sep)[-1].replace(".usc", ".SCP") ...
[ "def", "extract_stripchart", "(", "self", ",", "stripchart", "=", "'overall'", ",", "expose_data", "=", "True", ")", ":", "csv_fname", "=", "self", ".", "fname", ".", "split", "(", "os", ".", "sep", ")", "[", "-", "1", "]", ".", "replace", "(", "\".u...
Extract a specific stripchard and exposes the data in the namespace
[ "Extract", "a", "specific", "stripchard", "and", "exposes", "the", "data", "in", "the", "namespace" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L76-L99
52,742
gpagliuca/pyfas
build/lib/pyfas/usc.py
Usc.extract_profiles
def extract_profiles(self, pipeline_name, expose_data=True): """ Extract all the profiles of a specific pipeline and exposes the data in the namespace """ compas_pipe = self.__profile_definition(pipeline_name) get_variable = compas_pipe.GEtUserVariable if os.path....
python
def extract_profiles(self, pipeline_name, expose_data=True): """ Extract all the profiles of a specific pipeline and exposes the data in the namespace """ compas_pipe = self.__profile_definition(pipeline_name) get_variable = compas_pipe.GEtUserVariable if os.path....
[ "def", "extract_profiles", "(", "self", ",", "pipeline_name", ",", "expose_data", "=", "True", ")", ":", "compas_pipe", "=", "self", ".", "__profile_definition", "(", "pipeline_name", ")", "get_variable", "=", "compas_pipe", ".", "GEtUserVariable", "if", "os", "...
Extract all the profiles of a specific pipeline and exposes the data in the namespace
[ "Extract", "all", "the", "profiles", "of", "a", "specific", "pipeline", "and", "exposes", "the", "data", "in", "the", "namespace" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L101-L124
52,743
gpagliuca/pyfas
build/lib/pyfas/usc.py
Usc.__profile_definition
def __profile_definition(self, pipeline_name): """ Prepare the profiles extraction from a specific profile """ pipe = self.flsh.Operations[pipeline_name] x_st = pipe.GetUserVariable(PROFILE_LENGTH_ST).Variable() x_non_st = pipe.GetUserVariable(PROFILE_LENGTH_NON_ST).Varia...
python
def __profile_definition(self, pipeline_name): """ Prepare the profiles extraction from a specific profile """ pipe = self.flsh.Operations[pipeline_name] x_st = pipe.GetUserVariable(PROFILE_LENGTH_ST).Variable() x_non_st = pipe.GetUserVariable(PROFILE_LENGTH_NON_ST).Varia...
[ "def", "__profile_definition", "(", "self", ",", "pipeline_name", ")", ":", "pipe", "=", "self", ".", "flsh", ".", "Operations", "[", "pipeline_name", "]", "x_st", "=", "pipe", ".", "GetUserVariable", "(", "PROFILE_LENGTH_ST", ")", ".", "Variable", "(", ")",...
Prepare the profiles extraction from a specific profile
[ "Prepare", "the", "profiles", "extraction", "from", "a", "specific", "profile" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L126-L139
52,744
gpagliuca/pyfas
build/lib/pyfas/usc.py
Usc.run_until
def run_until(self, endtime, timeunit='minutes', save=True): """ Run a case untile the specifiend endtime """ integrator = self.case.solver.Integrator integrator.rununtil(endtime, timeunit) if save is True: self.case.save()
python
def run_until(self, endtime, timeunit='minutes', save=True): """ Run a case untile the specifiend endtime """ integrator = self.case.solver.Integrator integrator.rununtil(endtime, timeunit) if save is True: self.case.save()
[ "def", "run_until", "(", "self", ",", "endtime", ",", "timeunit", "=", "'minutes'", ",", "save", "=", "True", ")", ":", "integrator", "=", "self", ".", "case", ".", "solver", ".", "Integrator", "integrator", ".", "rununtil", "(", "endtime", ",", "timeuni...
Run a case untile the specifiend endtime
[ "Run", "a", "case", "untile", "the", "specifiend", "endtime" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L141-L148
52,745
gpagliuca/pyfas
build/lib/pyfas/usc.py
Usc.save
def save(self, fname=''): """ Save the current case """ if fname is '': self.case.save() else: self.case.SaveAs(self.path+os.sep+fname)
python
def save(self, fname=''): """ Save the current case """ if fname is '': self.case.save() else: self.case.SaveAs(self.path+os.sep+fname)
[ "def", "save", "(", "self", ",", "fname", "=", "''", ")", ":", "if", "fname", "is", "''", ":", "self", ".", "case", ".", "save", "(", ")", "else", ":", "self", ".", "case", ".", "SaveAs", "(", "self", ".", "path", "+", "os", ".", "sep", "+", ...
Save the current case
[ "Save", "the", "current", "case" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/usc.py#L150-L157
52,746
ionelmc/python-fields
src/fields/__init__.py
tuple_sealer
def tuple_sealer(fields, defaults): """ This sealer returns an equivalent of a ``namedtuple``. """ baseclass_name = 'FieldsBase_for__{0}'.format('__'.join(fields)) global_namespace, local_namespace = make_init_func( fields, defaults, baseclass_name, header_name='__new__', hea...
python
def tuple_sealer(fields, defaults): """ This sealer returns an equivalent of a ``namedtuple``. """ baseclass_name = 'FieldsBase_for__{0}'.format('__'.join(fields)) global_namespace, local_namespace = make_init_func( fields, defaults, baseclass_name, header_name='__new__', hea...
[ "def", "tuple_sealer", "(", "fields", ",", "defaults", ")", ":", "baseclass_name", "=", "'FieldsBase_for__{0}'", ".", "format", "(", "'__'", ".", "join", "(", "fields", ")", ")", "global_namespace", ",", "local_namespace", "=", "make_init_func", "(", "fields", ...
This sealer returns an equivalent of a ``namedtuple``.
[ "This", "sealer", "returns", "an", "equivalent", "of", "a", "namedtuple", "." ]
91e13560173abcc42cc1a95cbe2956b307126416
https://github.com/ionelmc/python-fields/blob/91e13560173abcc42cc1a95cbe2956b307126416/src/fields/__init__.py#L225-L255
52,747
gpagliuca/pyfas
build/lib/pyfas/tpl.py
Tpl.filter_trends
def filter_trends(self, pattern=''): """ Filter available trends """ filtered_trends = {} with open(self.abspath) as fobj: for idx, line in enumerate(fobj): variable_idx = idx-self._attributes['CATALOG']-1 if 'TIME SERIES' in li...
python
def filter_trends(self, pattern=''): """ Filter available trends """ filtered_trends = {} with open(self.abspath) as fobj: for idx, line in enumerate(fobj): variable_idx = idx-self._attributes['CATALOG']-1 if 'TIME SERIES' in li...
[ "def", "filter_trends", "(", "self", ",", "pattern", "=", "''", ")", ":", "filtered_trends", "=", "{", "}", "with", "open", "(", "self", ".", "abspath", ")", "as", "fobj", ":", "for", "idx", ",", "line", "in", "enumerate", "(", "fobj", ")", ":", "v...
Filter available trends
[ "Filter", "available", "trends" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tpl.py#L46-L58
52,748
gpagliuca/pyfas
build/lib/pyfas/tpl.py
Tpl.extract
def extract(self, *args): """ Extract a specific variable """ self.time = np.loadtxt(self.abspath, skiprows=self._attributes['data_idx']+1, unpack=True, usecols=(0,)) for variable_idx in args: data ...
python
def extract(self, *args): """ Extract a specific variable """ self.time = np.loadtxt(self.abspath, skiprows=self._attributes['data_idx']+1, unpack=True, usecols=(0,)) for variable_idx in args: data ...
[ "def", "extract", "(", "self", ",", "*", "args", ")", ":", "self", ".", "time", "=", "np", ".", "loadtxt", "(", "self", ".", "abspath", ",", "skiprows", "=", "self", ".", "_attributes", "[", "'data_idx'", "]", "+", "1", ",", "unpack", "=", "True", ...
Extract a specific variable
[ "Extract", "a", "specific", "variable" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tpl.py#L60-L82
52,749
gpagliuca/pyfas
build/lib/pyfas/tpl.py
Tpl.view_trends
def view_trends(self, pattern=''): """ Return a pandas df with the available trends """ d = OrderedDict() d['Index'] = None d['Variable'] = [] d['Position'] = [] d['Unit'] = [] d['Description'] = [] raw_d = self.filter_trends(patt...
python
def view_trends(self, pattern=''): """ Return a pandas df with the available trends """ d = OrderedDict() d['Index'] = None d['Variable'] = [] d['Position'] = [] d['Unit'] = [] d['Description'] = [] raw_d = self.filter_trends(patt...
[ "def", "view_trends", "(", "self", ",", "pattern", "=", "''", ")", ":", "d", "=", "OrderedDict", "(", ")", "d", "[", "'Index'", "]", "=", "None", "d", "[", "'Variable'", "]", "=", "[", "]", "d", "[", "'Position'", "]", "=", "[", "]", "d", "[", ...
Return a pandas df with the available trends
[ "Return", "a", "pandas", "df", "with", "the", "available", "trends" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tpl.py#L84-L106
52,750
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab._tab_type
def _tab_type(self): """ Private method to define the tab type """ with open(self.abspath) as fobj: contents = fobj.readlines() for line in contents: if 'COMPONENTS' in line: return 'keyword' else: ...
python
def _tab_type(self): """ Private method to define the tab type """ with open(self.abspath) as fobj: contents = fobj.readlines() for line in contents: if 'COMPONENTS' in line: return 'keyword' else: ...
[ "def", "_tab_type", "(", "self", ")", ":", "with", "open", "(", "self", ".", "abspath", ")", "as", "fobj", ":", "contents", "=", "fobj", ".", "readlines", "(", ")", "for", "line", "in", "contents", ":", "if", "'COMPONENTS'", "in", "line", ":", "retur...
Private method to define the tab type
[ "Private", "method", "to", "define", "the", "tab", "type" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L32-L42
52,751
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab._partial_extraction_fixed
def _partial_extraction_fixed(self, idx, extra_idx=0): """ Private method for a single extraction on a fixed-type tab file """ myarray = np.array([]) with open(self.abspath) as fobj: contents = fobj.readlines()[idx+extra_idx:] for line in contents: ...
python
def _partial_extraction_fixed(self, idx, extra_idx=0): """ Private method for a single extraction on a fixed-type tab file """ myarray = np.array([]) with open(self.abspath) as fobj: contents = fobj.readlines()[idx+extra_idx:] for line in contents: ...
[ "def", "_partial_extraction_fixed", "(", "self", ",", "idx", ",", "extra_idx", "=", "0", ")", ":", "myarray", "=", "np", ".", "array", "(", "[", "]", ")", "with", "open", "(", "self", ".", "abspath", ")", "as", "fobj", ":", "contents", "=", "fobj", ...
Private method for a single extraction on a fixed-type tab file
[ "Private", "method", "for", "a", "single", "extraction", "on", "a", "fixed", "-", "type", "tab", "file" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L117-L132
52,752
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab._export_all_fixed
def _export_all_fixed(self): """ Exports all the properties for a fixed-type tab file """ array_ts = [] array_ps = [] for array_t, array_p in it.product(self.metadata["t_array"][0], self.metadata["p_array"][0]): ...
python
def _export_all_fixed(self): """ Exports all the properties for a fixed-type tab file """ array_ts = [] array_ps = [] for array_t, array_p in it.product(self.metadata["t_array"][0], self.metadata["p_array"][0]): ...
[ "def", "_export_all_fixed", "(", "self", ")", ":", "array_ts", "=", "[", "]", "array_ps", "=", "[", "]", "for", "array_t", ",", "array_p", "in", "it", ".", "product", "(", "self", ".", "metadata", "[", "\"t_array\"", "]", "[", "0", "]", ",", "self", ...
Exports all the properties for a fixed-type tab file
[ "Exports", "all", "the", "properties", "for", "a", "fixed", "-", "type", "tab", "file" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L134-L152
52,753
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab._metadata_keyword
def _metadata_keyword(self): """ Define the most important tab parameters for a keyword-type tab file """ with open(self.abspath) as fobj: for line in fobj: if 'PVTTABLE LABEL' in line: label = re.findall(r"\=[\w\ \"]*\,", line)[0][1...
python
def _metadata_keyword(self): """ Define the most important tab parameters for a keyword-type tab file """ with open(self.abspath) as fobj: for line in fobj: if 'PVTTABLE LABEL' in line: label = re.findall(r"\=[\w\ \"]*\,", line)[0][1...
[ "def", "_metadata_keyword", "(", "self", ")", ":", "with", "open", "(", "self", ".", "abspath", ")", "as", "fobj", ":", "for", "line", "in", "fobj", ":", "if", "'PVTTABLE LABEL'", "in", "line", ":", "label", "=", "re", ".", "findall", "(", "r\"\\=[\\w\...
Define the most important tab parameters for a keyword-type tab file
[ "Define", "the", "most", "important", "tab", "parameters", "for", "a", "keyword", "-", "type", "tab", "file" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L154-L181
52,754
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab._export_all_keyword
def _export_all_keyword(self): """ Export method for keyword tab files """ data = {} for fluid_idx, fluid in enumerate(self.metadata["fluids"]): data[fluid] = {} with open(self.abspath) as fobj: text = fobj.read() t...
python
def _export_all_keyword(self): """ Export method for keyword tab files """ data = {} for fluid_idx, fluid in enumerate(self.metadata["fluids"]): data[fluid] = {} with open(self.abspath) as fobj: text = fobj.read() t...
[ "def", "_export_all_keyword", "(", "self", ")", ":", "data", "=", "{", "}", "for", "fluid_idx", ",", "fluid", "in", "enumerate", "(", "self", ".", "metadata", "[", "\"fluids\"", "]", ")", ":", "data", "[", "fluid", "]", "=", "{", "}", "with", "open",...
Export method for keyword tab files
[ "Export", "method", "for", "keyword", "tab", "files" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L183-L204
52,755
gpagliuca/pyfas
build/lib/pyfas/tab.py
Tab.export_all
def export_all(self): """ It makes all the properties avaiable as data attribute """ if self.tab_type == 'fixed': self._export_all_fixed() if self.tab_type == 'keyword': self._export_all_keyword()
python
def export_all(self): """ It makes all the properties avaiable as data attribute """ if self.tab_type == 'fixed': self._export_all_fixed() if self.tab_type == 'keyword': self._export_all_keyword()
[ "def", "export_all", "(", "self", ")", ":", "if", "self", ".", "tab_type", "==", "'fixed'", ":", "self", ".", "_export_all_fixed", "(", ")", "if", "self", ".", "tab_type", "==", "'keyword'", ":", "self", ".", "_export_all_keyword", "(", ")" ]
It makes all the properties avaiable as data attribute
[ "It", "makes", "all", "the", "properties", "avaiable", "as", "data", "attribute" ]
5daa1199bd124d315d02bef0ad3888a8f58355b2
https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L206-L213
52,756
flammified/terrabot
terrabot/client.py
Client.read_packets
def read_packets(self): """Read packets from the socket and parse them""" while self.running: packet_length = self.client.recv(2) if len(packet_length) < 2: self.stop() continue packet_length = struct.unpack("<h", packet_length)[0] - 2 ...
python
def read_packets(self): """Read packets from the socket and parse them""" while self.running: packet_length = self.client.recv(2) if len(packet_length) < 2: self.stop() continue packet_length = struct.unpack("<h", packet_length)[0] - 2 ...
[ "def", "read_packets", "(", "self", ")", ":", "while", "self", ".", "running", ":", "packet_length", "=", "self", ".", "client", ".", "recv", "(", "2", ")", "if", "len", "(", "packet_length", ")", "<", "2", ":", "self", ".", "stop", "(", ")", "cont...
Read packets from the socket and parse them
[ "Read", "packets", "from", "the", "socket", "and", "parse", "them" ]
14372aa2e1ed441ef4af5d0dc4ea465b2278af86
https://github.com/flammified/terrabot/blob/14372aa2e1ed441ef4af5d0dc4ea465b2278af86/terrabot/client.py#L34-L55
52,757
flammified/terrabot
terrabot/client.py
Client.write_packets
def write_packets(self): """Write packets from the queue""" while self.running: if len(self.write_queue) > 0: self.write_queue[0].send(self.client) self.write_queue.pop(0)
python
def write_packets(self): """Write packets from the queue""" while self.running: if len(self.write_queue) > 0: self.write_queue[0].send(self.client) self.write_queue.pop(0)
[ "def", "write_packets", "(", "self", ")", ":", "while", "self", ".", "running", ":", "if", "len", "(", "self", ".", "write_queue", ")", ">", "0", ":", "self", ".", "write_queue", "[", "0", "]", ".", "send", "(", "self", ".", "client", ")", "self", ...
Write packets from the queue
[ "Write", "packets", "from", "the", "queue" ]
14372aa2e1ed441ef4af5d0dc4ea465b2278af86
https://github.com/flammified/terrabot/blob/14372aa2e1ed441ef4af5d0dc4ea465b2278af86/terrabot/client.py#L57-L62
52,758
flammified/terrabot
terrabot/client.py
Client.start
def start(self): """Open sockets to the server and start threads""" if not self.writeThread.isAlive() and not self.readThread.isAlive(): self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client.connect(self.ADDR) self.running = True self...
python
def start(self): """Open sockets to the server and start threads""" if not self.writeThread.isAlive() and not self.readThread.isAlive(): self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client.connect(self.ADDR) self.running = True self...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "writeThread", ".", "isAlive", "(", ")", "and", "not", "self", ".", "readThread", ".", "isAlive", "(", ")", ":", "self", ".", "client", "=", "socket", ".", "socket", "(", "socket", "....
Open sockets to the server and start threads
[ "Open", "sockets", "to", "the", "server", "and", "start", "threads" ]
14372aa2e1ed441ef4af5d0dc4ea465b2278af86
https://github.com/flammified/terrabot/blob/14372aa2e1ed441ef4af5d0dc4ea465b2278af86/terrabot/client.py#L64-L71
52,759
zeldamods/aamp
aamp/parameters.py
ParameterObject.set_param
def set_param(self, name: str, v) -> None: """Add or update an existing parameter.""" self.params[zlib.crc32(name.encode())] = v
python
def set_param(self, name: str, v) -> None: """Add or update an existing parameter.""" self.params[zlib.crc32(name.encode())] = v
[ "def", "set_param", "(", "self", ",", "name", ":", "str", ",", "v", ")", "->", "None", ":", "self", ".", "params", "[", "zlib", ".", "crc32", "(", "name", ".", "encode", "(", ")", ")", "]", "=", "v" ]
Add or update an existing parameter.
[ "Add", "or", "update", "an", "existing", "parameter", "." ]
90d722d33357af5af9809a3fc83b9ceaecf943c1
https://github.com/zeldamods/aamp/blob/90d722d33357af5af9809a3fc83b9ceaecf943c1/aamp/parameters.py#L40-L42
52,760
zeldamods/aamp
aamp/parameters.py
ParameterList.set_object
def set_object(self, name: str, pobj: ParameterObject) -> None: """Add or update an existing object.""" self.objects[zlib.crc32(name.encode())] = pobj
python
def set_object(self, name: str, pobj: ParameterObject) -> None: """Add or update an existing object.""" self.objects[zlib.crc32(name.encode())] = pobj
[ "def", "set_object", "(", "self", ",", "name", ":", "str", ",", "pobj", ":", "ParameterObject", ")", "->", "None", ":", "self", ".", "objects", "[", "zlib", ".", "crc32", "(", "name", ".", "encode", "(", ")", ")", "]", "=", "pobj" ]
Add or update an existing object.
[ "Add", "or", "update", "an", "existing", "object", "." ]
90d722d33357af5af9809a3fc83b9ceaecf943c1
https://github.com/zeldamods/aamp/blob/90d722d33357af5af9809a3fc83b9ceaecf943c1/aamp/parameters.py#L60-L62
52,761
zeldamods/aamp
aamp/parameters.py
ParameterList.set_list
def set_list(self, name: str, plist) -> None: """Add or update an existing list.""" self.lists[zlib.crc32(name.encode())] = plist
python
def set_list(self, name: str, plist) -> None: """Add or update an existing list.""" self.lists[zlib.crc32(name.encode())] = plist
[ "def", "set_list", "(", "self", ",", "name", ":", "str", ",", "plist", ")", "->", "None", ":", "self", ".", "lists", "[", "zlib", ".", "crc32", "(", "name", ".", "encode", "(", ")", ")", "]", "=", "plist" ]
Add or update an existing list.
[ "Add", "or", "update", "an", "existing", "list", "." ]
90d722d33357af5af9809a3fc83b9ceaecf943c1
https://github.com/zeldamods/aamp/blob/90d722d33357af5af9809a3fc83b9ceaecf943c1/aamp/parameters.py#L64-L66
52,762
dancsalo/TensorBase
tensorbase/base.py
Data.queue_setup
def queue_setup(filename, mode, batch_size, num_readers, min_examples): """ Sets up the queue runners for data input """ filename_queue = tf.train.string_input_producer([filename], shuffle=True, capacity=16) if mode == "train": examples_queue = tf.RandomShuffleQueue(capacity=min_exam...
python
def queue_setup(filename, mode, batch_size, num_readers, min_examples): """ Sets up the queue runners for data input """ filename_queue = tf.train.string_input_producer([filename], shuffle=True, capacity=16) if mode == "train": examples_queue = tf.RandomShuffleQueue(capacity=min_exam...
[ "def", "queue_setup", "(", "filename", ",", "mode", ",", "batch_size", ",", "num_readers", ",", "min_examples", ")", ":", "filename_queue", "=", "tf", ".", "train", ".", "string_input_producer", "(", "[", "filename", "]", ",", "shuffle", "=", "True", ",", ...
Sets up the queue runners for data input
[ "Sets", "up", "the", "queue", "runners", "for", "data", "input" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L152-L167
52,763
dancsalo/TensorBase
tensorbase/base.py
Data.thread_setup
def thread_setup(read_and_decode_fn, example_serialized, num_threads): """ Sets up the threads within each reader """ decoded_data = list() for _ in range(num_threads): decoded_data.append(read_and_decode_fn(example_serialized)) return decoded_data
python
def thread_setup(read_and_decode_fn, example_serialized, num_threads): """ Sets up the threads within each reader """ decoded_data = list() for _ in range(num_threads): decoded_data.append(read_and_decode_fn(example_serialized)) return decoded_data
[ "def", "thread_setup", "(", "read_and_decode_fn", ",", "example_serialized", ",", "num_threads", ")", ":", "decoded_data", "=", "list", "(", ")", "for", "_", "in", "range", "(", "num_threads", ")", ":", "decoded_data", ".", "append", "(", "read_and_decode_fn", ...
Sets up the threads within each reader
[ "Sets", "up", "the", "threads", "within", "each", "reader" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L170-L175
52,764
dancsalo/TensorBase
tensorbase/base.py
Data.init_threads
def init_threads(tf_session): """ Starts threads running """ coord = tf.train.Coordinator() threads = list() for qr in tf.get_collection(tf.GraphKeys.QUEUE_RUNNERS): threads.extend(qr.create_threads(tf_session, coord=coord, daemon=True, start=True)) return threads, co...
python
def init_threads(tf_session): """ Starts threads running """ coord = tf.train.Coordinator() threads = list() for qr in tf.get_collection(tf.GraphKeys.QUEUE_RUNNERS): threads.extend(qr.create_threads(tf_session, coord=coord, daemon=True, start=True)) return threads, co...
[ "def", "init_threads", "(", "tf_session", ")", ":", "coord", "=", "tf", ".", "train", ".", "Coordinator", "(", ")", "threads", "=", "list", "(", ")", "for", "qr", "in", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "QUEUE_RUNNERS", ")"...
Starts threads running
[ "Starts", "threads", "running" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L178-L184
52,765
dancsalo/TensorBase
tensorbase/base.py
Model.load_config_yaml
def load_config_yaml(self, flags, config_dict): """ Load config dict and yaml dict and then override both with flags dict. """ if config_dict is None: print('Config File not specified. Using only input flags.') return flags try: config_yaml_dict = self.cfg_fro...
python
def load_config_yaml(self, flags, config_dict): """ Load config dict and yaml dict and then override both with flags dict. """ if config_dict is None: print('Config File not specified. Using only input flags.') return flags try: config_yaml_dict = self.cfg_fro...
[ "def", "load_config_yaml", "(", "self", ",", "flags", ",", "config_dict", ")", ":", "if", "config_dict", "is", "None", ":", "print", "(", "'Config File not specified. Using only input flags.'", ")", "return", "flags", "try", ":", "config_yaml_dict", "=", "self", "...
Load config dict and yaml dict and then override both with flags dict.
[ "Load", "config", "dict", "and", "yaml", "dict", "and", "then", "override", "both", "with", "flags", "dict", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L218-L230
52,766
dancsalo/TensorBase
tensorbase/base.py
Model.check_dict_keys
def check_dict_keys(self, config_yaml_flags_dict): """ Fill in all optional keys with None. Exit in a crucial key is not defined. """ crucial_keys = ['MODEL_DIRECTORY', 'SAVE_DIRECTORY'] for key in crucial_keys: if key not in config_yaml_flags_dict: print('You must de...
python
def check_dict_keys(self, config_yaml_flags_dict): """ Fill in all optional keys with None. Exit in a crucial key is not defined. """ crucial_keys = ['MODEL_DIRECTORY', 'SAVE_DIRECTORY'] for key in crucial_keys: if key not in config_yaml_flags_dict: print('You must de...
[ "def", "check_dict_keys", "(", "self", ",", "config_yaml_flags_dict", ")", ":", "crucial_keys", "=", "[", "'MODEL_DIRECTORY'", ",", "'SAVE_DIRECTORY'", "]", "for", "key", "in", "crucial_keys", ":", "if", "key", "not", "in", "config_yaml_flags_dict", ":", "print", ...
Fill in all optional keys with None. Exit in a crucial key is not defined.
[ "Fill", "in", "all", "optional", "keys", "with", "None", ".", "Exit", "in", "a", "crucial", "key", "is", "not", "defined", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L232-L248
52,767
dancsalo/TensorBase
tensorbase/base.py
Model._check_file_io
def _check_file_io(self): """ Create and define logging directory """ folder = 'Model' + str(self.flags['RUN_NUM']) + '/' folder_restore = 'Model' + str(self.flags['MODEL_RESTORE']) + '/' self.flags['RESTORE_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[ 'MODEL_DIRE...
python
def _check_file_io(self): """ Create and define logging directory """ folder = 'Model' + str(self.flags['RUN_NUM']) + '/' folder_restore = 'Model' + str(self.flags['MODEL_RESTORE']) + '/' self.flags['RESTORE_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[ 'MODEL_DIRE...
[ "def", "_check_file_io", "(", "self", ")", ":", "folder", "=", "'Model'", "+", "str", "(", "self", ".", "flags", "[", "'RUN_NUM'", "]", ")", "+", "'/'", "folder_restore", "=", "'Model'", "+", "str", "(", "self", ".", "flags", "[", "'MODEL_RESTORE'", "]...
Create and define logging directory
[ "Create", "and", "define", "logging", "directory" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L250-L260
52,768
dancsalo/TensorBase
tensorbase/base.py
Model._set_tf_functions
def _set_tf_functions(self): """ Sets up summary writer, saver, and session, with configurable gpu visibility """ merged = tf.summary.merge_all() saver = tf.train.Saver() if type(self.flags['GPU']) is int: os.environ["CUDA_VISIBLE_DEVICES"] = str(self.flags['GPU']) ...
python
def _set_tf_functions(self): """ Sets up summary writer, saver, and session, with configurable gpu visibility """ merged = tf.summary.merge_all() saver = tf.train.Saver() if type(self.flags['GPU']) is int: os.environ["CUDA_VISIBLE_DEVICES"] = str(self.flags['GPU']) ...
[ "def", "_set_tf_functions", "(", "self", ")", ":", "merged", "=", "tf", ".", "summary", ".", "merge_all", "(", ")", "saver", "=", "tf", ".", "train", ".", "Saver", "(", ")", "if", "type", "(", "self", ".", "flags", "[", "'GPU'", "]", ")", "is", "...
Sets up summary writer, saver, and session, with configurable gpu visibility
[ "Sets", "up", "summary", "writer", "saver", "and", "session", "with", "configurable", "gpu", "visibility" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L262-L273
52,769
dancsalo/TensorBase
tensorbase/base.py
Model._restore_meta
def _restore_meta(self): """ Restore from meta file. 'RESTORE_META_FILE' is expected to have .meta at the end. """ restore_meta_file = self._get_restore_meta_file() filename = self.flags['RESTORE_DIRECTORY'] + self._get_restore_meta_file() new_saver = tf.train.import_meta_graph(filename)...
python
def _restore_meta(self): """ Restore from meta file. 'RESTORE_META_FILE' is expected to have .meta at the end. """ restore_meta_file = self._get_restore_meta_file() filename = self.flags['RESTORE_DIRECTORY'] + self._get_restore_meta_file() new_saver = tf.train.import_meta_graph(filename)...
[ "def", "_restore_meta", "(", "self", ")", ":", "restore_meta_file", "=", "self", ".", "_get_restore_meta_file", "(", ")", "filename", "=", "self", ".", "flags", "[", "'RESTORE_DIRECTORY'", "]", "+", "self", ".", "_get_restore_meta_file", "(", ")", "new_saver", ...
Restore from meta file. 'RESTORE_META_FILE' is expected to have .meta at the end.
[ "Restore", "from", "meta", "file", ".", "RESTORE_META_FILE", "is", "expected", "to", "have", ".", "meta", "at", "the", "end", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L278-L284
52,770
dancsalo/TensorBase
tensorbase/base.py
Model._initialize_model
def _initialize_model(self): """ Initialize the defined network and restore from files is so specified. """ # Initialize all variables first self.sess.run(tf.local_variables_initializer()) self.sess.run(tf.global_variables_initializer()) if self.flags['RESTORE_META'] == 1: ...
python
def _initialize_model(self): """ Initialize the defined network and restore from files is so specified. """ # Initialize all variables first self.sess.run(tf.local_variables_initializer()) self.sess.run(tf.global_variables_initializer()) if self.flags['RESTORE_META'] == 1: ...
[ "def", "_initialize_model", "(", "self", ")", ":", "# Initialize all variables first", "self", ".", "sess", ".", "run", "(", "tf", ".", "local_variables_initializer", "(", ")", ")", "self", ".", "sess", ".", "run", "(", "tf", ".", "global_variables_initializer",...
Initialize the defined network and restore from files is so specified.
[ "Initialize", "the", "defined", "network", "and", "restore", "from", "files", "is", "so", "specified", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L297-L310
52,771
dancsalo/TensorBase
tensorbase/base.py
Model._init_uninit_vars
def _init_uninit_vars(self): """ Initialize all other trainable variables, i.e. those which are uninitialized """ uninit_vars = self.sess.run(tf.report_uninitialized_variables()) vars_list = list() for v in uninit_vars: var = v.decode("utf-8") vars_list.append(var...
python
def _init_uninit_vars(self): """ Initialize all other trainable variables, i.e. those which are uninitialized """ uninit_vars = self.sess.run(tf.report_uninitialized_variables()) vars_list = list() for v in uninit_vars: var = v.decode("utf-8") vars_list.append(var...
[ "def", "_init_uninit_vars", "(", "self", ")", ":", "uninit_vars", "=", "self", ".", "sess", ".", "run", "(", "tf", ".", "report_uninitialized_variables", "(", ")", ")", "vars_list", "=", "list", "(", ")", "for", "v", "in", "uninit_vars", ":", "var", "=",...
Initialize all other trainable variables, i.e. those which are uninitialized
[ "Initialize", "all", "other", "trainable", "variables", "i", ".", "e", ".", "those", "which", "are", "uninitialized" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L312-L320
52,772
dancsalo/TensorBase
tensorbase/base.py
Model._save_model
def _save_model(self, section): """ Save model in the logging directory """ checkpoint_name = self.flags['LOGGING_DIRECTORY'] + 'part_%d' % section + '.ckpt' save_path = self.saver.save(self.sess, checkpoint_name) print("Model saved in file: %s" % save_path)
python
def _save_model(self, section): """ Save model in the logging directory """ checkpoint_name = self.flags['LOGGING_DIRECTORY'] + 'part_%d' % section + '.ckpt' save_path = self.saver.save(self.sess, checkpoint_name) print("Model saved in file: %s" % save_path)
[ "def", "_save_model", "(", "self", ",", "section", ")", ":", "checkpoint_name", "=", "self", ".", "flags", "[", "'LOGGING_DIRECTORY'", "]", "+", "'part_%d'", "%", "section", "+", "'.ckpt'", "save_path", "=", "self", ".", "saver", ".", "save", "(", "self", ...
Save model in the logging directory
[ "Save", "model", "in", "the", "logging", "directory" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L322-L326
52,773
dancsalo/TensorBase
tensorbase/base.py
Model._record_training_step
def _record_training_step(self, summary): """ Adds summary to writer and increments the step. """ self.writer.add_summary(summary=summary, global_step=self.step) self.step += 1
python
def _record_training_step(self, summary): """ Adds summary to writer and increments the step. """ self.writer.add_summary(summary=summary, global_step=self.step) self.step += 1
[ "def", "_record_training_step", "(", "self", ",", "summary", ")", ":", "self", ".", "writer", ".", "add_summary", "(", "summary", "=", "summary", ",", "global_step", "=", "self", ".", "step", ")", "self", ".", "step", "+=", "1" ]
Adds summary to writer and increments the step.
[ "Adds", "summary", "to", "writer", "and", "increments", "the", "step", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L328-L331
52,774
dancsalo/TensorBase
tensorbase/base.py
Model._set_seed
def _set_seed(self): """ Set random seed for numpy and tensorflow packages """ if self.flags['SEED'] is not None: tf.set_random_seed(self.flags['SEED']) np.random.seed(self.flags['SEED'])
python
def _set_seed(self): """ Set random seed for numpy and tensorflow packages """ if self.flags['SEED'] is not None: tf.set_random_seed(self.flags['SEED']) np.random.seed(self.flags['SEED'])
[ "def", "_set_seed", "(", "self", ")", ":", "if", "self", ".", "flags", "[", "'SEED'", "]", "is", "not", "None", ":", "tf", ".", "set_random_seed", "(", "self", ".", "flags", "[", "'SEED'", "]", ")", "np", ".", "random", ".", "seed", "(", "self", ...
Set random seed for numpy and tensorflow packages
[ "Set", "random", "seed", "for", "numpy", "and", "tensorflow", "packages" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L333-L337
52,775
dancsalo/TensorBase
tensorbase/base.py
Model._summaries
def _summaries(self): """ Print out summaries for every variable. Can be overriden in main function. """ for var in tf.trainable_variables(): tf.summary.histogram(var.name, var) print(var.name)
python
def _summaries(self): """ Print out summaries for every variable. Can be overriden in main function. """ for var in tf.trainable_variables(): tf.summary.histogram(var.name, var) print(var.name)
[ "def", "_summaries", "(", "self", ")", ":", "for", "var", "in", "tf", ".", "trainable_variables", "(", ")", ":", "tf", ".", "summary", ".", "histogram", "(", "var", ".", "name", ",", "var", ")", "print", "(", "var", ".", "name", ")" ]
Print out summaries for every variable. Can be overriden in main function.
[ "Print", "out", "summaries", "for", "every", "variable", ".", "Can", "be", "overriden", "in", "main", "function", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L339-L343
52,776
dancsalo/TensorBase
tensorbase/base.py
Model.check_str
def check_str(obj): """ Returns a string for various input types """ if isinstance(obj, str): return obj if isinstance(obj, float): return str(int(obj)) else: return str(obj)
python
def check_str(obj): """ Returns a string for various input types """ if isinstance(obj, str): return obj if isinstance(obj, float): return str(int(obj)) else: return str(obj)
[ "def", "check_str", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "float", ")", ":", "return", "str", "(", "int", "(", "obj", ")", ")", "else", ":", "return", "st...
Returns a string for various input types
[ "Returns", "a", "string", "for", "various", "input", "types" ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L373-L380
52,777
dancsalo/TensorBase
tensorbase/base.py
Model.name_in_checkpoint
def name_in_checkpoint(var): """ Removes 'model' scoping if it is present in order to properly restore weights. """ if var.op.name.startswith('model/'): return var.op.name[len('model/'):]
python
def name_in_checkpoint(var): """ Removes 'model' scoping if it is present in order to properly restore weights. """ if var.op.name.startswith('model/'): return var.op.name[len('model/'):]
[ "def", "name_in_checkpoint", "(", "var", ")", ":", "if", "var", ".", "op", ".", "name", ".", "startswith", "(", "'model/'", ")", ":", "return", "var", ".", "op", ".", "name", "[", "len", "(", "'model/'", ")", ":", "]" ]
Removes 'model' scoping if it is present in order to properly restore weights.
[ "Removes", "model", "scoping", "if", "it", "is", "present", "in", "order", "to", "properly", "restore", "weights", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L383-L386
52,778
dancsalo/TensorBase
tensorbase/base.py
Model._merge_a_into_b
def _merge_a_into_b(self, a, b): """Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a. """ from easydict import EasyDict as edict if type(a) is not edict: return for k, v in a.items(): ...
python
def _merge_a_into_b(self, a, b): """Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a. """ from easydict import EasyDict as edict if type(a) is not edict: return for k, v in a.items(): ...
[ "def", "_merge_a_into_b", "(", "self", ",", "a", ",", "b", ")", ":", "from", "easydict", "import", "EasyDict", "as", "edict", "if", "type", "(", "a", ")", "is", "not", "edict", ":", "return", "for", "k", ",", "v", "in", "a", ".", "items", "(", ")...
Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a.
[ "Merge", "config", "dictionary", "a", "into", "config", "dictionary", "b", "clobbering", "the", "options", "in", "b", "whenever", "they", "are", "also", "specified", "in", "a", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L400-L432
52,779
dancsalo/TensorBase
tensorbase/base.py
Model._merge_a_into_b_simple
def _merge_a_into_b_simple(self, a, b): """Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a. Do not do any checking. """ for k, v in a.items(): b[k] = v return b
python
def _merge_a_into_b_simple(self, a, b): """Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a. Do not do any checking. """ for k, v in a.items(): b[k] = v return b
[ "def", "_merge_a_into_b_simple", "(", "self", ",", "a", ",", "b", ")", ":", "for", "k", ",", "v", "in", "a", ".", "items", "(", ")", ":", "b", "[", "k", "]", "=", "v", "return", "b" ]
Merge config dictionary a into config dictionary b, clobbering the options in b whenever they are also specified in a. Do not do any checking.
[ "Merge", "config", "dictionary", "a", "into", "config", "dictionary", "b", "clobbering", "the", "options", "in", "b", "whenever", "they", "are", "also", "specified", "in", "a", ".", "Do", "not", "do", "any", "checking", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L434-L440
52,780
dancsalo/TensorBase
tensorbase/base.py
Model.cfg_from_file
def cfg_from_file(self, yaml_filename, config_dict): """Load a config file and merge it into the default options.""" import yaml from easydict import EasyDict as edict with open(yaml_filename, 'r') as f: yaml_cfg = edict(yaml.load(f)) return self._merge_a_into_b(yaml...
python
def cfg_from_file(self, yaml_filename, config_dict): """Load a config file and merge it into the default options.""" import yaml from easydict import EasyDict as edict with open(yaml_filename, 'r') as f: yaml_cfg = edict(yaml.load(f)) return self._merge_a_into_b(yaml...
[ "def", "cfg_from_file", "(", "self", ",", "yaml_filename", ",", "config_dict", ")", ":", "import", "yaml", "from", "easydict", "import", "EasyDict", "as", "edict", "with", "open", "(", "yaml_filename", ",", "'r'", ")", "as", "f", ":", "yaml_cfg", "=", "edi...
Load a config file and merge it into the default options.
[ "Load", "a", "config", "file", "and", "merge", "it", "into", "the", "default", "options", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L442-L449
52,781
lpomfrey/django-debreach
debreach/utils.py
xor
def xor(s, pad): '''XOR a given string ``s`` with the one-time-pad ``pad``''' from itertools import cycle s = bytearray(force_bytes(s, encoding='latin-1')) pad = bytearray(force_bytes(pad, encoding='latin-1')) return binary_type(bytearray(x ^ y for x, y in zip(s, cycle(pad))))
python
def xor(s, pad): '''XOR a given string ``s`` with the one-time-pad ``pad``''' from itertools import cycle s = bytearray(force_bytes(s, encoding='latin-1')) pad = bytearray(force_bytes(pad, encoding='latin-1')) return binary_type(bytearray(x ^ y for x, y in zip(s, cycle(pad))))
[ "def", "xor", "(", "s", ",", "pad", ")", ":", "from", "itertools", "import", "cycle", "s", "=", "bytearray", "(", "force_bytes", "(", "s", ",", "encoding", "=", "'latin-1'", ")", ")", "pad", "=", "bytearray", "(", "force_bytes", "(", "pad", ",", "enc...
XOR a given string ``s`` with the one-time-pad ``pad``
[ "XOR", "a", "given", "string", "s", "with", "the", "one", "-", "time", "-", "pad", "pad" ]
b425bb719ea5de583fae7db5b7419e5fed569cb0
https://github.com/lpomfrey/django-debreach/blob/b425bb719ea5de583fae7db5b7419e5fed569cb0/debreach/utils.py#L8-L13
52,782
abhishek-ram/pyas2-lib
pyas2lib/cms.py
encrypt_message
def encrypt_message(data_to_encrypt, enc_alg, encryption_cert): """Function encrypts data and returns the generated ASN.1 :param data_to_encrypt: A byte string of the data to be encrypted :param enc_alg: The algorithm to be used for encrypting the data :param encryption_cert: The certificate ...
python
def encrypt_message(data_to_encrypt, enc_alg, encryption_cert): """Function encrypts data and returns the generated ASN.1 :param data_to_encrypt: A byte string of the data to be encrypted :param enc_alg: The algorithm to be used for encrypting the data :param encryption_cert: The certificate ...
[ "def", "encrypt_message", "(", "data_to_encrypt", ",", "enc_alg", ",", "encryption_cert", ")", ":", "enc_alg_list", "=", "enc_alg", ".", "split", "(", "'_'", ")", "cipher", ",", "key_length", ",", "mode", "=", "enc_alg_list", "[", "0", "]", ",", "enc_alg_lis...
Function encrypts data and returns the generated ASN.1 :param data_to_encrypt: A byte string of the data to be encrypted :param enc_alg: The algorithm to be used for encrypting the data :param encryption_cert: The certificate to be used for encrypting the data :return: A CMS ASN.1 byte strin...
[ "Function", "encrypts", "data", "and", "returns", "the", "generated", "ASN", ".", "1" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/cms.py#L72-L128
52,783
abhishek-ram/pyas2-lib
pyas2lib/as2.py
Organization.load_key
def load_key(key_str, key_pass): """ Function to load password protected key file in p12 or pem format""" try: # First try to parse as a p12 file key, cert, _ = asymmetric.load_pkcs12(key_str, key_pass) except ValueError as e: # If it fails due to invalid pas...
python
def load_key(key_str, key_pass): """ Function to load password protected key file in p12 or pem format""" try: # First try to parse as a p12 file key, cert, _ = asymmetric.load_pkcs12(key_str, key_pass) except ValueError as e: # If it fails due to invalid pas...
[ "def", "load_key", "(", "key_str", ",", "key_pass", ")", ":", "try", ":", "# First try to parse as a p12 file", "key", ",", "cert", ",", "_", "=", "asymmetric", ".", "load_pkcs12", "(", "key_str", ",", "key_pass", ")", "except", "ValueError", "as", "e", ":",...
Function to load password protected key file in p12 or pem format
[ "Function", "to", "load", "password", "protected", "key", "file", "in", "p12", "or", "pem", "format" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/as2.py#L77-L104
52,784
abhishek-ram/pyas2-lib
pyas2lib/as2.py
Message.content
def content(self): """Function returns the body of the as2 payload as a bytes object""" if not self.payload: return '' if self.payload.is_multipart(): message_bytes = mime_to_bytes( self.payload, 0).replace(b'\n', b'\r\n') boundary = b'--' + ...
python
def content(self): """Function returns the body of the as2 payload as a bytes object""" if not self.payload: return '' if self.payload.is_multipart(): message_bytes = mime_to_bytes( self.payload, 0).replace(b'\n', b'\r\n') boundary = b'--' + ...
[ "def", "content", "(", "self", ")", ":", "if", "not", "self", ".", "payload", ":", "return", "''", "if", "self", ".", "payload", ".", "is_multipart", "(", ")", ":", "message_bytes", "=", "mime_to_bytes", "(", "self", ".", "payload", ",", "0", ")", "....
Function returns the body of the as2 payload as a bytes object
[ "Function", "returns", "the", "body", "of", "the", "as2", "payload", "as", "a", "bytes", "object" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/as2.py#L263-L280
52,785
abhishek-ram/pyas2-lib
pyas2lib/as2.py
Mdn.content
def content(self): """Function returns the body of the mdn message as a byte string""" if self.payload: message_bytes = mime_to_bytes( self.payload, 0).replace(b'\n', b'\r\n') boundary = b'--' + self.payload.get_boundary().encode('utf-8') temp = messa...
python
def content(self): """Function returns the body of the mdn message as a byte string""" if self.payload: message_bytes = mime_to_bytes( self.payload, 0).replace(b'\n', b'\r\n') boundary = b'--' + self.payload.get_boundary().encode('utf-8') temp = messa...
[ "def", "content", "(", "self", ")", ":", "if", "self", ".", "payload", ":", "message_bytes", "=", "mime_to_bytes", "(", "self", ".", "payload", ",", "0", ")", ".", "replace", "(", "b'\\n'", ",", "b'\\r\\n'", ")", "boundary", "=", "b'--'", "+", "self", ...
Function returns the body of the mdn message as a byte string
[ "Function", "returns", "the", "body", "of", "the", "mdn", "message", "as", "a", "byte", "string" ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/as2.py#L640-L651
52,786
abhishek-ram/pyas2-lib
pyas2lib/as2.py
Mdn.parse
def parse(self, raw_content, find_message_cb): """Function parses the RAW AS2 MDN, verifies it and extracts the processing status of the orginal AS2 message. :param raw_content: A byte string of the received HTTP headers followed by the body. :param find_message_cb: ...
python
def parse(self, raw_content, find_message_cb): """Function parses the RAW AS2 MDN, verifies it and extracts the processing status of the orginal AS2 message. :param raw_content: A byte string of the received HTTP headers followed by the body. :param find_message_cb: ...
[ "def", "parse", "(", "self", ",", "raw_content", ",", "find_message_cb", ")", ":", "status", ",", "detailed_status", "=", "None", ",", "None", "self", ".", "payload", "=", "parse_mime", "(", "raw_content", ")", "self", ".", "orig_message_id", ",", "orig_reci...
Function parses the RAW AS2 MDN, verifies it and extracts the processing status of the orginal AS2 message. :param raw_content: A byte string of the received HTTP headers followed by the body. :param find_message_cb: A callback the must returns the original Message Obje...
[ "Function", "parses", "the", "RAW", "AS2", "MDN", "verifies", "it", "and", "extracts", "the", "processing", "status", "of", "the", "orginal", "AS2", "message", "." ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/as2.py#L787-L869
52,787
abhishek-ram/pyas2-lib
pyas2lib/as2.py
Mdn.detect_mdn
def detect_mdn(self): """ Function checks if the received raw message is an AS2 MDN or not. :raises MDNNotFound: If the received payload is not an MDN then this exception is raised. :return: A two element tuple containing (message_id, message_recipient). The mes...
python
def detect_mdn(self): """ Function checks if the received raw message is an AS2 MDN or not. :raises MDNNotFound: If the received payload is not an MDN then this exception is raised. :return: A two element tuple containing (message_id, message_recipient). The mes...
[ "def", "detect_mdn", "(", "self", ")", ":", "mdn_message", "=", "None", "if", "self", ".", "payload", ".", "get_content_type", "(", ")", "==", "'multipart/report'", ":", "mdn_message", "=", "self", ".", "payload", "elif", "self", ".", "payload", ".", "get_...
Function checks if the received raw message is an AS2 MDN or not. :raises MDNNotFound: If the received payload is not an MDN then this exception is raised. :return: A two element tuple containing (message_id, message_recipient). The message_id is the original AS2 messag...
[ "Function", "checks", "if", "the", "received", "raw", "message", "is", "an", "AS2", "MDN", "or", "not", "." ]
6af6bc71fe8a8cfb3465dad82ecc50539e3fd551
https://github.com/abhishek-ram/pyas2-lib/blob/6af6bc71fe8a8cfb3465dad82ecc50539e3fd551/pyas2lib/as2.py#L871-L900
52,788
mitodl/flask-log
flask_log.py
Logging.init_app
def init_app(self, app): """Setup the logging handlers, level and formatters. Level (DEBUG, INFO, CRITICAL, etc) is determined by the app.config['FLASK_LOG_LEVEL'] setting, and defaults to ``None``/``logging.NOTSET``. """ config_log_level = app.config.get('FLASK_LOG_LEV...
python
def init_app(self, app): """Setup the logging handlers, level and formatters. Level (DEBUG, INFO, CRITICAL, etc) is determined by the app.config['FLASK_LOG_LEVEL'] setting, and defaults to ``None``/``logging.NOTSET``. """ config_log_level = app.config.get('FLASK_LOG_LEV...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "config_log_level", "=", "app", ".", "config", ".", "get", "(", "'FLASK_LOG_LEVEL'", ",", "None", ")", "# Set up format for default logging", "hostname", "=", "platform", ".", "node", "(", ")", ".", "spli...
Setup the logging handlers, level and formatters. Level (DEBUG, INFO, CRITICAL, etc) is determined by the app.config['FLASK_LOG_LEVEL'] setting, and defaults to ``None``/``logging.NOTSET``.
[ "Setup", "the", "logging", "handlers", "level", "and", "formatters", "." ]
b8a960b3b4af9b49f082ca1d584ed22efa524c67
https://github.com/mitodl/flask-log/blob/b8a960b3b4af9b49f082ca1d584ed22efa524c67/flask_log.py#L22-L76
52,789
mitodl/flask-log
flask_log.py
Logging.set_formatter
def set_formatter(log_formatter): """Override the default log formatter with your own.""" # Add our formatter to all the handlers root_logger = logging.getLogger() for handler in root_logger.handlers: handler.setFormatter(logging.Formatter(log_formatter))
python
def set_formatter(log_formatter): """Override the default log formatter with your own.""" # Add our formatter to all the handlers root_logger = logging.getLogger() for handler in root_logger.handlers: handler.setFormatter(logging.Formatter(log_formatter))
[ "def", "set_formatter", "(", "log_formatter", ")", ":", "# Add our formatter to all the handlers", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "for", "handler", "in", "root_logger", ".", "handlers", ":", "handler", ".", "setFormatter", "(", "logging",...
Override the default log formatter with your own.
[ "Override", "the", "default", "log", "formatter", "with", "your", "own", "." ]
b8a960b3b4af9b49f082ca1d584ed22efa524c67
https://github.com/mitodl/flask-log/blob/b8a960b3b4af9b49f082ca1d584ed22efa524c67/flask_log.py#L79-L84
52,790
jupyterhub/nullauthenticator
examples/token-only/login-service.py
api_request
def api_request(path, **kwargs): """Make an API request to the Hub to reduce boilerplate repetition. """ url = url_path_join(os.environ['JUPYTERHUB_API_URL'], path) client = AsyncHTTPClient() headers = { 'Authorization': 'token %s' % os.environ['JUPYTERHUB_API_TOKEN'], } if kwa...
python
def api_request(path, **kwargs): """Make an API request to the Hub to reduce boilerplate repetition. """ url = url_path_join(os.environ['JUPYTERHUB_API_URL'], path) client = AsyncHTTPClient() headers = { 'Authorization': 'token %s' % os.environ['JUPYTERHUB_API_TOKEN'], } if kwa...
[ "def", "api_request", "(", "path", ",", "*", "*", "kwargs", ")", ":", "url", "=", "url_path_join", "(", "os", ".", "environ", "[", "'JUPYTERHUB_API_URL'", "]", ",", "path", ")", "client", "=", "AsyncHTTPClient", "(", ")", "headers", "=", "{", "'Authoriza...
Make an API request to the Hub to reduce boilerplate repetition.
[ "Make", "an", "API", "request", "to", "the", "Hub" ]
155a44f85cf4474a5ecf7fa74bc6834f1f04393d
https://github.com/jupyterhub/nullauthenticator/blob/155a44f85cf4474a5ecf7fa74bc6834f1f04393d/examples/token-only/login-service.py#L21-L35
52,791
jupyterhub/nullauthenticator
examples/token-only/login-service.py
delete_user
async def delete_user(name): """Stop a user's server and delete the user""" app_log.info("Deleting user %s", name) await api_request('users/{}/server'.format(name), method='DELETE') await api_request('users/{}'.format(name), method='DELETE')
python
async def delete_user(name): """Stop a user's server and delete the user""" app_log.info("Deleting user %s", name) await api_request('users/{}/server'.format(name), method='DELETE') await api_request('users/{}'.format(name), method='DELETE')
[ "async", "def", "delete_user", "(", "name", ")", ":", "app_log", ".", "info", "(", "\"Deleting user %s\"", ",", "name", ")", "await", "api_request", "(", "'users/{}/server'", ".", "format", "(", "name", ")", ",", "method", "=", "'DELETE'", ")", "await", "a...
Stop a user's server and delete the user
[ "Stop", "a", "user", "s", "server", "and", "delete", "the", "user" ]
155a44f85cf4474a5ecf7fa74bc6834f1f04393d
https://github.com/jupyterhub/nullauthenticator/blob/155a44f85cf4474a5ecf7fa74bc6834f1f04393d/examples/token-only/login-service.py#L38-L42
52,792
dancsalo/TensorBase
tensorbase/data.py
Mnist.dense_to_one_hot
def dense_to_one_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = np.arange(num_labels) * num_classes labels_one_hot = np.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset...
python
def dense_to_one_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = np.arange(num_labels) * num_classes labels_one_hot = np.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset...
[ "def", "dense_to_one_hot", "(", "labels_dense", ",", "num_classes", ")", ":", "num_labels", "=", "labels_dense", ".", "shape", "[", "0", "]", "index_offset", "=", "np", ".", "arange", "(", "num_labels", ")", "*", "num_classes", "labels_one_hot", "=", "np", "...
Convert class labels from scalars to one-hot vectors.
[ "Convert", "class", "labels", "from", "scalars", "to", "one", "-", "hot", "vectors", "." ]
3d42a326452bd03427034916ff2fb90730020204
https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/data.py#L119-L125
52,793
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
_render_iteratable
def _render_iteratable(iteratable, level): """Renders iteratable sequence of HTML elements.""" if isinstance(iteratable, basestring): return unicode(iteratable) return ''.join([render(element, level) for element in iteratable])
python
def _render_iteratable(iteratable, level): """Renders iteratable sequence of HTML elements.""" if isinstance(iteratable, basestring): return unicode(iteratable) return ''.join([render(element, level) for element in iteratable])
[ "def", "_render_iteratable", "(", "iteratable", ",", "level", ")", ":", "if", "isinstance", "(", "iteratable", ",", "basestring", ")", ":", "return", "unicode", "(", "iteratable", ")", "return", "''", ".", "join", "(", "[", "render", "(", "element", ",", ...
Renders iteratable sequence of HTML elements.
[ "Renders", "iteratable", "sequence", "of", "HTML", "elements", "." ]
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L552-L556
52,794
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
_serialize_attributes
def _serialize_attributes(attributes): """Serializes HTML element attributes in a name="value" pair form.""" result = '' for name, value in attributes.items(): if not value: continue result += ' ' + _unmangle_attribute_name(name) result += '="' + escape(value, True) + '"'...
python
def _serialize_attributes(attributes): """Serializes HTML element attributes in a name="value" pair form.""" result = '' for name, value in attributes.items(): if not value: continue result += ' ' + _unmangle_attribute_name(name) result += '="' + escape(value, True) + '"'...
[ "def", "_serialize_attributes", "(", "attributes", ")", ":", "result", "=", "''", "for", "name", ",", "value", "in", "attributes", ".", "items", "(", ")", ":", "if", "not", "value", ":", "continue", "result", "+=", "' '", "+", "_unmangle_attribute_name", "...
Serializes HTML element attributes in a name="value" pair form.
[ "Serializes", "HTML", "element", "attributes", "in", "a", "name", "=", "value", "pair", "form", "." ]
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L559-L567
52,795
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
_unmangle_attribute_name
def _unmangle_attribute_name(name): """Unmangles attribute names so that correct Python variable names are used for mapping attribute names.""" # Python keywords cannot be used as variable names, an underscore should # be appended at the end of each of them when defining attribute names. name = _PY...
python
def _unmangle_attribute_name(name): """Unmangles attribute names so that correct Python variable names are used for mapping attribute names.""" # Python keywords cannot be used as variable names, an underscore should # be appended at the end of each of them when defining attribute names. name = _PY...
[ "def", "_unmangle_attribute_name", "(", "name", ")", ":", "# Python keywords cannot be used as variable names, an underscore should", "# be appended at the end of each of them when defining attribute names.", "name", "=", "_PYTHON_KEYWORD_MAP", ".", "get", "(", "name", ",", "name", ...
Unmangles attribute names so that correct Python variable names are used for mapping attribute names.
[ "Unmangles", "attribute", "names", "so", "that", "correct", "Python", "variable", "names", "are", "used", "for", "mapping", "attribute", "names", "." ]
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L581-L594
52,796
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
escape
def escape(string, quote=False): """Standard HTML text escaping, but protecting against the agressive behavior of Jinja 2 `Markup` and the like. """ if string is None: return '' elif hasattr(string, '__html__'): return unicode(string) string = string.replace('&', '&amp;').replace...
python
def escape(string, quote=False): """Standard HTML text escaping, but protecting against the agressive behavior of Jinja 2 `Markup` and the like. """ if string is None: return '' elif hasattr(string, '__html__'): return unicode(string) string = string.replace('&', '&amp;').replace...
[ "def", "escape", "(", "string", ",", "quote", "=", "False", ")", ":", "if", "string", "is", "None", ":", "return", "''", "elif", "hasattr", "(", "string", ",", "'__html__'", ")", ":", "return", "unicode", "(", "string", ")", "string", "=", "string", ...
Standard HTML text escaping, but protecting against the agressive behavior of Jinja 2 `Markup` and the like.
[ "Standard", "HTML", "text", "escaping", "but", "protecting", "against", "the", "agressive", "behavior", "of", "Jinja", "2", "Markup", "and", "the", "like", "." ]
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L597-L608
52,797
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
root_block
def root_block(template_name=DEFAULT_TEMPLATE_NAME): """A decorator that is used to define that the decorated block function will be at the root of the block template hierarchy. In the usual case this will be the HTML skeleton of the document, unless the template is used to serve partial HTML rendering...
python
def root_block(template_name=DEFAULT_TEMPLATE_NAME): """A decorator that is used to define that the decorated block function will be at the root of the block template hierarchy. In the usual case this will be the HTML skeleton of the document, unless the template is used to serve partial HTML rendering...
[ "def", "root_block", "(", "template_name", "=", "DEFAULT_TEMPLATE_NAME", ")", ":", "def", "decorator", "(", "block_func", ")", ":", "block", "=", "RootBlock", "(", "block_func", ",", "template_name", ")", "return", "block_func", "return", "decorator" ]
A decorator that is used to define that the decorated block function will be at the root of the block template hierarchy. In the usual case this will be the HTML skeleton of the document, unless the template is used to serve partial HTML rendering for Ajax. The :func:`root_block` decorator accepts the...
[ "A", "decorator", "that", "is", "used", "to", "define", "that", "the", "decorated", "block", "function", "will", "be", "at", "the", "root", "of", "the", "block", "template", "hierarchy", ".", "In", "the", "usual", "case", "this", "will", "be", "the", "HT...
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L626-L644
52,798
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
block
def block(context_name, parent_block_func, view_func=None): """A decorator that is used for inserting the decorated block function in the block template hierarchy. The :func:`block` decorator accepts the following arguments: :param context_name: key in the `g.blocks` dictionary in which the result ...
python
def block(context_name, parent_block_func, view_func=None): """A decorator that is used for inserting the decorated block function in the block template hierarchy. The :func:`block` decorator accepts the following arguments: :param context_name: key in the `g.blocks` dictionary in which the result ...
[ "def", "block", "(", "context_name", ",", "parent_block_func", ",", "view_func", "=", "None", ")", ":", "def", "decorator", "(", "block_func", ")", ":", "block", "=", "Block", "(", "block_func", ",", "view_func", ")", "parent_block", "=", "Block", ".", "bl...
A decorator that is used for inserting the decorated block function in the block template hierarchy. The :func:`block` decorator accepts the following arguments: :param context_name: key in the `g.blocks` dictionary in which the result of the decorated block function will be store...
[ "A", "decorator", "that", "is", "used", "for", "inserting", "the", "decorated", "block", "function", "in", "the", "block", "template", "hierarchy", "." ]
ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L647-L672
52,799
HacKanCuBa/passphrase-py
passphrase/calc.py
entropy_bits
def entropy_bits( lst: Union[ List[Union[int, str, float, complex]], Tuple[Union[int, str, float, complex]] ] ) -> float: """Calculate the number of entropy bits in a list or tuple of elements.""" # Based on https://stackoverflow.com/a/45091961 if not isinstance(lst, ...
python
def entropy_bits( lst: Union[ List[Union[int, str, float, complex]], Tuple[Union[int, str, float, complex]] ] ) -> float: """Calculate the number of entropy bits in a list or tuple of elements.""" # Based on https://stackoverflow.com/a/45091961 if not isinstance(lst, ...
[ "def", "entropy_bits", "(", "lst", ":", "Union", "[", "List", "[", "Union", "[", "int", ",", "str", ",", "float", ",", "complex", "]", "]", ",", "Tuple", "[", "Union", "[", "int", ",", "str", ",", "float", ",", "complex", "]", "]", "]", ")", "-...
Calculate the number of entropy bits in a list or tuple of elements.
[ "Calculate", "the", "number", "of", "entropy", "bits", "in", "a", "list", "or", "tuple", "of", "elements", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L29-L59