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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
booktype/python-ooxml
ooxml/serialize.py
open_list
def open_list(ctx, document, par, root, elem): """Open list if it is needed and place current element as first member of a list. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - par (:class:`ooxml.doc.Paragraph`): Paragraph element ...
python
def open_list(ctx, document, par, root, elem): """Open list if it is needed and place current element as first member of a list. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - par (:class:`ooxml.doc.Paragraph`): Paragraph element ...
[ "def", "open_list", "(", "ctx", ",", "document", ",", "par", ",", "root", ",", "elem", ")", ":", "_ls", "=", "None", "if", "par", ".", "ilvl", "!=", "ctx", ".", "ilvl", "or", "par", ".", "numid", "!=", "ctx", ".", "numid", ":", "# start", "if", ...
Open list if it is needed and place current element as first member of a list. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - par (:class:`ooxml.doc.Paragraph`): Paragraph element - root (Element): lxml element of current location...
[ "Open", "list", "if", "it", "is", "needed", "and", "place", "current", "element", "as", "first", "member", "of", "a", "list", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L160-L231
train
60,800
booktype/python-ooxml
ooxml/serialize.py
serialize_break
def serialize_break(ctx, document, elem, root): "Serialize break element." if elem.break_type == u'textWrapping': _div = etree.SubElement(root, 'br') else: _div = etree.SubElement(root, 'span') if ctx.options['embed_styles']: _div.set('style', 'page-break-after: always;'...
python
def serialize_break(ctx, document, elem, root): "Serialize break element." if elem.break_type == u'textWrapping': _div = etree.SubElement(root, 'br') else: _div = etree.SubElement(root, 'span') if ctx.options['embed_styles']: _div.set('style', 'page-break-after: always;'...
[ "def", "serialize_break", "(", "ctx", ",", "document", ",", "elem", ",", "root", ")", ":", "if", "elem", ".", "break_type", "==", "u'textWrapping'", ":", "_div", "=", "etree", ".", "SubElement", "(", "root", ",", "'br'", ")", "else", ":", "_div", "=", ...
Serialize break element.
[ "Serialize", "break", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L238-L250
train
60,801
booktype/python-ooxml
ooxml/serialize.py
serialize_math
def serialize_math(ctx, document, elem, root): """Serialize math element. Math objects are not supported at the moment. This is wht we only show error message. """ _div = etree.SubElement(root, 'span') if ctx.options['embed_styles']: _div.set('style', 'border: 1px solid red') _div.text...
python
def serialize_math(ctx, document, elem, root): """Serialize math element. Math objects are not supported at the moment. This is wht we only show error message. """ _div = etree.SubElement(root, 'span') if ctx.options['embed_styles']: _div.set('style', 'border: 1px solid red') _div.text...
[ "def", "serialize_math", "(", "ctx", ",", "document", ",", "elem", ",", "root", ")", ":", "_div", "=", "etree", ".", "SubElement", "(", "root", ",", "'span'", ")", "if", "ctx", ".", "options", "[", "'embed_styles'", "]", ":", "_div", ".", "set", "(",...
Serialize math element. Math objects are not supported at the moment. This is wht we only show error message.
[ "Serialize", "math", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L253-L266
train
60,802
booktype/python-ooxml
ooxml/serialize.py
serialize_link
def serialize_link(ctx, document, elem, root): """Serilaze link element. This works only for external links at the moment. """ _a = etree.SubElement(root, 'a') for el in elem.elements: _ser = ctx.get_serializer(el) if _ser: _td = _ser(ctx, document, el, _a) el...
python
def serialize_link(ctx, document, elem, root): """Serilaze link element. This works only for external links at the moment. """ _a = etree.SubElement(root, 'a') for el in elem.elements: _ser = ctx.get_serializer(el) if _ser: _td = _ser(ctx, document, el, _a) el...
[ "def", "serialize_link", "(", "ctx", ",", "document", ",", "elem", ",", "root", ")", ":", "_a", "=", "etree", ".", "SubElement", "(", "root", ",", "'a'", ")", "for", "el", "in", "elem", ".", "elements", ":", "_ser", "=", "ctx", ".", "get_serializer",...
Serilaze link element. This works only for external links at the moment.
[ "Serilaze", "link", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L268-L299
train
60,803
booktype/python-ooxml
ooxml/serialize.py
serialize_image
def serialize_image(ctx, document, elem, root): """Serialize image element. This is not abstract enough. """ _img = etree.SubElement(root, 'img') # make path configurable if elem.rid in document.relationships[ctx.options['relationship']]: img_src = document.relationships[ctx.options['...
python
def serialize_image(ctx, document, elem, root): """Serialize image element. This is not abstract enough. """ _img = etree.SubElement(root, 'img') # make path configurable if elem.rid in document.relationships[ctx.options['relationship']]: img_src = document.relationships[ctx.options['...
[ "def", "serialize_image", "(", "ctx", ",", "document", ",", "elem", ",", "root", ")", ":", "_img", "=", "etree", ".", "SubElement", "(", "root", ",", "'img'", ")", "# make path configurable", "if", "elem", ".", "rid", "in", "document", ".", "relationships"...
Serialize image element. This is not abstract enough.
[ "Serialize", "image", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L302-L319
train
60,804
booktype/python-ooxml
ooxml/serialize.py
fire_hooks
def fire_hooks(ctx, document, elem, element, hooks): """Fire hooks on newly created element. For each newly created element we will try to find defined hooks and execute them. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - elem...
python
def fire_hooks(ctx, document, elem, element, hooks): """Fire hooks on newly created element. For each newly created element we will try to find defined hooks and execute them. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - elem...
[ "def", "fire_hooks", "(", "ctx", ",", "document", ",", "elem", ",", "element", ",", "hooks", ")", ":", "if", "not", "hooks", ":", "return", "for", "hook", "in", "hooks", ":", "hook", "(", "ctx", ",", "document", ",", "elem", ",", "element", ")" ]
Fire hooks on newly created element. For each newly created element we will try to find defined hooks and execute them. :Args: - ctx (:class:`Context`): Context object - document (:class:`ooxml.doc.Document`): Document object - elem (:class:`ooxml.doc.Element`): Element which we serialized ...
[ "Fire", "hooks", "on", "newly", "created", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L322-L339
train
60,805
booktype/python-ooxml
ooxml/serialize.py
has_style
def has_style(node): """Tells us if node element has defined styling. :Args: - node (:class:`ooxml.doc.Element`): Element :Returns: True or False """ elements = ['b', 'i', 'u', 'strike', 'color', 'jc', 'sz', 'ind', 'superscript', 'subscript', 'small_caps'] return any([True f...
python
def has_style(node): """Tells us if node element has defined styling. :Args: - node (:class:`ooxml.doc.Element`): Element :Returns: True or False """ elements = ['b', 'i', 'u', 'strike', 'color', 'jc', 'sz', 'ind', 'superscript', 'subscript', 'small_caps'] return any([True f...
[ "def", "has_style", "(", "node", ")", ":", "elements", "=", "[", "'b'", ",", "'i'", ",", "'u'", ",", "'strike'", ",", "'color'", ",", "'jc'", ",", "'sz'", ",", "'ind'", ",", "'superscript'", ",", "'subscript'", ",", "'small_caps'", "]", "return", "any"...
Tells us if node element has defined styling. :Args: - node (:class:`ooxml.doc.Element`): Element :Returns: True or False
[ "Tells", "us", "if", "node", "element", "has", "defined", "styling", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L342-L355
train
60,806
booktype/python-ooxml
ooxml/serialize.py
get_style_css
def get_style_css(ctx, node, embed=True, fontsize=-1): """Returns as string defined CSS for this node. Defined CSS can be different if it is embeded or no. When it is embeded styling for bold,italic and underline will not be defined with CSS. In that case we use defined tags <b>,<i>,<u> from the conte...
python
def get_style_css(ctx, node, embed=True, fontsize=-1): """Returns as string defined CSS for this node. Defined CSS can be different if it is embeded or no. When it is embeded styling for bold,italic and underline will not be defined with CSS. In that case we use defined tags <b>,<i>,<u> from the conte...
[ "def", "get_style_css", "(", "ctx", ",", "node", ",", "embed", "=", "True", ",", "fontsize", "=", "-", "1", ")", ":", "style", "=", "[", "]", "if", "not", "node", ":", "return", "if", "fontsize", "in", "[", "-", "1", ",", "2", "]", ":", "if", ...
Returns as string defined CSS for this node. Defined CSS can be different if it is embeded or no. When it is embeded styling for bold,italic and underline will not be defined with CSS. In that case we use defined tags <b>,<i>,<u> from the content. :Args: - ctx (:class:`Context`): Context object...
[ "Returns", "as", "string", "defined", "CSS", "for", "this", "node", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L375-L454
train
60,807
booktype/python-ooxml
ooxml/serialize.py
get_all_styles
def get_all_styles(document, style): """Returns list of styles on which specified style is based on. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object :Returns: List of style objects. """ classes = [] while Tru...
python
def get_all_styles(document, style): """Returns list of styles on which specified style is based on. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object :Returns: List of style objects. """ classes = [] while Tru...
[ "def", "get_all_styles", "(", "document", ",", "style", ")", ":", "classes", "=", "[", "]", "while", "True", ":", "classes", ".", "insert", "(", "0", ",", "get_style_name", "(", "style", ")", ")", "if", "style", ".", "based_on", ":", "style", "=", "d...
Returns list of styles on which specified style is based on. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object :Returns: List of style objects.
[ "Returns", "list", "of", "styles", "on", "which", "specified", "style", "is", "based", "on", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L481-L502
train
60,808
booktype/python-ooxml
ooxml/serialize.py
get_css_classes
def get_css_classes(document, style): """Returns CSS classes for this style. This function will check all the styles specified style is based on and return their CSS classes. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object ...
python
def get_css_classes(document, style): """Returns CSS classes for this style. This function will check all the styles specified style is based on and return their CSS classes. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object ...
[ "def", "get_css_classes", "(", "document", ",", "style", ")", ":", "lst", "=", "[", "st", ".", "lower", "(", ")", "for", "st", "in", "get_all_styles", "(", "document", ",", "style", ")", "[", "-", "1", ":", "]", "]", "+", "[", "'{}-fontsize'", ".",...
Returns CSS classes for this style. This function will check all the styles specified style is based on and return their CSS classes. :Args: - document (:class:`ooxml.doc.Document`): Document object - style (:class:`ooxml.doc.Style`): Style object :Returns: String representing all the C...
[ "Returns", "CSS", "classes", "for", "this", "style", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L505-L523
train
60,809
booktype/python-ooxml
ooxml/serialize.py
serialize_symbol
def serialize_symbol(ctx, document, el, root): "Serialize special symbols." span = etree.SubElement(root, 'span') span.text = el.value() fire_hooks(ctx, document, el, span, ctx.get_hook('symbol')) return root
python
def serialize_symbol(ctx, document, el, root): "Serialize special symbols." span = etree.SubElement(root, 'span') span.text = el.value() fire_hooks(ctx, document, el, span, ctx.get_hook('symbol')) return root
[ "def", "serialize_symbol", "(", "ctx", ",", "document", ",", "el", ",", "root", ")", ":", "span", "=", "etree", ".", "SubElement", "(", "root", ",", "'span'", ")", "span", ".", "text", "=", "el", ".", "value", "(", ")", "fire_hooks", "(", "ctx", ",...
Serialize special symbols.
[ "Serialize", "special", "symbols", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L720-L728
train
60,810
booktype/python-ooxml
ooxml/serialize.py
serialize_footnote
def serialize_footnote(ctx, document, el, root): "Serializes footnotes." footnote_num = el.rid if el.rid not in ctx.footnote_list: ctx.footnote_id += 1 ctx.footnote_list[el.rid] = ctx.footnote_id footnote_num = ctx.footnote_list[el.rid] note = etree.SubElement(root, 'sup') li...
python
def serialize_footnote(ctx, document, el, root): "Serializes footnotes." footnote_num = el.rid if el.rid not in ctx.footnote_list: ctx.footnote_id += 1 ctx.footnote_list[el.rid] = ctx.footnote_id footnote_num = ctx.footnote_list[el.rid] note = etree.SubElement(root, 'sup') li...
[ "def", "serialize_footnote", "(", "ctx", ",", "document", ",", "el", ",", "root", ")", ":", "footnote_num", "=", "el", ".", "rid", "if", "el", ".", "rid", "not", "in", "ctx", ".", "footnote_list", ":", "ctx", ".", "footnote_id", "+=", "1", "ctx", "."...
Serializes footnotes.
[ "Serializes", "footnotes", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L731-L749
train
60,811
booktype/python-ooxml
ooxml/serialize.py
serialize_comment
def serialize_comment(ctx, document, el, root): "Serializes comment." # Check if option is turned on if el.comment_type == 'end': ctx.opened_comments.remove(el.cid) else: if el.comment_type != 'reference': ctx.opened_comments.append(el.cid) if ctx.options['comment_...
python
def serialize_comment(ctx, document, el, root): "Serializes comment." # Check if option is turned on if el.comment_type == 'end': ctx.opened_comments.remove(el.cid) else: if el.comment_type != 'reference': ctx.opened_comments.append(el.cid) if ctx.options['comment_...
[ "def", "serialize_comment", "(", "ctx", ",", "document", ",", "el", ",", "root", ")", ":", "# Check if option is turned on", "if", "el", ".", "comment_type", "==", "'end'", ":", "ctx", ".", "opened_comments", ".", "remove", "(", "el", ".", "cid", ")", "els...
Serializes comment.
[ "Serializes", "comment", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L752-L773
train
60,812
booktype/python-ooxml
ooxml/serialize.py
serialize_endnote
def serialize_endnote(ctx, document, el, root): "Serializes endnotes." footnote_num = el.rid if el.rid not in ctx.endnote_list: ctx.endnote_id += 1 ctx.endnote_list[el.rid] = ctx.endnote_id footnote_num = ctx.endnote_list[el.rid] note = etree.SubElement(root, 'sup') link = et...
python
def serialize_endnote(ctx, document, el, root): "Serializes endnotes." footnote_num = el.rid if el.rid not in ctx.endnote_list: ctx.endnote_id += 1 ctx.endnote_list[el.rid] = ctx.endnote_id footnote_num = ctx.endnote_list[el.rid] note = etree.SubElement(root, 'sup') link = et...
[ "def", "serialize_endnote", "(", "ctx", ",", "document", ",", "el", ",", "root", ")", ":", "footnote_num", "=", "el", ".", "rid", "if", "el", ".", "rid", "not", "in", "ctx", ".", "endnote_list", ":", "ctx", ".", "endnote_id", "+=", "1", "ctx", ".", ...
Serializes endnotes.
[ "Serializes", "endnotes", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L776-L794
train
60,813
booktype/python-ooxml
ooxml/serialize.py
serialize_smarttag
def serialize_smarttag(ctx, document, el, root): "Serializes smarttag." if ctx.options['smarttag_span']: _span = etree.SubElement(root, 'span', {'class': 'smarttag', 'data-smarttag-element': el.element}) else: _span = root for elem in el.elements: _ser = ctx.get_serializer(elem...
python
def serialize_smarttag(ctx, document, el, root): "Serializes smarttag." if ctx.options['smarttag_span']: _span = etree.SubElement(root, 'span', {'class': 'smarttag', 'data-smarttag-element': el.element}) else: _span = root for elem in el.elements: _ser = ctx.get_serializer(elem...
[ "def", "serialize_smarttag", "(", "ctx", ",", "document", ",", "el", ",", "root", ")", ":", "if", "ctx", ".", "options", "[", "'smarttag_span'", "]", ":", "_span", "=", "etree", ".", "SubElement", "(", "root", ",", "'span'", ",", "{", "'class'", ":", ...
Serializes smarttag.
[ "Serializes", "smarttag", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L797-L825
train
60,814
booktype/python-ooxml
ooxml/serialize.py
serialize_table
def serialize_table(ctx, document, table, root): """Serializes table element. """ # What we should check really is why do we pass None as root element # There is a good chance some content is missing after the import if root is None: return root if ctx.ilvl != None: root = clo...
python
def serialize_table(ctx, document, table, root): """Serializes table element. """ # What we should check really is why do we pass None as root element # There is a good chance some content is missing after the import if root is None: return root if ctx.ilvl != None: root = clo...
[ "def", "serialize_table", "(", "ctx", ",", "document", ",", "table", ",", "root", ")", ":", "# What we should check really is why do we pass None as root element", "# There is a good chance some content is missing after the import", "if", "root", "is", "None", ":", "return", ...
Serializes table element.
[ "Serializes", "table", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L828-L879
train
60,815
booktype/python-ooxml
ooxml/serialize.py
serialize_textbox
def serialize_textbox(ctx, document, txtbox, root): """Serialize textbox element.""" _div = etree.SubElement(root, 'div') _div.set('class', 'textbox') for elem in txtbox.elements: _ser = ctx.get_serializer(elem) if _ser: _ser(ctx, document, elem, _div) fire_hooks(ctx,...
python
def serialize_textbox(ctx, document, txtbox, root): """Serialize textbox element.""" _div = etree.SubElement(root, 'div') _div.set('class', 'textbox') for elem in txtbox.elements: _ser = ctx.get_serializer(elem) if _ser: _ser(ctx, document, elem, _div) fire_hooks(ctx,...
[ "def", "serialize_textbox", "(", "ctx", ",", "document", ",", "txtbox", ",", "root", ")", ":", "_div", "=", "etree", ".", "SubElement", "(", "root", ",", "'div'", ")", "_div", ".", "set", "(", "'class'", ",", "'textbox'", ")", "for", "elem", "in", "t...
Serialize textbox element.
[ "Serialize", "textbox", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L882-L896
train
60,816
booktype/python-ooxml
ooxml/serialize.py
serialize_elements
def serialize_elements(document, elements, options=None): """Serialize list of elements into HTML string. :Args: - document (:class:`ooxml.doc.Document`): Document object - elements (list): List of elements - options (dict): Optional dictionary with :class:`Context` options :Returns: ...
python
def serialize_elements(document, elements, options=None): """Serialize list of elements into HTML string. :Args: - document (:class:`ooxml.doc.Document`): Document object - elements (list): List of elements - options (dict): Optional dictionary with :class:`Context` options :Returns: ...
[ "def", "serialize_elements", "(", "document", ",", "elements", ",", "options", "=", "None", ")", ":", "ctx", "=", "Context", "(", "document", ",", "options", ")", "tree_root", "=", "root", "=", "etree", ".", "Element", "(", "'div'", ")", "for", "elem", ...
Serialize list of elements into HTML string. :Args: - document (:class:`ooxml.doc.Document`): Document object - elements (list): List of elements - options (dict): Optional dictionary with :class:`Context` options :Returns: Returns HTML representation of the document.
[ "Serialize", "list", "of", "elements", "into", "HTML", "string", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L1215-L1239
train
60,817
booktype/python-ooxml
ooxml/serialize.py
HeaderContext.is_header
def is_header(self, elem, font_size, node, style=None): """Used for checking if specific element is a header or not. :Returns: True or False """ # This logic has been disabled for now. Mark this as header if it has # been marked during the parsing or mark. ...
python
def is_header(self, elem, font_size, node, style=None): """Used for checking if specific element is a header or not. :Returns: True or False """ # This logic has been disabled for now. Mark this as header if it has # been marked during the parsing or mark. ...
[ "def", "is_header", "(", "self", ",", "elem", ",", "font_size", ",", "node", ",", "style", "=", "None", ")", ":", "# This logic has been disabled for now. Mark this as header if it has", "# been marked during the parsing or mark.", "# if hasattr(elem, 'possible_header'):", "# ...
Used for checking if specific element is a header or not. :Returns: True or False
[ "Used", "for", "checking", "if", "specific", "element", "is", "a", "header", "or", "not", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L955-L1002
train
60,818
booktype/python-ooxml
ooxml/serialize.py
HeaderContext.get_header
def get_header(self, elem, style, node): """Returns HTML tag representing specific header for this element. :Returns: String representation of HTML tag. """ font_size = style if hasattr(elem, 'possible_header'): if elem.possible_header: ret...
python
def get_header(self, elem, style, node): """Returns HTML tag representing specific header for this element. :Returns: String representation of HTML tag. """ font_size = style if hasattr(elem, 'possible_header'): if elem.possible_header: ret...
[ "def", "get_header", "(", "self", ",", "elem", ",", "style", ",", "node", ")", ":", "font_size", "=", "style", "if", "hasattr", "(", "elem", ",", "'possible_header'", ")", ":", "if", "elem", ".", "possible_header", ":", "return", "'h1'", "if", "not", "...
Returns HTML tag representing specific header for this element. :Returns: String representation of HTML tag.
[ "Returns", "HTML", "tag", "representing", "specific", "header", "for", "this", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L1005-L1029
train
60,819
booktype/python-ooxml
ooxml/serialize.py
Context.get_serializer
def get_serializer(self, node): """Returns serializer for specific element. :Args: - node (:class:`ooxml.doc.Element`): Element object :Returns: Returns reference to a function which will be used for serialization. """ return self.options['serializers'].ge...
python
def get_serializer(self, node): """Returns serializer for specific element. :Args: - node (:class:`ooxml.doc.Element`): Element object :Returns: Returns reference to a function which will be used for serialization. """ return self.options['serializers'].ge...
[ "def", "get_serializer", "(", "self", ",", "node", ")", ":", "return", "self", ".", "options", "[", "'serializers'", "]", ".", "get", "(", "type", "(", "node", ")", ",", "None", ")", "if", "type", "(", "node", ")", "in", "self", ".", "options", "["...
Returns serializer for specific element. :Args: - node (:class:`ooxml.doc.Element`): Element object :Returns: Returns reference to a function which will be used for serialization.
[ "Returns", "serializer", "for", "specific", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/serialize.py#L1105-L1120
train
60,820
rfk/threading2
threading2/__init__.py
ThreadGroup.priority
def priority(self,priority): """Set the priority for all threads in this group. If setting priority fails on any thread, the priority of all threads is restored to its previous value. """ with self.__lock: old_priorities = {} try: for thre...
python
def priority(self,priority): """Set the priority for all threads in this group. If setting priority fails on any thread, the priority of all threads is restored to its previous value. """ with self.__lock: old_priorities = {} try: for thre...
[ "def", "priority", "(", "self", ",", "priority", ")", ":", "with", "self", ".", "__lock", ":", "old_priorities", "=", "{", "}", "try", ":", "for", "thread", "in", "self", ".", "__threads", ":", "old_priorities", "[", "thread", "]", "=", "thread", ".", ...
Set the priority for all threads in this group. If setting priority fails on any thread, the priority of all threads is restored to its previous value.
[ "Set", "the", "priority", "for", "all", "threads", "in", "this", "group", "." ]
7ec234ddd8c0d7e683b1a5c4a79a3d001143189f
https://github.com/rfk/threading2/blob/7ec234ddd8c0d7e683b1a5c4a79a3d001143189f/threading2/__init__.py#L104-L124
train
60,821
rfk/threading2
threading2/__init__.py
ThreadGroup.affinity
def affinity(self,affinity): """Set the affinity for all threads in this group. If setting affinity fails on any thread, the affinity of all threads is restored to its previous value. """ with self.__lock: old_affinities = {} try: for thre...
python
def affinity(self,affinity): """Set the affinity for all threads in this group. If setting affinity fails on any thread, the affinity of all threads is restored to its previous value. """ with self.__lock: old_affinities = {} try: for thre...
[ "def", "affinity", "(", "self", ",", "affinity", ")", ":", "with", "self", ".", "__lock", ":", "old_affinities", "=", "{", "}", "try", ":", "for", "thread", "in", "self", ".", "__threads", ":", "old_affinities", "[", "thread", "]", "=", "thread", ".", ...
Set the affinity for all threads in this group. If setting affinity fails on any thread, the affinity of all threads is restored to its previous value.
[ "Set", "the", "affinity", "for", "all", "threads", "in", "this", "group", "." ]
7ec234ddd8c0d7e683b1a5c4a79a3d001143189f
https://github.com/rfk/threading2/blob/7ec234ddd8c0d7e683b1a5c4a79a3d001143189f/threading2/__init__.py#L131-L151
train
60,822
rfk/threading2
threading2/__init__.py
ThreadGroup.join
def join(self,timeout=None): """Join all threads in this group. If the optional "timeout" argument is given, give up after that many seconds. This method returns True is the threads were successfully joined, False if a timeout occurred. """ if timeout is None: ...
python
def join(self,timeout=None): """Join all threads in this group. If the optional "timeout" argument is given, give up after that many seconds. This method returns True is the threads were successfully joined, False if a timeout occurred. """ if timeout is None: ...
[ "def", "join", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "None", ":", "for", "thread", "in", "self", ".", "__threads", ":", "thread", ".", "join", "(", ")", "else", ":", "deadline", "=", "_time", "(", ")", "+", "t...
Join all threads in this group. If the optional "timeout" argument is given, give up after that many seconds. This method returns True is the threads were successfully joined, False if a timeout occurred.
[ "Join", "all", "threads", "in", "this", "group", "." ]
7ec234ddd8c0d7e683b1a5c4a79a3d001143189f
https://github.com/rfk/threading2/blob/7ec234ddd8c0d7e683b1a5c4a79a3d001143189f/threading2/__init__.py#L158-L176
train
60,823
booktype/python-ooxml
ooxml/importer.py
text_length
def text_length(elem): """Returns length of the content in this element. Return value is not correct but it is **good enough***. """ if not elem: return 0 value = elem.value() try: value = len(value) except: value = 0 try: for a in elem.elements: ...
python
def text_length(elem): """Returns length of the content in this element. Return value is not correct but it is **good enough***. """ if not elem: return 0 value = elem.value() try: value = len(value) except: value = 0 try: for a in elem.elements: ...
[ "def", "text_length", "(", "elem", ")", ":", "if", "not", "elem", ":", "return", "0", "value", "=", "elem", ".", "value", "(", ")", "try", ":", "value", "=", "len", "(", "value", ")", "except", ":", "value", "=", "0", "try", ":", "for", "a", "i...
Returns length of the content in this element. Return value is not correct but it is **good enough***.
[ "Returns", "length", "of", "the", "content", "in", "this", "element", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/importer.py#L21-L43
train
60,824
booktype/python-ooxml
ooxml/docxfile.py
DOCXFile.reset
def reset(self): "Resets the values." self.zf = zipfile.ZipFile(self.file_name, 'r') self._doc = None
python
def reset(self): "Resets the values." self.zf = zipfile.ZipFile(self.file_name, 'r') self._doc = None
[ "def", "reset", "(", "self", ")", ":", "self", ".", "zf", "=", "zipfile", ".", "ZipFile", "(", "self", ".", "file_name", ",", "'r'", ")", "self", ".", "_doc", "=", "None" ]
Resets the values.
[ "Resets", "the", "values", "." ]
b56990a5bee2e1bc46839cec5161ff3726dc4d87
https://github.com/booktype/python-ooxml/blob/b56990a5bee2e1bc46839cec5161ff3726dc4d87/ooxml/docxfile.py#L39-L43
train
60,825
jazzband/django-ical
django_ical/utils.py
build_rrule
def build_rrule(count=None, interval=None, bysecond=None, byminute=None, byhour=None, byweekno=None, bymonthday=None, byyearday=None, bymonth=None, until=None, bysetpos=None, wkst=None, byday=None, freq=None): """ Build rrule dictionary for vRecur class. :par...
python
def build_rrule(count=None, interval=None, bysecond=None, byminute=None, byhour=None, byweekno=None, bymonthday=None, byyearday=None, bymonth=None, until=None, bysetpos=None, wkst=None, byday=None, freq=None): """ Build rrule dictionary for vRecur class. :par...
[ "def", "build_rrule", "(", "count", "=", "None", ",", "interval", "=", "None", ",", "bysecond", "=", "None", ",", "byminute", "=", "None", ",", "byhour", "=", "None", ",", "byweekno", "=", "None", ",", "bymonthday", "=", "None", ",", "byyearday", "=", ...
Build rrule dictionary for vRecur class. :param count: int :param interval: int :param bysecond: int :param byminute: int :param byhour: int :param byweekno: int :param bymonthday: int :param byyearday: int :param bymonth: int :param until: datetime :param bysetpos: int ...
[ "Build", "rrule", "dictionary", "for", "vRecur", "class", "." ]
7d616b9e319509b56c3ddab8cac18b0439f33b59
https://github.com/jazzband/django-ical/blob/7d616b9e319509b56c3ddab8cac18b0439f33b59/django_ical/utils.py#L12-L82
train
60,826
jazzband/django-ical
django_ical/utils.py
build_rrule_from_recurrences_rrule
def build_rrule_from_recurrences_rrule(rule): """ Build rrule dictionary for vRecur class from a django_recurrences rrule. django_recurrences is a popular implementation for recurrences in django. https://pypi.org/project/django-recurrence/ this is a shortcut to interface between recurrences and ic...
python
def build_rrule_from_recurrences_rrule(rule): """ Build rrule dictionary for vRecur class from a django_recurrences rrule. django_recurrences is a popular implementation for recurrences in django. https://pypi.org/project/django-recurrence/ this is a shortcut to interface between recurrences and ic...
[ "def", "build_rrule_from_recurrences_rrule", "(", "rule", ")", ":", "from", "recurrence", "import", "serialize", "line", "=", "serialize", "(", "rule", ")", "if", "line", ".", "startswith", "(", "'RRULE:'", ")", ":", "line", "=", "line", "[", "6", ":", "]"...
Build rrule dictionary for vRecur class from a django_recurrences rrule. django_recurrences is a popular implementation for recurrences in django. https://pypi.org/project/django-recurrence/ this is a shortcut to interface between recurrences and icalendar.
[ "Build", "rrule", "dictionary", "for", "vRecur", "class", "from", "a", "django_recurrences", "rrule", "." ]
7d616b9e319509b56c3ddab8cac18b0439f33b59
https://github.com/jazzband/django-ical/blob/7d616b9e319509b56c3ddab8cac18b0439f33b59/django_ical/utils.py#L91-L103
train
60,827
jazzband/django-ical
django_ical/utils.py
build_rrule_from_dateutil_rrule
def build_rrule_from_dateutil_rrule(rule): """ Build rrule dictionary for vRecur class from a dateutil rrule. Dateutils rrule is a popular implementation of rrule in python. https://pypi.org/project/python-dateutil/ this is a shortcut to interface between dateutil and icalendar. """ lines =...
python
def build_rrule_from_dateutil_rrule(rule): """ Build rrule dictionary for vRecur class from a dateutil rrule. Dateutils rrule is a popular implementation of rrule in python. https://pypi.org/project/python-dateutil/ this is a shortcut to interface between dateutil and icalendar. """ lines =...
[ "def", "build_rrule_from_dateutil_rrule", "(", "rule", ")", ":", "lines", "=", "str", "(", "rule", ")", ".", "splitlines", "(", ")", "for", "line", "in", "lines", ":", "if", "line", ".", "startswith", "(", "'DTSTART:'", ")", ":", "continue", "if", "line"...
Build rrule dictionary for vRecur class from a dateutil rrule. Dateutils rrule is a popular implementation of rrule in python. https://pypi.org/project/python-dateutil/ this is a shortcut to interface between dateutil and icalendar.
[ "Build", "rrule", "dictionary", "for", "vRecur", "class", "from", "a", "dateutil", "rrule", "." ]
7d616b9e319509b56c3ddab8cac18b0439f33b59
https://github.com/jazzband/django-ical/blob/7d616b9e319509b56c3ddab8cac18b0439f33b59/django_ical/utils.py#L106-L120
train
60,828
jazzband/django-ical
django_ical/feedgenerator.py
ICal20Feed.write
def write(self, outfile, encoding): u""" Writes the feed to the specified file in the specified encoding. """ cal = Calendar() cal.add('version', '2.0') cal.add('calscale', 'GREGORIAN') for ifield, efield in FEED_FIELD_MAP: val = self.feed.get...
python
def write(self, outfile, encoding): u""" Writes the feed to the specified file in the specified encoding. """ cal = Calendar() cal.add('version', '2.0') cal.add('calscale', 'GREGORIAN') for ifield, efield in FEED_FIELD_MAP: val = self.feed.get...
[ "def", "write", "(", "self", ",", "outfile", ",", "encoding", ")", ":", "cal", "=", "Calendar", "(", ")", "cal", ".", "add", "(", "'version'", ",", "'2.0'", ")", "cal", ".", "add", "(", "'calscale'", ",", "'GREGORIAN'", ")", "for", "ifield", ",", "...
u""" Writes the feed to the specified file in the specified encoding.
[ "u", "Writes", "the", "feed", "to", "the", "specified", "file", "in", "the", "specified", "encoding", "." ]
7d616b9e319509b56c3ddab8cac18b0439f33b59
https://github.com/jazzband/django-ical/blob/7d616b9e319509b56c3ddab8cac18b0439f33b59/django_ical/feedgenerator.py#L80-L99
train
60,829
jazzband/django-ical
django_ical/feedgenerator.py
ICal20Feed.write_items
def write_items(self, calendar): """ Write all events to the calendar """ for item in self.items: event = Event() for ifield, efield in ITEM_EVENT_FIELD_MAP: val = item.get(ifield) if val is not None: event.add(e...
python
def write_items(self, calendar): """ Write all events to the calendar """ for item in self.items: event = Event() for ifield, efield in ITEM_EVENT_FIELD_MAP: val = item.get(ifield) if val is not None: event.add(e...
[ "def", "write_items", "(", "self", ",", "calendar", ")", ":", "for", "item", "in", "self", ".", "items", ":", "event", "=", "Event", "(", ")", "for", "ifield", ",", "efield", "in", "ITEM_EVENT_FIELD_MAP", ":", "val", "=", "item", ".", "get", "(", "if...
Write all events to the calendar
[ "Write", "all", "events", "to", "the", "calendar" ]
7d616b9e319509b56c3ddab8cac18b0439f33b59
https://github.com/jazzband/django-ical/blob/7d616b9e319509b56c3ddab8cac18b0439f33b59/django_ical/feedgenerator.py#L101-L111
train
60,830
barryp/py-amqplib
extras/generate_skeleton_0_8.py
_textlist
def _textlist(self, _addtail=False): '''Returns a list of text strings contained within an element and its sub-elements. Helpful for extracting text from prose-oriented XML (such as XHTML or DocBook). ''' result = [] if (not _addtail) and (self.text is not None): result.append(self.text) ...
python
def _textlist(self, _addtail=False): '''Returns a list of text strings contained within an element and its sub-elements. Helpful for extracting text from prose-oriented XML (such as XHTML or DocBook). ''' result = [] if (not _addtail) and (self.text is not None): result.append(self.text) ...
[ "def", "_textlist", "(", "self", ",", "_addtail", "=", "False", ")", ":", "result", "=", "[", "]", "if", "(", "not", "_addtail", ")", "and", "(", "self", ".", "text", "is", "not", "None", ")", ":", "result", ".", "append", "(", "self", ".", "text...
Returns a list of text strings contained within an element and its sub-elements. Helpful for extracting text from prose-oriented XML (such as XHTML or DocBook).
[ "Returns", "a", "list", "of", "text", "strings", "contained", "within", "an", "element", "and", "its", "sub", "-", "elements", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/extras/generate_skeleton_0_8.py#L39-L51
train
60,831
barryp/py-amqplib
extras/generate_skeleton_0_8.py
_reindent
def _reindent(s, indent, reformat=True): """ Remove the existing indentation from each line of a chunk of text, s, and then prefix each line with a new indent string. Also removes trailing whitespace from each line, and leading and trailing blank lines. """ s = textwrap.dedent(s) s = s...
python
def _reindent(s, indent, reformat=True): """ Remove the existing indentation from each line of a chunk of text, s, and then prefix each line with a new indent string. Also removes trailing whitespace from each line, and leading and trailing blank lines. """ s = textwrap.dedent(s) s = s...
[ "def", "_reindent", "(", "s", ",", "indent", ",", "reformat", "=", "True", ")", ":", "s", "=", "textwrap", ".", "dedent", "(", "s", ")", "s", "=", "s", ".", "split", "(", "'\\n'", ")", "s", "=", "[", "x", ".", "rstrip", "(", ")", "for", "x", ...
Remove the existing indentation from each line of a chunk of text, s, and then prefix each line with a new indent string. Also removes trailing whitespace from each line, and leading and trailing blank lines.
[ "Remove", "the", "existing", "indentation", "from", "each", "line", "of", "a", "chunk", "of", "text", "s", "and", "then", "prefix", "each", "line", "with", "a", "new", "indent", "string", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/extras/generate_skeleton_0_8.py#L83-L104
train
60,832
barryp/py-amqplib
extras/generate_skeleton_0_8.py
generate_docstr
def generate_docstr(element, indent='', wrap=None): """ Generate a Python docstr for a given element in the AMQP XML spec file. The element could be a class or method The 'wrap' parameter is an optional chunk of text that's added to the beginning and end of the resulting docstring. """ re...
python
def generate_docstr(element, indent='', wrap=None): """ Generate a Python docstr for a given element in the AMQP XML spec file. The element could be a class or method The 'wrap' parameter is an optional chunk of text that's added to the beginning and end of the resulting docstring. """ re...
[ "def", "generate_docstr", "(", "element", ",", "indent", "=", "''", ",", "wrap", "=", "None", ")", ":", "result", "=", "[", "]", "txt", "=", "element", ".", "text", "and", "element", ".", "text", ".", "rstrip", "(", ")", "if", "txt", ":", "result",...
Generate a Python docstr for a given element in the AMQP XML spec file. The element could be a class or method The 'wrap' parameter is an optional chunk of text that's added to the beginning and end of the resulting docstring.
[ "Generate", "a", "Python", "docstr", "for", "a", "given", "element", "in", "the", "AMQP", "XML", "spec", "file", ".", "The", "element", "could", "be", "a", "class", "or", "method" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/extras/generate_skeleton_0_8.py#L107-L160
train
60,833
barryp/py-amqplib
extras/generate_skeleton_0_8.py
generate_module
def generate_module(spec, out): """ Given an AMQP spec parsed into an xml.etree.ElemenTree, and a file-like 'out' object to write to, generate the skeleton of a Python module. """ # # HACK THE SPEC so that 'access' is handled by 'channel' instead of 'connection' # for amqp_class in ...
python
def generate_module(spec, out): """ Given an AMQP spec parsed into an xml.etree.ElemenTree, and a file-like 'out' object to write to, generate the skeleton of a Python module. """ # # HACK THE SPEC so that 'access' is handled by 'channel' instead of 'connection' # for amqp_class in ...
[ "def", "generate_module", "(", "spec", ",", "out", ")", ":", "#", "# HACK THE SPEC so that 'access' is handled by 'channel' instead of 'connection'", "#", "for", "amqp_class", "in", "spec", ".", "findall", "(", "'class'", ")", ":", "if", "amqp_class", ".", "attrib", ...
Given an AMQP spec parsed into an xml.etree.ElemenTree, and a file-like 'out' object to write to, generate the skeleton of a Python module.
[ "Given", "an", "AMQP", "spec", "parsed", "into", "an", "xml", ".", "etree", ".", "ElemenTree", "and", "a", "file", "-", "like", "out", "object", "to", "write", "to", "generate", "the", "skeleton", "of", "a", "Python", "module", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/extras/generate_skeleton_0_8.py#L257-L320
train
60,834
barryp/py-amqplib
amqplib/client_0_8/method_framing.py
MethodReader._process_method_frame
def _process_method_frame(self, channel, payload): """ Process Method frames """ method_sig = unpack('>HH', payload[:4]) args = AMQPReader(payload[4:]) if method_sig in _CONTENT_METHODS: # # Save what we've got so far and wait for the content-hea...
python
def _process_method_frame(self, channel, payload): """ Process Method frames """ method_sig = unpack('>HH', payload[:4]) args = AMQPReader(payload[4:]) if method_sig in _CONTENT_METHODS: # # Save what we've got so far and wait for the content-hea...
[ "def", "_process_method_frame", "(", "self", ",", "channel", ",", "payload", ")", ":", "method_sig", "=", "unpack", "(", "'>HH'", ",", "payload", "[", ":", "4", "]", ")", "args", "=", "AMQPReader", "(", "payload", "[", "4", ":", "]", ")", "if", "meth...
Process Method frames
[ "Process", "Method", "frames" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/method_framing.py#L156-L171
train
60,835
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel._alert
def _alert(self, args): """ This method allows the server to send a non-fatal warning to the client. This is used for methods that are normally asynchronous and thus do not have confirmations, and for which the server may detect errors that need to be reported. Fatal er...
python
def _alert(self, args): """ This method allows the server to send a non-fatal warning to the client. This is used for methods that are normally asynchronous and thus do not have confirmations, and for which the server may detect errors that need to be reported. Fatal er...
[ "def", "_alert", "(", "self", ",", "args", ")", ":", "reply_code", "=", "args", ".", "read_short", "(", ")", "reply_text", "=", "args", ".", "read_shortstr", "(", ")", "details", "=", "args", ".", "read_table", "(", ")", "self", ".", "alerts", ".", "...
This method allows the server to send a non-fatal warning to the client. This is used for methods that are normally asynchronous and thus do not have confirmations, and for which the server may detect errors that need to be reported. Fatal errors are handled as channel or connection ex...
[ "This", "method", "allows", "the", "server", "to", "send", "a", "non", "-", "fatal", "warning", "to", "the", "client", ".", "This", "is", "used", "for", "methods", "that", "are", "normally", "asynchronous", "and", "thus", "do", "not", "have", "confirmation...
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L99-L132
train
60,836
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.access_request
def access_request(self, realm, exclusive=False, passive=False, active=False, write=False, read=False): """ request an access ticket This method requests an access ticket for an access realm. The server responds by granting the access ticket. If the client does not have...
python
def access_request(self, realm, exclusive=False, passive=False, active=False, write=False, read=False): """ request an access ticket This method requests an access ticket for an access realm. The server responds by granting the access ticket. If the client does not have...
[ "def", "access_request", "(", "self", ",", "realm", ",", "exclusive", "=", "False", ",", "passive", "=", "False", ",", "active", "=", "False", ",", "write", "=", "False", ",", "read", "=", "False", ")", ":", "args", "=", "AMQPWriter", "(", ")", "args...
request an access ticket This method requests an access ticket for an access realm. The server responds by granting the access ticket. If the client does not have access rights to the requested realm this causes a connection exception. Access tickets are a per-channel resource...
[ "request", "an", "access", "ticket" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L505-L597
train
60,837
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.exchange_declare
def exchange_declare(self, exchange, type, passive=False, durable=False, auto_delete=True, internal=False, nowait=False, arguments=None, ticket=None): """ declare exchange, create if needed This method creates an exchange if it does not already exist, and if the exchange...
python
def exchange_declare(self, exchange, type, passive=False, durable=False, auto_delete=True, internal=False, nowait=False, arguments=None, ticket=None): """ declare exchange, create if needed This method creates an exchange if it does not already exist, and if the exchange...
[ "def", "exchange_declare", "(", "self", ",", "exchange", ",", "type", ",", "passive", "=", "False", ",", "durable", "=", "False", ",", "auto_delete", "=", "True", ",", "internal", "=", "False", ",", "nowait", "=", "False", ",", "arguments", "=", "None", ...
declare exchange, create if needed This method creates an exchange if it does not already exist, and if the exchange exists, verifies that it is of the correct and expected class. RULE: The server SHOULD support a minimum of 16 exchanges per virtual host and id...
[ "declare", "exchange", "create", "if", "needed" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L675-L844
train
60,838
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.exchange_delete
def exchange_delete(self, exchange, if_unused=False, nowait=False, ticket=None): """ delete an exchange This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are cancelled. PARAMETERS: exchange: shortstr ...
python
def exchange_delete(self, exchange, if_unused=False, nowait=False, ticket=None): """ delete an exchange This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are cancelled. PARAMETERS: exchange: shortstr ...
[ "def", "exchange_delete", "(", "self", ",", "exchange", ",", "if_unused", "=", "False", ",", "nowait", "=", "False", ",", "ticket", "=", "None", ")", ":", "args", "=", "AMQPWriter", "(", ")", "if", "ticket", "is", "not", "None", ":", "args", ".", "wr...
delete an exchange This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are cancelled. PARAMETERS: exchange: shortstr RULE: The exchange MUST exist. Attempting to delete a non-exis...
[ "delete", "an", "exchange" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L858-L924
train
60,839
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.queue_bind
def queue_bind(self, queue, exchange, routing_key='', nowait=False, arguments=None, ticket=None): """ bind queue to an exchange This method binds a queue to an exchange. Until a queue is bound it will not receive any messages. In a classic messaging model, store-and-fo...
python
def queue_bind(self, queue, exchange, routing_key='', nowait=False, arguments=None, ticket=None): """ bind queue to an exchange This method binds a queue to an exchange. Until a queue is bound it will not receive any messages. In a classic messaging model, store-and-fo...
[ "def", "queue_bind", "(", "self", ",", "queue", ",", "exchange", ",", "routing_key", "=", "''", ",", "nowait", "=", "False", ",", "arguments", "=", "None", ",", "ticket", "=", "None", ")", ":", "if", "arguments", "is", "None", ":", "arguments", "=", ...
bind queue to an exchange This method binds a queue to an exchange. Until a queue is bound it will not receive any messages. In a classic messaging model, store-and-forward queues are bound to a dest exchange and subscription queues are bound to a dest_wild exchange. ...
[ "bind", "queue", "to", "an", "exchange" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L964-L1094
train
60,840
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel._queue_declare_ok
def _queue_declare_ok(self, args): """ confirms a queue definition This method confirms a Declare method and confirms the name of the queue, essential for automatically-named queues. PARAMETERS: queue: shortstr Reports the name of the queue. If the ...
python
def _queue_declare_ok(self, args): """ confirms a queue definition This method confirms a Declare method and confirms the name of the queue, essential for automatically-named queues. PARAMETERS: queue: shortstr Reports the name of the queue. If the ...
[ "def", "_queue_declare_ok", "(", "self", ",", "args", ")", ":", "queue", "=", "args", ".", "read_shortstr", "(", ")", "message_count", "=", "args", ".", "read_long", "(", ")", "consumer_count", "=", "args", ".", "read_long", "(", ")", "return", "queue", ...
confirms a queue definition This method confirms a Declare method and confirms the name of the queue, essential for automatically-named queues. PARAMETERS: queue: shortstr Reports the name of the queue. If the server generated a queue name, this fie...
[ "confirms", "a", "queue", "definition" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L1385-L1419
train
60,841
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.basic_consume
def basic_consume(self, queue='', consumer_tag='', no_local=False, no_ack=False, exclusive=False, nowait=False, callback=None, ticket=None): """ start a queue consumer This method asks the server to start a "consumer", which is a transient request for messages from a spe...
python
def basic_consume(self, queue='', consumer_tag='', no_local=False, no_ack=False, exclusive=False, nowait=False, callback=None, ticket=None): """ start a queue consumer This method asks the server to start a "consumer", which is a transient request for messages from a spe...
[ "def", "basic_consume", "(", "self", ",", "queue", "=", "''", ",", "consumer_tag", "=", "''", ",", "no_local", "=", "False", ",", "no_ack", "=", "False", ",", "exclusive", "=", "False", ",", "nowait", "=", "False", ",", "callback", "=", "None", ",", ...
start a queue consumer This method asks the server to start a "consumer", which is a transient request for messages from a specific queue. Consumers last as long as the channel they were created on, or until the client cancels them. RULE: The server SHOULD support ...
[ "start", "a", "queue", "consumer" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L1821-L1948
train
60,842
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel._basic_deliver
def _basic_deliver(self, args, msg): """ notify the client of a consumer message This method delivers a message to the client, via a consumer. In the asynchronous message delivery model, the client starts a consumer using the Consume method, then the server responds with...
python
def _basic_deliver(self, args, msg): """ notify the client of a consumer message This method delivers a message to the client, via a consumer. In the asynchronous message delivery model, the client starts a consumer using the Consume method, then the server responds with...
[ "def", "_basic_deliver", "(", "self", ",", "args", ",", "msg", ")", ":", "consumer_tag", "=", "args", ".", "read_shortstr", "(", ")", "delivery_tag", "=", "args", ".", "read_longlong", "(", ")", "redelivered", "=", "args", ".", "read_bit", "(", ")", "exc...
notify the client of a consumer message This method delivers a message to the client, via a consumer. In the asynchronous message delivery model, the client starts a consumer using the Consume method, then the server responds with Deliver methods as and when messages arrive for that ...
[ "notify", "the", "client", "of", "a", "consumer", "message" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L1969-L2060
train
60,843
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.basic_get
def basic_get(self, queue='', no_ack=False, ticket=None): """ direct access to a queue This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more ...
python
def basic_get(self, queue='', no_ack=False, ticket=None): """ direct access to a queue This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more ...
[ "def", "basic_get", "(", "self", ",", "queue", "=", "''", ",", "no_ack", "=", "False", ",", "ticket", "=", "None", ")", ":", "args", "=", "AMQPWriter", "(", ")", "if", "ticket", "is", "not", "None", ":", "args", ".", "write_short", "(", "ticket", "...
direct access to a queue This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more important than performance. PARAMETERS: queue: shortstr ...
[ "direct", "access", "to", "a", "queue" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L2063-L2120
train
60,844
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel.basic_publish
def basic_publish(self, msg, exchange='', routing_key='', mandatory=False, immediate=False, ticket=None): """ publish a message This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distr...
python
def basic_publish(self, msg, exchange='', routing_key='', mandatory=False, immediate=False, ticket=None): """ publish a message This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distr...
[ "def", "basic_publish", "(", "self", ",", "msg", ",", "exchange", "=", "''", ",", "routing_key", "=", "''", ",", "mandatory", "=", "False", ",", "immediate", "=", "False", ",", "ticket", "=", "None", ")", ":", "args", "=", "AMQPWriter", "(", ")", "if...
publish a message This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distributed to any active consumers when the transaction, if any, is committed. PARAMETERS: exchange: shortstr...
[ "publish", "a", "message" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L2218-L2310
train
60,845
barryp/py-amqplib
amqplib/client_0_8/channel.py
Channel._basic_return
def _basic_return(self, args, msg): """ return a failed message This method returns an undeliverable message that was published with the "immediate" flag set, or an unroutable message published with the "mandatory" flag set. The reply code and text provide information ab...
python
def _basic_return(self, args, msg): """ return a failed message This method returns an undeliverable message that was published with the "immediate" flag set, or an unroutable message published with the "mandatory" flag set. The reply code and text provide information ab...
[ "def", "_basic_return", "(", "self", ",", "args", ",", "msg", ")", ":", "reply_code", "=", "args", ".", "read_short", "(", ")", "reply_text", "=", "args", ".", "read_shortstr", "(", ")", "exchange", "=", "args", ".", "read_shortstr", "(", ")", "routing_k...
return a failed message This method returns an undeliverable message that was published with the "immediate" flag set, or an unroutable message published with the "mandatory" flag set. The reply code and text provide information about the reason that the message was undeliverabl...
[ "return", "a", "failed", "message" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L2513-L2554
train
60,846
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._wait_method
def _wait_method(self, channel_id, allowed_methods): """ Wait for a method from the server destined for a particular channel. """ # # Check the channel's deferred methods # method_queue = self.channels[channel_id].method_queue for queued_method i...
python
def _wait_method(self, channel_id, allowed_methods): """ Wait for a method from the server destined for a particular channel. """ # # Check the channel's deferred methods # method_queue = self.channels[channel_id].method_queue for queued_method i...
[ "def", "_wait_method", "(", "self", ",", "channel_id", ",", "allowed_methods", ")", ":", "#", "# Check the channel's deferred methods", "#", "method_queue", "=", "self", ".", "channels", "[", "channel_id", "]", ".", "method_queue", "for", "queued_method", "in", "m...
Wait for a method from the server destined for a particular channel.
[ "Wait", "for", "a", "method", "from", "the", "server", "destined", "for", "a", "particular", "channel", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L178-L231
train
60,847
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection.channel
def channel(self, channel_id=None): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. """ if channel_id in self.channels: return self.channels[channel_id] return Channel(self, channel_id)
python
def channel(self, channel_id=None): """ Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. """ if channel_id in self.channels: return self.channels[channel_id] return Channel(self, channel_id)
[ "def", "channel", "(", "self", ",", "channel_id", "=", "None", ")", ":", "if", "channel_id", "in", "self", ".", "channels", ":", "return", "self", ".", "channels", "[", "channel_id", "]", "return", "Channel", "(", "self", ",", "channel_id", ")" ]
Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist.
[ "Fetch", "a", "Channel", "object", "identified", "by", "the", "numeric", "channel_id", "or", "create", "that", "object", "if", "it", "doesn", "t", "already", "exist", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L234-L243
train
60,848
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._close
def _close(self, args): """ request a connection close This method indicates that the sender wants to close the connection. This may be due to internal conditions (e.g. a forced shut-down) or due to an error handling a specific method, i.e. an exception. When a close is...
python
def _close(self, args): """ request a connection close This method indicates that the sender wants to close the connection. This may be due to internal conditions (e.g. a forced shut-down) or due to an error handling a specific method, i.e. an exception. When a close is...
[ "def", "_close", "(", "self", ",", "args", ")", ":", "reply_code", "=", "args", ".", "read_short", "(", ")", "reply_text", "=", "args", ".", "read_shortstr", "(", ")", "class_id", "=", "args", ".", "read_short", "(", ")", "method_id", "=", "args", ".",...
request a connection close This method indicates that the sender wants to close the connection. This may be due to internal conditions (e.g. a forced shut-down) or due to an error handling a specific method, i.e. an exception. When a close is due to an exception, the sender pro...
[ "request", "a", "connection", "close" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L318-L380
train
60,849
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._x_open
def _x_open(self, virtual_host, capabilities='', insist=False): """ open connection to virtual host This method opens a connection to a virtual host, which is a collection of resources, and acts to separate multiple application domains within a server. RULE: ...
python
def _x_open(self, virtual_host, capabilities='', insist=False): """ open connection to virtual host This method opens a connection to a virtual host, which is a collection of resources, and acts to separate multiple application domains within a server. RULE: ...
[ "def", "_x_open", "(", "self", ",", "virtual_host", ",", "capabilities", "=", "''", ",", "insist", "=", "False", ")", ":", "args", "=", "AMQPWriter", "(", ")", "args", ".", "write_shortstr", "(", "virtual_host", ")", "args", ".", "write_shortstr", "(", "...
open connection to virtual host This method opens a connection to a virtual host, which is a collection of resources, and acts to separate multiple application domains within a server. RULE: The client MUST open the context before doing any work on the connecti...
[ "open", "connection", "to", "virtual", "host" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L418-L492
train
60,850
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._open_ok
def _open_ok(self, args): """ signal that the connection is ready This method signals to the client that the connection is ready for use. PARAMETERS: known_hosts: shortstr """ self.known_hosts = args.read_shortstr() AMQP_LOGGER.debug('Open O...
python
def _open_ok(self, args): """ signal that the connection is ready This method signals to the client that the connection is ready for use. PARAMETERS: known_hosts: shortstr """ self.known_hosts = args.read_shortstr() AMQP_LOGGER.debug('Open O...
[ "def", "_open_ok", "(", "self", ",", "args", ")", ":", "self", ".", "known_hosts", "=", "args", ".", "read_shortstr", "(", ")", "AMQP_LOGGER", ".", "debug", "(", "'Open OK! known_hosts [%s]'", "%", "self", ".", "known_hosts", ")", "return", "None" ]
signal that the connection is ready This method signals to the client that the connection is ready for use. PARAMETERS: known_hosts: shortstr
[ "signal", "that", "the", "connection", "is", "ready" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L495-L508
train
60,851
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._redirect
def _redirect(self, args): """ asks the client to use a different server This method redirects the client to another server, based on the requested virtual host and/or capabilities. RULE: When getting the Connection.Redirect method, the client SHOULD re...
python
def _redirect(self, args): """ asks the client to use a different server This method redirects the client to another server, based on the requested virtual host and/or capabilities. RULE: When getting the Connection.Redirect method, the client SHOULD re...
[ "def", "_redirect", "(", "self", ",", "args", ")", ":", "host", "=", "args", ".", "read_shortstr", "(", ")", "self", ".", "known_hosts", "=", "args", ".", "read_shortstr", "(", ")", "AMQP_LOGGER", ".", "debug", "(", "'Redirected to [%s], known_hosts [%s]'", ...
asks the client to use a different server This method redirects the client to another server, based on the requested virtual host and/or capabilities. RULE: When getting the Connection.Redirect method, the client SHOULD reconnect to the host specified, and if that host...
[ "asks", "the", "client", "to", "use", "a", "different", "server" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L511-L542
train
60,852
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._start
def _start(self, args): """ start connection negotiation This method starts the connection negotiation process by telling the client the protocol version that the server proposes, along with a list of security mechanisms which the client can use for authentication. ...
python
def _start(self, args): """ start connection negotiation This method starts the connection negotiation process by telling the client the protocol version that the server proposes, along with a list of security mechanisms which the client can use for authentication. ...
[ "def", "_start", "(", "self", ",", "args", ")", ":", "self", ".", "version_major", "=", "args", ".", "read_octet", "(", ")", "self", ".", "version_minor", "=", "args", ".", "read_octet", "(", ")", "self", ".", "server_properties", "=", "args", ".", "re...
start connection negotiation This method starts the connection negotiation process by telling the client the protocol version that the server proposes, along with a list of security mechanisms which the client can use for authentication. RULE: If the client cannot ...
[ "start", "connection", "negotiation" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L588-L661
train
60,853
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._x_start_ok
def _x_start_ok(self, client_properties, mechanism, response, locale): """ select security mechanism and locale This method selects a SASL security mechanism. ASL uses SASL (RFC2222) to negotiate authentication and encryption. PARAMETERS: client_properties: table ...
python
def _x_start_ok(self, client_properties, mechanism, response, locale): """ select security mechanism and locale This method selects a SASL security mechanism. ASL uses SASL (RFC2222) to negotiate authentication and encryption. PARAMETERS: client_properties: table ...
[ "def", "_x_start_ok", "(", "self", ",", "client_properties", ",", "mechanism", ",", "response", ",", "locale", ")", ":", "args", "=", "AMQPWriter", "(", ")", "args", ".", "write_table", "(", "client_properties", ")", "args", ".", "write_shortstr", "(", "mech...
select security mechanism and locale This method selects a SASL security mechanism. ASL uses SASL (RFC2222) to negotiate authentication and encryption. PARAMETERS: client_properties: table client properties mechanism: shortstr selected...
[ "select", "security", "mechanism", "and", "locale" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L664-L719
train
60,854
barryp/py-amqplib
amqplib/client_0_8/connection.py
Connection._tune
def _tune(self, args): """ propose connection tuning parameters This method proposes a set of connection configuration values to the client. The client can accept and/or adjust these. PARAMETERS: channel_max: short proposed maximum channels ...
python
def _tune(self, args): """ propose connection tuning parameters This method proposes a set of connection configuration values to the client. The client can accept and/or adjust these. PARAMETERS: channel_max: short proposed maximum channels ...
[ "def", "_tune", "(", "self", ",", "args", ")", ":", "self", ".", "channel_max", "=", "args", ".", "read_short", "(", ")", "or", "self", ".", "channel_max", "self", ".", "frame_max", "=", "args", ".", "read_long", "(", ")", "or", "self", ".", "frame_m...
propose connection tuning parameters This method proposes a set of connection configuration values to the client. The client can accept and/or adjust these. PARAMETERS: channel_max: short proposed maximum channels The maximum total number of chann...
[ "propose", "connection", "tuning", "parameters" ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/connection.py#L722-L770
train
60,855
barryp/py-amqplib
amqplib/client_0_8/abstract_channel.py
AbstractChannel._send_method
def _send_method(self, method_sig, args=bytes(), content=None): """ Send a method for our channel. """ if isinstance(args, AMQPWriter): args = args.getvalue() self.connection.method_writer.write_method(self.channel_id, method_sig, args, content)
python
def _send_method(self, method_sig, args=bytes(), content=None): """ Send a method for our channel. """ if isinstance(args, AMQPWriter): args = args.getvalue() self.connection.method_writer.write_method(self.channel_id, method_sig, args, content)
[ "def", "_send_method", "(", "self", ",", "method_sig", ",", "args", "=", "bytes", "(", ")", ",", "content", "=", "None", ")", ":", "if", "isinstance", "(", "args", ",", "AMQPWriter", ")", ":", "args", "=", "args", ".", "getvalue", "(", ")", "self", ...
Send a method for our channel.
[ "Send", "a", "method", "for", "our", "channel", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/abstract_channel.py#L67-L76
train
60,856
barryp/py-amqplib
amqplib/client_0_8/transport.py
_AbstractTransport.read_frame
def read_frame(self): """ Read an AMQP frame. """ frame_type, channel, size = unpack('>BHI', self._read(7)) payload = self._read(size) ch = ord(self._read(1)) if ch == 206: # '\xce' return frame_type, channel, payload else: raise E...
python
def read_frame(self): """ Read an AMQP frame. """ frame_type, channel, size = unpack('>BHI', self._read(7)) payload = self._read(size) ch = ord(self._read(1)) if ch == 206: # '\xce' return frame_type, channel, payload else: raise E...
[ "def", "read_frame", "(", "self", ")", ":", "frame_type", ",", "channel", ",", "size", "=", "unpack", "(", "'>BHI'", ",", "self", ".", "_read", "(", "7", ")", ")", "payload", "=", "self", ".", "_read", "(", "size", ")", "ch", "=", "ord", "(", "se...
Read an AMQP frame.
[ "Read", "an", "AMQP", "frame", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/transport.py#L144-L155
train
60,857
barryp/py-amqplib
amqplib/client_0_8/transport.py
_AbstractTransport.write_frame
def write_frame(self, frame_type, channel, payload): """ Write out an AMQP frame. """ size = len(payload) self._write(pack('>BHI%dsB' % size, frame_type, channel, size, payload, 0xce))
python
def write_frame(self, frame_type, channel, payload): """ Write out an AMQP frame. """ size = len(payload) self._write(pack('>BHI%dsB' % size, frame_type, channel, size, payload, 0xce))
[ "def", "write_frame", "(", "self", ",", "frame_type", ",", "channel", ",", "payload", ")", ":", "size", "=", "len", "(", "payload", ")", "self", ".", "_write", "(", "pack", "(", "'>BHI%dsB'", "%", "size", ",", "frame_type", ",", "channel", ",", "size",...
Write out an AMQP frame.
[ "Write", "out", "an", "AMQP", "frame", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/transport.py#L158-L165
train
60,858
barryp/py-amqplib
amqplib/client_0_8/transport.py
SSLTransport._setup_transport
def _setup_transport(self): """ Wrap the socket in an SSL object, either the new Python 2.6 version, or the older Python 2.5 and lower version. """ if HAVE_PY26_SSL: if hasattr(self, 'sslopts'): self.sslobj = ssl.wrap_socket(self.sock, **self....
python
def _setup_transport(self): """ Wrap the socket in an SSL object, either the new Python 2.6 version, or the older Python 2.5 and lower version. """ if HAVE_PY26_SSL: if hasattr(self, 'sslopts'): self.sslobj = ssl.wrap_socket(self.sock, **self....
[ "def", "_setup_transport", "(", "self", ")", ":", "if", "HAVE_PY26_SSL", ":", "if", "hasattr", "(", "self", ",", "'sslopts'", ")", ":", "self", ".", "sslobj", "=", "ssl", ".", "wrap_socket", "(", "self", ".", "sock", ",", "*", "*", "self", ".", "sslo...
Wrap the socket in an SSL object, either the new Python 2.6 version, or the older Python 2.5 and lower version.
[ "Wrap", "the", "socket", "in", "an", "SSL", "object", "either", "the", "new", "Python", "2", ".", "6", "version", "or", "the", "older", "Python", "2", ".", "5", "and", "lower", "version", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/transport.py#L182-L196
train
60,859
barryp/py-amqplib
amqplib/client_0_8/serialization.py
AMQPWriter.write_bit
def write_bit(self, b): """ Write a boolean value. """ if b: b = 1 else: b = 0 shift = self.bitcount % 8 if shift == 0: self.bits.append(0) self.bits[-1] |= (b << shift) self.bitcount += 1
python
def write_bit(self, b): """ Write a boolean value. """ if b: b = 1 else: b = 0 shift = self.bitcount % 8 if shift == 0: self.bits.append(0) self.bits[-1] |= (b << shift) self.bitcount += 1
[ "def", "write_bit", "(", "self", ",", "b", ")", ":", "if", "b", ":", "b", "=", "1", "else", ":", "b", "=", "0", "shift", "=", "self", ".", "bitcount", "%", "8", "if", "shift", "==", "0", ":", "self", ".", "bits", ".", "append", "(", "0", ")...
Write a boolean value.
[ "Write", "a", "boolean", "value", "." ]
2b3a47de34b4712c111d0a55d7ff109dffc2a7b2
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/serialization.py#L270-L283
train
60,860
miguelgrinberg/slam
slam/cli.py
on_unexpected_error
def on_unexpected_error(e): # pragma: no cover """Catch-all error handler Unexpected errors will be handled by this function. """ sys.stderr.write('Unexpected error: {} ({})\n'.format( str(e), e.__class__.__name__)) sys.stderr.write('See file slam_error.log for additional details.\n') ...
python
def on_unexpected_error(e): # pragma: no cover """Catch-all error handler Unexpected errors will be handled by this function. """ sys.stderr.write('Unexpected error: {} ({})\n'.format( str(e), e.__class__.__name__)) sys.stderr.write('See file slam_error.log for additional details.\n') ...
[ "def", "on_unexpected_error", "(", "e", ")", ":", "# pragma: no cover", "sys", ".", "stderr", ".", "write", "(", "'Unexpected error: {} ({})\\n'", ".", "format", "(", "str", "(", "e", ")", ",", "e", ".", "__class__", ".", "__name__", ")", ")", "sys", ".", ...
Catch-all error handler Unexpected errors will be handled by this function.
[ "Catch", "-", "all", "error", "handler" ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L60-L68
train
60,861
miguelgrinberg/slam
slam/cli.py
init
def init(name, description, bucket, timeout, memory, stages, requirements, function, runtime, config_file, **kwargs): """Generate a configuration file.""" if os.path.exists(config_file): raise RuntimeError('Please delete the old version {} if you want to ' 'reconfigur...
python
def init(name, description, bucket, timeout, memory, stages, requirements, function, runtime, config_file, **kwargs): """Generate a configuration file.""" if os.path.exists(config_file): raise RuntimeError('Please delete the old version {} if you want to ' 'reconfigur...
[ "def", "init", "(", "name", ",", "description", ",", "bucket", ",", "timeout", ",", "memory", ",", "stages", ",", "requirements", ",", "function", ",", "runtime", ",", "config_file", ",", "*", "*", "kwargs", ")", ":", "if", "os", ".", "path", ".", "e...
Generate a configuration file.
[ "Generate", "a", "configuration", "file", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L103-L160
train
60,862
miguelgrinberg/slam
slam/cli.py
_generate_lambda_handler
def _generate_lambda_handler(config, output='.slam/handler.py'): """Generate a handler.py file for the lambda function start up.""" # Determine what the start up code is. The default is to just run the # function, but it can be overriden by a plugin such as wsgi for a more # elaborated way to run the fu...
python
def _generate_lambda_handler(config, output='.slam/handler.py'): """Generate a handler.py file for the lambda function start up.""" # Determine what the start up code is. The default is to just run the # function, but it can be overriden by a plugin such as wsgi for a more # elaborated way to run the fu...
[ "def", "_generate_lambda_handler", "(", "config", ",", "output", "=", "'.slam/handler.py'", ")", ":", "# Determine what the start up code is. The default is to just run the", "# function, but it can be overriden by a plugin such as wsgi for a more", "# elaborated way to run the function.", ...
Generate a handler.py file for the lambda function start up.
[ "Generate", "a", "handler", ".", "py", "file", "for", "the", "lambda", "function", "start", "up", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L192-L213
train
60,863
miguelgrinberg/slam
slam/cli.py
build
def build(rebuild_deps, config_file): """Build lambda package.""" config = _load_config(config_file) print("Building lambda package...") package = _build(config, rebuild_deps=rebuild_deps) print("{} has been built successfully.".format(package))
python
def build(rebuild_deps, config_file): """Build lambda package.""" config = _load_config(config_file) print("Building lambda package...") package = _build(config, rebuild_deps=rebuild_deps) print("{} has been built successfully.".format(package))
[ "def", "build", "(", "rebuild_deps", ",", "config_file", ")", ":", "config", "=", "_load_config", "(", "config_file", ")", "print", "(", "\"Building lambda package...\"", ")", "package", "=", "_build", "(", "config", ",", "rebuild_deps", "=", "rebuild_deps", ")"...
Build lambda package.
[ "Build", "lambda", "package", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L316-L322
train
60,864
miguelgrinberg/slam
slam/cli.py
deploy
def deploy(stage, lambda_package, no_lambda, rebuild_deps, config_file): """Deploy the project to the development stage.""" config = _load_config(config_file) if stage is None: stage = config['devstage'] s3 = boto3.client('s3') cfn = boto3.client('cloudformation') region = _get_aws_regi...
python
def deploy(stage, lambda_package, no_lambda, rebuild_deps, config_file): """Deploy the project to the development stage.""" config = _load_config(config_file) if stage is None: stage = config['devstage'] s3 = boto3.client('s3') cfn = boto3.client('cloudformation') region = _get_aws_regi...
[ "def", "deploy", "(", "stage", ",", "lambda_package", ",", "no_lambda", ",", "rebuild_deps", ",", "config_file", ")", ":", "config", "=", "_load_config", "(", "config_file", ")", "if", "stage", "is", "None", ":", "stage", "=", "config", "[", "'devstage'", ...
Deploy the project to the development stage.
[ "Deploy", "the", "project", "to", "the", "development", "stage", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L335-L426
train
60,865
miguelgrinberg/slam
slam/cli.py
publish
def publish(version, stage, config_file): """Publish a version of the project to a stage.""" config = _load_config(config_file) cfn = boto3.client('cloudformation') if version is None: version = config['devstage'] elif version not in config['stage_environments'].keys() and \ not...
python
def publish(version, stage, config_file): """Publish a version of the project to a stage.""" config = _load_config(config_file) cfn = boto3.client('cloudformation') if version is None: version = config['devstage'] elif version not in config['stage_environments'].keys() and \ not...
[ "def", "publish", "(", "version", ",", "stage", ",", "config_file", ")", ":", "config", "=", "_load_config", "(", "config_file", ")", "cfn", "=", "boto3", ".", "client", "(", "'cloudformation'", ")", "if", "version", "is", "None", ":", "version", "=", "c...
Publish a version of the project to a stage.
[ "Publish", "a", "version", "of", "the", "project", "to", "a", "stage", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L434-L505
train
60,866
miguelgrinberg/slam
slam/cli.py
invoke
def invoke(stage, async, dry_run, config_file, args): """Invoke the lambda function.""" config = _load_config(config_file) if stage is None: stage = config['devstage'] cfn = boto3.client('cloudformation') lmb = boto3.client('lambda') try: stack = cfn.describe_stacks(StackName=c...
python
def invoke(stage, async, dry_run, config_file, args): """Invoke the lambda function.""" config = _load_config(config_file) if stage is None: stage = config['devstage'] cfn = boto3.client('cloudformation') lmb = boto3.client('lambda') try: stack = cfn.describe_stacks(StackName=c...
[ "def", "invoke", "(", "stage", ",", "async", ",", "dry_run", ",", "config_file", ",", "args", ")", ":", "config", "=", "_load_config", "(", "config_file", ")", "if", "stage", "is", "None", ":", "stage", "=", "config", "[", "'devstage'", "]", "cfn", "="...
Invoke the lambda function.
[ "Invoke", "the", "lambda", "function", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L519-L574
train
60,867
miguelgrinberg/slam
slam/cli.py
template
def template(config_file): """Print the default Cloudformation deployment template.""" config = _load_config(config_file) print(get_cfn_template(config, pretty=True))
python
def template(config_file): """Print the default Cloudformation deployment template.""" config = _load_config(config_file) print(get_cfn_template(config, pretty=True))
[ "def", "template", "(", "config_file", ")", ":", "config", "=", "_load_config", "(", "config_file", ")", "print", "(", "get_cfn_template", "(", "config", ",", "pretty", "=", "True", ")", ")" ]
Print the default Cloudformation deployment template.
[ "Print", "the", "default", "Cloudformation", "deployment", "template", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L713-L716
train
60,868
miguelgrinberg/slam
slam/cli.py
register_plugins
def register_plugins(): """find any installed plugins and register them.""" if pkg_resources: # pragma: no cover for ep in pkg_resources.iter_entry_points('slam_plugins'): plugin = ep.load() # add any init options to the main init command if hasattr(plugin, 'init') ...
python
def register_plugins(): """find any installed plugins and register them.""" if pkg_resources: # pragma: no cover for ep in pkg_resources.iter_entry_points('slam_plugins'): plugin = ep.load() # add any init options to the main init command if hasattr(plugin, 'init') ...
[ "def", "register_plugins", "(", ")", ":", "if", "pkg_resources", ":", "# pragma: no cover", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "'slam_plugins'", ")", ":", "plugin", "=", "ep", ".", "load", "(", ")", "# add any init options to the ma...
find any installed plugins and register them.
[ "find", "any", "installed", "plugins", "and", "register", "them", "." ]
cf68a4bbc16d909718f8a9e71072b822e0a3d94b
https://github.com/miguelgrinberg/slam/blob/cf68a4bbc16d909718f8a9e71072b822e0a3d94b/slam/cli.py#L719-L732
train
60,869
richtier/alexa-voice-service-client
alexa_client/alexa_client/connection.py
ConnectionManager.synchronise_device_state
def synchronise_device_state(self, device_state, authentication_headers): """ Synchronizing the component states with AVS Components state must be synchronised with AVS after establishing the downchannel stream in order to create a persistent connection with AVS. Note that curr...
python
def synchronise_device_state(self, device_state, authentication_headers): """ Synchronizing the component states with AVS Components state must be synchronised with AVS after establishing the downchannel stream in order to create a persistent connection with AVS. Note that curr...
[ "def", "synchronise_device_state", "(", "self", ",", "device_state", ",", "authentication_headers", ")", ":", "payload", "=", "{", "'context'", ":", "device_state", ",", "'event'", ":", "{", "'header'", ":", "{", "'namespace'", ":", "'System'", ",", "'name'", ...
Synchronizing the component states with AVS Components state must be synchronised with AVS after establishing the downchannel stream in order to create a persistent connection with AVS. Note that currently this function is paying lip-service synchronising the device state: the device s...
[ "Synchronizing", "the", "component", "states", "with", "AVS" ]
b423d0da6f3008bfa38fd4aaeb970fbb56159789
https://github.com/richtier/alexa-voice-service-client/blob/b423d0da6f3008bfa38fd4aaeb970fbb56159789/alexa_client/alexa_client/connection.py#L27-L74
train
60,870
richtier/alexa-voice-service-client
alexa_client/alexa_client/connection.py
ConnectionManager.send_audio_file
def send_audio_file( self, audio_file, device_state, authentication_headers, dialog_request_id, distance_profile, audio_format ): """ Send audio to AVS The file-like object are steaming uploaded for improved latency. Returns: bytes -- wav audio bytes ret...
python
def send_audio_file( self, audio_file, device_state, authentication_headers, dialog_request_id, distance_profile, audio_format ): """ Send audio to AVS The file-like object are steaming uploaded for improved latency. Returns: bytes -- wav audio bytes ret...
[ "def", "send_audio_file", "(", "self", ",", "audio_file", ",", "device_state", ",", "authentication_headers", ",", "dialog_request_id", ",", "distance_profile", ",", "audio_format", ")", ":", "payload", "=", "{", "'context'", ":", "device_state", ",", "'event'", "...
Send audio to AVS The file-like object are steaming uploaded for improved latency. Returns: bytes -- wav audio bytes returned from AVS
[ "Send", "audio", "to", "AVS" ]
b423d0da6f3008bfa38fd4aaeb970fbb56159789
https://github.com/richtier/alexa-voice-service-client/blob/b423d0da6f3008bfa38fd4aaeb970fbb56159789/alexa_client/alexa_client/connection.py#L76-L137
train
60,871
richtier/alexa-voice-service-client
alexa_client/alexa_client/authentication.py
AlexaVoiceServiceTokenAuthenticator.retrieve_api_token
def retrieve_api_token(self): """ Retrieve the access token from AVS. This function is memoized, so the value returned by the function will be remembered and returned by subsequent calls until the memo expires. This is because the access token lasts for one hour, then a ...
python
def retrieve_api_token(self): """ Retrieve the access token from AVS. This function is memoized, so the value returned by the function will be remembered and returned by subsequent calls until the memo expires. This is because the access token lasts for one hour, then a ...
[ "def", "retrieve_api_token", "(", "self", ")", ":", "payload", "=", "self", ".", "oauth2_manager", ".", "get_access_token_params", "(", "refresh_token", "=", "self", ".", "refresh_token", ")", "response", "=", "requests", ".", "post", "(", "self", ".", "oauth2...
Retrieve the access token from AVS. This function is memoized, so the value returned by the function will be remembered and returned by subsequent calls until the memo expires. This is because the access token lasts for one hour, then a new token needs to be requested. Decorato...
[ "Retrieve", "the", "access", "token", "from", "AVS", "." ]
b423d0da6f3008bfa38fd4aaeb970fbb56159789
https://github.com/richtier/alexa-voice-service-client/blob/b423d0da6f3008bfa38fd4aaeb970fbb56159789/alexa_client/alexa_client/authentication.py#L20-L45
train
60,872
markfinger/python-webpack
webpack/templatetags/webpack.py
webpack_template_tag
def webpack_template_tag(path_to_config): """ A template tag that will output a webpack bundle. Usage: {% load webpack %} {% webpack 'path/to/webpack.config.js' as bundle %} {{ bundle.render_css|safe }} {{ bundle.render_js|safe }} """ # TODO: allow selec...
python
def webpack_template_tag(path_to_config): """ A template tag that will output a webpack bundle. Usage: {% load webpack %} {% webpack 'path/to/webpack.config.js' as bundle %} {{ bundle.render_css|safe }} {{ bundle.render_js|safe }} """ # TODO: allow selec...
[ "def", "webpack_template_tag", "(", "path_to_config", ")", ":", "# TODO: allow selection of entries", "# Django's template system silently fails on some exceptions", "try", ":", "return", "webpack", "(", "path_to_config", ")", "except", "(", "AttributeError", ",", "ValueError",...
A template tag that will output a webpack bundle. Usage: {% load webpack %} {% webpack 'path/to/webpack.config.js' as bundle %} {{ bundle.render_css|safe }} {{ bundle.render_js|safe }}
[ "A", "template", "tag", "that", "will", "output", "a", "webpack", "bundle", "." ]
41ed0a3afac0dc96cb22093bd2da1dcbd31cfc42
https://github.com/markfinger/python-webpack/blob/41ed0a3afac0dc96cb22093bd2da1dcbd31cfc42/webpack/templatetags/webpack.py#L11-L32
train
60,873
jneen/python-cache
src/cache/__init__.py
_prepare_key
def _prepare_key(key, *args, **kwargs): """ if arguments are given, adds a hash of the args to the key. """ if not args and not kwargs: return key items = sorted(kwargs.items()) hashable_args = (args, tuple(items)) args_key = hashlib.md5(pickle.dumps(hashable_args)).hexdigest() ...
python
def _prepare_key(key, *args, **kwargs): """ if arguments are given, adds a hash of the args to the key. """ if not args and not kwargs: return key items = sorted(kwargs.items()) hashable_args = (args, tuple(items)) args_key = hashlib.md5(pickle.dumps(hashable_args)).hexdigest() ...
[ "def", "_prepare_key", "(", "key", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", "and", "not", "kwargs", ":", "return", "key", "items", "=", "sorted", "(", "kwargs", ".", "items", "(", ")", ")", "hashable_args", "=", "("...
if arguments are given, adds a hash of the args to the key.
[ "if", "arguments", "are", "given", "adds", "a", "hash", "of", "the", "args", "to", "the", "key", "." ]
4f0d4e299221d3ff612905ff632b7c6d3afd82db
https://github.com/jneen/python-cache/blob/4f0d4e299221d3ff612905ff632b7c6d3afd82db/src/cache/__init__.py#L164-L176
train
60,874
acschaefer/duallog
duallog/duallog.py
setup
def setup(logdir='log'): """ Set up dual logging to console and to logfile. When this function is called, it first creates the given directory. It then creates a logfile and passes all log messages to come to it. The logfile name encodes the date and time when it was created, for example "2018111...
python
def setup(logdir='log'): """ Set up dual logging to console and to logfile. When this function is called, it first creates the given directory. It then creates a logfile and passes all log messages to come to it. The logfile name encodes the date and time when it was created, for example "2018111...
[ "def", "setup", "(", "logdir", "=", "'log'", ")", ":", "# Create the root logger.", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "# Validate the given directory.", "logdir", "=", "os", ".",...
Set up dual logging to console and to logfile. When this function is called, it first creates the given directory. It then creates a logfile and passes all log messages to come to it. The logfile name encodes the date and time when it was created, for example "20181115-153559.txt". All messages with ...
[ "Set", "up", "dual", "logging", "to", "console", "and", "to", "logfile", "." ]
6e8dd367713d7954292320300bba2a0d75a4aac4
https://github.com/acschaefer/duallog/blob/6e8dd367713d7954292320300bba2a0d75a4aac4/duallog/duallog.py#L25-L77
train
60,875
urda/django-letsencrypt
scripts/version_manager.py
get_versions
def get_versions() -> FileVersionResult: """ Search specific project files and extract versions to check. :return: A FileVersionResult object for reporting. """ version_counter = Counter() versions_match = False version_str = None versions_discovered = OrderedDict() for version_ob...
python
def get_versions() -> FileVersionResult: """ Search specific project files and extract versions to check. :return: A FileVersionResult object for reporting. """ version_counter = Counter() versions_match = False version_str = None versions_discovered = OrderedDict() for version_ob...
[ "def", "get_versions", "(", ")", "->", "FileVersionResult", ":", "version_counter", "=", "Counter", "(", ")", "versions_match", "=", "False", "version_str", "=", "None", "versions_discovered", "=", "OrderedDict", "(", ")", "for", "version_obj", "in", "version_obje...
Search specific project files and extract versions to check. :return: A FileVersionResult object for reporting.
[ "Search", "specific", "project", "files", "and", "extract", "versions", "to", "check", "." ]
e0149163d3544cc0a8b4df64187237cdc75797ed
https://github.com/urda/django-letsencrypt/blob/e0149163d3544cc0a8b4df64187237cdc75797ed/scripts/version_manager.py#L159-L184
train
60,876
olls/graphics
graphics/console.py
supportedChars
def supportedChars(*tests): """ Takes any number of strings, and returns the first one the terminal encoding supports. If none are supported it returns '?' the length of the first string. """ for test in tests: try: test.encode(sys.stdout.encoding) ...
python
def supportedChars(*tests): """ Takes any number of strings, and returns the first one the terminal encoding supports. If none are supported it returns '?' the length of the first string. """ for test in tests: try: test.encode(sys.stdout.encoding) ...
[ "def", "supportedChars", "(", "*", "tests", ")", ":", "for", "test", "in", "tests", ":", "try", ":", "test", ".", "encode", "(", "sys", ".", "stdout", ".", "encoding", ")", "return", "test", "except", "UnicodeEncodeError", ":", "pass", "return", "'?'", ...
Takes any number of strings, and returns the first one the terminal encoding supports. If none are supported it returns '?' the length of the first string.
[ "Takes", "any", "number", "of", "strings", "and", "returns", "the", "first", "one", "the", "terminal", "encoding", "supports", ".", "If", "none", "are", "supported", "it", "returns", "?", "the", "length", "of", "the", "first", "string", "." ]
a302e9fe648d2d44603b52ac5bb80df4863b2a7d
https://github.com/olls/graphics/blob/a302e9fe648d2d44603b52ac5bb80df4863b2a7d/graphics/console.py#L78-L90
train
60,877
Fantomas42/django-app-namespace-template-loader
app_namespace/loader.py
Loader.app_templates_dirs
def app_templates_dirs(self): """ Build a cached dict with settings.INSTALLED_APPS as keys and the 'templates' directory of each application as values. """ app_templates_dirs = OrderedDict() for app_config in apps.get_app_configs(): templates_dir = os.path.joi...
python
def app_templates_dirs(self): """ Build a cached dict with settings.INSTALLED_APPS as keys and the 'templates' directory of each application as values. """ app_templates_dirs = OrderedDict() for app_config in apps.get_app_configs(): templates_dir = os.path.joi...
[ "def", "app_templates_dirs", "(", "self", ")", ":", "app_templates_dirs", "=", "OrderedDict", "(", ")", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ")", ":", "templates_dir", "=", "os", ".", "path", ".", "join", "(", "getattr", "(", "ap...
Build a cached dict with settings.INSTALLED_APPS as keys and the 'templates' directory of each application as values.
[ "Build", "a", "cached", "dict", "with", "settings", ".", "INSTALLED_APPS", "as", "keys", "and", "the", "templates", "directory", "of", "each", "application", "as", "values", "." ]
9d56e8eef25082e126549be97856582d28d1e84d
https://github.com/Fantomas42/django-app-namespace-template-loader/blob/9d56e8eef25082e126549be97856582d28d1e84d/app_namespace/loader.py#L57-L70
train
60,878
Fantomas42/django-app-namespace-template-loader
app_namespace/loader.py
Loader.get_contents
def get_contents(self, origin): """ Try to load the origin. """ try: path = self.get_app_template_path( origin.app_name, origin.template_name) with io.open(path, encoding=self.engine.file_charset) as fp: return fp.read() exc...
python
def get_contents(self, origin): """ Try to load the origin. """ try: path = self.get_app_template_path( origin.app_name, origin.template_name) with io.open(path, encoding=self.engine.file_charset) as fp: return fp.read() exc...
[ "def", "get_contents", "(", "self", ",", "origin", ")", ":", "try", ":", "path", "=", "self", ".", "get_app_template_path", "(", "origin", ".", "app_name", ",", "origin", ".", "template_name", ")", "with", "io", ".", "open", "(", "path", ",", "encoding",...
Try to load the origin.
[ "Try", "to", "load", "the", "origin", "." ]
9d56e8eef25082e126549be97856582d28d1e84d
https://github.com/Fantomas42/django-app-namespace-template-loader/blob/9d56e8eef25082e126549be97856582d28d1e84d/app_namespace/loader.py#L72-L86
train
60,879
Fantomas42/django-app-namespace-template-loader
app_namespace/loader.py
Loader.load_template_source
def load_template_source(self, *ka): """ Backward compatible method for Django < 2.0. """ template_name = ka[0] for origin in self.get_template_sources(template_name): try: return self.get_contents(origin), origin.name except TemplateDoesNo...
python
def load_template_source(self, *ka): """ Backward compatible method for Django < 2.0. """ template_name = ka[0] for origin in self.get_template_sources(template_name): try: return self.get_contents(origin), origin.name except TemplateDoesNo...
[ "def", "load_template_source", "(", "self", ",", "*", "ka", ")", ":", "template_name", "=", "ka", "[", "0", "]", "for", "origin", "in", "self", ".", "get_template_sources", "(", "template_name", ")", ":", "try", ":", "return", "self", ".", "get_contents", ...
Backward compatible method for Django < 2.0.
[ "Backward", "compatible", "method", "for", "Django", "<", "2", ".", "0", "." ]
9d56e8eef25082e126549be97856582d28d1e84d
https://github.com/Fantomas42/django-app-namespace-template-loader/blob/9d56e8eef25082e126549be97856582d28d1e84d/app_namespace/loader.py#L120-L130
train
60,880
olls/graphics
graphics/funcs.py
rotateImage
def rotateImage(image, angle): """ rotates a 2d array to a multiple of 90 deg. 0 = default 1 = 90 deg. cw 2 = 180 deg. 3 = 90 deg. ccw """ image = [list(row) for row in image] for n in range(angle % 4): image = list(zip(*image[::-1])) return image
python
def rotateImage(image, angle): """ rotates a 2d array to a multiple of 90 deg. 0 = default 1 = 90 deg. cw 2 = 180 deg. 3 = 90 deg. ccw """ image = [list(row) for row in image] for n in range(angle % 4): image = list(zip(*image[::-1])) return image
[ "def", "rotateImage", "(", "image", ",", "angle", ")", ":", "image", "=", "[", "list", "(", "row", ")", "for", "row", "in", "image", "]", "for", "n", "in", "range", "(", "angle", "%", "4", ")", ":", "image", "=", "list", "(", "zip", "(", "*", ...
rotates a 2d array to a multiple of 90 deg. 0 = default 1 = 90 deg. cw 2 = 180 deg. 3 = 90 deg. ccw
[ "rotates", "a", "2d", "array", "to", "a", "multiple", "of", "90", "deg", ".", "0", "=", "default", "1", "=", "90", "deg", ".", "cw", "2", "=", "180", "deg", ".", "3", "=", "90", "deg", ".", "ccw" ]
a302e9fe648d2d44603b52ac5bb80df4863b2a7d
https://github.com/olls/graphics/blob/a302e9fe648d2d44603b52ac5bb80df4863b2a7d/graphics/funcs.py#L7-L20
train
60,881
olls/graphics
graphics/sprite.py
Sprite.overlaps
def overlaps(self, canvas, exclude=[]): """ Returns True if sprite is touching any other sprite. """ try: exclude = list(exclude) except TypeError: exclude = [exclude] exclude.append(self) for selfY, row in enumerate(self.image.image()...
python
def overlaps(self, canvas, exclude=[]): """ Returns True if sprite is touching any other sprite. """ try: exclude = list(exclude) except TypeError: exclude = [exclude] exclude.append(self) for selfY, row in enumerate(self.image.image()...
[ "def", "overlaps", "(", "self", ",", "canvas", ",", "exclude", "=", "[", "]", ")", ":", "try", ":", "exclude", "=", "list", "(", "exclude", ")", "except", "TypeError", ":", "exclude", "=", "[", "exclude", "]", "exclude", ".", "append", "(", "self", ...
Returns True if sprite is touching any other sprite.
[ "Returns", "True", "if", "sprite", "is", "touching", "any", "other", "sprite", "." ]
a302e9fe648d2d44603b52ac5bb80df4863b2a7d
https://github.com/olls/graphics/blob/a302e9fe648d2d44603b52ac5bb80df4863b2a7d/graphics/sprite.py#L128-L146
train
60,882
olls/graphics
graphics/sprite.py
Sprite.onEdge
def onEdge(self, canvas): """ Returns a list of the sides of the sprite which are touching the edge of the canvas. 0 = Bottom 1 = Left 2 = Top 3 = Right """ sides = [] if int(self.position[0]) <= 0: ...
python
def onEdge(self, canvas): """ Returns a list of the sides of the sprite which are touching the edge of the canvas. 0 = Bottom 1 = Left 2 = Top 3 = Right """ sides = [] if int(self.position[0]) <= 0: ...
[ "def", "onEdge", "(", "self", ",", "canvas", ")", ":", "sides", "=", "[", "]", "if", "int", "(", "self", ".", "position", "[", "0", "]", ")", "<=", "0", ":", "sides", ".", "append", "(", "1", ")", "if", "(", "int", "(", "self", ".", "position...
Returns a list of the sides of the sprite which are touching the edge of the canvas. 0 = Bottom 1 = Left 2 = Top 3 = Right
[ "Returns", "a", "list", "of", "the", "sides", "of", "the", "sprite", "which", "are", "touching", "the", "edge", "of", "the", "canvas", "." ]
a302e9fe648d2d44603b52ac5bb80df4863b2a7d
https://github.com/olls/graphics/blob/a302e9fe648d2d44603b52ac5bb80df4863b2a7d/graphics/sprite.py#L148-L171
train
60,883
arachnidlabs/mcp2210
build/lib/mcp2210/device.py
remote_property
def remote_property(name, get_command, set_command, field_name, doc=None): """Property decorator that facilitates writing properties for values from a remote device. Arguments: name: The field name to use on the local object to store the cached property. get_command: A function that returns the rem...
python
def remote_property(name, get_command, set_command, field_name, doc=None): """Property decorator that facilitates writing properties for values from a remote device. Arguments: name: The field name to use on the local object to store the cached property. get_command: A function that returns the rem...
[ "def", "remote_property", "(", "name", ",", "get_command", ",", "set_command", ",", "field_name", ",", "doc", "=", "None", ")", ":", "def", "getter", "(", "self", ")", ":", "try", ":", "return", "getattr", "(", "self", ",", "name", ")", "except", "Attr...
Property decorator that facilitates writing properties for values from a remote device. Arguments: name: The field name to use on the local object to store the cached property. get_command: A function that returns the remote value of the property. set_command: A function that accepts a new value ...
[ "Property", "decorator", "that", "facilitates", "writing", "properties", "for", "values", "from", "a", "remote", "device", "." ]
ee15973d66697feb3b8a685ab59c774bee55d10b
https://github.com/arachnidlabs/mcp2210/blob/ee15973d66697feb3b8a685ab59c774bee55d10b/build/lib/mcp2210/device.py#L43-L65
train
60,884
arachnidlabs/mcp2210
build/lib/mcp2210/device.py
MCP2210.sendCommand
def sendCommand(self, command): """Sends a Command object to the MCP2210 and returns its response. Arguments: A commands.Command instance Returns: A commands.Response instance, or raises a CommandException on error. """ command_data = [ord(x) for x in bu...
python
def sendCommand(self, command): """Sends a Command object to the MCP2210 and returns its response. Arguments: A commands.Command instance Returns: A commands.Response instance, or raises a CommandException on error. """ command_data = [ord(x) for x in bu...
[ "def", "sendCommand", "(", "self", ",", "command", ")", ":", "command_data", "=", "[", "ord", "(", "x", ")", "for", "x", "in", "buffer", "(", "command", ")", "]", "self", ".", "hid", ".", "write", "(", "command_data", ")", "response_data", "=", "''",...
Sends a Command object to the MCP2210 and returns its response. Arguments: A commands.Command instance Returns: A commands.Response instance, or raises a CommandException on error.
[ "Sends", "a", "Command", "object", "to", "the", "MCP2210", "and", "returns", "its", "response", "." ]
ee15973d66697feb3b8a685ab59c774bee55d10b
https://github.com/arachnidlabs/mcp2210/blob/ee15973d66697feb3b8a685ab59c774bee55d10b/build/lib/mcp2210/device.py#L125-L140
train
60,885
arachnidlabs/mcp2210
build/lib/mcp2210/device.py
MCP2210.transfer
def transfer(self, data): """Transfers data over SPI. Arguments: data: The data to transfer. Returns: The data returned by the SPI device. """ settings = self.transfer_settings settings.spi_tx_size = len(data) self.transfer_settings = set...
python
def transfer(self, data): """Transfers data over SPI. Arguments: data: The data to transfer. Returns: The data returned by the SPI device. """ settings = self.transfer_settings settings.spi_tx_size = len(data) self.transfer_settings = set...
[ "def", "transfer", "(", "self", ",", "data", ")", ":", "settings", "=", "self", ".", "transfer_settings", "settings", ".", "spi_tx_size", "=", "len", "(", "data", ")", "self", ".", "transfer_settings", "=", "settings", "response", "=", "''", "for", "i", ...
Transfers data over SPI. Arguments: data: The data to transfer. Returns: The data returned by the SPI device.
[ "Transfers", "data", "over", "SPI", "." ]
ee15973d66697feb3b8a685ab59c774bee55d10b
https://github.com/arachnidlabs/mcp2210/blob/ee15973d66697feb3b8a685ab59c774bee55d10b/build/lib/mcp2210/device.py#L199-L220
train
60,886
django-fm/django-fm
fm/views.py
JSONResponseMixin.render_json_response
def render_json_response(self, context_dict, status=200): """ Limited serialization for shipping plain data. Do not use for models or other complex or custom objects. """ json_context = json.dumps( context_dict, cls=DjangoJSONEncoder, **self.ge...
python
def render_json_response(self, context_dict, status=200): """ Limited serialization for shipping plain data. Do not use for models or other complex or custom objects. """ json_context = json.dumps( context_dict, cls=DjangoJSONEncoder, **self.ge...
[ "def", "render_json_response", "(", "self", ",", "context_dict", ",", "status", "=", "200", ")", ":", "json_context", "=", "json", ".", "dumps", "(", "context_dict", ",", "cls", "=", "DjangoJSONEncoder", ",", "*", "*", "self", ".", "get_json_dumps_kwargs", "...
Limited serialization for shipping plain data. Do not use for models or other complex or custom objects.
[ "Limited", "serialization", "for", "shipping", "plain", "data", ".", "Do", "not", "use", "for", "models", "or", "other", "complex", "or", "custom", "objects", "." ]
da203f70d97200ff851ff47965d71751c917f9b1
https://github.com/django-fm/django-fm/blob/da203f70d97200ff851ff47965d71751c917f9b1/fm/views.py#L29-L43
train
60,887
django-fm/django-fm
fm/views.py
AjaxFormMixin.form_valid
def form_valid(self, form): """ If the request is ajax, save the form and return a json response. Otherwise return super as expected. """ self.object = form.save(commit=False) self.pre_save() self.object.save() if hasattr(form, 'save_m2m'): for...
python
def form_valid(self, form): """ If the request is ajax, save the form and return a json response. Otherwise return super as expected. """ self.object = form.save(commit=False) self.pre_save() self.object.save() if hasattr(form, 'save_m2m'): for...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "self", ".", "object", "=", "form", ".", "save", "(", "commit", "=", "False", ")", "self", ".", "pre_save", "(", ")", "self", ".", "object", ".", "save", "(", ")", "if", "hasattr", "(", "fo...
If the request is ajax, save the form and return a json response. Otherwise return super as expected.
[ "If", "the", "request", "is", "ajax", "save", "the", "form", "and", "return", "a", "json", "response", ".", "Otherwise", "return", "super", "as", "expected", "." ]
da203f70d97200ff851ff47965d71751c917f9b1
https://github.com/django-fm/django-fm/blob/da203f70d97200ff851ff47965d71751c917f9b1/fm/views.py#L56-L70
train
60,888
django-fm/django-fm
fm/views.py
AjaxFormMixin.form_invalid
def form_invalid(self, form): """ We have errors in the form. If ajax, return them as json. Otherwise, proceed as normal. """ if self.request.is_ajax(): return self.render_json_response(self.get_error_result(form)) return super(AjaxFormMixin, self).form_invali...
python
def form_invalid(self, form): """ We have errors in the form. If ajax, return them as json. Otherwise, proceed as normal. """ if self.request.is_ajax(): return self.render_json_response(self.get_error_result(form)) return super(AjaxFormMixin, self).form_invali...
[ "def", "form_invalid", "(", "self", ",", "form", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "return", "self", ".", "render_json_response", "(", "self", ".", "get_error_result", "(", "form", ")", ")", "return", "super", "(", ...
We have errors in the form. If ajax, return them as json. Otherwise, proceed as normal.
[ "We", "have", "errors", "in", "the", "form", ".", "If", "ajax", "return", "them", "as", "json", ".", "Otherwise", "proceed", "as", "normal", "." ]
da203f70d97200ff851ff47965d71751c917f9b1
https://github.com/django-fm/django-fm/blob/da203f70d97200ff851ff47965d71751c917f9b1/fm/views.py#L72-L79
train
60,889
atmos-python/atmos
atmos/decorators.py
assumes
def assumes(*args): '''Stores a function's assumptions as an attribute.''' args = tuple(args) def decorator(func): func.assumptions = args return func return decorator
python
def assumes(*args): '''Stores a function's assumptions as an attribute.''' args = tuple(args) def decorator(func): func.assumptions = args return func return decorator
[ "def", "assumes", "(", "*", "args", ")", ":", "args", "=", "tuple", "(", "args", ")", "def", "decorator", "(", "func", ")", ":", "func", ".", "assumptions", "=", "args", "return", "func", "return", "decorator" ]
Stores a function's assumptions as an attribute.
[ "Stores", "a", "function", "s", "assumptions", "as", "an", "attribute", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/decorators.py#L12-L19
train
60,890
atmos-python/atmos
atmos/decorators.py
overridden_by_assumptions
def overridden_by_assumptions(*args): '''Stores what assumptions a function is overridden by as an attribute.''' args = tuple(args) def decorator(func): func.overridden_by_assumptions = args return func return decorator
python
def overridden_by_assumptions(*args): '''Stores what assumptions a function is overridden by as an attribute.''' args = tuple(args) def decorator(func): func.overridden_by_assumptions = args return func return decorator
[ "def", "overridden_by_assumptions", "(", "*", "args", ")", ":", "args", "=", "tuple", "(", "args", ")", "def", "decorator", "(", "func", ")", ":", "func", ".", "overridden_by_assumptions", "=", "args", "return", "func", "return", "decorator" ]
Stores what assumptions a function is overridden by as an attribute.
[ "Stores", "what", "assumptions", "a", "function", "is", "overridden", "by", "as", "an", "attribute", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/decorators.py#L22-L29
train
60,891
atmos-python/atmos
atmos/decorators.py
equation_docstring
def equation_docstring(quantity_dict, assumption_dict, equation=None, references=None, notes=None): ''' Creates a decorator that adds a docstring to an equation function. Parameters ---------- quantity_dict : dict A dictionary describing the quantities used in the equations. Its keys ...
python
def equation_docstring(quantity_dict, assumption_dict, equation=None, references=None, notes=None): ''' Creates a decorator that adds a docstring to an equation function. Parameters ---------- quantity_dict : dict A dictionary describing the quantities used in the equations. Its keys ...
[ "def", "equation_docstring", "(", "quantity_dict", ",", "assumption_dict", ",", "equation", "=", "None", ",", "references", "=", "None", ",", "notes", "=", "None", ")", ":", "# Now we have our utility functions, let's define the decorator itself", "def", "decorator", "(...
Creates a decorator that adds a docstring to an equation function. Parameters ---------- quantity_dict : dict A dictionary describing the quantities used in the equations. Its keys should be abbreviations for the quantities, and its values should be a dictionary of the form {'name': string, 'units': strin...
[ "Creates", "a", "decorator", "that", "adds", "a", "docstring", "to", "an", "equation", "function", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/decorators.py#L32-L115
train
60,892
atmos-python/atmos
atmos/util.py
sma
def sma(array, window_size, axis=-1, mode='reflect', **kwargs): """ Computes a 1D simple moving average along the given axis. Parameters ---------- array : ndarray Array on which to perform the convolution. window_size: int Width of the simple moving average window in indices. axis : int, optional Axis...
python
def sma(array, window_size, axis=-1, mode='reflect', **kwargs): """ Computes a 1D simple moving average along the given axis. Parameters ---------- array : ndarray Array on which to perform the convolution. window_size: int Width of the simple moving average window in indices. axis : int, optional Axis...
[ "def", "sma", "(", "array", ",", "window_size", ",", "axis", "=", "-", "1", ",", "mode", "=", "'reflect'", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'axis'", "]", "=", "axis", "kwargs", "[", "'mode'", "]", "=", "mode", "if", "not", "isin...
Computes a 1D simple moving average along the given axis. Parameters ---------- array : ndarray Array on which to perform the convolution. window_size: int Width of the simple moving average window in indices. axis : int, optional Axis along which to perform the moving average mode : {‘reflect’, ‘constant’...
[ "Computes", "a", "1D", "simple", "moving", "average", "along", "the", "given", "axis", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L17-L52
train
60,893
atmos-python/atmos
atmos/util.py
assumption_list_string
def assumption_list_string(assumptions, assumption_dict): ''' Takes in a list of short forms of assumptions and an assumption dictionary, and returns a "list" form of the long form of the assumptions. Raises ------ ValueError if one of the assumptions is not in assumption_dict. ''' if isinstance(assump...
python
def assumption_list_string(assumptions, assumption_dict): ''' Takes in a list of short forms of assumptions and an assumption dictionary, and returns a "list" form of the long form of the assumptions. Raises ------ ValueError if one of the assumptions is not in assumption_dict. ''' if isinstance(assump...
[ "def", "assumption_list_string", "(", "assumptions", ",", "assumption_dict", ")", ":", "if", "isinstance", "(", "assumptions", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'assumptions must be an iterable of strings, not a '", "'string itself'", ...
Takes in a list of short forms of assumptions and an assumption dictionary, and returns a "list" form of the long form of the assumptions. Raises ------ ValueError if one of the assumptions is not in assumption_dict.
[ "Takes", "in", "a", "list", "of", "short", "forms", "of", "assumptions", "and", "an", "assumption", "dictionary", "and", "returns", "a", "list", "form", "of", "the", "long", "form", "of", "the", "assumptions", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L94-L112
train
60,894
atmos-python/atmos
atmos/util.py
quantity_spec_string
def quantity_spec_string(name, quantity_dict): ''' Returns a quantity specification for docstrings. Example ------- >>> quantity_spec_string('Tv') >>> 'Tv : float or ndarray\n Data for virtual temperature.' ''' if name not in quantity_dict.keys(): raise ValueError('{0} not present in quantity_d...
python
def quantity_spec_string(name, quantity_dict): ''' Returns a quantity specification for docstrings. Example ------- >>> quantity_spec_string('Tv') >>> 'Tv : float or ndarray\n Data for virtual temperature.' ''' if name not in quantity_dict.keys(): raise ValueError('{0} not present in quantity_d...
[ "def", "quantity_spec_string", "(", "name", ",", "quantity_dict", ")", ":", "if", "name", "not", "in", "quantity_dict", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "'{0} not present in quantity_dict'", ".", "format", "(", "name", ")", ")", "s", "...
Returns a quantity specification for docstrings. Example ------- >>> quantity_spec_string('Tv') >>> 'Tv : float or ndarray\n Data for virtual temperature.'
[ "Returns", "a", "quantity", "specification", "for", "docstrings", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L115-L130
train
60,895
atmos-python/atmos
atmos/util.py
doc_paragraph
def doc_paragraph(s, indent=0): '''Takes in a string without wrapping corresponding to a paragraph, and returns a version of that string wrapped to be at most 80 characters in length on each line. If indent is given, ensures each line is indented to that number of spaces. ''' ret...
python
def doc_paragraph(s, indent=0): '''Takes in a string without wrapping corresponding to a paragraph, and returns a version of that string wrapped to be at most 80 characters in length on each line. If indent is given, ensures each line is indented to that number of spaces. ''' ret...
[ "def", "doc_paragraph", "(", "s", ",", "indent", "=", "0", ")", ":", "return", "'\\n'", ".", "join", "(", "[", "' '", "*", "indent", "+", "l", "for", "l", "in", "wrap", "(", "s", ",", "width", "=", "80", "-", "indent", ")", "]", ")" ]
Takes in a string without wrapping corresponding to a paragraph, and returns a version of that string wrapped to be at most 80 characters in length on each line. If indent is given, ensures each line is indented to that number of spaces.
[ "Takes", "in", "a", "string", "without", "wrapping", "corresponding", "to", "a", "paragraph", "and", "returns", "a", "version", "of", "that", "string", "wrapped", "to", "be", "at", "most", "80", "characters", "in", "length", "on", "each", "line", ".", "If"...
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L133-L140
train
60,896
atmos-python/atmos
atmos/util.py
closest_val
def closest_val(x, L): ''' Finds the index value in an iterable closest to a desired value. Parameters ---------- x : object The desired value. L : iterable The iterable in which to search for the desired value. Returns ------- index : int The index of the c...
python
def closest_val(x, L): ''' Finds the index value in an iterable closest to a desired value. Parameters ---------- x : object The desired value. L : iterable The iterable in which to search for the desired value. Returns ------- index : int The index of the c...
[ "def", "closest_val", "(", "x", ",", "L", ")", ":", "# Make sure the iterable is nonempty", "if", "len", "(", "L", ")", "==", "0", ":", "raise", "ValueError", "(", "'L must not be empty'", ")", "if", "isinstance", "(", "L", ",", "np", ".", "ndarray", ")", ...
Finds the index value in an iterable closest to a desired value. Parameters ---------- x : object The desired value. L : iterable The iterable in which to search for the desired value. Returns ------- index : int The index of the closest value to x in L. Notes ...
[ "Finds", "the", "index", "value", "in", "an", "iterable", "closest", "to", "a", "desired", "value", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L161-L205
train
60,897
atmos-python/atmos
atmos/util.py
area_poly_sphere
def area_poly_sphere(lat, lon, r_sphere): ''' Calculates the area enclosed by an arbitrary polygon on the sphere. Parameters ---------- lat : iterable The latitudes, in degrees, of the vertex locations of the polygon, in clockwise order. lon : iterable The longitudes, in degrees, of the vertex locatio...
python
def area_poly_sphere(lat, lon, r_sphere): ''' Calculates the area enclosed by an arbitrary polygon on the sphere. Parameters ---------- lat : iterable The latitudes, in degrees, of the vertex locations of the polygon, in clockwise order. lon : iterable The longitudes, in degrees, of the vertex locatio...
[ "def", "area_poly_sphere", "(", "lat", ",", "lon", ",", "r_sphere", ")", ":", "dtr", "=", "np", ".", "pi", "/", "180.", "def", "_tranlon", "(", "plat", ",", "plon", ",", "qlat", ",", "qlon", ")", ":", "t", "=", "np", ".", "sin", "(", "(", "qlon...
Calculates the area enclosed by an arbitrary polygon on the sphere. Parameters ---------- lat : iterable The latitudes, in degrees, of the vertex locations of the polygon, in clockwise order. lon : iterable The longitudes, in degrees, of the vertex locations of the polygon, in clockwise order. Return...
[ "Calculates", "the", "area", "enclosed", "by", "an", "arbitrary", "polygon", "on", "the", "sphere", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L208-L260
train
60,898
atmos-python/atmos
atmos/util.py
d_x
def d_x(data, axis, boundary='forward-backward'): ''' Calculates a second-order centered finite difference of data along the specified axis. Parameters ---------- data : ndarray Data on which we are taking a derivative. axis : int Index of the data array on which to take the difference. boundary : string,...
python
def d_x(data, axis, boundary='forward-backward'): ''' Calculates a second-order centered finite difference of data along the specified axis. Parameters ---------- data : ndarray Data on which we are taking a derivative. axis : int Index of the data array on which to take the difference. boundary : string,...
[ "def", "d_x", "(", "data", ",", "axis", ",", "boundary", "=", "'forward-backward'", ")", ":", "if", "abs", "(", "axis", ")", ">", "len", "(", "data", ".", "shape", ")", ":", "raise", "ValueError", "(", "'axis is out of bounds for the shape of data'", ")", ...
Calculates a second-order centered finite difference of data along the specified axis. Parameters ---------- data : ndarray Data on which we are taking a derivative. axis : int Index of the data array on which to take the difference. boundary : string, optional Boundary condition. If 'periodic', assume pe...
[ "Calculates", "a", "second", "-", "order", "centered", "finite", "difference", "of", "data", "along", "the", "specified", "axis", "." ]
f4af8eaca23cce881bde979599d15d322fc1935e
https://github.com/atmos-python/atmos/blob/f4af8eaca23cce881bde979599d15d322fc1935e/atmos/util.py#L352-L407
train
60,899