repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readList | def readList(self):
"""
Read a C{list} from the data stream.
"""
obj = []
self.context.addObject(obj)
l = self.stream.read_ulong()
for i in xrange(l):
obj.append(self.readElement())
return obj | python | def readList(self):
"""
Read a C{list} from the data stream.
"""
obj = []
self.context.addObject(obj)
l = self.stream.read_ulong()
for i in xrange(l):
obj.append(self.readElement())
return obj | [
"def",
"readList",
"(",
"self",
")",
":",
"obj",
"=",
"[",
"]",
"self",
".",
"context",
".",
"addObject",
"(",
"obj",
")",
"l",
"=",
"self",
".",
"stream",
".",
"read_ulong",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"l",
")",
":",
"obj",
".",... | Read a C{list} from the data stream. | [
"Read",
"a",
"C",
"{",
"list",
"}",
"from",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L247-L258 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readTypedObject | def readTypedObject(self):
"""
Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class}
"""
class_alias = self.readString()
try:
alias = self.context.getClassAlias(class_alias)
... | python | def readTypedObject(self):
"""
Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class}
"""
class_alias = self.readString()
try:
alias = self.context.getClassAlias(class_alias)
... | [
"def",
"readTypedObject",
"(",
"self",
")",
":",
"class_alias",
"=",
"self",
".",
"readString",
"(",
")",
"try",
":",
"alias",
"=",
"self",
".",
"context",
".",
"getClassAlias",
"(",
"class_alias",
")",
"except",
"pyamf",
".",
"UnknownClassAlias",
":",
"if... | Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class} | [
"Reads",
"an",
"aliased",
"ActionScript",
"object",
"from",
"the",
"stream",
"and",
"attempts",
"to",
"cast",
"it",
"into",
"a",
"python",
"class",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L260-L283 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readObject | def readObject(self):
"""
Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>}
"""
obj = pyamf.ASObject()
self.context.addObject(obj)
obj.update(self.readObjectAttributes(obj))
return obj | python | def readObject(self):
"""
Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>}
"""
obj = pyamf.ASObject()
self.context.addObject(obj)
obj.update(self.readObjectAttributes(obj))
return obj | [
"def",
"readObject",
"(",
"self",
")",
":",
"obj",
"=",
"pyamf",
".",
"ASObject",
"(",
")",
"self",
".",
"context",
".",
"addObject",
"(",
"obj",
")",
"obj",
".",
"update",
"(",
"self",
".",
"readObjectAttributes",
"(",
"obj",
")",
")",
"return",
"ob... | Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>} | [
"Reads",
"an",
"anonymous",
"object",
"from",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L307-L318 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readReference | def readReference(self):
"""
Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference.
"""
idx = self.stream.read_ushort()
o = self.context.getObject(idx)
if o is None:
raise pyamf.ReferenceError('Unknown reference %d' %... | python | def readReference(self):
"""
Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference.
"""
idx = self.stream.read_ushort()
o = self.context.getObject(idx)
if o is None:
raise pyamf.ReferenceError('Unknown reference %d' %... | [
"def",
"readReference",
"(",
"self",
")",
":",
"idx",
"=",
"self",
".",
"stream",
".",
"read_ushort",
"(",
")",
"o",
"=",
"self",
".",
"context",
".",
"getObject",
"(",
"idx",
")",
"if",
"o",
"is",
"None",
":",
"raise",
"pyamf",
".",
"ReferenceError"... | Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference. | [
"Reads",
"a",
"reference",
"from",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L320-L332 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readDate | def readDate(self):
"""
Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed si... | python | def readDate(self):
"""
Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed si... | [
"def",
"readDate",
"(",
"self",
")",
":",
"ms",
"=",
"self",
".",
"stream",
".",
"read_double",
"(",
")",
"/",
"1000.0",
"self",
".",
"stream",
".",
"read_short",
"(",
")",
"# tz",
"# Timezones are ignored",
"d",
"=",
"util",
".",
"get_datetime",
"(",
... | Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed since 1/1/1970 0:00 to the specified time.... | [
"Reads",
"a",
"UTC",
"date",
"from",
"the",
"data",
"stream",
".",
"Client",
"and",
"servers",
"are",
"responsible",
"for",
"applying",
"their",
"own",
"timezones",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L334-L357 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readLongString | def readLongString(self):
"""
Read UTF8 string.
"""
l = self.stream.read_ulong()
bytes = self.stream.read(l)
return self.context.getStringForBytes(bytes) | python | def readLongString(self):
"""
Read UTF8 string.
"""
l = self.stream.read_ulong()
bytes = self.stream.read(l)
return self.context.getStringForBytes(bytes) | [
"def",
"readLongString",
"(",
"self",
")",
":",
"l",
"=",
"self",
".",
"stream",
".",
"read_ulong",
"(",
")",
"bytes",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"l",
")",
"return",
"self",
".",
"context",
".",
"getStringForBytes",
"(",
"bytes",
"... | Read UTF8 string. | [
"Read",
"UTF8",
"string",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L359-L367 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readXML | def readXML(self):
"""
Read XML.
"""
data = self.readLongString()
root = xml.fromstring(data)
self.context.addObject(root)
return root | python | def readXML(self):
"""
Read XML.
"""
data = self.readLongString()
root = xml.fromstring(data)
self.context.addObject(root)
return root | [
"def",
"readXML",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"readLongString",
"(",
")",
"root",
"=",
"xml",
".",
"fromstring",
"(",
"data",
")",
"self",
".",
"context",
".",
"addObject",
"(",
"root",
")",
"return",
"root"
] | Read XML. | [
"Read",
"XML",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L369-L378 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeList | def writeList(self, a):
"""
Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream.
"""
if self.writeReference(a) != -1:
return
self.context.addObject(a)
self.writeType(TYPE_ARRAY)
self.stream.write_ulong(l... | python | def writeList(self, a):
"""
Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream.
"""
if self.writeReference(a) != -1:
return
self.context.addObject(a)
self.writeType(TYPE_ARRAY)
self.stream.write_ulong(l... | [
"def",
"writeList",
"(",
"self",
",",
"a",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"a",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"a",
")",
"self",
".",
"writeType",
"(",
"TYPE_ARRAY",
")",
"self... | Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream. | [
"Write",
"array",
"to",
"the",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L432-L447 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeNumber | def writeNumber(self, n):
"""
Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_NUMBER)
self.stream.write_double(float(n)) | python | def writeNumber(self, n):
"""
Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_NUMBER)
self.stream.write_double(float(n)) | [
"def",
"writeNumber",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_NUMBER",
")",
"self",
".",
"stream",
".",
"write_double",
"(",
"float",
"(",
"n",
")",
")"
] | Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream. | [
"Write",
"number",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L449-L456 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeBoolean | def writeBoolean(self, b):
"""
Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_BOOL)
if b:
self.stream.write_uchar(1)
else:
self.stream.write_uchar(0) | python | def writeBoolean(self, b):
"""
Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_BOOL)
if b:
self.stream.write_uchar(1)
else:
self.stream.write_uchar(0) | [
"def",
"writeBoolean",
"(",
"self",
",",
"b",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_BOOL",
")",
"if",
"b",
":",
"self",
".",
"stream",
".",
"write_uchar",
"(",
"1",
")",
"else",
":",
"self",
".",
"stream",
".",
"write_uchar",
"(",
"0",
")"... | Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream. | [
"Write",
"boolean",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L458-L469 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.serialiseString | def serialiseString(self, s):
"""
Similar to L{writeString} but does not encode a type byte.
"""
if type(s) is unicode:
s = self.context.getBytesForString(s)
l = len(s)
if l > 0xffff:
self.stream.write_ulong(l)
else:
self.stre... | python | def serialiseString(self, s):
"""
Similar to L{writeString} but does not encode a type byte.
"""
if type(s) is unicode:
s = self.context.getBytesForString(s)
l = len(s)
if l > 0xffff:
self.stream.write_ulong(l)
else:
self.stre... | [
"def",
"serialiseString",
"(",
"self",
",",
"s",
")",
":",
"if",
"type",
"(",
"s",
")",
"is",
"unicode",
":",
"s",
"=",
"self",
".",
"context",
".",
"getBytesForString",
"(",
"s",
")",
"l",
"=",
"len",
"(",
"s",
")",
"if",
"l",
">",
"0xffff",
"... | Similar to L{writeString} but does not encode a type byte. | [
"Similar",
"to",
"L",
"{",
"writeString",
"}",
"but",
"does",
"not",
"encode",
"a",
"type",
"byte",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L471-L485 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeBytes | def writeBytes(self, s):
"""
Write a string of bytes to the data stream.
"""
l = len(s)
if l > 0xffff:
self.writeType(TYPE_LONGSTRING)
else:
self.writeType(TYPE_STRING)
if l > 0xffff:
self.stream.write_ulong(l)
else:
... | python | def writeBytes(self, s):
"""
Write a string of bytes to the data stream.
"""
l = len(s)
if l > 0xffff:
self.writeType(TYPE_LONGSTRING)
else:
self.writeType(TYPE_STRING)
if l > 0xffff:
self.stream.write_ulong(l)
else:
... | [
"def",
"writeBytes",
"(",
"self",
",",
"s",
")",
":",
"l",
"=",
"len",
"(",
"s",
")",
"if",
"l",
">",
"0xffff",
":",
"self",
".",
"writeType",
"(",
"TYPE_LONGSTRING",
")",
"else",
":",
"self",
".",
"writeType",
"(",
"TYPE_STRING",
")",
"if",
"l",
... | Write a string of bytes to the data stream. | [
"Write",
"a",
"string",
"of",
"bytes",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L487-L503 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeString | def writeString(self, u):
"""
Write a unicode to the data stream.
"""
s = self.context.getBytesForString(u)
self.writeBytes(s) | python | def writeString(self, u):
"""
Write a unicode to the data stream.
"""
s = self.context.getBytesForString(u)
self.writeBytes(s) | [
"def",
"writeString",
"(",
"self",
",",
"u",
")",
":",
"s",
"=",
"self",
".",
"context",
".",
"getBytesForString",
"(",
"u",
")",
"self",
".",
"writeBytes",
"(",
"s",
")"
] | Write a unicode to the data stream. | [
"Write",
"a",
"unicode",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L505-L511 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeReference | def writeReference(self, o):
"""
Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream.
"""
idx = self.context.getObjectReference(o)
if idx == -1 or idx > 65535:
return -1
self.writeType(TYPE_REFERENCE... | python | def writeReference(self, o):
"""
Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream.
"""
idx = self.context.getObjectReference(o)
if idx == -1 or idx > 65535:
return -1
self.writeType(TYPE_REFERENCE... | [
"def",
"writeReference",
"(",
"self",
",",
"o",
")",
":",
"idx",
"=",
"self",
".",
"context",
".",
"getObjectReference",
"(",
"o",
")",
"if",
"idx",
"==",
"-",
"1",
"or",
"idx",
">",
"65535",
":",
"return",
"-",
"1",
"self",
".",
"writeType",
"(",
... | Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream. | [
"Write",
"reference",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L513-L527 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder._writeDict | def _writeDict(self, o):
"""
Write C{dict} to the data stream.
@param o: The C{dict} data to be encoded to the AMF0 data stream.
"""
for key, val in o.iteritems():
if type(key) in python.int_types:
key = str(key)
self.serialiseString(key)... | python | def _writeDict(self, o):
"""
Write C{dict} to the data stream.
@param o: The C{dict} data to be encoded to the AMF0 data stream.
"""
for key, val in o.iteritems():
if type(key) in python.int_types:
key = str(key)
self.serialiseString(key)... | [
"def",
"_writeDict",
"(",
"self",
",",
"o",
")",
":",
"for",
"key",
",",
"val",
"in",
"o",
".",
"iteritems",
"(",
")",
":",
"if",
"type",
"(",
"key",
")",
"in",
"python",
".",
"int_types",
":",
"key",
"=",
"str",
"(",
"key",
")",
"self",
".",
... | Write C{dict} to the data stream.
@param o: The C{dict} data to be encoded to the AMF0 data stream. | [
"Write",
"C",
"{",
"dict",
"}",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L529-L540 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeMixedArray | def writeMixedArray(self, o):
"""
Write mixed array to the data stream.
@type o: L{pyamf.MixedArray}
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
self.writeType(TYPE_MIXEDARRAY)
# TODO: optimise this
# work o... | python | def writeMixedArray(self, o):
"""
Write mixed array to the data stream.
@type o: L{pyamf.MixedArray}
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
self.writeType(TYPE_MIXEDARRAY)
# TODO: optimise this
# work o... | [
"def",
"writeMixedArray",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"o",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"o",
")",
"self",
".",
"writeType",
"(",
"TYPE_MIXEDARRAY",
"... | Write mixed array to the data stream.
@type o: L{pyamf.MixedArray} | [
"Write",
"mixed",
"array",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L542-L569 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeObject | def writeObject(self, o):
"""
Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream.
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
alias = self.context.getClassAlias(o.__class__)
... | python | def writeObject(self, o):
"""
Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream.
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
alias = self.context.getClassAlias(o.__class__)
... | [
"def",
"writeObject",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"o",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"o",
")",
"alias",
"=",
"self",
".",
"context",
".",
"getClassA... | Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream. | [
"Write",
"a",
"Python",
"object",
"to",
"the",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L574-L611 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeDate | def writeDate(self, d):
"""
Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream.
"""
if isinstance(d, datetime.time):
raise pyamf.EncodeError('A datetime.time instance was found ... | python | def writeDate(self, d):
"""
Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream.
"""
if isinstance(d, datetime.time):
raise pyamf.EncodeError('A datetime.time instance was found ... | [
"def",
"writeDate",
"(",
"self",
",",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"datetime",
".",
"time",
")",
":",
"raise",
"pyamf",
".",
"EncodeError",
"(",
"'A datetime.time instance was found but '",
"'AMF0 has no way to encode time objects. Please use '",
... | Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream. | [
"Writes",
"a",
"date",
"to",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L613-L635 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeXML | def writeXML(self, e):
"""
Writes an XML instance.
"""
self.writeType(TYPE_XML)
data = xml.tostring(e)
if isinstance(data, unicode):
data = data.encode('utf-8')
self.stream.write_ulong(len(data))
self.stream.write(data) | python | def writeXML(self, e):
"""
Writes an XML instance.
"""
self.writeType(TYPE_XML)
data = xml.tostring(e)
if isinstance(data, unicode):
data = data.encode('utf-8')
self.stream.write_ulong(len(data))
self.stream.write(data) | [
"def",
"writeXML",
"(",
"self",
",",
"e",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_XML",
")",
"data",
"=",
"xml",
".",
"tostring",
"(",
"e",
")",
"if",
"isinstance",
"(",
"data",
",",
"unicode",
")",
":",
"data",
"=",
"data",
".",
"encode",
... | Writes an XML instance. | [
"Writes",
"an",
"XML",
"instance",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L637-L649 |
jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeAMF3 | def writeAMF3(self, data):
"""
Writes an element in L{AMF3<pyamf.amf3>} format.
"""
self.writeType(TYPE_AMF3)
self.context.getAMF3Encoder(self).writeElement(data) | python | def writeAMF3(self, data):
"""
Writes an element in L{AMF3<pyamf.amf3>} format.
"""
self.writeType(TYPE_AMF3)
self.context.getAMF3Encoder(self).writeElement(data) | [
"def",
"writeAMF3",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_AMF3",
")",
"self",
".",
"context",
".",
"getAMF3Encoder",
"(",
"self",
")",
".",
"writeElement",
"(",
"data",
")"
] | Writes an element in L{AMF3<pyamf.amf3>} format. | [
"Writes",
"an",
"element",
"in",
"L",
"{",
"AMF3<pyamf",
".",
"amf3",
">",
"}",
"format",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L651-L657 |
abe-winter/pg13-py | pg13/redismodel.py | RedisModel.make_val | def make_val(clas,*vals):
"this doesn't need to be a classmethod -- it can be a normal instance method"
if clas.VALUE is None: raise TypeError('null meta-information in class for VALUE')
clas.type_check(zip(*clas.VALUE)[1],vals,'VALUE')
return msgpack.dumps(vals) | python | def make_val(clas,*vals):
"this doesn't need to be a classmethod -- it can be a normal instance method"
if clas.VALUE is None: raise TypeError('null meta-information in class for VALUE')
clas.type_check(zip(*clas.VALUE)[1],vals,'VALUE')
return msgpack.dumps(vals) | [
"def",
"make_val",
"(",
"clas",
",",
"*",
"vals",
")",
":",
"if",
"clas",
".",
"VALUE",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'null meta-information in class for VALUE'",
")",
"clas",
".",
"type_check",
"(",
"zip",
"(",
"*",
"clas",
".",
"VALUE",
... | this doesn't need to be a classmethod -- it can be a normal instance method | [
"this",
"doesn",
"t",
"need",
"to",
"be",
"a",
"classmethod",
"--",
"it",
"can",
"be",
"a",
"normal",
"instance",
"method"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L23-L27 |
abe-winter/pg13-py | pg13/redismodel.py | RedisModel.des | def des(clas,keyblob,valblob):
"deserialize. translate publish message, basically"
raise NotImplementedError("don't use tuples, it breaks __eq__. this function probably isn't used in real life")
raw_keyvals=msgpack.loads(keyblob)
(namespace,version),keyvals=raw_keyvals[:2],raw_keyvals[2:]
if na... | python | def des(clas,keyblob,valblob):
"deserialize. translate publish message, basically"
raise NotImplementedError("don't use tuples, it breaks __eq__. this function probably isn't used in real life")
raw_keyvals=msgpack.loads(keyblob)
(namespace,version),keyvals=raw_keyvals[:2],raw_keyvals[2:]
if na... | [
"def",
"des",
"(",
"clas",
",",
"keyblob",
",",
"valblob",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"don't use tuples, it breaks __eq__. this function probably isn't used in real life\"",
")",
"raw_keyvals",
"=",
"msgpack",
".",
"loads",
"(",
"keyblob",
")",
"("... | deserialize. translate publish message, basically | [
"deserialize",
".",
"translate",
"publish",
"message",
"basically"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L41-L51 |
abe-winter/pg13-py | pg13/redismodel.py | RedisModel.saveget | def saveget(self,con):
"save, return old value. todo: make the expire() atomic with a redis script"
k,v=self.kv()
oldv=con.getset(k,v)
if self.TTL is not None: con.expire(k,self.TTL)
return None if oldv is None else msgpack.loads(oldv) | python | def saveget(self,con):
"save, return old value. todo: make the expire() atomic with a redis script"
k,v=self.kv()
oldv=con.getset(k,v)
if self.TTL is not None: con.expire(k,self.TTL)
return None if oldv is None else msgpack.loads(oldv) | [
"def",
"saveget",
"(",
"self",
",",
"con",
")",
":",
"k",
",",
"v",
"=",
"self",
".",
"kv",
"(",
")",
"oldv",
"=",
"con",
".",
"getset",
"(",
"k",
",",
"v",
")",
"if",
"self",
".",
"TTL",
"is",
"not",
"None",
":",
"con",
".",
"expire",
"(",... | save, return old value. todo: make the expire() atomic with a redis script | [
"save",
"return",
"old",
"value",
".",
"todo",
":",
"make",
"the",
"expire",
"()",
"atomic",
"with",
"a",
"redis",
"script"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L57-L62 |
abe-winter/pg13-py | pg13/redismodel.py | RedisModel.pub | def pub(self,con):
"careful -- save and pub aren't the same"
k,v=self.kv()
con.publish(k,v) | python | def pub(self,con):
"careful -- save and pub aren't the same"
k,v=self.kv()
con.publish(k,v) | [
"def",
"pub",
"(",
"self",
",",
"con",
")",
":",
"k",
",",
"v",
"=",
"self",
".",
"kv",
"(",
")",
"con",
".",
"publish",
"(",
"k",
",",
"v",
")"
] | careful -- save and pub aren't the same | [
"careful",
"--",
"save",
"and",
"pub",
"aren",
"t",
"the",
"same"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L63-L66 |
abe-winter/pg13-py | pg13/redismodel.py | RedisSimplePubsub.wait | def wait(self):
"wait for a message, respecting timeout"
data=self.getcon().recv(256) # this can raise socket.timeout
if not data: raise PubsubDisco
if self.reset:
self.reset=False # i.e. ack it. reset is used to tell the wait-thread there was a reconnect (though it's plausible that this neve... | python | def wait(self):
"wait for a message, respecting timeout"
data=self.getcon().recv(256) # this can raise socket.timeout
if not data: raise PubsubDisco
if self.reset:
self.reset=False # i.e. ack it. reset is used to tell the wait-thread there was a reconnect (though it's plausible that this neve... | [
"def",
"wait",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"getcon",
"(",
")",
".",
"recv",
"(",
"256",
")",
"# this can raise socket.timeout\r",
"if",
"not",
"data",
":",
"raise",
"PubsubDisco",
"if",
"self",
".",
"reset",
":",
"self",
".",
"rese... | wait for a message, respecting timeout | [
"wait",
"for",
"a",
"message",
"respecting",
"timeout"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L117-L126 |
jut-io/jut-python-tools | jut/api/auth.py | get_access_token | def get_access_token(username=None,
password=None,
client_id=None,
client_secret=None,
app_url=defaults.APP_URL):
"""
get the access token (http://docs.jut.io/api-guide/#unique_171637733),
by either using the direct username... | python | def get_access_token(username=None,
password=None,
client_id=None,
client_secret=None,
app_url=defaults.APP_URL):
"""
get the access token (http://docs.jut.io/api-guide/#unique_171637733),
by either using the direct username... | [
"def",
"get_access_token",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"client_secret",
"=",
"None",
",",
"app_url",
"=",
"defaults",
".",
"APP_URL",
")",
":",
"sess",
"=",
"requests",
".",
"Session",
"... | get the access token (http://docs.jut.io/api-guide/#unique_171637733),
by either using the direct username, password combination or better yet by
using the authorization grant you generated on jut with the client_id,
client_secret combination
auth_url: auth url for the jut application (defaults to prod... | [
"get",
"the",
"access",
"token",
"(",
"http",
":",
"//",
"docs",
".",
"jut",
".",
"io",
"/",
"api",
"-",
"guide",
"/",
"#unique_171637733",
")",
"by",
"either",
"using",
"the",
"direct",
"username",
"password",
"combination",
"or",
"better",
"yet",
"by",... | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/auth.py#L96-L160 |
jut-io/jut-python-tools | jut/api/auth.py | TokenManager.get_access_token | def get_access_token(self):
"""
get a valid access token
"""
if self.is_access_token_expired():
if is_debug_enabled():
debug('requesting new access_token')
token = get_access_token(username=self.username,
pas... | python | def get_access_token(self):
"""
get a valid access token
"""
if self.is_access_token_expired():
if is_debug_enabled():
debug('requesting new access_token')
token = get_access_token(username=self.username,
pas... | [
"def",
"get_access_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_access_token_expired",
"(",
")",
":",
"if",
"is_debug_enabled",
"(",
")",
":",
"debug",
"(",
"'requesting new access_token'",
")",
"token",
"=",
"get_access_token",
"(",
"username",
"=",
... | get a valid access token | [
"get",
"a",
"valid",
"access",
"token"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/auth.py#L61-L81 |
chrisdrackett/django-support | support/forms/html5/fields.py | IntegerField.widget_attrs | def widget_attrs(self, widget):
"""
Given a Widget instance (*not* a Widget class), returns a dictionary of
any HTML attributes that should be added to the Widget, based on this
Field.
"""
attrs = {}
if getattr(self, "min_value", None) is not None:
att... | python | def widget_attrs(self, widget):
"""
Given a Widget instance (*not* a Widget class), returns a dictionary of
any HTML attributes that should be added to the Widget, based on this
Field.
"""
attrs = {}
if getattr(self, "min_value", None) is not None:
att... | [
"def",
"widget_attrs",
"(",
"self",
",",
"widget",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"getattr",
"(",
"self",
",",
"\"min_value\"",
",",
"None",
")",
"is",
"not",
"None",
":",
"attrs",
"[",
"'min'",
"]",
"=",
"self",
".",
"min_value",
"if",
"g... | Given a Widget instance (*not* a Widget class), returns a dictionary of
any HTML attributes that should be added to the Widget, based on this
Field. | [
"Given",
"a",
"Widget",
"instance",
"(",
"*",
"not",
"*",
"a",
"Widget",
"class",
")",
"returns",
"a",
"dictionary",
"of",
"any",
"HTML",
"attributes",
"that",
"should",
"be",
"added",
"to",
"the",
"Widget",
"based",
"on",
"this",
"Field",
"."
] | train | https://github.com/chrisdrackett/django-support/blob/a4f29421a31797e0b069637a0afec85328b4f0ca/support/forms/html5/fields.py#L12-L23 |
rbarrois/confutils | confutils/configfile.py | ConfigLineList.find_lines | def find_lines(self, line):
"""Find all lines matching a given line."""
for other_line in self.lines:
if other_line.match(line):
yield other_line | python | def find_lines(self, line):
"""Find all lines matching a given line."""
for other_line in self.lines:
if other_line.match(line):
yield other_line | [
"def",
"find_lines",
"(",
"self",
",",
"line",
")",
":",
"for",
"other_line",
"in",
"self",
".",
"lines",
":",
"if",
"other_line",
".",
"match",
"(",
"line",
")",
":",
"yield",
"other_line"
] | Find all lines matching a given line. | [
"Find",
"all",
"lines",
"matching",
"a",
"given",
"line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L110-L114 |
rbarrois/confutils | confutils/configfile.py | ConfigLineList.update | def update(self, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
"""
nb = 0
for i, line in enumerate(self.lines):
if line.match(old_line):
self.line... | python | def update(self, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
"""
nb = 0
for i, line in enumerate(self.lines):
if line.match(old_line):
self.line... | [
"def",
"update",
"(",
"self",
",",
"old_line",
",",
"new_line",
",",
"once",
"=",
"False",
")",
":",
"nb",
"=",
"0",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"self",
".",
"lines",
")",
":",
"if",
"line",
".",
"match",
"(",
"old_line",
")"... | Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance. | [
"Replace",
"all",
"lines",
"matching",
"old_line",
"with",
"new_line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L121-L133 |
rbarrois/confutils | confutils/configfile.py | Section.update | def update(self, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
"""
nb = 0
for block in self.blocks:
nb += block.update(old_line, new_line, once=once)
... | python | def update(self, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
"""
nb = 0
for block in self.blocks:
nb += block.update(old_line, new_line, once=once)
... | [
"def",
"update",
"(",
"self",
",",
"old_line",
",",
"new_line",
",",
"once",
"=",
"False",
")",
":",
"nb",
"=",
"0",
"for",
"block",
"in",
"self",
".",
"blocks",
":",
"nb",
"+=",
"block",
".",
"update",
"(",
"old_line",
",",
"new_line",
",",
"once"... | Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance. | [
"Replace",
"all",
"lines",
"matching",
"old_line",
"with",
"new_line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L215-L225 |
rbarrois/confutils | confutils/configfile.py | Section.remove | def remove(self, line):
"""Delete all lines matching the given line."""
nb = 0
for block in self.blocks:
nb += block.remove(line)
return nb | python | def remove(self, line):
"""Delete all lines matching the given line."""
nb = 0
for block in self.blocks:
nb += block.remove(line)
return nb | [
"def",
"remove",
"(",
"self",
",",
"line",
")",
":",
"nb",
"=",
"0",
"for",
"block",
"in",
"self",
".",
"blocks",
":",
"nb",
"+=",
"block",
".",
"remove",
"(",
"line",
")",
"return",
"nb"
] | Delete all lines matching the given line. | [
"Delete",
"all",
"lines",
"matching",
"the",
"given",
"line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L227-L233 |
rbarrois/confutils | confutils/configfile.py | MultiValuedSectionView.add | def add(self, key, value):
"""Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values.
"""
self.configfile.add(self.name, key, value) | python | def add(self, key, value):
"""Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values.
"""
self.configfile.add(self.name, key, value) | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"configfile",
".",
"add",
"(",
"self",
".",
"name",
",",
"key",
",",
"value",
")"
] | Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values. | [
"Add",
"a",
"new",
"value",
"for",
"a",
"key",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L298-L305 |
rbarrois/confutils | confutils/configfile.py | ConfigFile._get_section | def _get_section(self, name, create=True):
"""Retrieve a section by name. Create it on first access."""
try:
return self.sections[name]
except KeyError:
if not create:
raise
section = Section(name)
self.sections[name] = section
... | python | def _get_section(self, name, create=True):
"""Retrieve a section by name. Create it on first access."""
try:
return self.sections[name]
except KeyError:
if not create:
raise
section = Section(name)
self.sections[name] = section
... | [
"def",
"_get_section",
"(",
"self",
",",
"name",
",",
"create",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"sections",
"[",
"name",
"]",
"except",
"KeyError",
":",
"if",
"not",
"create",
":",
"raise",
"section",
"=",
"Section",
"(",
"n... | Retrieve a section by name. Create it on first access. | [
"Retrieve",
"a",
"section",
"by",
"name",
".",
"Create",
"it",
"on",
"first",
"access",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L339-L349 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.get_line | def get_line(self, section, line):
"""Retrieve all lines compatible with a given line."""
try:
section = self._get_section(section, create=False)
except KeyError:
return []
return section.find_lines(line) | python | def get_line(self, section, line):
"""Retrieve all lines compatible with a given line."""
try:
section = self._get_section(section, create=False)
except KeyError:
return []
return section.find_lines(line) | [
"def",
"get_line",
"(",
"self",
",",
"section",
",",
"line",
")",
":",
"try",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"return",
"[",
"]",
"return",
"section",
".",
... | Retrieve all lines compatible with a given line. | [
"Retrieve",
"all",
"lines",
"compatible",
"with",
"a",
"given",
"line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L358-L364 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.iter_lines | def iter_lines(self, section):
"""Iterate over all lines in a section.
This will skip 'header' lines.
"""
try:
section = self._get_section(section, create=False)
except KeyError:
return
for block in section:
for line in block:
... | python | def iter_lines(self, section):
"""Iterate over all lines in a section.
This will skip 'header' lines.
"""
try:
section = self._get_section(section, create=False)
except KeyError:
return
for block in section:
for line in block:
... | [
"def",
"iter_lines",
"(",
"self",
",",
"section",
")",
":",
"try",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"return",
"for",
"block",
"in",
"section",
":",
"for",
"li... | Iterate over all lines in a section.
This will skip 'header' lines. | [
"Iterate",
"over",
"all",
"lines",
"in",
"a",
"section",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L366-L378 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.enter_block | def enter_block(self, name):
"""Mark 'entering a block'."""
section = self._get_section(name)
block = self.current_block = section.new_block()
self.blocks.append(block)
return block | python | def enter_block(self, name):
"""Mark 'entering a block'."""
section = self._get_section(name)
block = self.current_block = section.new_block()
self.blocks.append(block)
return block | [
"def",
"enter_block",
"(",
"self",
",",
"name",
")",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"name",
")",
"block",
"=",
"self",
".",
"current_block",
"=",
"section",
".",
"new_block",
"(",
")",
"self",
".",
"blocks",
".",
"append",
"(",
... | Mark 'entering a block'. | [
"Mark",
"entering",
"a",
"block",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L383-L388 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.insert_line | def insert_line(self, line):
"""Insert a new line"""
if self.current_block is not None:
self.current_block.append(line)
else:
self.header.append(line) | python | def insert_line(self, line):
"""Insert a new line"""
if self.current_block is not None:
self.current_block.append(line)
else:
self.header.append(line) | [
"def",
"insert_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"current_block",
"is",
"not",
"None",
":",
"self",
".",
"current_block",
".",
"append",
"(",
"line",
")",
"else",
":",
"self",
".",
"header",
".",
"append",
"(",
"line",
")"... | Insert a new line | [
"Insert",
"a",
"new",
"line"
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L390-L395 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.handle_line | def handle_line(self, line):
"""Read one line."""
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line) | python | def handle_line(self, line):
"""Read one line."""
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line) | [
"def",
"handle_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
".",
"kind",
"==",
"ConfigLine",
".",
"KIND_HEADER",
":",
"self",
".",
"enter_block",
"(",
"line",
".",
"header",
")",
"else",
":",
"self",
".",
"insert_line",
"(",
"line",
")"
] | Read one line. | [
"Read",
"one",
"line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L397-L402 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.parse | def parse(self, fileobj, name_hint='', parser=None):
"""Fill from a file-like object."""
self.current_block = None # Reset current block
parser = parser or Parser()
for line in parser.parse(fileobj, name_hint=name_hint):
self.handle_line(line) | python | def parse(self, fileobj, name_hint='', parser=None):
"""Fill from a file-like object."""
self.current_block = None # Reset current block
parser = parser or Parser()
for line in parser.parse(fileobj, name_hint=name_hint):
self.handle_line(line) | [
"def",
"parse",
"(",
"self",
",",
"fileobj",
",",
"name_hint",
"=",
"''",
",",
"parser",
"=",
"None",
")",
":",
"self",
".",
"current_block",
"=",
"None",
"# Reset current block",
"parser",
"=",
"parser",
"or",
"Parser",
"(",
")",
"for",
"line",
"in",
... | Fill from a file-like object. | [
"Fill",
"from",
"a",
"file",
"-",
"like",
"object",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L404-L409 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.update_line | def update_line(self, section, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
Returns:
int: the number of updates performed
"""
try:
s = self._get_sec... | python | def update_line(self, section, old_line, new_line, once=False):
"""Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
Returns:
int: the number of updates performed
"""
try:
s = self._get_sec... | [
"def",
"update_line",
"(",
"self",
",",
"section",
",",
"old_line",
",",
"new_line",
",",
"once",
"=",
"False",
")",
":",
"try",
":",
"s",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
... | Replace all lines matching `old_line` with `new_line`.
If ``once`` is set to True, remove only the first instance.
Returns:
int: the number of updates performed | [
"Replace",
"all",
"lines",
"matching",
"old_line",
"with",
"new_line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L434-L446 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.remove_line | def remove_line(self, section, line):
"""Remove all instances of a line.
Returns:
int: the number of lines removed
"""
try:
s = self._get_section(section, create=False)
except KeyError:
# No such section, skip.
return 0
re... | python | def remove_line(self, section, line):
"""Remove all instances of a line.
Returns:
int: the number of lines removed
"""
try:
s = self._get_section(section, create=False)
except KeyError:
# No such section, skip.
return 0
re... | [
"def",
"remove_line",
"(",
"self",
",",
"section",
",",
"line",
")",
":",
"try",
":",
"s",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"# No such section, skip.",
"return",
"0",
"return",
... | Remove all instances of a line.
Returns:
int: the number of lines removed | [
"Remove",
"all",
"instances",
"of",
"a",
"line",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L448-L460 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.items | def items(self, section):
"""Retrieve all key/value pairs for a given section."""
for line in self.iter_lines(section):
if line.kind == ConfigLine.KIND_DATA:
yield line.key, line.value | python | def items(self, section):
"""Retrieve all key/value pairs for a given section."""
for line in self.iter_lines(section):
if line.kind == ConfigLine.KIND_DATA:
yield line.key, line.value | [
"def",
"items",
"(",
"self",
",",
"section",
")",
":",
"for",
"line",
"in",
"self",
".",
"iter_lines",
"(",
"section",
")",
":",
"if",
"line",
".",
"kind",
"==",
"ConfigLine",
".",
"KIND_DATA",
":",
"yield",
"line",
".",
"key",
",",
"line",
".",
"v... | Retrieve all key/value pairs for a given section. | [
"Retrieve",
"all",
"key",
"/",
"value",
"pairs",
"for",
"a",
"given",
"section",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L468-L472 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.get | def get(self, section, key):
"""Return the 'value' of all lines matching the section/key.
Yields:
values for matching lines.
"""
line = self._make_line(key)
for line in self.get_line(section, line):
yield line.value | python | def get(self, section, key):
"""Return the 'value' of all lines matching the section/key.
Yields:
values for matching lines.
"""
line = self._make_line(key)
for line in self.get_line(section, line):
yield line.value | [
"def",
"get",
"(",
"self",
",",
"section",
",",
"key",
")",
":",
"line",
"=",
"self",
".",
"_make_line",
"(",
"key",
")",
"for",
"line",
"in",
"self",
".",
"get_line",
"(",
"section",
",",
"line",
")",
":",
"yield",
"line",
".",
"value"
] | Return the 'value' of all lines matching the section/key.
Yields:
values for matching lines. | [
"Return",
"the",
"value",
"of",
"all",
"lines",
"matching",
"the",
"section",
"/",
"key",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L474-L482 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.get_one | def get_one(self, section, key):
"""Retrieve the first value for a section/key.
Raises:
KeyError: If no line match the given section/key.
"""
lines = iter(self.get(section, key))
try:
return next(lines)
except StopIteration:
raise KeyE... | python | def get_one(self, section, key):
"""Retrieve the first value for a section/key.
Raises:
KeyError: If no line match the given section/key.
"""
lines = iter(self.get(section, key))
try:
return next(lines)
except StopIteration:
raise KeyE... | [
"def",
"get_one",
"(",
"self",
",",
"section",
",",
"key",
")",
":",
"lines",
"=",
"iter",
"(",
"self",
".",
"get",
"(",
"section",
",",
"key",
")",
")",
"try",
":",
"return",
"next",
"(",
"lines",
")",
"except",
"StopIteration",
":",
"raise",
"Key... | Retrieve the first value for a section/key.
Raises:
KeyError: If no line match the given section/key. | [
"Retrieve",
"the",
"first",
"value",
"for",
"a",
"section",
"/",
"key",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L484-L494 |
rbarrois/confutils | confutils/configfile.py | ConfigFile.add_or_update | def add_or_update(self, section, key, value):
"""Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines.
"""
updates = self.update(section, key, value)
if updates == 0:
self.add(section, key, value)
return u... | python | def add_or_update(self, section, key, value):
"""Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines.
"""
updates = self.update(section, key, value)
if updates == 0:
self.add(section, key, value)
return u... | [
"def",
"add_or_update",
"(",
"self",
",",
"section",
",",
"key",
",",
"value",
")",
":",
"updates",
"=",
"self",
".",
"update",
"(",
"section",
",",
"key",
",",
"value",
")",
"if",
"updates",
"==",
"0",
":",
"self",
".",
"add",
"(",
"section",
",",... | Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines. | [
"Update",
"the",
"key",
"or",
"if",
"no",
"previous",
"value",
"existed",
"add",
"it",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L500-L509 |
minhhoit/yacms | yacms/utils/cache.py | cache_set | def cache_set(key, value, timeout=None, refreshed=False):
"""
Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry... | python | def cache_set(key, value, timeout=None, refreshed=False):
"""
Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry... | [
"def",
"cache_set",
"(",
"key",
",",
"value",
",",
"timeout",
"=",
"None",
",",
"refreshed",
"=",
"False",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"settings",
".",
"CACHE_MIDDLEWARE_SECONDS",
"refresh_time",
"=",
"timeout",
"+",
"time... | Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry that has
``CACHE_SET_DELAY_SECONDS`` added to it. In this case th... | [
"Wrapper",
"for",
"cache",
".",
"set",
".",
"Stores",
"the",
"cache",
"entry",
"packed",
"with",
"the",
"desired",
"cache",
"expiry",
"time",
".",
"When",
"the",
"entry",
"is",
"retrieved",
"from",
"cache",
"the",
"packed",
"expiry",
"time",
"is",
"also",
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L26-L42 |
minhhoit/yacms | yacms/utils/cache.py | cache_get | def cache_get(key):
"""
Wrapper for ``cache.get``. The expiry time for the cache entry
is stored with the entry. If the expiry time has past, put the
stale entry back into cache, and don't return it to trigger a
fake cache miss.
"""
packed = cache.get(_hashed_key(key))
if packed is None:... | python | def cache_get(key):
"""
Wrapper for ``cache.get``. The expiry time for the cache entry
is stored with the entry. If the expiry time has past, put the
stale entry back into cache, and don't return it to trigger a
fake cache miss.
"""
packed = cache.get(_hashed_key(key))
if packed is None:... | [
"def",
"cache_get",
"(",
"key",
")",
":",
"packed",
"=",
"cache",
".",
"get",
"(",
"_hashed_key",
"(",
"key",
")",
")",
"if",
"packed",
"is",
"None",
":",
"return",
"None",
"value",
",",
"refresh_time",
",",
"refreshed",
"=",
"packed",
"if",
"(",
"ti... | Wrapper for ``cache.get``. The expiry time for the cache entry
is stored with the entry. If the expiry time has past, put the
stale entry back into cache, and don't return it to trigger a
fake cache miss. | [
"Wrapper",
"for",
"cache",
".",
"get",
".",
"The",
"expiry",
"time",
"for",
"the",
"cache",
"entry",
"is",
"stored",
"with",
"the",
"entry",
".",
"If",
"the",
"expiry",
"time",
"has",
"past",
"put",
"the",
"stale",
"entry",
"back",
"into",
"cache",
"an... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L45-L59 |
minhhoit/yacms | yacms/utils/cache.py | cache_installed | def cache_installed():
"""
Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached.
"""
has_key = bool(getattr(settings, "NEVERCACHE_KEY", ""))
def flatten(seqs):
retu... | python | def cache_installed():
"""
Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached.
"""
has_key = bool(getattr(settings, "NEVERCACHE_KEY", ""))
def flatten(seqs):
retu... | [
"def",
"cache_installed",
"(",
")",
":",
"has_key",
"=",
"bool",
"(",
"getattr",
"(",
"settings",
",",
"\"NEVERCACHE_KEY\"",
",",
"\"\"",
")",
")",
"def",
"flatten",
"(",
"seqs",
")",
":",
"return",
"(",
"item",
"for",
"seq",
"in",
"seqs",
"for",
"item... | Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached. | [
"Returns",
"True",
"if",
"a",
"cache",
"backend",
"is",
"configured",
"and",
"the",
"cache",
"middleware",
"classes",
"or",
"subclasses",
"thereof",
"are",
"present",
".",
"This",
"will",
"be",
"evaluated",
"once",
"per",
"run",
"and",
"then",
"cached",
"."
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L63-L83 |
minhhoit/yacms | yacms/utils/cache.py | cache_key_prefix | def cache_key_prefix(request):
"""
Cache key for yacms's cache middleware. Adds the current
device and site ID.
"""
cache_key = "%s.%s.%s." % (
settings.CACHE_MIDDLEWARE_KEY_PREFIX,
current_site_id(),
device_from_request(request) or "default",
)
return _i18n_cache_key... | python | def cache_key_prefix(request):
"""
Cache key for yacms's cache middleware. Adds the current
device and site ID.
"""
cache_key = "%s.%s.%s." % (
settings.CACHE_MIDDLEWARE_KEY_PREFIX,
current_site_id(),
device_from_request(request) or "default",
)
return _i18n_cache_key... | [
"def",
"cache_key_prefix",
"(",
"request",
")",
":",
"cache_key",
"=",
"\"%s.%s.%s.\"",
"%",
"(",
"settings",
".",
"CACHE_MIDDLEWARE_KEY_PREFIX",
",",
"current_site_id",
"(",
")",
",",
"device_from_request",
"(",
"request",
")",
"or",
"\"default\"",
",",
")",
"r... | Cache key for yacms's cache middleware. Adds the current
device and site ID. | [
"Cache",
"key",
"for",
"yacms",
"s",
"cache",
"middleware",
".",
"Adds",
"the",
"current",
"device",
"and",
"site",
"ID",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L86-L96 |
minhhoit/yacms | yacms/utils/cache.py | add_cache_bypass | def add_cache_bypass(url):
"""
Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings.
"""
if not cache_installed():
return url
hash_str =... | python | def add_cache_bypass(url):
"""
Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings.
"""
if not cache_installed():
return url
hash_str =... | [
"def",
"add_cache_bypass",
"(",
"url",
")",
":",
"if",
"not",
"cache_installed",
"(",
")",
":",
"return",
"url",
"hash_str",
"=",
"\"\"",
"if",
"\"#\"",
"in",
"url",
":",
"url",
",",
"hash_str",
"=",
"url",
".",
"split",
"(",
"\"#\"",
",",
"1",
")",
... | Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings. | [
"Adds",
"the",
"current",
"time",
"to",
"the",
"querystring",
"of",
"the",
"URL",
"to",
"force",
"a",
"cache",
"reload",
".",
"Used",
"for",
"when",
"a",
"form",
"post",
"redirects",
"back",
"to",
"a",
"page",
"that",
"should",
"display",
"updated",
"con... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L107-L121 |
xtrementl/focus | focus/plugin/modules/im.py | _dbus_get_object | def _dbus_get_object(bus_name, object_name):
""" Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``.
"""
try:
bus = dbus.... | python | def _dbus_get_object(bus_name, object_name):
""" Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``.
"""
try:
bus = dbus.... | [
"def",
"_dbus_get_object",
"(",
"bus_name",
",",
"object_name",
")",
":",
"try",
":",
"bus",
"=",
"dbus",
".",
"SessionBus",
"(",
")",
"obj",
"=",
"bus",
".",
"get_object",
"(",
"bus_name",
",",
"object_name",
")",
"return",
"obj",
"except",
"(",
"NameEr... | Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``. | [
"Fetches",
"DBUS",
"proxy",
"object",
"given",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L50-L67 |
xtrementl/focus | focus/plugin/modules/im.py | _dbus_get_interface | def _dbus_get_interface(bus_name, object_name, interface_name):
""" Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the ... | python | def _dbus_get_interface(bus_name, object_name, interface_name):
""" Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the ... | [
"def",
"_dbus_get_interface",
"(",
"bus_name",
",",
"object_name",
",",
"interface_name",
")",
":",
"try",
":",
"obj",
"=",
"_dbus_get_object",
"(",
"bus_name",
",",
"object_name",
")",
"if",
"not",
"obj",
":",
"raise",
"NameError",
"return",
"dbus",
".",
"I... | Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the interface.
Returns object or ``None``. | [
"Fetches",
"DBUS",
"interface",
"proxy",
"object",
"given",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L70-L90 |
xtrementl/focus | focus/plugin/modules/im.py | _pidgin_status | def _pidgin_status(status, message):
""" Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('im.pidgin.purple.PurpleService',
'/im... | python | def _pidgin_status(status, message):
""" Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('im.pidgin.purple.PurpleService',
'/im... | [
"def",
"_pidgin_status",
"(",
"status",
",",
"message",
")",
":",
"try",
":",
"iface",
"=",
"_dbus_get_interface",
"(",
"'im.pidgin.purple.PurpleService'",
",",
"'/im/pidgin/purple/PurpleObject'",
",",
"'im.pidgin.purple.PurpleInterface'",
")",
"if",
"iface",
":",
"# cr... | Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Pidgin",
"IM",
"application",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L93-L119 |
xtrementl/focus | focus/plugin/modules/im.py | _adium_status | def _adium_status(status, message):
""" Updates status and message for Adium IM application.
`status`
Status type.
`message`
Status message.
"""
# map status code
code = ADIUM_CODE_MAP[status]
# get message
if not message:
default_messages =... | python | def _adium_status(status, message):
""" Updates status and message for Adium IM application.
`status`
Status type.
`message`
Status message.
"""
# map status code
code = ADIUM_CODE_MAP[status]
# get message
if not message:
default_messages =... | [
"def",
"_adium_status",
"(",
"status",
",",
"message",
")",
":",
"# map status code",
"code",
"=",
"ADIUM_CODE_MAP",
"[",
"status",
"]",
"# get message",
"if",
"not",
"message",
":",
"default_messages",
"=",
"{",
"'busy'",
":",
"'Busy'",
",",
"'long_away'",
":... | Updates status and message for Adium IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Adium",
"IM",
"application",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L122-L162 |
xtrementl/focus | focus/plugin/modules/im.py | _empathy_status | def _empathy_status(status, message):
""" Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message.
"""
ACCT_IFACE = 'org.freedesktop.Telepathy.Account'
DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
ACCT... | python | def _empathy_status(status, message):
""" Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message.
"""
ACCT_IFACE = 'org.freedesktop.Telepathy.Account'
DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
ACCT... | [
"def",
"_empathy_status",
"(",
"status",
",",
"message",
")",
":",
"ACCT_IFACE",
"=",
"'org.freedesktop.Telepathy.Account'",
"DBUS_PROP_IFACE",
"=",
"'org.freedesktop.DBus.Properties'",
"ACCT_MAN_IFACE",
"=",
"'org.freedesktop.Telepathy.AccountManager'",
"ACCT_MAN_PATH",
"=",
"... | Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Empathy",
"IM",
"application",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L165-L213 |
xtrementl/focus | focus/plugin/modules/im.py | _linux_skype_status | def _linux_skype_status(status, message):
""" Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('com.Skype.API',
'/com/Sk... | python | def _linux_skype_status(status, message):
""" Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('com.Skype.API',
'/com/Sk... | [
"def",
"_linux_skype_status",
"(",
"status",
",",
"message",
")",
":",
"try",
":",
"iface",
"=",
"_dbus_get_interface",
"(",
"'com.Skype.API'",
",",
"'/com/Skype'",
",",
"'com.Skype.API'",
")",
"if",
"iface",
":",
"# authenticate",
"if",
"iface",
".",
"Invoke",
... | Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Skype",
"IM",
"application",
"on",
"Linux",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L216-L244 |
xtrementl/focus | focus/plugin/modules/im.py | _osx_skype_status | def _osx_skype_status(status, message):
""" Updates status and message for Skype IM application on Mac OSX.
`status`
Status type.
`message`
Status message.
"""
# XXX: Skype has a bug with it's applescript support on Snow Leopard
# where it will ignore the "n... | python | def _osx_skype_status(status, message):
""" Updates status and message for Skype IM application on Mac OSX.
`status`
Status type.
`message`
Status message.
"""
# XXX: Skype has a bug with it's applescript support on Snow Leopard
# where it will ignore the "n... | [
"def",
"_osx_skype_status",
"(",
"status",
",",
"message",
")",
":",
"# XXX: Skype has a bug with it's applescript support on Snow Leopard",
"# where it will ignore the \"not exists process\" expression when",
"# combined with \"tell application Skype\" and thus launches Skype if",
"# it's not... | Updates status and message for Skype IM application on Mac OSX.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Skype",
"IM",
"application",
"on",
"Mac",
"OSX",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L247-L330 |
xtrementl/focus | focus/plugin/modules/im.py | IMStatus._set_status | def _set_status(self, status, message=''):
""" Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message.
"""
message = message.strip()
# fetch away messa... | python | def _set_status(self, status, message=''):
""" Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message.
"""
message = message.strip()
# fetch away messa... | [
"def",
"_set_status",
"(",
"self",
",",
"status",
",",
"message",
"=",
"''",
")",
":",
"message",
"=",
"message",
".",
"strip",
"(",
")",
"# fetch away message from provided id",
"if",
"message",
".",
"startswith",
"(",
"':'",
")",
":",
"msg_id",
"=",
"mes... | Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message. | [
"Updates",
"the",
"status",
"and",
"message",
"on",
"all",
"supported",
"IM",
"apps",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L389-L409 |
xtrementl/focus | focus/plugin/modules/im.py | IMStatus.parse_option | def parse_option(self, option, block_name, *values):
""" Parse status, end_status, timer_status and status_msg options.
"""
if option.endswith('status'):
status = values[0]
if status not in self.VALID_STATUSES:
raise ValueError(u'Invalid IM status "{0... | python | def parse_option(self, option, block_name, *values):
""" Parse status, end_status, timer_status and status_msg options.
"""
if option.endswith('status'):
status = values[0]
if status not in self.VALID_STATUSES:
raise ValueError(u'Invalid IM status "{0... | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"if",
"option",
".",
"endswith",
"(",
"'status'",
")",
":",
"status",
"=",
"values",
"[",
"0",
"]",
"if",
"status",
"not",
"in",
"self",
".",
"VALID_S... | Parse status, end_status, timer_status and status_msg options. | [
"Parse",
"status",
"end_status",
"timer_status",
"and",
"status_msg",
"options",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L411-L434 |
cirruscluster/cirruscluster | cirruscluster/core.py | RetryUntilReturnsTrue | def RetryUntilReturnsTrue(tries, delay=2, backoff=1.5):
'''Retries a function or method until it returns True.
delay sets the initial delay in seconds, and backoff sets the factor by which
the delay should lengthen after each failure. backoff must be greater than 1,
or else it isn't really a backoff. tries mus... | python | def RetryUntilReturnsTrue(tries, delay=2, backoff=1.5):
'''Retries a function or method until it returns True.
delay sets the initial delay in seconds, and backoff sets the factor by which
the delay should lengthen after each failure. backoff must be greater than 1,
or else it isn't really a backoff. tries mus... | [
"def",
"RetryUntilReturnsTrue",
"(",
"tries",
",",
"delay",
"=",
"2",
",",
"backoff",
"=",
"1.5",
")",
":",
"if",
"backoff",
"<=",
"1",
":",
"raise",
"ValueError",
"(",
"\"backoff must be greater than 1\"",
")",
"tries",
"=",
"math",
".",
"floor",
"(",
"tr... | Retries a function or method until it returns True.
delay sets the initial delay in seconds, and backoff sets the factor by which
the delay should lengthen after each failure. backoff must be greater than 1,
or else it isn't really a backoff. tries must be at least 0, and delay
greater than 0. | [
"Retries",
"a",
"function",
"or",
"method",
"until",
"it",
"returns",
"True",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L50-L86 |
cirruscluster/cirruscluster | cirruscluster/core.py | GetNumCoresOnHosts | def GetNumCoresOnHosts(hosts, private_key):
""" Returns list of the number of cores for each host requested in hosts. """
results = runner.Runner(host_list=hosts, private_key=private_key,
module_name='setup').run()
num_cores_list = []
for _, props in results['contacted'].iteritems():
... | python | def GetNumCoresOnHosts(hosts, private_key):
""" Returns list of the number of cores for each host requested in hosts. """
results = runner.Runner(host_list=hosts, private_key=private_key,
module_name='setup').run()
num_cores_list = []
for _, props in results['contacted'].iteritems():
... | [
"def",
"GetNumCoresOnHosts",
"(",
"hosts",
",",
"private_key",
")",
":",
"results",
"=",
"runner",
".",
"Runner",
"(",
"host_list",
"=",
"hosts",
",",
"private_key",
"=",
"private_key",
",",
"module_name",
"=",
"'setup'",
")",
".",
"run",
"(",
")",
"num_co... | Returns list of the number of cores for each host requested in hosts. | [
"Returns",
"list",
"of",
"the",
"number",
"of",
"cores",
"for",
"each",
"host",
"requested",
"in",
"hosts",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L91-L104 |
cirruscluster/cirruscluster | cirruscluster/core.py | RunPlaybookOnHosts | def RunPlaybookOnHosts(playbook_path, hosts, private_key, extra_vars=None):
""" Runs the playbook and returns True if it completes successfully on all
hosts. """
inventory = ansible_inventory.Inventory(hosts)
if not inventory.list_hosts():
raise RuntimeError("Host list is empty.")
stats = callbacks.Aggreg... | python | def RunPlaybookOnHosts(playbook_path, hosts, private_key, extra_vars=None):
""" Runs the playbook and returns True if it completes successfully on all
hosts. """
inventory = ansible_inventory.Inventory(hosts)
if not inventory.list_hosts():
raise RuntimeError("Host list is empty.")
stats = callbacks.Aggreg... | [
"def",
"RunPlaybookOnHosts",
"(",
"playbook_path",
",",
"hosts",
",",
"private_key",
",",
"extra_vars",
"=",
"None",
")",
":",
"inventory",
"=",
"ansible_inventory",
".",
"Inventory",
"(",
"hosts",
")",
"if",
"not",
"inventory",
".",
"list_hosts",
"(",
")",
... | Runs the playbook and returns True if it completes successfully on all
hosts. | [
"Runs",
"the",
"playbook",
"and",
"returns",
"True",
"if",
"it",
"completes",
"successfully",
"on",
"all",
"hosts",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L106-L141 |
cirruscluster/cirruscluster | cirruscluster/core.py | RunPlaybookOnHost | def RunPlaybookOnHost(playbook_path, host, private_key, extra_vars=None):
"""
Runs the playbook and returns True if it completes successfully on
a single host.
"""
return RunPlaybookOnHosts(playbook_path, [host], private_key, extra_vars) | python | def RunPlaybookOnHost(playbook_path, host, private_key, extra_vars=None):
"""
Runs the playbook and returns True if it completes successfully on
a single host.
"""
return RunPlaybookOnHosts(playbook_path, [host], private_key, extra_vars) | [
"def",
"RunPlaybookOnHost",
"(",
"playbook_path",
",",
"host",
",",
"private_key",
",",
"extra_vars",
"=",
"None",
")",
":",
"return",
"RunPlaybookOnHosts",
"(",
"playbook_path",
",",
"[",
"host",
"]",
",",
"private_key",
",",
"extra_vars",
")"
] | Runs the playbook and returns True if it completes successfully on
a single host. | [
"Runs",
"the",
"playbook",
"and",
"returns",
"True",
"if",
"it",
"completes",
"successfully",
"on",
"a",
"single",
"host",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L143-L148 |
cirruscluster/cirruscluster | cirruscluster/core.py | ExecuteCmd | def ExecuteCmd(cmd, quiet=False):
""" Run a command in a shell. """
result = None
if quiet:
with open(os.devnull, "w") as fnull:
result = subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
else:
result = subprocess.call(cmd, shell=True)
return result | python | def ExecuteCmd(cmd, quiet=False):
""" Run a command in a shell. """
result = None
if quiet:
with open(os.devnull, "w") as fnull:
result = subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
else:
result = subprocess.call(cmd, shell=True)
return result | [
"def",
"ExecuteCmd",
"(",
"cmd",
",",
"quiet",
"=",
"False",
")",
":",
"result",
"=",
"None",
"if",
"quiet",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"as",
"fnull",
":",
"result",
"=",
"subprocess",
".",
"call",
"(",
"cmd"... | Run a command in a shell. | [
"Run",
"a",
"command",
"in",
"a",
"shell",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L154-L162 |
cirruscluster/cirruscluster | cirruscluster/core.py | CheckOutput | def CheckOutput(*popenargs, **kwargs):
"""
Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, _ = process.communicate()
retcode = pr... | python | def CheckOutput(*popenargs, **kwargs):
"""
Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, _ = process.communicate()
retcode = pr... | [
"def",
"CheckOutput",
"(",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
"output",
",",
"_",
"=",
... | Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib. | [
"Run",
"command",
"with",
"arguments",
"and",
"return",
"its",
"output",
"as",
"a",
"byte",
"string",
".",
"Backported",
"from",
"Python",
"2",
".",
"7",
"as",
"it",
"s",
"implemented",
"as",
"pure",
"python",
"on",
"stdlib",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L164-L179 |
cirruscluster/cirruscluster | cirruscluster/core.py | UrlGet | def UrlGet(url, timeout=10, retries=0):
""" Retrieve content from the given URL. """
# in Python 2.6 we can pass timeout to urllib2.urlopen
socket.setdefaulttimeout(timeout)
attempts = 0
content = None
while not content:
try:
content = urllib2.urlopen(url).read()
except urllib2.URLErr... | python | def UrlGet(url, timeout=10, retries=0):
""" Retrieve content from the given URL. """
# in Python 2.6 we can pass timeout to urllib2.urlopen
socket.setdefaulttimeout(timeout)
attempts = 0
content = None
while not content:
try:
content = urllib2.urlopen(url).read()
except urllib2.URLErr... | [
"def",
"UrlGet",
"(",
"url",
",",
"timeout",
"=",
"10",
",",
"retries",
"=",
"0",
")",
":",
"# in Python 2.6 we can pass timeout to urllib2.urlopen",
"socket",
".",
"setdefaulttimeout",
"(",
"timeout",
")",
"attempts",
"=",
"0",
"content",
"=",
"None",
"while",
... | Retrieve content from the given URL. | [
"Retrieve",
"content",
"from",
"the",
"given",
"URL",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L181-L194 |
cirruscluster/cirruscluster | cirruscluster/core.py | RunCommandOnHosts | def RunCommandOnHosts(cmd, hostnames, ssh_key):
""" Executes a command via ssh and sends back the exit status code. """
if not hostnames:
return
p = multiprocessing.Pool(1)
remote_command_args = [(cmd, hostname, ssh_key) for hostname in hostnames]
#print remote_command_args
result = None
while not res... | python | def RunCommandOnHosts(cmd, hostnames, ssh_key):
""" Executes a command via ssh and sends back the exit status code. """
if not hostnames:
return
p = multiprocessing.Pool(1)
remote_command_args = [(cmd, hostname, ssh_key) for hostname in hostnames]
#print remote_command_args
result = None
while not res... | [
"def",
"RunCommandOnHosts",
"(",
"cmd",
",",
"hostnames",
",",
"ssh_key",
")",
":",
"if",
"not",
"hostnames",
":",
"return",
"p",
"=",
"multiprocessing",
".",
"Pool",
"(",
"1",
")",
"remote_command_args",
"=",
"[",
"(",
"cmd",
",",
"hostname",
",",
"ssh_... | Executes a command via ssh and sends back the exit status code. | [
"Executes",
"a",
"command",
"via",
"ssh",
"and",
"sends",
"back",
"the",
"exit",
"status",
"code",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L200-L217 |
cirruscluster/cirruscluster | cirruscluster/core.py | RunCommandOnHost | def RunCommandOnHost(cmd, hostname, ssh_key):
""" Executes a command via ssh and sends back the exit status code. """
hostnames = [hostname]
results = RunCommandOnHosts(cmd, hostnames, ssh_key)
assert(len(results) == 1)
return results[0] | python | def RunCommandOnHost(cmd, hostname, ssh_key):
""" Executes a command via ssh and sends back the exit status code. """
hostnames = [hostname]
results = RunCommandOnHosts(cmd, hostnames, ssh_key)
assert(len(results) == 1)
return results[0] | [
"def",
"RunCommandOnHost",
"(",
"cmd",
",",
"hostname",
",",
"ssh_key",
")",
":",
"hostnames",
"=",
"[",
"hostname",
"]",
"results",
"=",
"RunCommandOnHosts",
"(",
"cmd",
",",
"hostnames",
",",
"ssh_key",
")",
"assert",
"(",
"len",
"(",
"results",
")",
"... | Executes a command via ssh and sends back the exit status code. | [
"Executes",
"a",
"command",
"via",
"ssh",
"and",
"sends",
"back",
"the",
"exit",
"status",
"code",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L219-L224 |
cirruscluster/cirruscluster | cirruscluster/core.py | ReadRemoteFile | def ReadRemoteFile(remote_file_path, hostname, ssh_key):
""" Reads a remote file into a string. """
cmd = 'sudo cat %s' % remote_file_path
exit_code, output = RunCommandOnHost(cmd, hostname, ssh_key)
if exit_code:
raise IOError('Can not read remote path: %s' % (remote_file_path))
return output | python | def ReadRemoteFile(remote_file_path, hostname, ssh_key):
""" Reads a remote file into a string. """
cmd = 'sudo cat %s' % remote_file_path
exit_code, output = RunCommandOnHost(cmd, hostname, ssh_key)
if exit_code:
raise IOError('Can not read remote path: %s' % (remote_file_path))
return output | [
"def",
"ReadRemoteFile",
"(",
"remote_file_path",
",",
"hostname",
",",
"ssh_key",
")",
":",
"cmd",
"=",
"'sudo cat %s'",
"%",
"remote_file_path",
"exit_code",
",",
"output",
"=",
"RunCommandOnHost",
"(",
"cmd",
",",
"hostname",
",",
"ssh_key",
")",
"if",
"exi... | Reads a remote file into a string. | [
"Reads",
"a",
"remote",
"file",
"into",
"a",
"string",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L226-L232 |
cirruscluster/cirruscluster | cirruscluster/core.py | __RemoteExecuteHelper | def __RemoteExecuteHelper(args):
""" Helper for multiprocessing. """
cmd, hostname, ssh_key = args
#Random.atfork() # needed to fix bug in old python 2.6 interpreters
private_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(... | python | def __RemoteExecuteHelper(args):
""" Helper for multiprocessing. """
cmd, hostname, ssh_key = args
#Random.atfork() # needed to fix bug in old python 2.6 interpreters
private_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(... | [
"def",
"__RemoteExecuteHelper",
"(",
"args",
")",
":",
"cmd",
",",
"hostname",
",",
"ssh_key",
"=",
"args",
"#Random.atfork() # needed to fix bug in old python 2.6 interpreters",
"private_key",
"=",
"paramiko",
".",
"RSAKey",
".",
"from_private_key",
"(",
"StringIO",
"... | Helper for multiprocessing. | [
"Helper",
"for",
"multiprocessing",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L241-L264 |
cirruscluster/cirruscluster | cirruscluster/core.py | WaitForHostsReachable | def WaitForHostsReachable(hostnames, ssh_key):
""" Blocks until host is reachable via ssh. """
while True:
unreachable = GetUnreachableHosts(hostnames, ssh_key)
if unreachable:
print 'waiting for unreachable hosts: %s' % unreachable
time.sleep(5)
else:
break
return | python | def WaitForHostsReachable(hostnames, ssh_key):
""" Blocks until host is reachable via ssh. """
while True:
unreachable = GetUnreachableHosts(hostnames, ssh_key)
if unreachable:
print 'waiting for unreachable hosts: %s' % unreachable
time.sleep(5)
else:
break
return | [
"def",
"WaitForHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"while",
"True",
":",
"unreachable",
"=",
"GetUnreachableHosts",
"(",
"hostnames",
",",
"ssh_key",
")",
"if",
"unreachable",
":",
"print",
"'waiting for unreachable hosts: %s'",
"%",
"unreac... | Blocks until host is reachable via ssh. | [
"Blocks",
"until",
"host",
"is",
"reachable",
"via",
"ssh",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L283-L292 |
cirruscluster/cirruscluster | cirruscluster/core.py | GetUnreachableInstances | def GetUnreachableInstances(instances, ssh_key):
""" Returns list of instances unreachable via ssh. """
hostnames = [i.private_ip for i in instances]
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_instances = [instance for (instance, ssh_ok) in
... | python | def GetUnreachableInstances(instances, ssh_key):
""" Returns list of instances unreachable via ssh. """
hostnames = [i.private_ip for i in instances]
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_instances = [instance for (instance, ssh_ok) in
... | [
"def",
"GetUnreachableInstances",
"(",
"instances",
",",
"ssh_key",
")",
":",
"hostnames",
"=",
"[",
"i",
".",
"private_ip",
"for",
"i",
"in",
"instances",
"]",
"ssh_status",
"=",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
"assert",
"(",
"le... | Returns list of instances unreachable via ssh. | [
"Returns",
"list",
"of",
"instances",
"unreachable",
"via",
"ssh",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L294-L301 |
cirruscluster/cirruscluster | cirruscluster/core.py | GetUnreachableHosts | def GetUnreachableHosts(hostnames, ssh_key):
""" Returns list of hosts unreachable via ssh. """
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_hostnames = [host for (host, ssh_ok) in
zip(hostnames, ssh_status) if not ssh_ok... | python | def GetUnreachableHosts(hostnames, ssh_key):
""" Returns list of hosts unreachable via ssh. """
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_hostnames = [host for (host, ssh_ok) in
zip(hostnames, ssh_status) if not ssh_ok... | [
"def",
"GetUnreachableHosts",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"ssh_status",
"=",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
"assert",
"(",
"len",
"(",
"hostnames",
")",
"==",
"len",
"(",
"ssh_status",
")",
")",
"nonresponsive_hostn... | Returns list of hosts unreachable via ssh. | [
"Returns",
"list",
"of",
"hosts",
"unreachable",
"via",
"ssh",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L303-L309 |
cirruscluster/cirruscluster | cirruscluster/core.py | AreHostsReachable | def AreHostsReachable(hostnames, ssh_key):
""" Returns list of bools indicating if host reachable via ssh. """
# validate input
for hostname in hostnames:
assert(len(hostname))
ssh_ok = [exit_code == 0 for (exit_code, _) in
RunCommandOnHosts('echo test > /dev/null', hostnames, ssh_key)]
return... | python | def AreHostsReachable(hostnames, ssh_key):
""" Returns list of bools indicating if host reachable via ssh. """
# validate input
for hostname in hostnames:
assert(len(hostname))
ssh_ok = [exit_code == 0 for (exit_code, _) in
RunCommandOnHosts('echo test > /dev/null', hostnames, ssh_key)]
return... | [
"def",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"# validate input",
"for",
"hostname",
"in",
"hostnames",
":",
"assert",
"(",
"len",
"(",
"hostname",
")",
")",
"ssh_ok",
"=",
"[",
"exit_code",
"==",
"0",
"for",
"(",
"exit_code",
","... | Returns list of bools indicating if host reachable via ssh. | [
"Returns",
"list",
"of",
"bools",
"indicating",
"if",
"host",
"reachable",
"via",
"ssh",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L311-L318 |
cirruscluster/cirruscluster | cirruscluster/core.py | AmiName | def AmiName(ami_release_name, ubuntu_release_name, virtualization_type,
mapr_version, role):
""" Returns AMI name using Cirrus ami naming convention. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' %
(role, valid_instanc... | python | def AmiName(ami_release_name, ubuntu_release_name, virtualization_type,
mapr_version, role):
""" Returns AMI name using Cirrus ami naming convention. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' %
(role, valid_instanc... | [
"def",
"AmiName",
"(",
"ami_release_name",
",",
"ubuntu_release_name",
",",
"virtualization_type",
",",
"mapr_version",
",",
"role",
")",
":",
"if",
"not",
"role",
"in",
"valid_instance_roles",
":",
"raise",
"RuntimeError",
"(",
"'Specified role (%s) not a valid role: %... | Returns AMI name using Cirrus ami naming convention. | [
"Returns",
"AMI",
"name",
"using",
"Cirrus",
"ami",
"naming",
"convention",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L324-L337 |
cirruscluster/cirruscluster | cirruscluster/core.py | LookupCirrusAmi | def LookupCirrusAmi(ec2, instance_type, ubuntu_release_name, mapr_version, role,
ami_release_name,
ami_owner_id):
""" Returns AMI satisfying provided constraints. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' % (r... | python | def LookupCirrusAmi(ec2, instance_type, ubuntu_release_name, mapr_version, role,
ami_release_name,
ami_owner_id):
""" Returns AMI satisfying provided constraints. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' % (r... | [
"def",
"LookupCirrusAmi",
"(",
"ec2",
",",
"instance_type",
",",
"ubuntu_release_name",
",",
"mapr_version",
",",
"role",
",",
"ami_release_name",
",",
"ami_owner_id",
")",
":",
"if",
"not",
"role",
"in",
"valid_instance_roles",
":",
"raise",
"RuntimeError",
"(",
... | Returns AMI satisfying provided constraints. | [
"Returns",
"AMI",
"satisfying",
"provided",
"constraints",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L342-L361 |
cirruscluster/cirruscluster | cirruscluster/core.py | GetRegion | def GetRegion(region_name):
""" Converts region name string into boto Region object. """
regions = boto_ec2.regions()
region = None
valid_region_names = []
for r in regions:
valid_region_names.append(r.name)
if r.name == region_name:
region = r
break
if not region:
logging.info( ... | python | def GetRegion(region_name):
""" Converts region name string into boto Region object. """
regions = boto_ec2.regions()
region = None
valid_region_names = []
for r in regions:
valid_region_names.append(r.name)
if r.name == region_name:
region = r
break
if not region:
logging.info( ... | [
"def",
"GetRegion",
"(",
"region_name",
")",
":",
"regions",
"=",
"boto_ec2",
".",
"regions",
"(",
")",
"region",
"=",
"None",
"valid_region_names",
"=",
"[",
"]",
"for",
"r",
"in",
"regions",
":",
"valid_region_names",
".",
"append",
"(",
"r",
".",
"nam... | Converts region name string into boto Region object. | [
"Converts",
"region",
"name",
"string",
"into",
"boto",
"Region",
"object",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L368-L382 |
cirruscluster/cirruscluster | cirruscluster/core.py | PrivateToPublicOpenSSH | def PrivateToPublicOpenSSH(key, host):
""" Computes the OpenSSH public key format given a private key. """
# Create public key from private key.
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
# Exponent.
exponent = '%x' % (key.e,)
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x'... | python | def PrivateToPublicOpenSSH(key, host):
""" Computes the OpenSSH public key format given a private key. """
# Create public key from private key.
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
# Exponent.
exponent = '%x' % (key.e,)
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x'... | [
"def",
"PrivateToPublicOpenSSH",
"(",
"key",
",",
"host",
")",
":",
"# Create public key from private key.",
"ssh_rsa",
"=",
"'00000007'",
"+",
"base64",
".",
"b16encode",
"(",
"'ssh-rsa'",
")",
"# Exponent.",
"exponent",
"=",
"'%x'",
"%",
"(",
"key",
".",
"e",
... | Computes the OpenSSH public key format given a private key. | [
"Computes",
"the",
"OpenSSH",
"public",
"key",
"format",
"given",
"a",
"private",
"key",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L500-L519 |
cirruscluster/cirruscluster | cirruscluster/core.py | InitKeypair | def InitKeypair(aws_id, aws_secret, ec2, s3, keypair_name, src_region,
dst_regions):
"""
Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3.
"""
# check if a keypair has been created
metada... | python | def InitKeypair(aws_id, aws_secret, ec2, s3, keypair_name, src_region,
dst_regions):
"""
Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3.
"""
# check if a keypair has been created
metada... | [
"def",
"InitKeypair",
"(",
"aws_id",
",",
"aws_secret",
",",
"ec2",
",",
"s3",
",",
"keypair_name",
",",
"src_region",
",",
"dst_regions",
")",
":",
"# check if a keypair has been created",
"metadata",
"=",
"CirrusAccessIdMetadata",
"(",
"s3",
",",
"aws_id",
")",
... | Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3. | [
"Returns",
"the",
"ssh",
"private",
"key",
"for",
"the",
"given",
"keypair",
"name",
"Cirrus",
"created",
"bucket",
".",
"Creates",
"the",
"keypair",
"if",
"it",
"doesn",
"t",
"yet",
"exist",
"and",
"stores",
"private",
"key",
"in",
"S3",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L522-L549 |
cirruscluster/cirruscluster | cirruscluster/core.py | DistributeKeyToRegions | def DistributeKeyToRegions(src_region, dst_regions, private_keypair,
aws_id, aws_secret):
"""
Copies the keypair from the src to the dst regions.
Note: keypair must be a newly created key... that is the key material is
the private key not the public key.
"""
private_key = RSA.im... | python | def DistributeKeyToRegions(src_region, dst_regions, private_keypair,
aws_id, aws_secret):
"""
Copies the keypair from the src to the dst regions.
Note: keypair must be a newly created key... that is the key material is
the private key not the public key.
"""
private_key = RSA.im... | [
"def",
"DistributeKeyToRegions",
"(",
"src_region",
",",
"dst_regions",
",",
"private_keypair",
",",
"aws_id",
",",
"aws_secret",
")",
":",
"private_key",
"=",
"RSA",
".",
"importKey",
"(",
"private_keypair",
".",
"material",
")",
"public_key_material",
"=",
"Priv... | Copies the keypair from the src to the dst regions.
Note: keypair must be a newly created key... that is the key material is
the private key not the public key. | [
"Copies",
"the",
"keypair",
"from",
"the",
"src",
"to",
"the",
"dst",
"regions",
".",
"Note",
":",
"keypair",
"must",
"be",
"a",
"newly",
"created",
"key",
"...",
"that",
"is",
"the",
"key",
"material",
"is",
"the",
"private",
"key",
"not",
"the",
"pub... | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L552-L574 |
cirruscluster/cirruscluster | cirruscluster/core.py | __WaitForVolume | def __WaitForVolume(volume, desired_state):
""" Blocks until EBS volume is in desired state. """
print 'Waiting for volume %s to be %s...' % (volume.id, desired_state)
while True:
volume.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % volume.status
if volume.status =... | python | def __WaitForVolume(volume, desired_state):
""" Blocks until EBS volume is in desired state. """
print 'Waiting for volume %s to be %s...' % (volume.id, desired_state)
while True:
volume.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % volume.status
if volume.status =... | [
"def",
"__WaitForVolume",
"(",
"volume",
",",
"desired_state",
")",
":",
"print",
"'Waiting for volume %s to be %s...'",
"%",
"(",
"volume",
".",
"id",
",",
"desired_state",
")",
"while",
"True",
":",
"volume",
".",
"update",
"(",
")",
"sys",
".",
"stdout",
... | Blocks until EBS volume is in desired state. | [
"Blocks",
"until",
"EBS",
"volume",
"is",
"in",
"desired",
"state",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L586-L597 |
cirruscluster/cirruscluster | cirruscluster/core.py | WaitForSnapshotCompleted | def WaitForSnapshotCompleted(snapshot):
""" Blocks until snapshot is complete. """
print 'Waiting for snapshot %s to be completed...' % (snapshot)
while True:
snapshot.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % snapshot.status
if snapshot.status == 'co... | python | def WaitForSnapshotCompleted(snapshot):
""" Blocks until snapshot is complete. """
print 'Waiting for snapshot %s to be completed...' % (snapshot)
while True:
snapshot.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % snapshot.status
if snapshot.status == 'co... | [
"def",
"WaitForSnapshotCompleted",
"(",
"snapshot",
")",
":",
"print",
"'Waiting for snapshot %s to be completed...'",
"%",
"(",
"snapshot",
")",
"while",
"True",
":",
"snapshot",
".",
"update",
"(",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"'.'",
")",
"s... | Blocks until snapshot is complete. | [
"Blocks",
"until",
"snapshot",
"is",
"complete",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L599-L610 |
cirruscluster/cirruscluster | cirruscluster/core.py | __WaitForInstance | def __WaitForInstance(instance, desired_state):
""" Blocks until instance is in desired_state. """
print 'Waiting for instance %s to change to %s' % (instance.id, desired_state)
while True:
try:
instance.update()
state = instance.state
sys.stdout.write('.')
sys.stdout... | python | def __WaitForInstance(instance, desired_state):
""" Blocks until instance is in desired_state. """
print 'Waiting for instance %s to change to %s' % (instance.id, desired_state)
while True:
try:
instance.update()
state = instance.state
sys.stdout.write('.')
sys.stdout... | [
"def",
"__WaitForInstance",
"(",
"instance",
",",
"desired_state",
")",
":",
"print",
"'Waiting for instance %s to change to %s'",
"%",
"(",
"instance",
".",
"id",
",",
"desired_state",
")",
"while",
"True",
":",
"try",
":",
"instance",
".",
"update",
"(",
")",
... | Blocks until instance is in desired_state. | [
"Blocks",
"until",
"instance",
"is",
"in",
"desired_state",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L618-L634 |
cirruscluster/cirruscluster | cirruscluster/core.py | SearchUbuntuAmiDatabase | def SearchUbuntuAmiDatabase(release_name, region_name, root_store_type,
virtualization_type):
""" Returns the ubuntu created ami matching the given criteria. """
ami_list_url = 'http://cloud-images.ubuntu.com/query/%s/server/released.txt' \
% (release_name)
url_file = urllib2.urlope... | python | def SearchUbuntuAmiDatabase(release_name, region_name, root_store_type,
virtualization_type):
""" Returns the ubuntu created ami matching the given criteria. """
ami_list_url = 'http://cloud-images.ubuntu.com/query/%s/server/released.txt' \
% (release_name)
url_file = urllib2.urlope... | [
"def",
"SearchUbuntuAmiDatabase",
"(",
"release_name",
",",
"region_name",
",",
"root_store_type",
",",
"virtualization_type",
")",
":",
"ami_list_url",
"=",
"'http://cloud-images.ubuntu.com/query/%s/server/released.txt'",
"%",
"(",
"release_name",
")",
"url_file",
"=",
"ur... | Returns the ubuntu created ami matching the given criteria. | [
"Returns",
"the",
"ubuntu",
"created",
"ami",
"matching",
"the",
"given",
"criteria",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L666-L704 |
bruth/restlib2 | restlib2/mixins.py | TemplateResponseMixin.render | def render(self, request, context, status=codes.ok, content_type=None,
args=None, kwargs=None):
"Expects the method handler to return the `context` for the template."
if isinstance(self.template_name, (list, tuple)):
template = loader.select_template(self.template_name)
... | python | def render(self, request, context, status=codes.ok, content_type=None,
args=None, kwargs=None):
"Expects the method handler to return the `context` for the template."
if isinstance(self.template_name, (list, tuple)):
template = loader.select_template(self.template_name)
... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"context",
",",
"status",
"=",
"codes",
".",
"ok",
",",
"content_type",
"=",
"None",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"template_na... | Expects the method handler to return the `context` for the template. | [
"Expects",
"the",
"method",
"handler",
"to",
"return",
"the",
"context",
"for",
"the",
"template",
"."
] | train | https://github.com/bruth/restlib2/blob/cb147527496ddf08263364f1fb52e7c48f215667/restlib2/mixins.py#L11-L25 |
daknuett/py_register_machine2 | engine_tools/operations.py | bitsetxor | def bitsetxor(b1, b2):
"""
If b1 and b2 would be ``int`` s this would be ``b1 ^ b2`` :
>>> from py_register_machine2.engine_tools.operations import bitsetxor
>>> b1 = [1, 1, 1, 1]
>>> b2 = [1, 1, 0, 1]
>>> bitsetxor(b1, b2)
[0, 0, 1, 0]
>>> bin(0b1111 ^ 0b1101)
'0b10'
"""
res = []
for bit1, bit2 in zip(b1,... | python | def bitsetxor(b1, b2):
"""
If b1 and b2 would be ``int`` s this would be ``b1 ^ b2`` :
>>> from py_register_machine2.engine_tools.operations import bitsetxor
>>> b1 = [1, 1, 1, 1]
>>> b2 = [1, 1, 0, 1]
>>> bitsetxor(b1, b2)
[0, 0, 1, 0]
>>> bin(0b1111 ^ 0b1101)
'0b10'
"""
res = []
for bit1, bit2 in zip(b1,... | [
"def",
"bitsetxor",
"(",
"b1",
",",
"b2",
")",
":",
"res",
"=",
"[",
"]",
"for",
"bit1",
",",
"bit2",
"in",
"zip",
"(",
"b1",
",",
"b2",
")",
":",
"res",
".",
"append",
"(",
"bit1",
"^",
"bit2",
")",
"return",
"res"
] | If b1 and b2 would be ``int`` s this would be ``b1 ^ b2`` :
>>> from py_register_machine2.engine_tools.operations import bitsetxor
>>> b1 = [1, 1, 1, 1]
>>> b2 = [1, 1, 0, 1]
>>> bitsetxor(b1, b2)
[0, 0, 1, 0]
>>> bin(0b1111 ^ 0b1101)
'0b10' | [
"If",
"b1",
"and",
"b2",
"would",
"be",
"int",
"s",
"this",
"would",
"be",
"b1",
"^",
"b2",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/operations.py#L8-L23 |
ddorn/superprompt | superprompt/core.py | prompt_autocomplete | def prompt_autocomplete(prompt, complete, default=None, contains_spaces=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given ... | python | def prompt_autocomplete(prompt, complete, default=None, contains_spaces=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given ... | [
"def",
"prompt_autocomplete",
"(",
"prompt",
",",
"complete",
",",
"default",
"=",
"None",
",",
"contains_spaces",
"=",
"True",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"def",
"real_completer",... | Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given text.
def complete(text: str) -> List[str]: ... | [
"Prompt",
"a",
"string",
"with",
"autocompletion"
] | train | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L47-L101 |
ddorn/superprompt | superprompt/core.py | prompt_file | def prompt_file(prompt, default=None, must_exist=True, is_dir=False,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or dir... | python | def prompt_file(prompt, default=None, must_exist=True, is_dir=False,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or dir... | [
"def",
"prompt_file",
"(",
"prompt",
",",
"default",
"=",
"None",
",",
"must_exist",
"=",
"True",
",",
"is_dir",
"=",
"False",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"if",
"must_exist",
... | Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or directory name.
If is_dir is True, this will show only the directories for the completion. | [
"Prompt",
"a",
"filename",
"using",
"using",
"glob",
"for",
"autocompetion",
"."
] | train | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L104-L125 |
ddorn/superprompt | superprompt/core.py | prompt_choice | def prompt_choice(prompt, possibilities, default=None, only_in_poss=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to... | python | def prompt_choice(prompt, possibilities, default=None, only_in_poss=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to... | [
"def",
"prompt_choice",
"(",
"prompt",
",",
"possibilities",
",",
"default",
"=",
"None",
",",
"only_in_poss",
"=",
"True",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"p... | Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to find what he wants,
If only_in_poss is False, you are not guaranteed that this
will return one of the possibilities. | [
"Prompt",
"for",
"a",
"string",
"in",
"a",
"given",
"range",
"of",
"possibilities",
"."
] | train | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L128-L162 |
ryanjdillon/pyotelem | pyotelem/plots/plotglides.py | plot_glide_depths | def plot_glide_depths(depths, mask_tag_filt):
'''Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data
'''
import numpy
from . import plotutils
fig, ax = pl... | python | def plot_glide_depths(depths, mask_tag_filt):
'''Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data
'''
import numpy
from . import plotutils
fig, ax = pl... | [
"def",
"plot_glide_depths",
"(",
"depths",
",",
"mask_tag_filt",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"plotutils",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
")",
"ax",
"=",
"plotutils",
".",
"plot_noncontiguous",
"(",
"ax",
",",
... | Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data | [
"Plot",
"depth",
"at",
"glides"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotglides.py#L9-L30 |
ryanjdillon/pyotelem | pyotelem/plots/plotglides.py | plot_sgls | def plot_sgls(mask_exp, depths, mask_tag_filt, sgls, mask_sgls_filt, Az_g_hf,
idx_start=None, idx_end=None, path_plot=None, linewidth=0.5,
leg_bbox=(1.23,1), clip_x=False):
'''Plot sub-glides over depth and high-pass filtered accelerometer signal
Args
----
mask_exp: ndarray
Bool... | python | def plot_sgls(mask_exp, depths, mask_tag_filt, sgls, mask_sgls_filt, Az_g_hf,
idx_start=None, idx_end=None, path_plot=None, linewidth=0.5,
leg_bbox=(1.23,1), clip_x=False):
'''Plot sub-glides over depth and high-pass filtered accelerometer signal
Args
----
mask_exp: ndarray
Bool... | [
"def",
"plot_sgls",
"(",
"mask_exp",
",",
"depths",
",",
"mask_tag_filt",
",",
"sgls",
",",
"mask_sgls_filt",
",",
"Az_g_hf",
",",
"idx_start",
"=",
"None",
",",
"idx_end",
"=",
"None",
",",
"path_plot",
"=",
"None",
",",
"linewidth",
"=",
"0.5",
",",
"l... | Plot sub-glides over depth and high-pass filtered accelerometer signal
Args
----
mask_exp: ndarray
Boolean mask array to slice tag data to experimtal period
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides ... | [
"Plot",
"sub",
"-",
"glides",
"over",
"depth",
"and",
"high",
"-",
"pass",
"filtered",
"accelerometer",
"signal"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotglides.py#L33-L212 |
Mollom/mollom_python | mollom/mollom.py | Mollom.verify_keys | def verify_keys(self):
"""Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise"""
verify_keys_endpoint = Template("${rest_root}/site/${public_key}")
url = verify_keys_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
... | python | def verify_keys(self):
"""Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise"""
verify_keys_endpoint = Template("${rest_root}/site/${public_key}")
url = verify_keys_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
... | [
"def",
"verify_keys",
"(",
"self",
")",
":",
"verify_keys_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/site/${public_key}\"",
")",
"url",
"=",
"verify_keys_endpoint",
".",
"substitute",
"(",
"rest_root",
"=",
"self",
".",
"_rest_root",
",",
"public_key",
"=",
... | Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise | [
"Verify",
"that",
"the",
"public",
"and",
"private",
"key",
"combination",
"is",
"valid",
";",
"raises",
"MollomAuthenticationError",
"otherwise"
] | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L49-L62 |
Mollom/mollom_python | mollom/mollom.py | Mollom.check_content | def check_content(self,
content_id=None,
post_title=None,
post_body=None,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
... | python | def check_content(self,
content_id=None,
post_title=None,
post_body=None,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
... | [
"def",
"check_content",
"(",
"self",
",",
"content_id",
"=",
"None",
",",
"post_title",
"=",
"None",
",",
"post_body",
"=",
"None",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
",",
"author_mail",
"=",
"None",
",",
"author_ip",
"=",
"... | Requests a ham/spam/unsure classification for content.
If rechecking or updating previously checked content, the content_id must be passed in.
An example of this usage:
* checking the subsequent post after previewing the content
* checking the subsequent post after solvi... | [
"Requests",
"a",
"ham",
"/",
"spam",
"/",
"unsure",
"classification",
"for",
"content",
".",
"If",
"rechecking",
"or",
"updating",
"previously",
"checked",
"content",
"the",
"content_id",
"must",
"be",
"passed",
"in",
".",
"An",
"example",
"of",
"this",
"usa... | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L102-L185 |
Mollom/mollom_python | mollom/mollom.py | Mollom.create_captcha | def create_captcha(self, captcha_type="image", ssl=None, content_id=None):
"""Creates a CAPTCHA to be served to the end-user.
Keyword arguments:
captcha_type -- Type of CAPTCHA to create: "image" or "audio". Defaults to "image".
ssl -- True for a CAPTCHA served over https. Defau... | python | def create_captcha(self, captcha_type="image", ssl=None, content_id=None):
"""Creates a CAPTCHA to be served to the end-user.
Keyword arguments:
captcha_type -- Type of CAPTCHA to create: "image" or "audio". Defaults to "image".
ssl -- True for a CAPTCHA served over https. Defau... | [
"def",
"create_captcha",
"(",
"self",
",",
"captcha_type",
"=",
"\"image\"",
",",
"ssl",
"=",
"None",
",",
"content_id",
"=",
"None",
")",
":",
"create_captcha_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/captcha\"",
")",
"url",
"=",
"create_captcha_endpoint",... | Creates a CAPTCHA to be served to the end-user.
Keyword arguments:
captcha_type -- Type of CAPTCHA to create: "image" or "audio". Defaults to "image".
ssl -- True for a CAPTCHA served over https. Defaults to False.
content_id -- Unique identifier of the content to link the CAPTC... | [
"Creates",
"a",
"CAPTCHA",
"to",
"be",
"served",
"to",
"the",
"end",
"-",
"user",
".",
"Keyword",
"arguments",
":",
"captcha_type",
"--",
"Type",
"of",
"CAPTCHA",
"to",
"create",
":",
"image",
"or",
"audio",
".",
"Defaults",
"to",
"image",
".",
"ssl",
... | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L187-L209 |
Mollom/mollom_python | mollom/mollom.py | Mollom.check_captcha | def check_captcha(self,
captcha_id,
solution,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
author_id=None,
author_o... | python | def check_captcha(self,
captcha_id,
solution,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
author_id=None,
author_o... | [
"def",
"check_captcha",
"(",
"self",
",",
"captcha_id",
",",
"solution",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
",",
"author_mail",
"=",
"None",
",",
"author_ip",
"=",
"None",
",",
"author_id",
"=",
"None",
",",
"author_open_id",
... | Checks a CAPTCHA that was solved by the end-user.
Keyword arguments:
captcha_id -- Unique identifier of the CAPTCHA solved.
solution -- Solution provided by the end-user for the CAPTCHA.
author_name -- The name of the content author.
author_url -- The homepage/website URL of the... | [
"Checks",
"a",
"CAPTCHA",
"that",
"was",
"solved",
"by",
"the",
"end",
"-",
"user",
"."
] | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L211-L246 |
Mollom/mollom_python | mollom/mollom.py | Mollom.send_feedback | def send_feedback(
self,
reason,
type=None,
author_ip=None,
author_id=None,
author_open_id=None,
content_id=None,
captcha_id=None,
source=None
):
"""Sends feedback to Mollom in the case of false negative or false positives.
... | python | def send_feedback(
self,
reason,
type=None,
author_ip=None,
author_id=None,
author_open_id=None,
content_id=None,
captcha_id=None,
source=None
):
"""Sends feedback to Mollom in the case of false negative or false positives.
... | [
"def",
"send_feedback",
"(",
"self",
",",
"reason",
",",
"type",
"=",
"None",
",",
"author_ip",
"=",
"None",
",",
"author_id",
"=",
"None",
",",
"author_open_id",
"=",
"None",
",",
"content_id",
"=",
"None",
",",
"captcha_id",
"=",
"None",
",",
"source",... | Sends feedback to Mollom in the case of false negative or false positives.
Keyword arguments:
reason -- Feedback to give. Can be: "approve", "spam", "unwanted".
"approve" -- Report a false positive (legitimate content that was incorrectly classified as spam).
"spam" -- ... | [
"Sends",
"feedback",
"to",
"Mollom",
"in",
"the",
"case",
"of",
"false",
"negative",
"or",
"false",
"positives",
".",
"Keyword",
"arguments",
":",
"reason",
"--",
"Feedback",
"to",
"give",
".",
"Can",
"be",
":",
"approve",
"spam",
"unwanted",
".",
"approve... | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L248-L294 |
Mollom/mollom_python | mollom/mollom.py | Mollom.create_blacklist_entry | def create_blacklist_entry(self,
value,
reason="unwanted",
context="allFields",
exact_match = False,
enabled = True
):
""... | python | def create_blacklist_entry(self,
value,
reason="unwanted",
context="allFields",
exact_match = False,
enabled = True
):
""... | [
"def",
"create_blacklist_entry",
"(",
"self",
",",
"value",
",",
"reason",
"=",
"\"unwanted\"",
",",
"context",
"=",
"\"allFields\"",
",",
"exact_match",
"=",
"False",
",",
"enabled",
"=",
"True",
")",
":",
"create_blacklist_endpoint",
"=",
"Template",
"(",
"\... | Creates a new blacklist entry.
Keyword arguments:
value -- The string value to blacklist.
reason -- The reason for why the value is blacklisted. Can be: "spam", "unwanted".
context -- The context where the entry's value may match. Can be:
allFields -- Match can be ma... | [
"Creates",
"a",
"new",
"blacklist",
"entry",
".",
"Keyword",
"arguments",
":",
"value",
"--",
"The",
"string",
"value",
"to",
"blacklist",
".",
"reason",
"--",
"The",
"reason",
"for",
"why",
"the",
"value",
"is",
"blacklisted",
".",
"Can",
"be",
":",
"sp... | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L296-L336 |
Mollom/mollom_python | mollom/mollom.py | Mollom.delete_blacklist_entry | def delete_blacklist_entry(self, blacklist_entry_id):
"""Delete an existing blacklist entry.
Keyword arguments:
blacklist_entry_id -- The unique identifier of the blacklist entry to delete.
"""
delete_blacklist_endpoint = Template("${rest_root}/blacklist/${public_key}/${... | python | def delete_blacklist_entry(self, blacklist_entry_id):
"""Delete an existing blacklist entry.
Keyword arguments:
blacklist_entry_id -- The unique identifier of the blacklist entry to delete.
"""
delete_blacklist_endpoint = Template("${rest_root}/blacklist/${public_key}/${... | [
"def",
"delete_blacklist_entry",
"(",
"self",
",",
"blacklist_entry_id",
")",
":",
"delete_blacklist_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/blacklist/${public_key}/${blacklist_entry_id}/delete\"",
")",
"url",
"=",
"delete_blacklist_endpoint",
".",
"substitute",
"(",
... | Delete an existing blacklist entry.
Keyword arguments:
blacklist_entry_id -- The unique identifier of the blacklist entry to delete. | [
"Delete",
"an",
"existing",
"blacklist",
"entry",
".",
"Keyword",
"arguments",
":",
"blacklist_entry_id",
"--",
"The",
"unique",
"identifier",
"of",
"the",
"blacklist",
"entry",
"to",
"delete",
"."
] | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L338-L347 |
Mollom/mollom_python | mollom/mollom.py | Mollom.get_blacklist_entries | def get_blacklist_entries(self):
"""Get a list of all blacklist entries.
"""
get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/")
url = get_blacklist_entries_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
response = sel... | python | def get_blacklist_entries(self):
"""Get a list of all blacklist entries.
"""
get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/")
url = get_blacklist_entries_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
response = sel... | [
"def",
"get_blacklist_entries",
"(",
"self",
")",
":",
"get_blacklist_entries_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/blacklist/${public_key}/\"",
")",
"url",
"=",
"get_blacklist_entries_endpoint",
".",
"substitute",
"(",
"rest_root",
"=",
"self",
".",
"_rest_roo... | Get a list of all blacklist entries. | [
"Get",
"a",
"list",
"of",
"all",
"blacklist",
"entries",
"."
] | train | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L349-L357 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.