id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
243,400 | django-py/django-doberman | doberman/models.py | AbstractFailedAccessAttempt.expiration_time | def expiration_time(self):
"""
Returns the time until this access attempt is forgotten.
"""
logging_forgotten_time = configuration.behavior.login_forgotten_seconds
if logging_forgotten_time <= 0:
return None
now = timezone.now()
delta = now - self.mo... | python | def expiration_time(self):
"""
Returns the time until this access attempt is forgotten.
"""
logging_forgotten_time = configuration.behavior.login_forgotten_seconds
if logging_forgotten_time <= 0:
return None
now = timezone.now()
delta = now - self.mo... | [
"def",
"expiration_time",
"(",
"self",
")",
":",
"logging_forgotten_time",
"=",
"configuration",
".",
"behavior",
".",
"login_forgotten_seconds",
"if",
"logging_forgotten_time",
"<=",
"0",
":",
"return",
"None",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"del... | Returns the time until this access attempt is forgotten. | [
"Returns",
"the",
"time",
"until",
"this",
"access",
"attempt",
"is",
"forgotten",
"."
] | 2e5959737a1b64234ed5a179c93f96a0de1c3e5c | https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/models.py#L73-L86 |
243,401 | sarenji/pyrc | example.py | GangstaBot.bling | def bling(self, target, sender):
"will print yo"
if target.startswith("#"):
self.message(target, "%s: yo" % sender)
else:
self.message(sender, "yo") | python | def bling(self, target, sender):
"will print yo"
if target.startswith("#"):
self.message(target, "%s: yo" % sender)
else:
self.message(sender, "yo") | [
"def",
"bling",
"(",
"self",
",",
"target",
",",
"sender",
")",
":",
"if",
"target",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"self",
".",
"message",
"(",
"target",
",",
"\"%s: yo\"",
"%",
"sender",
")",
"else",
":",
"self",
".",
"message",
"(",
... | will print yo | [
"will",
"print",
"yo"
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/example.py#L11-L16 |
243,402 | sarenji/pyrc | example.py | GangstaBot.repeat | def repeat(self, target, sender, **kwargs):
"will repeat whatever yo say"
if target.startswith("#"):
self.message(target, kwargs["msg"])
else:
self.message(sender, kwargs["msg"]) | python | def repeat(self, target, sender, **kwargs):
"will repeat whatever yo say"
if target.startswith("#"):
self.message(target, kwargs["msg"])
else:
self.message(sender, kwargs["msg"]) | [
"def",
"repeat",
"(",
"self",
",",
"target",
",",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"target",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"self",
".",
"message",
"(",
"target",
",",
"kwargs",
"[",
"\"msg\"",
"]",
")",
"else",
":",
... | will repeat whatever yo say | [
"will",
"repeat",
"whatever",
"yo",
"say"
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/example.py#L19-L24 |
243,403 | sarenji/pyrc | example.py | GangstaBot.stopword | def stopword(self, target, sender, *args):
"""
will repeat 'lol', 'lmao, 'rofl' or 'roflmao' when seen in a message
only applies to channel messages
"""
if target.startswith("#"):
self.message(target, args[0]) | python | def stopword(self, target, sender, *args):
"""
will repeat 'lol', 'lmao, 'rofl' or 'roflmao' when seen in a message
only applies to channel messages
"""
if target.startswith("#"):
self.message(target, args[0]) | [
"def",
"stopword",
"(",
"self",
",",
"target",
",",
"sender",
",",
"*",
"args",
")",
":",
"if",
"target",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"self",
".",
"message",
"(",
"target",
",",
"args",
"[",
"0",
"]",
")"
] | will repeat 'lol', 'lmao, 'rofl' or 'roflmao' when seen in a message
only applies to channel messages | [
"will",
"repeat",
"lol",
"lmao",
"rofl",
"or",
"roflmao",
"when",
"seen",
"in",
"a",
"message",
"only",
"applies",
"to",
"channel",
"messages"
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/example.py#L27-L33 |
243,404 | 20tab/twentytab-utils | twentytab/utils.py | compare_dicts | def compare_dicts(dict1, dict2):
"""
Checks if dict1 equals dict2
"""
for k, v in dict2.items():
if v != dict1[k]:
return False
return True | python | def compare_dicts(dict1, dict2):
"""
Checks if dict1 equals dict2
"""
for k, v in dict2.items():
if v != dict1[k]:
return False
return True | [
"def",
"compare_dicts",
"(",
"dict1",
",",
"dict2",
")",
":",
"for",
"k",
",",
"v",
"in",
"dict2",
".",
"items",
"(",
")",
":",
"if",
"v",
"!=",
"dict1",
"[",
"k",
"]",
":",
"return",
"False",
"return",
"True"
] | Checks if dict1 equals dict2 | [
"Checks",
"if",
"dict1",
"equals",
"dict2"
] | e02d55b1fd848c8e11ca9b7e97a5916780544d34 | https://github.com/20tab/twentytab-utils/blob/e02d55b1fd848c8e11ca9b7e97a5916780544d34/twentytab/utils.py#L21-L28 |
243,405 | 20tab/twentytab-utils | twentytab/utils.py | getItalianAccentedVocal | def getItalianAccentedVocal(vocal, acc_type="g"):
"""
It returns given vocal with grave or acute accent
"""
vocals = {'a': {'g': u'\xe0', 'a': u'\xe1'},
'e': {'g': u'\xe8', 'a': u'\xe9'},
'i': {'g': u'\xec', 'a': u'\xed'},
'o': {'g': u'\xf2', 'a': u'\xf3'},
... | python | def getItalianAccentedVocal(vocal, acc_type="g"):
"""
It returns given vocal with grave or acute accent
"""
vocals = {'a': {'g': u'\xe0', 'a': u'\xe1'},
'e': {'g': u'\xe8', 'a': u'\xe9'},
'i': {'g': u'\xec', 'a': u'\xed'},
'o': {'g': u'\xf2', 'a': u'\xf3'},
... | [
"def",
"getItalianAccentedVocal",
"(",
"vocal",
",",
"acc_type",
"=",
"\"g\"",
")",
":",
"vocals",
"=",
"{",
"'a'",
":",
"{",
"'g'",
":",
"u'\\xe0'",
",",
"'a'",
":",
"u'\\xe1'",
"}",
",",
"'e'",
":",
"{",
"'g'",
":",
"u'\\xe8'",
",",
"'a'",
":",
"... | It returns given vocal with grave or acute accent | [
"It",
"returns",
"given",
"vocal",
"with",
"grave",
"or",
"acute",
"accent"
] | e02d55b1fd848c8e11ca9b7e97a5916780544d34 | https://github.com/20tab/twentytab-utils/blob/e02d55b1fd848c8e11ca9b7e97a5916780544d34/twentytab/utils.py#L31-L40 |
243,406 | collectiveacuity/labPack | labpack/authentication/aws/iam.py | iamClient.read_certificate | def read_certificate(self, certificate_name):
'''
a method to retrieve the details about a server certificate
:param certificate_name: string with name of server certificate
:return: dictionary with certificate details
'''
title = '%s.read_certificate' % self.__cla... | python | def read_certificate(self, certificate_name):
'''
a method to retrieve the details about a server certificate
:param certificate_name: string with name of server certificate
:return: dictionary with certificate details
'''
title = '%s.read_certificate' % self.__cla... | [
"def",
"read_certificate",
"(",
"self",
",",
"certificate_name",
")",
":",
"title",
"=",
"'%s.read_certificate'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs",
"input_fields",
"=",
"{",
"'certificate_name'",
":",
"certificate_name",
"}",
"for"... | a method to retrieve the details about a server certificate
:param certificate_name: string with name of server certificate
:return: dictionary with certificate details | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"about",
"a",
"server",
"certificate"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/authentication/aws/iam.py#L164-L210 |
243,407 | stephanepechard/projy | projy/TerminalView.py | TerminalView.text_in_color | def text_in_color(self, message, color_code):
""" Print with a beautiful color. See codes at the top of this file. """
return self.term.color(color_code) + message + self.term.normal | python | def text_in_color(self, message, color_code):
""" Print with a beautiful color. See codes at the top of this file. """
return self.term.color(color_code) + message + self.term.normal | [
"def",
"text_in_color",
"(",
"self",
",",
"message",
",",
"color_code",
")",
":",
"return",
"self",
".",
"term",
".",
"color",
"(",
"color_code",
")",
"+",
"message",
"+",
"self",
".",
"term",
".",
"normal"
] | Print with a beautiful color. See codes at the top of this file. | [
"Print",
"with",
"a",
"beautiful",
"color",
".",
"See",
"codes",
"at",
"the",
"top",
"of",
"this",
"file",
"."
] | 3146b0e3c207b977e1b51fcb33138746dae83c23 | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/TerminalView.py#L39-L41 |
243,408 | SkyLothar/shcmd | shcmd/tar.py | TarGenerator.files | def files(self):
"""files that will be add to tar file later
should be tuple, list or generator that returns strings
"""
ios_names = [info.name for info in self._ios_to_add.keys()]
return set(self.files_to_add + ios_names) | python | def files(self):
"""files that will be add to tar file later
should be tuple, list or generator that returns strings
"""
ios_names = [info.name for info in self._ios_to_add.keys()]
return set(self.files_to_add + ios_names) | [
"def",
"files",
"(",
"self",
")",
":",
"ios_names",
"=",
"[",
"info",
".",
"name",
"for",
"info",
"in",
"self",
".",
"_ios_to_add",
".",
"keys",
"(",
")",
"]",
"return",
"set",
"(",
"self",
".",
"files_to_add",
"+",
"ios_names",
")"
] | files that will be add to tar file later
should be tuple, list or generator that returns strings | [
"files",
"that",
"will",
"be",
"add",
"to",
"tar",
"file",
"later",
"should",
"be",
"tuple",
"list",
"or",
"generator",
"that",
"returns",
"strings"
] | d8cad6311a4da7ef09f3419c86b58e30388b7ee3 | https://github.com/SkyLothar/shcmd/blob/d8cad6311a4da7ef09f3419c86b58e30388b7ee3/shcmd/tar.py#L44-L49 |
243,409 | SkyLothar/shcmd | shcmd/tar.py | TarGenerator.add_fileobj | def add_fileobj(self, fname, fcontent):
"""add file like object, it will be add to tar file later
:param fname: name in tar file
:param fcontent: content. bytes, string, BytesIO or StringIO
"""
tar_info = tarfile.TarInfo(fname)
if isinstance(fcontent, io.BytesIO):
... | python | def add_fileobj(self, fname, fcontent):
"""add file like object, it will be add to tar file later
:param fname: name in tar file
:param fcontent: content. bytes, string, BytesIO or StringIO
"""
tar_info = tarfile.TarInfo(fname)
if isinstance(fcontent, io.BytesIO):
... | [
"def",
"add_fileobj",
"(",
"self",
",",
"fname",
",",
"fcontent",
")",
":",
"tar_info",
"=",
"tarfile",
".",
"TarInfo",
"(",
"fname",
")",
"if",
"isinstance",
"(",
"fcontent",
",",
"io",
".",
"BytesIO",
")",
":",
"tar_info",
".",
"size",
"=",
"len",
... | add file like object, it will be add to tar file later
:param fname: name in tar file
:param fcontent: content. bytes, string, BytesIO or StringIO | [
"add",
"file",
"like",
"object",
"it",
"will",
"be",
"add",
"to",
"tar",
"file",
"later"
] | d8cad6311a4da7ef09f3419c86b58e30388b7ee3 | https://github.com/SkyLothar/shcmd/blob/d8cad6311a4da7ef09f3419c86b58e30388b7ee3/shcmd/tar.py#L59-L78 |
243,410 | SkyLothar/shcmd | shcmd/tar.py | TarGenerator.generate | def generate(self):
"""generate tar file
..Usage::
>>> tarfile = b"".join(data for data in tg.generate())
"""
if self._tar_buffer.tell():
self._tar_buffer.seek(0, 0)
yield self._tar_buffer.read()
for fname in self._files_to_add:
... | python | def generate(self):
"""generate tar file
..Usage::
>>> tarfile = b"".join(data for data in tg.generate())
"""
if self._tar_buffer.tell():
self._tar_buffer.seek(0, 0)
yield self._tar_buffer.read()
for fname in self._files_to_add:
... | [
"def",
"generate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tar_buffer",
".",
"tell",
"(",
")",
":",
"self",
".",
"_tar_buffer",
".",
"seek",
"(",
"0",
",",
"0",
")",
"yield",
"self",
".",
"_tar_buffer",
".",
"read",
"(",
")",
"for",
"fname",
... | generate tar file
..Usage::
>>> tarfile = b"".join(data for data in tg.generate()) | [
"generate",
"tar",
"file"
] | d8cad6311a4da7ef09f3419c86b58e30388b7ee3 | https://github.com/SkyLothar/shcmd/blob/d8cad6311a4da7ef09f3419c86b58e30388b7ee3/shcmd/tar.py#L80-L107 |
243,411 | SkyLothar/shcmd | shcmd/tar.py | TarGenerator.tar | def tar(self):
"""tar in bytes format"""
if not self.generated:
for data in self.generate():
pass
return self._tar_buffer.getvalue() | python | def tar(self):
"""tar in bytes format"""
if not self.generated:
for data in self.generate():
pass
return self._tar_buffer.getvalue() | [
"def",
"tar",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"generated",
":",
"for",
"data",
"in",
"self",
".",
"generate",
"(",
")",
":",
"pass",
"return",
"self",
".",
"_tar_buffer",
".",
"getvalue",
"(",
")"
] | tar in bytes format | [
"tar",
"in",
"bytes",
"format"
] | d8cad6311a4da7ef09f3419c86b58e30388b7ee3 | https://github.com/SkyLothar/shcmd/blob/d8cad6311a4da7ef09f3419c86b58e30388b7ee3/shcmd/tar.py#L114-L119 |
243,412 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.connect | def connect(self):
"""
Starts the mongodb connection. Must be called before anything else
will work.
"""
self.client = MongoClient(self.mongo_uri)
self.db = self.client[self.db_name] | python | def connect(self):
"""
Starts the mongodb connection. Must be called before anything else
will work.
"""
self.client = MongoClient(self.mongo_uri)
self.db = self.client[self.db_name] | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"client",
"=",
"MongoClient",
"(",
"self",
".",
"mongo_uri",
")",
"self",
".",
"db",
"=",
"self",
".",
"client",
"[",
"self",
".",
"db_name",
"]"
] | Starts the mongodb connection. Must be called before anything else
will work. | [
"Starts",
"the",
"mongodb",
"connection",
".",
"Must",
"be",
"called",
"before",
"anything",
"else",
"will",
"work",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L68-L74 |
243,413 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.find | def find(self, collection, query):
"""
Search a collection for the query provided. Just a raw interface to
mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
Returns:
p... | python | def find(self, collection, query):
"""
Search a collection for the query provided. Just a raw interface to
mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
Returns:
p... | [
"def",
"find",
"(",
"self",
",",
"collection",
",",
"query",
")",
":",
"obj",
"=",
"getattr",
"(",
"self",
".",
"db",
",",
"collection",
")",
"result",
"=",
"obj",
".",
"find",
"(",
"query",
")",
"return",
"result"
] | Search a collection for the query provided. Just a raw interface to
mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
Returns:
pymongo Cursor object with the results. | [
"Search",
"a",
"collection",
"for",
"the",
"query",
"provided",
".",
"Just",
"a",
"raw",
"interface",
"to",
"mongo",
"to",
"do",
"any",
"query",
"you",
"want",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L76-L89 |
243,414 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.find_all | def find_all(self, collection):
"""
Search a collection for all available items.
Args:
collection: The db collection. See main class documentation.
Returns:
List of all items in the collection.
"""
obj = getattr(self.db, collection)
result... | python | def find_all(self, collection):
"""
Search a collection for all available items.
Args:
collection: The db collection. See main class documentation.
Returns:
List of all items in the collection.
"""
obj = getattr(self.db, collection)
result... | [
"def",
"find_all",
"(",
"self",
",",
"collection",
")",
":",
"obj",
"=",
"getattr",
"(",
"self",
".",
"db",
",",
"collection",
")",
"result",
"=",
"obj",
".",
"find",
"(",
")",
"return",
"result"
] | Search a collection for all available items.
Args:
collection: The db collection. See main class documentation.
Returns:
List of all items in the collection. | [
"Search",
"a",
"collection",
"for",
"all",
"available",
"items",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L91-L102 |
243,415 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.find_one | def find_one(self, collection, query):
"""
Search a collection for the query provided and return one result. Just
a raw interface to mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
... | python | def find_one(self, collection, query):
"""
Search a collection for the query provided and return one result. Just
a raw interface to mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
... | [
"def",
"find_one",
"(",
"self",
",",
"collection",
",",
"query",
")",
":",
"obj",
"=",
"getattr",
"(",
"self",
".",
"db",
",",
"collection",
")",
"result",
"=",
"obj",
".",
"find_one",
"(",
"query",
")",
"return",
"result"
] | Search a collection for the query provided and return one result. Just
a raw interface to mongo to do any query you want.
Args:
collection: The db collection. See main class documentation.
query: A mongo find query.
Returns:
pymongo Cursor object with the res... | [
"Search",
"a",
"collection",
"for",
"the",
"query",
"provided",
"and",
"return",
"one",
"result",
".",
"Just",
"a",
"raw",
"interface",
"to",
"mongo",
"to",
"do",
"any",
"query",
"you",
"want",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L104-L117 |
243,416 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.find_distinct | def find_distinct(self, collection, key):
"""
Search a collection for the distinct key values provided.
Args:
collection: The db collection. See main class documentation.
key: The name of the key to find distinct values. For example with
the indicators c... | python | def find_distinct(self, collection, key):
"""
Search a collection for the distinct key values provided.
Args:
collection: The db collection. See main class documentation.
key: The name of the key to find distinct values. For example with
the indicators c... | [
"def",
"find_distinct",
"(",
"self",
",",
"collection",
",",
"key",
")",
":",
"obj",
"=",
"getattr",
"(",
"self",
".",
"db",
",",
"collection",
")",
"result",
"=",
"obj",
".",
"distinct",
"(",
"key",
")",
"return",
"result"
] | Search a collection for the distinct key values provided.
Args:
collection: The db collection. See main class documentation.
key: The name of the key to find distinct values. For example with
the indicators collection, the key could be "type".
Returns:
... | [
"Search",
"a",
"collection",
"for",
"the",
"distinct",
"key",
"values",
"provided",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L119-L132 |
243,417 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.add_embedded_campaign | def add_embedded_campaign(self, id, collection, campaign, confidence,
analyst, date, description):
"""
Adds an embedded campaign to the TLO.
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation... | python | def add_embedded_campaign(self, id, collection, campaign, confidence,
analyst, date, description):
"""
Adds an embedded campaign to the TLO.
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation... | [
"def",
"add_embedded_campaign",
"(",
"self",
",",
"id",
",",
"collection",
",",
"campaign",
",",
"confidence",
",",
"analyst",
",",
"date",
",",
"description",
")",
":",
"if",
"type",
"(",
"id",
")",
"is",
"not",
"ObjectId",
":",
"id",
"=",
"ObjectId",
... | Adds an embedded campaign to the TLO.
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation.
campaign: The campaign to assign.
confidence: The campaign confidence
analyst: The analyst making the assignmen... | [
"Adds",
"an",
"embedded",
"campaign",
"to",
"the",
"TLO",
"."
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L134-L171 |
243,418 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.remove_bucket_list_item | def remove_bucket_list_item(self, id, collection, item):
"""
Removes an item from the bucket list
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation.
item: the bucket list item to remove
Returns:
... | python | def remove_bucket_list_item(self, id, collection, item):
"""
Removes an item from the bucket list
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation.
item: the bucket list item to remove
Returns:
... | [
"def",
"remove_bucket_list_item",
"(",
"self",
",",
"id",
",",
"collection",
",",
"item",
")",
":",
"if",
"type",
"(",
"id",
")",
"is",
"not",
"ObjectId",
":",
"id",
"=",
"ObjectId",
"(",
"id",
")",
"obj",
"=",
"getattr",
"(",
"self",
".",
"db",
",... | Removes an item from the bucket list
Args:
id: the CRITs object id of the TLO
collection: The db collection. See main class documentation.
item: the bucket list item to remove
Returns:
The mongodb result | [
"Removes",
"an",
"item",
"from",
"the",
"bucket",
"list"
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L173-L191 |
243,419 | IntegralDefense/critsapi | critsapi/critsdbapi.py | CRITsDBAPI.get_campaign_name_list | def get_campaign_name_list(self):
"""
Returns a list of all valid campaign names
Returns:
List of strings containing all valid campaign names
"""
campaigns = self.find('campaigns', {})
campaign_names = []
for campaign in campaigns:
if 'nam... | python | def get_campaign_name_list(self):
"""
Returns a list of all valid campaign names
Returns:
List of strings containing all valid campaign names
"""
campaigns = self.find('campaigns', {})
campaign_names = []
for campaign in campaigns:
if 'nam... | [
"def",
"get_campaign_name_list",
"(",
"self",
")",
":",
"campaigns",
"=",
"self",
".",
"find",
"(",
"'campaigns'",
",",
"{",
"}",
")",
"campaign_names",
"=",
"[",
"]",
"for",
"campaign",
"in",
"campaigns",
":",
"if",
"'name'",
"in",
"campaign",
":",
"cam... | Returns a list of all valid campaign names
Returns:
List of strings containing all valid campaign names | [
"Returns",
"a",
"list",
"of",
"all",
"valid",
"campaign",
"names"
] | e770bd81e124eaaeb5f1134ba95f4a35ff345c5a | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsdbapi.py#L213-L225 |
243,420 | sassoo/goldman | goldman/deserializers/json_7159.py | Deserializer.deserialize | def deserialize(self):
""" Invoke the RFC 7159 spec compliant parser
:return:
the parsed & vetted request body
"""
super(Deserializer, self).deserialize()
try:
return json.loads(self.req.get_body())
except TypeError:
link = 'tools.ie... | python | def deserialize(self):
""" Invoke the RFC 7159 spec compliant parser
:return:
the parsed & vetted request body
"""
super(Deserializer, self).deserialize()
try:
return json.loads(self.req.get_body())
except TypeError:
link = 'tools.ie... | [
"def",
"deserialize",
"(",
"self",
")",
":",
"super",
"(",
"Deserializer",
",",
"self",
")",
".",
"deserialize",
"(",
")",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"req",
".",
"get_body",
"(",
")",
")",
"except",
"TypeError",
":"... | Invoke the RFC 7159 spec compliant parser
:return:
the parsed & vetted request body | [
"Invoke",
"the",
"RFC",
"7159",
"spec",
"compliant",
"parser"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/json_7159.py#L22-L47 |
243,421 | callowayproject/Transmogrify | transmogrify/images2gif.py | NeuQuant.quantize_without_scipy | def quantize_without_scipy(self, image):
"""" This function can be used if no scipy is availabe.
It's 7 times slower though.
"""
w, h = image.size
px = np.asarray(image).copy()
memo = {}
for j in range(w):
for i in range(h):
key = (px[i... | python | def quantize_without_scipy(self, image):
"""" This function can be used if no scipy is availabe.
It's 7 times slower though.
"""
w, h = image.size
px = np.asarray(image).copy()
memo = {}
for j in range(w):
for i in range(h):
key = (px[i... | [
"def",
"quantize_without_scipy",
"(",
"self",
",",
"image",
")",
":",
"w",
",",
"h",
"=",
"image",
".",
"size",
"px",
"=",
"np",
".",
"asarray",
"(",
"image",
")",
".",
"copy",
"(",
")",
"memo",
"=",
"{",
"}",
"for",
"j",
"in",
"range",
"(",
"w... | This function can be used if no scipy is availabe.
It's 7 times slower though. | [
"This",
"function",
"can",
"be",
"used",
"if",
"no",
"scipy",
"is",
"availabe",
".",
"It",
"s",
"7",
"times",
"slower",
"though",
"."
] | f1f891b8b923b3a1ede5eac7f60531c1c472379e | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/images2gif.py#L1015-L1031 |
243,422 | espenak/djangosenchatools | djangosenchatools/management/commands/senchatoolsbuild.py | get_installed_extjs_apps | def get_installed_extjs_apps():
"""
Get all installed extjs apps.
:return: List of ``(appdir, module, appname)``.
"""
installed_apps = []
checked = set()
for app in settings.INSTALLED_APPS:
if not app.startswith('django.') and not app in checked:
checked.add(app)
... | python | def get_installed_extjs_apps():
"""
Get all installed extjs apps.
:return: List of ``(appdir, module, appname)``.
"""
installed_apps = []
checked = set()
for app in settings.INSTALLED_APPS:
if not app.startswith('django.') and not app in checked:
checked.add(app)
... | [
"def",
"get_installed_extjs_apps",
"(",
")",
":",
"installed_apps",
"=",
"[",
"]",
"checked",
"=",
"set",
"(",
")",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"if",
"not",
"app",
".",
"startswith",
"(",
"'django.'",
")",
"and",
"not",
"a... | Get all installed extjs apps.
:return: List of ``(appdir, module, appname)``. | [
"Get",
"all",
"installed",
"extjs",
"apps",
"."
] | da1bca9365300de303e833de4b4bd57671c1d11a | https://github.com/espenak/djangosenchatools/blob/da1bca9365300de303e833de4b4bd57671c1d11a/djangosenchatools/management/commands/senchatoolsbuild.py#L34-L49 |
243,423 | espenak/djangosenchatools | djangosenchatools/management/commands/senchatoolsbuild.py | SenchaToolsWrapper.createJsbConfig | def createJsbConfig(self):
"""
Create JSB config file using ``sencha create jsb``.
:return: The created jsb3 config as a string.
"""
tempdir = mkdtemp()
tempfile = join(tempdir, 'app.jsb3')
cmd = ['sencha', 'create', 'jsb', '-a', self.url, '-p', tempfile]
... | python | def createJsbConfig(self):
"""
Create JSB config file using ``sencha create jsb``.
:return: The created jsb3 config as a string.
"""
tempdir = mkdtemp()
tempfile = join(tempdir, 'app.jsb3')
cmd = ['sencha', 'create', 'jsb', '-a', self.url, '-p', tempfile]
... | [
"def",
"createJsbConfig",
"(",
"self",
")",
":",
"tempdir",
"=",
"mkdtemp",
"(",
")",
"tempfile",
"=",
"join",
"(",
"tempdir",
",",
"'app.jsb3'",
")",
"cmd",
"=",
"[",
"'sencha'",
",",
"'create'",
",",
"'jsb'",
",",
"'-a'",
",",
"self",
".",
"url",
"... | Create JSB config file using ``sencha create jsb``.
:return: The created jsb3 config as a string. | [
"Create",
"JSB",
"config",
"file",
"using",
"sencha",
"create",
"jsb",
"."
] | da1bca9365300de303e833de4b4bd57671c1d11a | https://github.com/espenak/djangosenchatools/blob/da1bca9365300de303e833de4b4bd57671c1d11a/djangosenchatools/management/commands/senchatoolsbuild.py#L76-L89 |
243,424 | espenak/djangosenchatools | djangosenchatools/management/commands/senchatoolsbuild.py | SenchaToolsWrapper.cleanJsbConfig | def cleanJsbConfig(self, jsbconfig):
"""
Clean up the JSB config.
"""
config = json.loads(jsbconfig)
self._cleanJsbAllClassesSection(config)
self._cleanJsbAppAllSection(config)
return json.dumps(config, indent=4) | python | def cleanJsbConfig(self, jsbconfig):
"""
Clean up the JSB config.
"""
config = json.loads(jsbconfig)
self._cleanJsbAllClassesSection(config)
self._cleanJsbAppAllSection(config)
return json.dumps(config, indent=4) | [
"def",
"cleanJsbConfig",
"(",
"self",
",",
"jsbconfig",
")",
":",
"config",
"=",
"json",
".",
"loads",
"(",
"jsbconfig",
")",
"self",
".",
"_cleanJsbAllClassesSection",
"(",
"config",
")",
"self",
".",
"_cleanJsbAppAllSection",
"(",
"config",
")",
"return",
... | Clean up the JSB config. | [
"Clean",
"up",
"the",
"JSB",
"config",
"."
] | da1bca9365300de303e833de4b4bd57671c1d11a | https://github.com/espenak/djangosenchatools/blob/da1bca9365300de303e833de4b4bd57671c1d11a/djangosenchatools/management/commands/senchatoolsbuild.py#L91-L98 |
243,425 | espenak/djangosenchatools | djangosenchatools/management/commands/senchatoolsbuild.py | SenchaToolsWrapper.buildFromJsbString | def buildFromJsbString(self, jsb, nocompressjs=False):
"""
Build from the given config file using ``sencha build``.
:param jsb: The JSB config as a string.
:param nocompressjs: Compress the javascript? If ``True``, run ``sencha build --nocompress``.
"""
tempconffile = 't... | python | def buildFromJsbString(self, jsb, nocompressjs=False):
"""
Build from the given config file using ``sencha build``.
:param jsb: The JSB config as a string.
:param nocompressjs: Compress the javascript? If ``True``, run ``sencha build --nocompress``.
"""
tempconffile = 't... | [
"def",
"buildFromJsbString",
"(",
"self",
",",
"jsb",
",",
"nocompressjs",
"=",
"False",
")",
":",
"tempconffile",
"=",
"'temp-app.jsb3'",
"cmd",
"=",
"[",
"'sencha'",
",",
"'build'",
",",
"'-p'",
",",
"tempconffile",
",",
"'-d'",
",",
"self",
".",
"outdir... | Build from the given config file using ``sencha build``.
:param jsb: The JSB config as a string.
:param nocompressjs: Compress the javascript? If ``True``, run ``sencha build --nocompress``. | [
"Build",
"from",
"the",
"given",
"config",
"file",
"using",
"sencha",
"build",
"."
] | da1bca9365300de303e833de4b4bd57671c1d11a | https://github.com/espenak/djangosenchatools/blob/da1bca9365300de303e833de4b4bd57671c1d11a/djangosenchatools/management/commands/senchatoolsbuild.py#L149-L165 |
243,426 | ronaldguillen/wave | wave/metadata.py | SimpleMetadata.determine_actions | def determine_actions(self, request, view):
"""
For generic class based views we return information about
the fields that are accepted for 'PUT' and 'POST' methods.
"""
actions = {}
for method in {'PUT', 'POST'} & set(view.allowed_methods):
view.request = clon... | python | def determine_actions(self, request, view):
"""
For generic class based views we return information about
the fields that are accepted for 'PUT' and 'POST' methods.
"""
actions = {}
for method in {'PUT', 'POST'} & set(view.allowed_methods):
view.request = clon... | [
"def",
"determine_actions",
"(",
"self",
",",
"request",
",",
"view",
")",
":",
"actions",
"=",
"{",
"}",
"for",
"method",
"in",
"{",
"'PUT'",
",",
"'POST'",
"}",
"&",
"set",
"(",
"view",
".",
"allowed_methods",
")",
":",
"view",
".",
"request",
"=",... | For generic class based views we return information about
the fields that are accepted for 'PUT' and 'POST' methods. | [
"For",
"generic",
"class",
"based",
"views",
"we",
"return",
"information",
"about",
"the",
"fields",
"that",
"are",
"accepted",
"for",
"PUT",
"and",
"POST",
"methods",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/metadata.py#L74-L99 |
243,427 | dasevilla/rovi-python | roviclient/search.py | SearchApi.music_search | def music_search(self, entitiy_type, query, **kwargs):
"""
Search the music database
Where ``entitiy_type`` is a comma separated list of:
``song``
songs
``album``
albums
``composition``
compositions
``artist``
p... | python | def music_search(self, entitiy_type, query, **kwargs):
"""
Search the music database
Where ``entitiy_type`` is a comma separated list of:
``song``
songs
``album``
albums
``composition``
compositions
``artist``
p... | [
"def",
"music_search",
"(",
"self",
",",
"entitiy_type",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"make_request",
"(",
"'music'",
",",
"entitiy_type",
",",
"query",
",",
"kwargs",
")"
] | Search the music database
Where ``entitiy_type`` is a comma separated list of:
``song``
songs
``album``
albums
``composition``
compositions
``artist``
people working in music | [
"Search",
"the",
"music",
"database"
] | 46039d6ebfcf2ff20b4edb4636cb972682cf6af4 | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/search.py#L30-L48 |
243,428 | dasevilla/rovi-python | roviclient/search.py | SearchApi.amg_video_search | def amg_video_search(self, entitiy_type, query, **kwargs):
"""
Search the Movies and TV database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movies
``tvseries``
TV series
``credit``
people working in TV or movies
... | python | def amg_video_search(self, entitiy_type, query, **kwargs):
"""
Search the Movies and TV database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movies
``tvseries``
TV series
``credit``
people working in TV or movies
... | [
"def",
"amg_video_search",
"(",
"self",
",",
"entitiy_type",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"make_request",
"(",
"'amgvideo'",
",",
"entitiy_type",
",",
"query",
",",
"kwargs",
")"
] | Search the Movies and TV database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movies
``tvseries``
TV series
``credit``
people working in TV or movies | [
"Search",
"the",
"Movies",
"and",
"TV",
"database"
] | 46039d6ebfcf2ff20b4edb4636cb972682cf6af4 | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/search.py#L50-L65 |
243,429 | dasevilla/rovi-python | roviclient/search.py | SearchApi.video_search | def video_search(self, entitiy_type, query, **kwargs):
"""
Search the TV schedule database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movie
``tvseries``
TV series
``episode``
Episode titles
``onetimeonly... | python | def video_search(self, entitiy_type, query, **kwargs):
"""
Search the TV schedule database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movie
``tvseries``
TV series
``episode``
Episode titles
``onetimeonly... | [
"def",
"video_search",
"(",
"self",
",",
"entitiy_type",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"make_request",
"(",
"'video'",
",",
"entitiy_type",
",",
"query",
",",
"kwargs",
")"
] | Search the TV schedule database
Where ``entitiy_type`` is a comma separated list of:
``movie``
Movie
``tvseries``
TV series
``episode``
Episode titles
``onetimeonly``
TV programs
``credit``
People working i... | [
"Search",
"the",
"TV",
"schedule",
"database"
] | 46039d6ebfcf2ff20b4edb4636cb972682cf6af4 | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/search.py#L67-L88 |
243,430 | TC01/calcpkg | calcrepo/index.py | structureOutput | def structureOutput(fileUrl, fileName, searchFiles, format=True, space=40):
"""Formats the output of a list of packages"""
#First, remove the filename
if format:
splitUrls = fileUrl[1:].split('/')
fileUrl = ""
for splitUrl in splitUrls:
# This is a gimmicky fix to make formatting consistent
# Cemetech do... | python | def structureOutput(fileUrl, fileName, searchFiles, format=True, space=40):
"""Formats the output of a list of packages"""
#First, remove the filename
if format:
splitUrls = fileUrl[1:].split('/')
fileUrl = ""
for splitUrl in splitUrls:
# This is a gimmicky fix to make formatting consistent
# Cemetech do... | [
"def",
"structureOutput",
"(",
"fileUrl",
",",
"fileName",
",",
"searchFiles",
",",
"format",
"=",
"True",
",",
"space",
"=",
"40",
")",
":",
"#First, remove the filename",
"if",
"format",
":",
"splitUrls",
"=",
"fileUrl",
"[",
"1",
":",
"]",
".",
"split",... | Formats the output of a list of packages | [
"Formats",
"the",
"output",
"of",
"a",
"list",
"of",
"packages"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L257-L280 |
243,431 | TC01/calcpkg | calcrepo/index.py | Index.count | def count(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
"""Counts the number of ticalc.org files containing some search term, doesn't return them"""
fileData = {}
nameData = {}
#Search the index
if searchFiles:
fileData = self.searchNamesIndex(self.fileIndex,... | python | def count(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
"""Counts the number of ticalc.org files containing some search term, doesn't return them"""
fileData = {}
nameData = {}
#Search the index
if searchFiles:
fileData = self.searchNamesIndex(self.fileIndex,... | [
"def",
"count",
"(",
"self",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"searchFiles",
"=",
"False",
",",
"extension",
"=",
"\"\"",
")",
":",
"fileData",
"=",
"{",
"}",
"nameData",
"=... | Counts the number of ticalc.org files containing some search term, doesn't return them | [
"Counts",
"the",
"number",
"of",
"ticalc",
".",
"org",
"files",
"containing",
"some",
"search",
"term",
"doesn",
"t",
"return",
"them"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L19-L49 |
243,432 | TC01/calcpkg | calcrepo/index.py | Index.searchHierarchy | def searchHierarchy(self, fparent):
"""Core function to search directory structure for child files and folders of a parent"""
data = []
returnData = []
parentslashes = fparent.count('/')
filecount = 0
foldercount = 0
#open files for folder searching
try:
dirFile = open(self.dirIndex, 'rt')
except... | python | def searchHierarchy(self, fparent):
"""Core function to search directory structure for child files and folders of a parent"""
data = []
returnData = []
parentslashes = fparent.count('/')
filecount = 0
foldercount = 0
#open files for folder searching
try:
dirFile = open(self.dirIndex, 'rt')
except... | [
"def",
"searchHierarchy",
"(",
"self",
",",
"fparent",
")",
":",
"data",
"=",
"[",
"]",
"returnData",
"=",
"[",
"]",
"parentslashes",
"=",
"fparent",
".",
"count",
"(",
"'/'",
")",
"filecount",
"=",
"0",
"foldercount",
"=",
"0",
"#open files for folder sea... | Core function to search directory structure for child files and folders of a parent | [
"Core",
"function",
"to",
"search",
"directory",
"structure",
"for",
"child",
"files",
"and",
"folders",
"of",
"a",
"parent"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L51-L98 |
243,433 | TC01/calcpkg | calcrepo/index.py | Index.search | def search(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
"""Core function to search the indexes and return data"""
data = []
nameData = {}
fileData = {}
#Search the name index
if searchFiles:
fileData = self.searchNamesIndex(self.fileIndex, fileData, search... | python | def search(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
"""Core function to search the indexes and return data"""
data = []
nameData = {}
fileData = {}
#Search the name index
if searchFiles:
fileData = self.searchNamesIndex(self.fileIndex, fileData, search... | [
"def",
"search",
"(",
"self",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"searchFiles",
"=",
"False",
",",
"extension",
"=",
"\"\"",
")",
":",
"data",
"=",
"[",
"]",
"nameData",
"=",
... | Core function to search the indexes and return data | [
"Core",
"function",
"to",
"search",
"the",
"indexes",
"and",
"return",
"data"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L101-L157 |
243,434 | TC01/calcpkg | calcrepo/index.py | Index.searchFilesIndex | def searchFilesIndex(self, nameData, fileData, fileIndex, searchString, category="", math=False, game=False, extension=""):
"""Search the files index using the namedata and returns the filedata"""
try:
fileFile = open(fileIndex, 'rt')
except IOError:
self.repo.printd("Error: Unable to read index file " + se... | python | def searchFilesIndex(self, nameData, fileData, fileIndex, searchString, category="", math=False, game=False, extension=""):
"""Search the files index using the namedata and returns the filedata"""
try:
fileFile = open(fileIndex, 'rt')
except IOError:
self.repo.printd("Error: Unable to read index file " + se... | [
"def",
"searchFilesIndex",
"(",
"self",
",",
"nameData",
",",
"fileData",
",",
"fileIndex",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"extension",
"=",
"\"\"",
")",
":",
"try",
":",
"f... | Search the files index using the namedata and returns the filedata | [
"Search",
"the",
"files",
"index",
"using",
"the",
"namedata",
"and",
"returns",
"the",
"filedata"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L159-L209 |
243,435 | TC01/calcpkg | calcrepo/index.py | Index.searchNamesIndex | def searchNamesIndex(self, nameIndex, nameData, searchString, category="", math=False, game=False, extension="", searchFiles=False):
"""Search the names index for a string and returns the namedata"""
nameData = {}
try:
nameFile = open(nameIndex, 'rt')
except IOError:
self.repo.printd("Error: Unable to rea... | python | def searchNamesIndex(self, nameIndex, nameData, searchString, category="", math=False, game=False, extension="", searchFiles=False):
"""Search the names index for a string and returns the namedata"""
nameData = {}
try:
nameFile = open(nameIndex, 'rt')
except IOError:
self.repo.printd("Error: Unable to rea... | [
"def",
"searchNamesIndex",
"(",
"self",
",",
"nameIndex",
",",
"nameData",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"extension",
"=",
"\"\"",
",",
"searchFiles",
"=",
"False",
")",
":",... | Search the names index for a string and returns the namedata | [
"Search",
"the",
"names",
"index",
"for",
"a",
"string",
"and",
"returns",
"the",
"namedata"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L211-L255 |
243,436 | ronaldguillen/wave | wave/negotiation.py | DefaultContentNegotiation.select_parser | def select_parser(self, request, parsers):
"""
Given a list of parsers and a media type, return the appropriate
parser to handle the incoming request.
"""
for parser in parsers:
if media_type_matches(parser.media_type, request.content_type):
return par... | python | def select_parser(self, request, parsers):
"""
Given a list of parsers and a media type, return the appropriate
parser to handle the incoming request.
"""
for parser in parsers:
if media_type_matches(parser.media_type, request.content_type):
return par... | [
"def",
"select_parser",
"(",
"self",
",",
"request",
",",
"parsers",
")",
":",
"for",
"parser",
"in",
"parsers",
":",
"if",
"media_type_matches",
"(",
"parser",
".",
"media_type",
",",
"request",
".",
"content_type",
")",
":",
"return",
"parser",
"return",
... | Given a list of parsers and a media type, return the appropriate
parser to handle the incoming request. | [
"Given",
"a",
"list",
"of",
"parsers",
"and",
"a",
"media",
"type",
"return",
"the",
"appropriate",
"parser",
"to",
"handle",
"the",
"incoming",
"request",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/negotiation.py#L27-L35 |
243,437 | ronaldguillen/wave | wave/negotiation.py | DefaultContentNegotiation.filter_renderers | def filter_renderers(self, renderers, format):
"""
If there is a '.json' style format suffix, filter the renderers
so that we only negotiation against those that accept that format.
"""
renderers = [renderer for renderer in renderers
if renderer.format == for... | python | def filter_renderers(self, renderers, format):
"""
If there is a '.json' style format suffix, filter the renderers
so that we only negotiation against those that accept that format.
"""
renderers = [renderer for renderer in renderers
if renderer.format == for... | [
"def",
"filter_renderers",
"(",
"self",
",",
"renderers",
",",
"format",
")",
":",
"renderers",
"=",
"[",
"renderer",
"for",
"renderer",
"in",
"renderers",
"if",
"renderer",
".",
"format",
"==",
"format",
"]",
"if",
"not",
"renderers",
":",
"raise",
"Http4... | If there is a '.json' style format suffix, filter the renderers
so that we only negotiation against those that accept that format. | [
"If",
"there",
"is",
"a",
".",
"json",
"style",
"format",
"suffix",
"filter",
"the",
"renderers",
"so",
"that",
"we",
"only",
"negotiation",
"against",
"those",
"that",
"accept",
"that",
"format",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/negotiation.py#L80-L89 |
243,438 | ronaldguillen/wave | wave/negotiation.py | DefaultContentNegotiation.get_accept_list | def get_accept_list(self, request):
"""
Given the incoming request, return a tokenised list of media
type strings.
"""
header = request.META.get('HTTP_ACCEPT', '*/*')
return [token.strip() for token in header.split(',')] | python | def get_accept_list(self, request):
"""
Given the incoming request, return a tokenised list of media
type strings.
"""
header = request.META.get('HTTP_ACCEPT', '*/*')
return [token.strip() for token in header.split(',')] | [
"def",
"get_accept_list",
"(",
"self",
",",
"request",
")",
":",
"header",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_ACCEPT'",
",",
"'*/*'",
")",
"return",
"[",
"token",
".",
"strip",
"(",
")",
"for",
"token",
"in",
"header",
".",
"split",
... | Given the incoming request, return a tokenised list of media
type strings. | [
"Given",
"the",
"incoming",
"request",
"return",
"a",
"tokenised",
"list",
"of",
"media",
"type",
"strings",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/negotiation.py#L91-L97 |
243,439 | etcher-be/emiz | emiz/parking_spots.py | unit_pos_to_spot | def unit_pos_to_spot(unit_pos) -> ParkingSpot:
"""
Translates a unit position to a known parking spot
Args:
unit_pos: unit position as Vec2
Returns: ParkingSpot object
"""
min_ = 50
res = None
for airport in parkings:
for spot in parkings[airport]: # type: ignore
... | python | def unit_pos_to_spot(unit_pos) -> ParkingSpot:
"""
Translates a unit position to a known parking spot
Args:
unit_pos: unit position as Vec2
Returns: ParkingSpot object
"""
min_ = 50
res = None
for airport in parkings:
for spot in parkings[airport]: # type: ignore
... | [
"def",
"unit_pos_to_spot",
"(",
"unit_pos",
")",
"->",
"ParkingSpot",
":",
"min_",
"=",
"50",
"res",
"=",
"None",
"for",
"airport",
"in",
"parkings",
":",
"for",
"spot",
"in",
"parkings",
"[",
"airport",
"]",
":",
"# type: ignore",
"spot_pos",
"=",
"parkin... | Translates a unit position to a known parking spot
Args:
unit_pos: unit position as Vec2
Returns: ParkingSpot object | [
"Translates",
"a",
"unit",
"position",
"to",
"a",
"known",
"parking",
"spot"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/parking_spots.py#L39-L58 |
243,440 | stephanepechard/projy | projy/collectors/Collector.py | Collector.collect | def collect(self):
""" Select the best suited data of all available in the subclasses.
In each subclass, the functions alphabetical order should
correspond to their importance.
Here, the first non null value is returned.
"""
class_functions = []
for ke... | python | def collect(self):
""" Select the best suited data of all available in the subclasses.
In each subclass, the functions alphabetical order should
correspond to their importance.
Here, the first non null value is returned.
"""
class_functions = []
for ke... | [
"def",
"collect",
"(",
"self",
")",
":",
"class_functions",
"=",
"[",
"]",
"for",
"key",
"in",
"self",
".",
"__class__",
".",
"__dict__",
".",
"keys",
"(",
")",
":",
"func",
"=",
"self",
".",
"__class__",
".",
"__dict__",
"[",
"key",
"]",
"if",
"("... | Select the best suited data of all available in the subclasses.
In each subclass, the functions alphabetical order should
correspond to their importance.
Here, the first non null value is returned. | [
"Select",
"the",
"best",
"suited",
"data",
"of",
"all",
"available",
"in",
"the",
"subclasses",
".",
"In",
"each",
"subclass",
"the",
"functions",
"alphabetical",
"order",
"should",
"correspond",
"to",
"their",
"importance",
".",
"Here",
"the",
"first",
"non",... | 3146b0e3c207b977e1b51fcb33138746dae83c23 | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/Collector.py#L15-L31 |
243,441 | raags/passdb | passdb/manage_passdb.py | MPassdb.init | def init(self):
"""
Initialize a new password db store
"""
self.y = {"version": int(time.time())}
recipient_email = raw_input("Enter Email ID: ")
self.import_key(emailid=recipient_email)
self.encrypt(emailid_list=[recipient_email]) | python | def init(self):
"""
Initialize a new password db store
"""
self.y = {"version": int(time.time())}
recipient_email = raw_input("Enter Email ID: ")
self.import_key(emailid=recipient_email)
self.encrypt(emailid_list=[recipient_email]) | [
"def",
"init",
"(",
"self",
")",
":",
"self",
".",
"y",
"=",
"{",
"\"version\"",
":",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"}",
"recipient_email",
"=",
"raw_input",
"(",
"\"Enter Email ID: \"",
")",
"self",
".",
"import_key",
"(",
"emailid",... | Initialize a new password db store | [
"Initialize",
"a",
"new",
"password",
"db",
"store"
] | 7fd6665e291bbfb4db59c1230ae0257e48ad503e | https://github.com/raags/passdb/blob/7fd6665e291bbfb4db59c1230ae0257e48ad503e/passdb/manage_passdb.py#L28-L35 |
243,442 | raags/passdb | passdb/manage_passdb.py | MPassdb.list_users | def list_users(self):
"""
Get user list from the encrypted passdb file
"""
crypt = self._decrypt_file()
self.logger.info(crypt.stderr)
raw_userlist = crypt.stderr.split('\n')
userlist = list()
for index, line in enumerate(raw_userlist):
if 'gp... | python | def list_users(self):
"""
Get user list from the encrypted passdb file
"""
crypt = self._decrypt_file()
self.logger.info(crypt.stderr)
raw_userlist = crypt.stderr.split('\n')
userlist = list()
for index, line in enumerate(raw_userlist):
if 'gp... | [
"def",
"list_users",
"(",
"self",
")",
":",
"crypt",
"=",
"self",
".",
"_decrypt_file",
"(",
")",
"self",
".",
"logger",
".",
"info",
"(",
"crypt",
".",
"stderr",
")",
"raw_userlist",
"=",
"crypt",
".",
"stderr",
".",
"split",
"(",
"'\\n'",
")",
"use... | Get user list from the encrypted passdb file | [
"Get",
"user",
"list",
"from",
"the",
"encrypted",
"passdb",
"file"
] | 7fd6665e291bbfb4db59c1230ae0257e48ad503e | https://github.com/raags/passdb/blob/7fd6665e291bbfb4db59c1230ae0257e48ad503e/passdb/manage_passdb.py#L37-L52 |
243,443 | raags/passdb | passdb/manage_passdb.py | MPassdb.add_user | def add_user(self, recipient_email):
"""
Add user to encryption
"""
self.import_key(emailid=recipient_email)
emailid_list = self.list_user_emails()
self.y = self.decrypt()
emailid_list.append(recipient_email)
self.encrypt(emailid_list=emailid_list) | python | def add_user(self, recipient_email):
"""
Add user to encryption
"""
self.import_key(emailid=recipient_email)
emailid_list = self.list_user_emails()
self.y = self.decrypt()
emailid_list.append(recipient_email)
self.encrypt(emailid_list=emailid_list) | [
"def",
"add_user",
"(",
"self",
",",
"recipient_email",
")",
":",
"self",
".",
"import_key",
"(",
"emailid",
"=",
"recipient_email",
")",
"emailid_list",
"=",
"self",
".",
"list_user_emails",
"(",
")",
"self",
".",
"y",
"=",
"self",
".",
"decrypt",
"(",
... | Add user to encryption | [
"Add",
"user",
"to",
"encryption"
] | 7fd6665e291bbfb4db59c1230ae0257e48ad503e | https://github.com/raags/passdb/blob/7fd6665e291bbfb4db59c1230ae0257e48ad503e/passdb/manage_passdb.py#L72-L80 |
243,444 | raags/passdb | passdb/manage_passdb.py | MPassdb.delete_user | def delete_user(self, recipient_email):
"""
Remove user from encryption
"""
emailid_list = self.list_user_emails()
if recipient_email not in emailid_list:
raise Exception("User {0} not present!".format(recipient_email))
else:
emailid_list.remove(re... | python | def delete_user(self, recipient_email):
"""
Remove user from encryption
"""
emailid_list = self.list_user_emails()
if recipient_email not in emailid_list:
raise Exception("User {0} not present!".format(recipient_email))
else:
emailid_list.remove(re... | [
"def",
"delete_user",
"(",
"self",
",",
"recipient_email",
")",
":",
"emailid_list",
"=",
"self",
".",
"list_user_emails",
"(",
")",
"if",
"recipient_email",
"not",
"in",
"emailid_list",
":",
"raise",
"Exception",
"(",
"\"User {0} not present!\"",
".",
"format",
... | Remove user from encryption | [
"Remove",
"user",
"from",
"encryption"
] | 7fd6665e291bbfb4db59c1230ae0257e48ad503e | https://github.com/raags/passdb/blob/7fd6665e291bbfb4db59c1230ae0257e48ad503e/passdb/manage_passdb.py#L82-L92 |
243,445 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/__init__.py | parse_meta | def parse_meta(filename, data):
"""
Parse `data` to EPublication.
Args:
filename (str): Used to choose right parser based at suffix.
data (str): Content of the metadata file.
Returns:
EPublication: object.
"""
if "." not in filename:
raise MetaParsingException(
... | python | def parse_meta(filename, data):
"""
Parse `data` to EPublication.
Args:
filename (str): Used to choose right parser based at suffix.
data (str): Content of the metadata file.
Returns:
EPublication: object.
"""
if "." not in filename:
raise MetaParsingException(
... | [
"def",
"parse_meta",
"(",
"filename",
",",
"data",
")",
":",
"if",
"\".\"",
"not",
"in",
"filename",
":",
"raise",
"MetaParsingException",
"(",
"\"Can't recognize type of your metadata ('%s')!\"",
"%",
"filename",
")",
"suffix",
"=",
"filename",
".",
"rsplit",
"("... | Parse `data` to EPublication.
Args:
filename (str): Used to choose right parser based at suffix.
data (str): Content of the metadata file.
Returns:
EPublication: object. | [
"Parse",
"data",
"to",
"EPublication",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/__init__.py#L30-L55 |
243,446 | nefarioustim/parker | parker/consumemodel.py | get_instance | def get_instance(page_to_consume):
"""Return an instance of ConsumeModel."""
global _instances
if isinstance(page_to_consume, basestring):
uri = page_to_consume
page_to_consume = consumepage.get_instance(uri)
elif isinstance(page_to_consume, consumepage.ConsumePage):
uri = page_t... | python | def get_instance(page_to_consume):
"""Return an instance of ConsumeModel."""
global _instances
if isinstance(page_to_consume, basestring):
uri = page_to_consume
page_to_consume = consumepage.get_instance(uri)
elif isinstance(page_to_consume, consumepage.ConsumePage):
uri = page_t... | [
"def",
"get_instance",
"(",
"page_to_consume",
")",
":",
"global",
"_instances",
"if",
"isinstance",
"(",
"page_to_consume",
",",
"basestring",
")",
":",
"uri",
"=",
"page_to_consume",
"page_to_consume",
"=",
"consumepage",
".",
"get_instance",
"(",
"uri",
")",
... | Return an instance of ConsumeModel. | [
"Return",
"an",
"instance",
"of",
"ConsumeModel",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/consumemodel.py#L12-L32 |
243,447 | nefarioustim/parker | parker/consumemodel.py | ConsumeModel.get_dict | def get_dict(self):
"""Return a dictionary of the object primed for dumping."""
data = self.data_dict.copy()
data.update({
"class": self.classification,
"tags": self.tags,
"key_value_data": self.key_value_dict,
"crumbs": self.crumb_list if len(sel... | python | def get_dict(self):
"""Return a dictionary of the object primed for dumping."""
data = self.data_dict.copy()
data.update({
"class": self.classification,
"tags": self.tags,
"key_value_data": self.key_value_dict,
"crumbs": self.crumb_list if len(sel... | [
"def",
"get_dict",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"data_dict",
".",
"copy",
"(",
")",
"data",
".",
"update",
"(",
"{",
"\"class\"",
":",
"self",
".",
"classification",
",",
"\"tags\"",
":",
"self",
".",
"tags",
",",
"\"key_value_data\... | Return a dictionary of the object primed for dumping. | [
"Return",
"a",
"dictionary",
"of",
"the",
"object",
"primed",
"for",
"dumping",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/consumemodel.py#L75-L94 |
243,448 | GemHQ/round-py | round/devices.py | Devices.create | def create(self, name, redirect_uri=None):
"""Create a new Device object.
Devices tie Users and Applications together. For your Application to
access and act on behalf of a User, the User must authorize a Device
created by your Application.
This function will return a `device_t... | python | def create(self, name, redirect_uri=None):
"""Create a new Device object.
Devices tie Users and Applications together. For your Application to
access and act on behalf of a User, the User must authorize a Device
created by your Application.
This function will return a `device_t... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"redirect_uri",
"=",
"None",
")",
":",
"data",
"=",
"dict",
"(",
"name",
"=",
"name",
")",
"if",
"redirect_uri",
":",
"data",
"[",
"'redirect_uri'",
"]",
"=",
"redirect_uri",
"auth_request_resource",
"=",
"... | Create a new Device object.
Devices tie Users and Applications together. For your Application to
access and act on behalf of a User, the User must authorize a Device
created by your Application.
This function will return a `device_token` which you must store and use
after the D... | [
"Create",
"a",
"new",
"Device",
"object",
"."
] | d0838f849cd260b1eb5df67ed3c6f2fe56c91c21 | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/devices.py#L16-L49 |
243,449 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/plugin.py | build_option_parser | def build_option_parser(parser):
"""Hook to add global options
Called from openstackclient.shell.OpenStackShell.__init__()
after the builtin parser has been initialized. This is
where a plugin can add global options such as an API version setting.
:param argparse.ArgumentParser parser: The parser... | python | def build_option_parser(parser):
"""Hook to add global options
Called from openstackclient.shell.OpenStackShell.__init__()
after the builtin parser has been initialized. This is
where a plugin can add global options such as an API version setting.
:param argparse.ArgumentParser parser: The parser... | [
"def",
"build_option_parser",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--os-rdomanager-oscplugin-api-version'",
",",
"metavar",
"=",
"'<rdomanager-oscplugin-api-version>'",
",",
"default",
"=",
"utils",
".",
"env",
"(",
"'OS_RDOMANAGER_OSCPLUGIN_API_... | Hook to add global options
Called from openstackclient.shell.OpenStackShell.__init__()
after the builtin parser has been initialized. This is
where a plugin can add global options such as an API version setting.
:param argparse.ArgumentParser parser: The parser object that has been
initialize... | [
"Hook",
"to",
"add",
"global",
"options"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/plugin.py#L42-L61 |
243,450 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/plugin.py | ClientWrapper.baremetal | def baremetal(self):
"""Returns an baremetal service client"""
# TODO(d0ugal): When the ironicclient has it's own OSC plugin, the
# following client handling code should be removed in favor of the
# upstream version.
if self._baremetal is not None:
return self._bare... | python | def baremetal(self):
"""Returns an baremetal service client"""
# TODO(d0ugal): When the ironicclient has it's own OSC plugin, the
# following client handling code should be removed in favor of the
# upstream version.
if self._baremetal is not None:
return self._bare... | [
"def",
"baremetal",
"(",
"self",
")",
":",
"# TODO(d0ugal): When the ironicclient has it's own OSC plugin, the",
"# following client handling code should be removed in favor of the",
"# upstream version.",
"if",
"self",
".",
"_baremetal",
"is",
"not",
"None",
":",
"return",
"self... | Returns an baremetal service client | [
"Returns",
"an",
"baremetal",
"service",
"client"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/plugin.py#L72-L93 |
243,451 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/plugin.py | ClientWrapper.orchestration | def orchestration(self):
"""Returns an orchestration service client"""
# TODO(d0ugal): This code is based on the upstream WIP implementation
# and should be removed when it lands:
# https://review.openstack.org/#/c/111786
if self._orchestration is not None:
return s... | python | def orchestration(self):
"""Returns an orchestration service client"""
# TODO(d0ugal): This code is based on the upstream WIP implementation
# and should be removed when it lands:
# https://review.openstack.org/#/c/111786
if self._orchestration is not None:
return s... | [
"def",
"orchestration",
"(",
"self",
")",
":",
"# TODO(d0ugal): This code is based on the upstream WIP implementation",
"# and should be removed when it lands:",
"# https://review.openstack.org/#/c/111786",
"if",
"self",
".",
"_orchestration",
"is",
"not",
"None",
":",
"return",
... | Returns an orchestration service client | [
"Returns",
"an",
"orchestration",
"service",
"client"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/plugin.py#L95-L131 |
243,452 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/plugin.py | ClientWrapper.management | def management(self):
"""Returns an management service client"""
endpoint = self._instance.get_endpoint_for_service_type(
"management",
region_name=self._instance._region_name,
)
token = self._instance.auth.get_token(self._instance.session)
self._manage... | python | def management(self):
"""Returns an management service client"""
endpoint = self._instance.get_endpoint_for_service_type(
"management",
region_name=self._instance._region_name,
)
token = self._instance.auth.get_token(self._instance.session)
self._manage... | [
"def",
"management",
"(",
"self",
")",
":",
"endpoint",
"=",
"self",
".",
"_instance",
".",
"get_endpoint_for_service_type",
"(",
"\"management\"",
",",
"region_name",
"=",
"self",
".",
"_instance",
".",
"_region_name",
",",
")",
"token",
"=",
"self",
".",
"... | Returns an management service client | [
"Returns",
"an",
"management",
"service",
"client"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/plugin.py#L133-L146 |
243,453 | ronaldguillen/wave | wave/utils/mediatypes.py | media_type_matches | def media_type_matches(lhs, rhs):
"""
Returns ``True`` if the media type in the first argument <= the
media type in the second argument. The media types are strings
as described by the HTTP spec.
Valid media type strings include:
'application/json; indent=4'
'application/json'
'text/*... | python | def media_type_matches(lhs, rhs):
"""
Returns ``True`` if the media type in the first argument <= the
media type in the second argument. The media types are strings
as described by the HTTP spec.
Valid media type strings include:
'application/json; indent=4'
'application/json'
'text/*... | [
"def",
"media_type_matches",
"(",
"lhs",
",",
"rhs",
")",
":",
"lhs",
"=",
"_MediaType",
"(",
"lhs",
")",
"rhs",
"=",
"_MediaType",
"(",
"rhs",
")",
"return",
"lhs",
".",
"match",
"(",
"rhs",
")"
] | Returns ``True`` if the media type in the first argument <= the
media type in the second argument. The media types are strings
as described by the HTTP spec.
Valid media type strings include:
'application/json; indent=4'
'application/json'
'text/*'
'*/*' | [
"Returns",
"True",
"if",
"the",
"media",
"type",
"in",
"the",
"first",
"argument",
"<",
"=",
"the",
"media",
"type",
"in",
"the",
"second",
"argument",
".",
"The",
"media",
"types",
"are",
"strings",
"as",
"described",
"by",
"the",
"HTTP",
"spec",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/mediatypes.py#L14-L29 |
243,454 | mbodenhamer/syn | syn/base_utils/py.py | subclasses | def subclasses(cls, lst=None):
'''Recursively gather subclasses of cls.
'''
if lst is None:
lst = []
for sc in cls.__subclasses__():
if sc not in lst:
lst.append(sc)
subclasses(sc, lst=lst)
return lst | python | def subclasses(cls, lst=None):
'''Recursively gather subclasses of cls.
'''
if lst is None:
lst = []
for sc in cls.__subclasses__():
if sc not in lst:
lst.append(sc)
subclasses(sc, lst=lst)
return lst | [
"def",
"subclasses",
"(",
"cls",
",",
"lst",
"=",
"None",
")",
":",
"if",
"lst",
"is",
"None",
":",
"lst",
"=",
"[",
"]",
"for",
"sc",
"in",
"cls",
".",
"__subclasses__",
"(",
")",
":",
"if",
"sc",
"not",
"in",
"lst",
":",
"lst",
".",
"append",... | Recursively gather subclasses of cls. | [
"Recursively",
"gather",
"subclasses",
"of",
"cls",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L50-L59 |
243,455 | mbodenhamer/syn | syn/base_utils/py.py | nearest_base | def nearest_base(cls, bases):
'''Returns the closest ancestor to cls in bases.
'''
if cls in bases:
return cls
dists = {base: index(mro(cls), base) for base in bases}
dists2 = {dist: base for base, dist in dists.items() if dist is not None}
if not dists2:
return None
return ... | python | def nearest_base(cls, bases):
'''Returns the closest ancestor to cls in bases.
'''
if cls in bases:
return cls
dists = {base: index(mro(cls), base) for base in bases}
dists2 = {dist: base for base, dist in dists.items() if dist is not None}
if not dists2:
return None
return ... | [
"def",
"nearest_base",
"(",
"cls",
",",
"bases",
")",
":",
"if",
"cls",
"in",
"bases",
":",
"return",
"cls",
"dists",
"=",
"{",
"base",
":",
"index",
"(",
"mro",
"(",
"cls",
")",
",",
"base",
")",
"for",
"base",
"in",
"bases",
"}",
"dists2",
"=",... | Returns the closest ancestor to cls in bases. | [
"Returns",
"the",
"closest",
"ancestor",
"to",
"cls",
"in",
"bases",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L93-L103 |
243,456 | mbodenhamer/syn | syn/base_utils/py.py | get_typename | def get_typename(x):
'''Returns the name of the type of x, if x is an object. Otherwise, returns the name of x.
'''
if isinstance(x, type):
ret = x.__name__
else:
ret = x.__class__.__name__
return ret | python | def get_typename(x):
'''Returns the name of the type of x, if x is an object. Otherwise, returns the name of x.
'''
if isinstance(x, type):
ret = x.__name__
else:
ret = x.__class__.__name__
return ret | [
"def",
"get_typename",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"type",
")",
":",
"ret",
"=",
"x",
".",
"__name__",
"else",
":",
"ret",
"=",
"x",
".",
"__class__",
".",
"__name__",
"return",
"ret"
] | Returns the name of the type of x, if x is an object. Otherwise, returns the name of x. | [
"Returns",
"the",
"name",
"of",
"the",
"type",
"of",
"x",
"if",
"x",
"is",
"an",
"object",
".",
"Otherwise",
"returns",
"the",
"name",
"of",
"x",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L105-L112 |
243,457 | mbodenhamer/syn | syn/base_utils/py.py | getfunc | def getfunc(obj, name=''):
'''Get the function corresponding to name from obj, not the method.'''
if name:
obj = getattr(obj, name)
return getattr(obj, '__func__', obj) | python | def getfunc(obj, name=''):
'''Get the function corresponding to name from obj, not the method.'''
if name:
obj = getattr(obj, name)
return getattr(obj, '__func__', obj) | [
"def",
"getfunc",
"(",
"obj",
",",
"name",
"=",
"''",
")",
":",
"if",
"name",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"name",
")",
"return",
"getattr",
"(",
"obj",
",",
"'__func__'",
",",
"obj",
")"
] | Get the function corresponding to name from obj, not the method. | [
"Get",
"the",
"function",
"corresponding",
"to",
"name",
"from",
"obj",
"not",
"the",
"method",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L220-L224 |
243,458 | mbodenhamer/syn | syn/base_utils/py.py | get_mod | def get_mod(cls):
'''Returns the string identifying the module that cls is defined in.
'''
if isinstance(cls, (type, types.FunctionType)):
ret = cls.__module__
else:
ret = cls.__class__.__module__
return ret | python | def get_mod(cls):
'''Returns the string identifying the module that cls is defined in.
'''
if isinstance(cls, (type, types.FunctionType)):
ret = cls.__module__
else:
ret = cls.__class__.__module__
return ret | [
"def",
"get_mod",
"(",
"cls",
")",
":",
"if",
"isinstance",
"(",
"cls",
",",
"(",
"type",
",",
"types",
".",
"FunctionType",
")",
")",
":",
"ret",
"=",
"cls",
".",
"__module__",
"else",
":",
"ret",
"=",
"cls",
".",
"__class__",
".",
"__module__",
"... | Returns the string identifying the module that cls is defined in. | [
"Returns",
"the",
"string",
"identifying",
"the",
"module",
"that",
"cls",
"is",
"defined",
"in",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L315-L323 |
243,459 | mbodenhamer/syn | syn/base_utils/py.py | this_module | def this_module(npop=1):
'''Returns the module object of the module this function is called from
'''
stack = inspect.stack()
st = stack[npop]
frame = st[0]
return inspect.getmodule(frame) | python | def this_module(npop=1):
'''Returns the module object of the module this function is called from
'''
stack = inspect.stack()
st = stack[npop]
frame = st[0]
return inspect.getmodule(frame) | [
"def",
"this_module",
"(",
"npop",
"=",
"1",
")",
":",
"stack",
"=",
"inspect",
".",
"stack",
"(",
")",
"st",
"=",
"stack",
"[",
"npop",
"]",
"frame",
"=",
"st",
"[",
"0",
"]",
"return",
"inspect",
".",
"getmodule",
"(",
"frame",
")"
] | Returns the module object of the module this function is called from | [
"Returns",
"the",
"module",
"object",
"of",
"the",
"module",
"this",
"function",
"is",
"called",
"from"
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L333-L339 |
243,460 | mbodenhamer/syn | syn/base_utils/py.py | assert_equivalent | def assert_equivalent(o1, o2):
'''Asserts that o1 and o2 are distinct, yet equivalent objects
'''
if not (isinstance(o1, type) and isinstance(o2, type)):
assert o1 is not o2
assert o1 == o2
assert o2 == o1 | python | def assert_equivalent(o1, o2):
'''Asserts that o1 and o2 are distinct, yet equivalent objects
'''
if not (isinstance(o1, type) and isinstance(o2, type)):
assert o1 is not o2
assert o1 == o2
assert o2 == o1 | [
"def",
"assert_equivalent",
"(",
"o1",
",",
"o2",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"o1",
",",
"type",
")",
"and",
"isinstance",
"(",
"o2",
",",
"type",
")",
")",
":",
"assert",
"o1",
"is",
"not",
"o2",
"assert",
"o1",
"==",
"o2",
"a... | Asserts that o1 and o2 are distinct, yet equivalent objects | [
"Asserts",
"that",
"o1",
"and",
"o2",
"are",
"distinct",
"yet",
"equivalent",
"objects"
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L421-L427 |
243,461 | mbodenhamer/syn | syn/base_utils/py.py | assert_inequivalent | def assert_inequivalent(o1, o2):
'''Asserts that o1 and o2 are distinct and inequivalent objects
'''
if not (isinstance(o1, type) and isinstance(o2, type)):
assert o1 is not o2
assert not o1 == o2 and o1 != o2
assert not o2 == o1 and o2 != o1 | python | def assert_inequivalent(o1, o2):
'''Asserts that o1 and o2 are distinct and inequivalent objects
'''
if not (isinstance(o1, type) and isinstance(o2, type)):
assert o1 is not o2
assert not o1 == o2 and o1 != o2
assert not o2 == o1 and o2 != o1 | [
"def",
"assert_inequivalent",
"(",
"o1",
",",
"o2",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"o1",
",",
"type",
")",
"and",
"isinstance",
"(",
"o2",
",",
"type",
")",
")",
":",
"assert",
"o1",
"is",
"not",
"o2",
"assert",
"not",
"o1",
"==",
... | Asserts that o1 and o2 are distinct and inequivalent objects | [
"Asserts",
"that",
"o1",
"and",
"o2",
"are",
"distinct",
"and",
"inequivalent",
"objects"
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L429-L435 |
243,462 | mbodenhamer/syn | syn/base_utils/py.py | assert_type_equivalent | def assert_type_equivalent(o1, o2):
'''Asserts that o1 and o2 are distinct, yet equivalent objects of the same type
'''
assert o1 == o2
assert o2 == o1
assert type(o1) is type(o2) | python | def assert_type_equivalent(o1, o2):
'''Asserts that o1 and o2 are distinct, yet equivalent objects of the same type
'''
assert o1 == o2
assert o2 == o1
assert type(o1) is type(o2) | [
"def",
"assert_type_equivalent",
"(",
"o1",
",",
"o2",
")",
":",
"assert",
"o1",
"==",
"o2",
"assert",
"o2",
"==",
"o1",
"assert",
"type",
"(",
"o1",
")",
"is",
"type",
"(",
"o2",
")"
] | Asserts that o1 and o2 are distinct, yet equivalent objects of the same type | [
"Asserts",
"that",
"o1",
"and",
"o2",
"are",
"distinct",
"yet",
"equivalent",
"objects",
"of",
"the",
"same",
"type"
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L437-L442 |
243,463 | mbodenhamer/syn | syn/base_utils/py.py | elog | def elog(exc, func, args=None, kwargs=None, str=str, pretty=True, name=''):
'''For logging exception-raising function invocations during randomized unit tests.
'''
from .str import safe_str
args = args if args else ()
kwargs = kwargs if kwargs else {}
name = '{}.{}'.format(get_mod(func), name) ... | python | def elog(exc, func, args=None, kwargs=None, str=str, pretty=True, name=''):
'''For logging exception-raising function invocations during randomized unit tests.
'''
from .str import safe_str
args = args if args else ()
kwargs = kwargs if kwargs else {}
name = '{}.{}'.format(get_mod(func), name) ... | [
"def",
"elog",
"(",
"exc",
",",
"func",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"str",
"=",
"str",
",",
"pretty",
"=",
"True",
",",
"name",
"=",
"''",
")",
":",
"from",
".",
"str",
"import",
"safe_str",
"args",
"=",
"args",
"... | For logging exception-raising function invocations during randomized unit tests. | [
"For",
"logging",
"exception",
"-",
"raising",
"function",
"invocations",
"during",
"randomized",
"unit",
"tests",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/py.py#L468-L490 |
243,464 | colab/colab-superarchives-plugin | src/colab_superarchives/management/commands/message.py | Message.get_body | def get_body(self):
"""Get the body of the email message"""
if self.is_multipart():
# get the plain text version only
text_parts = [part
for part in typed_subpart_iterator(self,
'text',
... | python | def get_body(self):
"""Get the body of the email message"""
if self.is_multipart():
# get the plain text version only
text_parts = [part
for part in typed_subpart_iterator(self,
'text',
... | [
"def",
"get_body",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_multipart",
"(",
")",
":",
"# get the plain text version only",
"text_parts",
"=",
"[",
"part",
"for",
"part",
"in",
"typed_subpart_iterator",
"(",
"self",
",",
"'text'",
",",
"'plain'",
")",
"... | Get the body of the email message | [
"Get",
"the",
"body",
"of",
"the",
"email",
"message"
] | fe588a1d4fac874ccad2063ee19a857028a22721 | https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/management/commands/message.py#L56-L79 |
243,465 | Akhail/Tebless | tebless/widgets/window.py | Window.listen | def listen(self):
"""Blocking call on widgets.
"""
while self._listen:
key = u''
key = self.term.inkey(timeout=0.2)
try:
if key.code == KEY_ENTER:
self.on_enter(key=key)
elif key.code in (KEY_DOWN, KEY_UP):
... | python | def listen(self):
"""Blocking call on widgets.
"""
while self._listen:
key = u''
key = self.term.inkey(timeout=0.2)
try:
if key.code == KEY_ENTER:
self.on_enter(key=key)
elif key.code in (KEY_DOWN, KEY_UP):
... | [
"def",
"listen",
"(",
"self",
")",
":",
"while",
"self",
".",
"_listen",
":",
"key",
"=",
"u''",
"key",
"=",
"self",
".",
"term",
".",
"inkey",
"(",
"timeout",
"=",
"0.2",
")",
"try",
":",
"if",
"key",
".",
"code",
"==",
"KEY_ENTER",
":",
"self",... | Blocking call on widgets. | [
"Blocking",
"call",
"on",
"widgets",
"."
] | 369ff76f06e7a0b6d04fabc287fa6c4095e158d4 | https://github.com/Akhail/Tebless/blob/369ff76f06e7a0b6d04fabc287fa6c4095e158d4/tebless/widgets/window.py#L81-L98 |
243,466 | Akhail/Tebless | tebless/widgets/window.py | Window.add | def add(self, widget, *args, **kwargs):
"""Insert new element.
Usage:
window.add(widget, **{
'prop1': val,
'prop2': val2
})
"""
ins_widget = widget(*args, **kwargs)
self.__iadd__(ins_widget)
return ins_widget | python | def add(self, widget, *args, **kwargs):
"""Insert new element.
Usage:
window.add(widget, **{
'prop1': val,
'prop2': val2
})
"""
ins_widget = widget(*args, **kwargs)
self.__iadd__(ins_widget)
return ins_widget | [
"def",
"add",
"(",
"self",
",",
"widget",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ins_widget",
"=",
"widget",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"__iadd__",
"(",
"ins_widget",
")",
"return",
"ins_widget"
] | Insert new element.
Usage:
window.add(widget, **{
'prop1': val,
'prop2': val2
}) | [
"Insert",
"new",
"element",
"."
] | 369ff76f06e7a0b6d04fabc287fa6c4095e158d4 | https://github.com/Akhail/Tebless/blob/369ff76f06e7a0b6d04fabc287fa6c4095e158d4/tebless/widgets/window.py#L100-L112 |
243,467 | emory-libraries/eulcommon | eulcommon/searchutil/__init__.py | search_terms | def search_terms(q):
'''Takes a search string and parses it into a list of keywords and
phrases.'''
tokens = parse_search_terms(q)
# iterate through all the tokens and make a list of token values
# (which are the actual words and phrases)
values = []
for t in tokens:
# word/phrase
... | python | def search_terms(q):
'''Takes a search string and parses it into a list of keywords and
phrases.'''
tokens = parse_search_terms(q)
# iterate through all the tokens and make a list of token values
# (which are the actual words and phrases)
values = []
for t in tokens:
# word/phrase
... | [
"def",
"search_terms",
"(",
"q",
")",
":",
"tokens",
"=",
"parse_search_terms",
"(",
"q",
")",
"# iterate through all the tokens and make a list of token values",
"# (which are the actual words and phrases)",
"values",
"=",
"[",
"]",
"for",
"t",
"in",
"tokens",
":",
"# ... | Takes a search string and parses it into a list of keywords and
phrases. | [
"Takes",
"a",
"search",
"string",
"and",
"parses",
"it",
"into",
"a",
"list",
"of",
"keywords",
"and",
"phrases",
"."
] | dc63a9b3b5e38205178235e0d716d1b28158d3a9 | https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/searchutil/__init__.py#L129-L150 |
243,468 | emory-libraries/eulcommon | eulcommon/searchutil/__init__.py | pages_to_show | def pages_to_show(paginator, page, page_labels=None):
"""Generate a dictionary of pages to show around the current page. Show
3 numbers on either side of the specified page, or more if close to end or
beginning of available pages.
:param paginator: django :class:`~django.core.paginator.Paginator`,
... | python | def pages_to_show(paginator, page, page_labels=None):
"""Generate a dictionary of pages to show around the current page. Show
3 numbers on either side of the specified page, or more if close to end or
beginning of available pages.
:param paginator: django :class:`~django.core.paginator.Paginator`,
... | [
"def",
"pages_to_show",
"(",
"paginator",
",",
"page",
",",
"page_labels",
"=",
"None",
")",
":",
"show_pages",
"=",
"{",
"}",
"# FIXME; do we need OrderedDict here ?",
"if",
"page_labels",
"is",
"None",
":",
"page_labels",
"=",
"{",
"}",
"def",
"get_page_label"... | Generate a dictionary of pages to show around the current page. Show
3 numbers on either side of the specified page, or more if close to end or
beginning of available pages.
:param paginator: django :class:`~django.core.paginator.Paginator`,
populated with objects
:param page: number of the cur... | [
"Generate",
"a",
"dictionary",
"of",
"pages",
"to",
"show",
"around",
"the",
"current",
"page",
".",
"Show",
"3",
"numbers",
"on",
"either",
"side",
"of",
"the",
"specified",
"page",
"or",
"more",
"if",
"close",
"to",
"end",
"or",
"beginning",
"of",
"ava... | dc63a9b3b5e38205178235e0d716d1b28158d3a9 | https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/searchutil/__init__.py#L153-L191 |
243,469 | micbou/flake8-ycm | flake8_ycm.py | Indentation | def Indentation( logical_line,
previous_logical,
indent_level,
previous_indent_level ):
"""Use two spaces per indentation level."""
comment = '' if logical_line else ' (comment)'
if indent_level % 2:
code = 'YCM111' if logical_line else 'YCM114'
message =... | python | def Indentation( logical_line,
previous_logical,
indent_level,
previous_indent_level ):
"""Use two spaces per indentation level."""
comment = '' if logical_line else ' (comment)'
if indent_level % 2:
code = 'YCM111' if logical_line else 'YCM114'
message =... | [
"def",
"Indentation",
"(",
"logical_line",
",",
"previous_logical",
",",
"indent_level",
",",
"previous_indent_level",
")",
":",
"comment",
"=",
"''",
"if",
"logical_line",
"else",
"' (comment)'",
"if",
"indent_level",
"%",
"2",
":",
"code",
"=",
"'YCM111'",
"if... | Use two spaces per indentation level. | [
"Use",
"two",
"spaces",
"per",
"indentation",
"level",
"."
] | 60eb837751260f28db44b51a1641ea8743c1c497 | https://github.com/micbou/flake8-ycm/blob/60eb837751260f28db44b51a1641ea8743c1c497/flake8_ycm.py#L35-L50 |
243,470 | micbou/flake8-ycm | flake8_ycm.py | SpacesInsideBrackets | def SpacesInsideBrackets( logical_line, tokens ):
"""Require spaces inside parentheses, square brackets, and braces for
non-empty content."""
for index in range( len( tokens ) ):
_, prev_text, _, prev_end, _ = ( tokens[ index - 1 ] if index - 1 >= 0 else
( None, None, None... | python | def SpacesInsideBrackets( logical_line, tokens ):
"""Require spaces inside parentheses, square brackets, and braces for
non-empty content."""
for index in range( len( tokens ) ):
_, prev_text, _, prev_end, _ = ( tokens[ index - 1 ] if index - 1 >= 0 else
( None, None, None... | [
"def",
"SpacesInsideBrackets",
"(",
"logical_line",
",",
"tokens",
")",
":",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tokens",
")",
")",
":",
"_",
",",
"prev_text",
",",
"_",
",",
"prev_end",
",",
"_",
"=",
"(",
"tokens",
"[",
"index",
"-",
... | Require spaces inside parentheses, square brackets, and braces for
non-empty content. | [
"Require",
"spaces",
"inside",
"parentheses",
"square",
"brackets",
"and",
"braces",
"for",
"non",
"-",
"empty",
"content",
"."
] | 60eb837751260f28db44b51a1641ea8743c1c497 | https://github.com/micbou/flake8-ycm/blob/60eb837751260f28db44b51a1641ea8743c1c497/flake8_ycm.py#L57-L89 |
243,471 | chairbender/fantasy-football-auction | fantasy_football_auction/owner.py | Owner.buy | def buy(self, player, cost):
"""
indicate that the player was bought at the specified cost
:param Player player: player to buy
:param int cost: cost to pay
:raises InsufficientFundsError: if owner doesn't have the money
:raises NoValidRosterSlotError: if owner doesn't h... | python | def buy(self, player, cost):
"""
indicate that the player was bought at the specified cost
:param Player player: player to buy
:param int cost: cost to pay
:raises InsufficientFundsError: if owner doesn't have the money
:raises NoValidRosterSlotError: if owner doesn't h... | [
"def",
"buy",
"(",
"self",
",",
"player",
",",
"cost",
")",
":",
"if",
"cost",
">",
"self",
".",
"max_bid",
"(",
")",
":",
"raise",
"InsufficientFundsError",
"(",
")",
"elif",
"not",
"any",
"(",
"roster_slot",
".",
"accepts",
"(",
"player",
")",
"and... | indicate that the player was bought at the specified cost
:param Player player: player to buy
:param int cost: cost to pay
:raises InsufficientFundsError: if owner doesn't have the money
:raises NoValidRosterSlotError: if owner doesn't have a slot this player could fill
:raises... | [
"indicate",
"that",
"the",
"player",
"was",
"bought",
"at",
"the",
"specified",
"cost"
] | f54868691ea37691c378b0a05b6b3280c2cbba11 | https://github.com/chairbender/fantasy-football-auction/blob/f54868691ea37691c378b0a05b6b3280c2cbba11/fantasy_football_auction/owner.py#L132-L153 |
243,472 | sarenji/pyrc | pyrc/threads.py | JobThread.run | def run(self):
"""Keep running this thread until it's stopped"""
while not self._finished.isSet():
self._func(self._reference)
self._finished.wait(self._func._interval / 1000.0) | python | def run(self):
"""Keep running this thread until it's stopped"""
while not self._finished.isSet():
self._func(self._reference)
self._finished.wait(self._func._interval / 1000.0) | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"_finished",
".",
"isSet",
"(",
")",
":",
"self",
".",
"_func",
"(",
"self",
".",
"_reference",
")",
"self",
".",
"_finished",
".",
"wait",
"(",
"self",
".",
"_func",
".",
"_interval... | Keep running this thread until it's stopped | [
"Keep",
"running",
"this",
"thread",
"until",
"it",
"s",
"stopped"
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/threads.py#L16-L20 |
243,473 | kankiri/pabiana | pabiana/zmqs/area.py | Area.subscribe | def subscribe(self, clock_name: str=None, clock_slots: Iterable[str]=None, subscriptions: Dict[str, Any]={}):
"""Subscribes this Area to the given Areas and optionally given Slots. Must be called before the Area is run.
Args:
clock_name: The name of the Area that is used as synchronizing Clock.
clock_slots: ... | python | def subscribe(self, clock_name: str=None, clock_slots: Iterable[str]=None, subscriptions: Dict[str, Any]={}):
"""Subscribes this Area to the given Areas and optionally given Slots. Must be called before the Area is run.
Args:
clock_name: The name of the Area that is used as synchronizing Clock.
clock_slots: ... | [
"def",
"subscribe",
"(",
"self",
",",
"clock_name",
":",
"str",
"=",
"None",
",",
"clock_slots",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"subscriptions",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"{",
"}",
")",
":",
"for",
"area",
... | Subscribes this Area to the given Areas and optionally given Slots. Must be called before the Area is run.
Args:
clock_name: The name of the Area that is used as synchronizing Clock.
clock_slots: The slots of the Clock relevant to this Area.
subscriptions: A dictionary containing the relevant Areas names as... | [
"Subscribes",
"this",
"Area",
"to",
"the",
"given",
"Areas",
"and",
"optionally",
"given",
"Slots",
".",
"Must",
"be",
"called",
"before",
"the",
"Area",
"is",
"run",
"."
] | 74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/pabiana/zmqs/area.py#L52-L68 |
243,474 | drcloud/magiclog | magiclog.py | logger | def logger(ref=0):
"""Finds a module logger.
If the argument passed is a module, find the logger for that module using
the modules' name; if it's a string, finds a logger of that name; if an
integer, walks the stack to the module at that height.
The logger is always extended with a ``.configure()`... | python | def logger(ref=0):
"""Finds a module logger.
If the argument passed is a module, find the logger for that module using
the modules' name; if it's a string, finds a logger of that name; if an
integer, walks the stack to the module at that height.
The logger is always extended with a ``.configure()`... | [
"def",
"logger",
"(",
"ref",
"=",
"0",
")",
":",
"if",
"inspect",
".",
"ismodule",
"(",
"ref",
")",
":",
"return",
"extend",
"(",
"logging",
".",
"getLogger",
"(",
"ref",
".",
"__name__",
")",
")",
"if",
"isinstance",
"(",
"ref",
",",
"basestring",
... | Finds a module logger.
If the argument passed is a module, find the logger for that module using
the modules' name; if it's a string, finds a logger of that name; if an
integer, walks the stack to the module at that height.
The logger is always extended with a ``.configure()`` method allowing
its ... | [
"Finds",
"a",
"module",
"logger",
"."
] | f045a68f9d3eff946c0a0d3147edff0ec0c0b344 | https://github.com/drcloud/magiclog/blob/f045a68f9d3eff946c0a0d3147edff0ec0c0b344/magiclog.py#L21-L36 |
243,475 | drcloud/magiclog | magiclog.py | Configuration.auto | def auto(cls, syslog=None, stderr=None, level=None, extended=None,
server=None):
"""Tries to guess a sound logging configuration.
"""
level = norm_level(level) or logging.INFO
if syslog is None and stderr is None:
if sys.stderr.isatty() or syslog_path() is None:
... | python | def auto(cls, syslog=None, stderr=None, level=None, extended=None,
server=None):
"""Tries to guess a sound logging configuration.
"""
level = norm_level(level) or logging.INFO
if syslog is None and stderr is None:
if sys.stderr.isatty() or syslog_path() is None:
... | [
"def",
"auto",
"(",
"cls",
",",
"syslog",
"=",
"None",
",",
"stderr",
"=",
"None",
",",
"level",
"=",
"None",
",",
"extended",
"=",
"None",
",",
"server",
"=",
"None",
")",
":",
"level",
"=",
"norm_level",
"(",
"level",
")",
"or",
"logging",
".",
... | Tries to guess a sound logging configuration. | [
"Tries",
"to",
"guess",
"a",
"sound",
"logging",
"configuration",
"."
] | f045a68f9d3eff946c0a0d3147edff0ec0c0b344 | https://github.com/drcloud/magiclog/blob/f045a68f9d3eff946c0a0d3147edff0ec0c0b344/magiclog.py#L68-L83 |
243,476 | Othernet-Project/bottle-fdsend | fdsend/sendfile.py | send_file | def send_file(fd, filename=None, size=None, timestamp=None, ctype=None,
charset=CHARSET, attachment=False, wrapper=DEFAULT_WRAPPER):
""" Send a file represented by file object
This function constcuts a HTTPResponse object that uses a file descriptor
as response body. The file descriptor is su... | python | def send_file(fd, filename=None, size=None, timestamp=None, ctype=None,
charset=CHARSET, attachment=False, wrapper=DEFAULT_WRAPPER):
""" Send a file represented by file object
This function constcuts a HTTPResponse object that uses a file descriptor
as response body. The file descriptor is su... | [
"def",
"send_file",
"(",
"fd",
",",
"filename",
"=",
"None",
",",
"size",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"ctype",
"=",
"None",
",",
"charset",
"=",
"CHARSET",
",",
"attachment",
"=",
"False",
",",
"wrapper",
"=",
"DEFAULT_WRAPPER",
")... | Send a file represented by file object
This function constcuts a HTTPResponse object that uses a file descriptor
as response body. The file descriptor is suppled as ``fd`` argument and it
must have a ``read()`` method. ``ValueError`` is raised when this is not
the case. It supports `byte serving`_ usin... | [
"Send",
"a",
"file",
"represented",
"by",
"file",
"object"
] | 5ff27e605e8cf878e24c71c1446dcf5c8caf4898 | https://github.com/Othernet-Project/bottle-fdsend/blob/5ff27e605e8cf878e24c71c1446dcf5c8caf4898/fdsend/sendfile.py#L36-L156 |
243,477 | maxfischer2781/chainlet | chainlet/primitives/linker.py | LinkPrimitives.convert | def convert(self, element):
"""Convert an element to a chainlink"""
if isinstance(element, self.base_link_type):
return element
for converter in self.converters:
link = converter(element)
if link is not NotImplemented:
return link
raise... | python | def convert(self, element):
"""Convert an element to a chainlink"""
if isinstance(element, self.base_link_type):
return element
for converter in self.converters:
link = converter(element)
if link is not NotImplemented:
return link
raise... | [
"def",
"convert",
"(",
"self",
",",
"element",
")",
":",
"if",
"isinstance",
"(",
"element",
",",
"self",
".",
"base_link_type",
")",
":",
"return",
"element",
"for",
"converter",
"in",
"self",
".",
"converters",
":",
"link",
"=",
"converter",
"(",
"elem... | Convert an element to a chainlink | [
"Convert",
"an",
"element",
"to",
"a",
"chainlink"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/primitives/linker.py#L39-L47 |
243,478 | ronaldguillen/wave | wave/views.py | get_view_name | def get_view_name(view_cls, suffix=None):
"""
Given a view class, return a textual name to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_NAME_FUNCTION` setting.
"""
name = view_cls.__name__
name = formatting.... | python | def get_view_name(view_cls, suffix=None):
"""
Given a view class, return a textual name to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_NAME_FUNCTION` setting.
"""
name = view_cls.__name__
name = formatting.... | [
"def",
"get_view_name",
"(",
"view_cls",
",",
"suffix",
"=",
"None",
")",
":",
"name",
"=",
"view_cls",
".",
"__name__",
"name",
"=",
"formatting",
".",
"remove_trailing_string",
"(",
"name",
",",
"'View'",
")",
"name",
"=",
"formatting",
".",
"remove_traili... | Given a view class, return a textual name to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_NAME_FUNCTION` setting. | [
"Given",
"a",
"view",
"class",
"return",
"a",
"textual",
"name",
"to",
"represent",
"the",
"view",
".",
"This",
"name",
"is",
"used",
"in",
"the",
"browsable",
"API",
"and",
"in",
"OPTIONS",
"responses",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L24-L38 |
243,479 | ronaldguillen/wave | wave/views.py | get_view_description | def get_view_description(view_cls, html=False):
"""
Given a view class, return a textual description to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
"""
description = view_cls.__do... | python | def get_view_description(view_cls, html=False):
"""
Given a view class, return a textual description to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
"""
description = view_cls.__do... | [
"def",
"get_view_description",
"(",
"view_cls",
",",
"html",
"=",
"False",
")",
":",
"description",
"=",
"view_cls",
".",
"__doc__",
"or",
"''",
"description",
"=",
"formatting",
".",
"dedent",
"(",
"smart_text",
"(",
"description",
")",
")",
"if",
"html",
... | Given a view class, return a textual description to represent the view.
This name is used in the browsable API, and in OPTIONS responses.
This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting. | [
"Given",
"a",
"view",
"class",
"return",
"a",
"textual",
"description",
"to",
"represent",
"the",
"view",
".",
"This",
"name",
"is",
"used",
"in",
"the",
"browsable",
"API",
"and",
"in",
"OPTIONS",
"responses",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L41-L52 |
243,480 | ronaldguillen/wave | wave/views.py | exception_handler | def exception_handler(exc, context):
"""
Returns the response that should be used for any given exception.
By default we handle the REST framework `APIException`, and also
Django's built-in `Http404` and `PermissionDenied` exceptions.
Any unhandled exceptions may return `None`, which will cause a ... | python | def exception_handler(exc, context):
"""
Returns the response that should be used for any given exception.
By default we handle the REST framework `APIException`, and also
Django's built-in `Http404` and `PermissionDenied` exceptions.
Any unhandled exceptions may return `None`, which will cause a ... | [
"def",
"exception_handler",
"(",
"exc",
",",
"context",
")",
":",
"if",
"isinstance",
"(",
"exc",
",",
"exceptions",
".",
"APIException",
")",
":",
"headers",
"=",
"{",
"}",
"if",
"getattr",
"(",
"exc",
",",
"'auth_header'",
",",
"None",
")",
":",
"hea... | Returns the response that should be used for any given exception.
By default we handle the REST framework `APIException`, and also
Django's built-in `Http404` and `PermissionDenied` exceptions.
Any unhandled exceptions may return `None`, which will cause a 500 error
to be raised. | [
"Returns",
"the",
"response",
"that",
"should",
"be",
"used",
"for",
"any",
"given",
"exception",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L55-L95 |
243,481 | ronaldguillen/wave | wave/views.py | RestView.as_view | def as_view(cls, **initkwargs):
"""
Store the original class on the view function.
This allows us to discover information about the view when we do URL
reverse lookups. Used for breadcrumb generation.
"""
if isinstance(getattr(cls, 'queryset', None), models.query.QueryS... | python | def as_view(cls, **initkwargs):
"""
Store the original class on the view function.
This allows us to discover information about the view when we do URL
reverse lookups. Used for breadcrumb generation.
"""
if isinstance(getattr(cls, 'queryset', None), models.query.QueryS... | [
"def",
"as_view",
"(",
"cls",
",",
"*",
"*",
"initkwargs",
")",
":",
"if",
"isinstance",
"(",
"getattr",
"(",
"cls",
",",
"'queryset'",
",",
"None",
")",
",",
"models",
".",
"query",
".",
"QuerySet",
")",
":",
"def",
"force_evaluation",
"(",
")",
":"... | Store the original class on the view function.
This allows us to discover information about the view when we do URL
reverse lookups. Used for breadcrumb generation. | [
"Store",
"the",
"original",
"class",
"on",
"the",
"view",
"function",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L114-L136 |
243,482 | ronaldguillen/wave | wave/views.py | RestView.permission_denied | def permission_denied(self, request, message=None):
"""
If request is not permitted, determine what kind of exception to raise.
"""
if not request.successful_authenticator:
raise exceptions.NotAuthenticated()
raise exceptions.PermissionDenied(detail=message) | python | def permission_denied(self, request, message=None):
"""
If request is not permitted, determine what kind of exception to raise.
"""
if not request.successful_authenticator:
raise exceptions.NotAuthenticated()
raise exceptions.PermissionDenied(detail=message) | [
"def",
"permission_denied",
"(",
"self",
",",
"request",
",",
"message",
"=",
"None",
")",
":",
"if",
"not",
"request",
".",
"successful_authenticator",
":",
"raise",
"exceptions",
".",
"NotAuthenticated",
"(",
")",
"raise",
"exceptions",
".",
"PermissionDenied"... | If request is not permitted, determine what kind of exception to raise. | [
"If",
"request",
"is",
"not",
"permitted",
"determine",
"what",
"kind",
"of",
"exception",
"to",
"raise",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L161-L167 |
243,483 | ronaldguillen/wave | wave/views.py | RestView.get_view_name | def get_view_name(self):
"""
Return the view name, as used in OPTIONS responses and in the
browsable API.
"""
func = self.settings.VIEW_NAME_FUNCTION
return func(self.__class__, getattr(self, 'suffix', None)) | python | def get_view_name(self):
"""
Return the view name, as used in OPTIONS responses and in the
browsable API.
"""
func = self.settings.VIEW_NAME_FUNCTION
return func(self.__class__, getattr(self, 'suffix', None)) | [
"def",
"get_view_name",
"(",
"self",
")",
":",
"func",
"=",
"self",
".",
"settings",
".",
"VIEW_NAME_FUNCTION",
"return",
"func",
"(",
"self",
".",
"__class__",
",",
"getattr",
"(",
"self",
",",
"'suffix'",
",",
"None",
")",
")"
] | Return the view name, as used in OPTIONS responses and in the
browsable API. | [
"Return",
"the",
"view",
"name",
"as",
"used",
"in",
"OPTIONS",
"responses",
"and",
"in",
"the",
"browsable",
"API",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L223-L229 |
243,484 | ronaldguillen/wave | wave/views.py | RestView.get_view_description | def get_view_description(self, html=False):
"""
Return some descriptive text for the view, as used in OPTIONS responses
and in the browsable API.
"""
func = self.settings.VIEW_DESCRIPTION_FUNCTION
return func(self.__class__, html) | python | def get_view_description(self, html=False):
"""
Return some descriptive text for the view, as used in OPTIONS responses
and in the browsable API.
"""
func = self.settings.VIEW_DESCRIPTION_FUNCTION
return func(self.__class__, html) | [
"def",
"get_view_description",
"(",
"self",
",",
"html",
"=",
"False",
")",
":",
"func",
"=",
"self",
".",
"settings",
".",
"VIEW_DESCRIPTION_FUNCTION",
"return",
"func",
"(",
"self",
".",
"__class__",
",",
"html",
")"
] | Return some descriptive text for the view, as used in OPTIONS responses
and in the browsable API. | [
"Return",
"some",
"descriptive",
"text",
"for",
"the",
"view",
"as",
"used",
"in",
"OPTIONS",
"responses",
"and",
"in",
"the",
"browsable",
"API",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L231-L237 |
243,485 | ronaldguillen/wave | wave/views.py | RestView.get_format_suffix | def get_format_suffix(self, **kwargs):
"""
Determine if the request includes a '.json' style format suffix
"""
if self.settings.FORMAT_SUFFIX_KWARG:
return kwargs.get(self.settings.FORMAT_SUFFIX_KWARG) | python | def get_format_suffix(self, **kwargs):
"""
Determine if the request includes a '.json' style format suffix
"""
if self.settings.FORMAT_SUFFIX_KWARG:
return kwargs.get(self.settings.FORMAT_SUFFIX_KWARG) | [
"def",
"get_format_suffix",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"settings",
".",
"FORMAT_SUFFIX_KWARG",
":",
"return",
"kwargs",
".",
"get",
"(",
"self",
".",
"settings",
".",
"FORMAT_SUFFIX_KWARG",
")"
] | Determine if the request includes a '.json' style format suffix | [
"Determine",
"if",
"the",
"request",
"includes",
"a",
".",
"json",
"style",
"format",
"suffix"
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L241-L246 |
243,486 | ronaldguillen/wave | wave/views.py | RestView.get_content_negotiator | def get_content_negotiator(self):
"""
Instantiate and return the content negotiation class to use.
"""
if not getattr(self, '_negotiator', None):
self._negotiator = self.content_negotiation_class()
return self._negotiator | python | def get_content_negotiator(self):
"""
Instantiate and return the content negotiation class to use.
"""
if not getattr(self, '_negotiator', None):
self._negotiator = self.content_negotiation_class()
return self._negotiator | [
"def",
"get_content_negotiator",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"'_negotiator'",
",",
"None",
")",
":",
"self",
".",
"_negotiator",
"=",
"self",
".",
"content_negotiation_class",
"(",
")",
"return",
"self",
".",
"_negotiator... | Instantiate and return the content negotiation class to use. | [
"Instantiate",
"and",
"return",
"the",
"content",
"negotiation",
"class",
"to",
"use",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L278-L284 |
243,487 | ronaldguillen/wave | wave/views.py | RestView.perform_content_negotiation | def perform_content_negotiation(self, request, force=False):
"""
Determine which renderer and media type to use render the response.
"""
renderers = self.get_renderers()
conneg = self.get_content_negotiator()
try:
return conneg.select_renderer(request, render... | python | def perform_content_negotiation(self, request, force=False):
"""
Determine which renderer and media type to use render the response.
"""
renderers = self.get_renderers()
conneg = self.get_content_negotiator()
try:
return conneg.select_renderer(request, render... | [
"def",
"perform_content_negotiation",
"(",
"self",
",",
"request",
",",
"force",
"=",
"False",
")",
":",
"renderers",
"=",
"self",
".",
"get_renderers",
"(",
")",
"conneg",
"=",
"self",
".",
"get_content_negotiator",
"(",
")",
"try",
":",
"return",
"conneg",... | Determine which renderer and media type to use render the response. | [
"Determine",
"which",
"renderer",
"and",
"media",
"type",
"to",
"use",
"render",
"the",
"response",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L288-L300 |
243,488 | ronaldguillen/wave | wave/views.py | RestView.check_throttles | def check_throttles(self, request):
"""
Check if request should be throttled.
Raises an appropriate exception if the request is throttled.
"""
for throttle in self.get_throttles():
if not throttle.allow_request(request, self):
self.throttled(request, t... | python | def check_throttles(self, request):
"""
Check if request should be throttled.
Raises an appropriate exception if the request is throttled.
"""
for throttle in self.get_throttles():
if not throttle.allow_request(request, self):
self.throttled(request, t... | [
"def",
"check_throttles",
"(",
"self",
",",
"request",
")",
":",
"for",
"throttle",
"in",
"self",
".",
"get_throttles",
"(",
")",
":",
"if",
"not",
"throttle",
".",
"allow_request",
"(",
"request",
",",
"self",
")",
":",
"self",
".",
"throttled",
"(",
... | Check if request should be throttled.
Raises an appropriate exception if the request is throttled. | [
"Check",
"if",
"request",
"should",
"be",
"throttled",
".",
"Raises",
"an",
"appropriate",
"exception",
"if",
"the",
"request",
"is",
"throttled",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L334-L341 |
243,489 | ronaldguillen/wave | wave/views.py | RestView.initialize_request | def initialize_request(self, request, *args, **kwargs):
"""
Returns the initial request object.
"""
parser_context = self.get_parser_context(request)
return Request(
request,
parsers=self.get_parsers(),
authenticators=self.get_authenticators()... | python | def initialize_request(self, request, *args, **kwargs):
"""
Returns the initial request object.
"""
parser_context = self.get_parser_context(request)
return Request(
request,
parsers=self.get_parsers(),
authenticators=self.get_authenticators()... | [
"def",
"initialize_request",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"parser_context",
"=",
"self",
".",
"get_parser_context",
"(",
"request",
")",
"return",
"Request",
"(",
"request",
",",
"parsers",
"=",
"self",
... | Returns the initial request object. | [
"Returns",
"the",
"initial",
"request",
"object",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L355-L367 |
243,490 | ronaldguillen/wave | wave/views.py | RestView.initial | def initial(self, request, *args, **kwargs):
"""
Runs anything that needs to occur prior to calling the method handler.
"""
self.format_kwarg = self.get_format_suffix(**kwargs)
# Ensure that the incoming request is permitted
self.perform_authentication(request)
s... | python | def initial(self, request, *args, **kwargs):
"""
Runs anything that needs to occur prior to calling the method handler.
"""
self.format_kwarg = self.get_format_suffix(**kwargs)
# Ensure that the incoming request is permitted
self.perform_authentication(request)
s... | [
"def",
"initial",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"format_kwarg",
"=",
"self",
".",
"get_format_suffix",
"(",
"*",
"*",
"kwargs",
")",
"# Ensure that the incoming request is permitted",
"self",
"... | Runs anything that needs to occur prior to calling the method handler. | [
"Runs",
"anything",
"that",
"needs",
"to",
"occur",
"prior",
"to",
"calling",
"the",
"method",
"handler",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L369-L386 |
243,491 | ronaldguillen/wave | wave/views.py | RestView.finalize_response | def finalize_response(self, request, response, *args, **kwargs):
"""
Returns the final response object.
"""
# Make the error obvious if a proper response is not returned
assert isinstance(response, HttpResponseBase), (
'Expected a `Response`, `HttpResponse` or `HttpSt... | python | def finalize_response(self, request, response, *args, **kwargs):
"""
Returns the final response object.
"""
# Make the error obvious if a proper response is not returned
assert isinstance(response, HttpResponseBase), (
'Expected a `Response`, `HttpResponse` or `HttpSt... | [
"def",
"finalize_response",
"(",
"self",
",",
"request",
",",
"response",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Make the error obvious if a proper response is not returned",
"assert",
"isinstance",
"(",
"response",
",",
"HttpResponseBase",
")",
","... | Returns the final response object. | [
"Returns",
"the",
"final",
"response",
"object",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L388-L411 |
243,492 | ronaldguillen/wave | wave/views.py | RestView.handle_exception | def handle_exception(self, exc):
"""
Handle any exception that occurs, by returning an appropriate response,
or re-raising the error.
"""
if isinstance(exc, (exceptions.NotAuthenticated,
exceptions.AuthenticationFailed)):
# WWW-Authenticate... | python | def handle_exception(self, exc):
"""
Handle any exception that occurs, by returning an appropriate response,
or re-raising the error.
"""
if isinstance(exc, (exceptions.NotAuthenticated,
exceptions.AuthenticationFailed)):
# WWW-Authenticate... | [
"def",
"handle_exception",
"(",
"self",
",",
"exc",
")",
":",
"if",
"isinstance",
"(",
"exc",
",",
"(",
"exceptions",
".",
"NotAuthenticated",
",",
"exceptions",
".",
"AuthenticationFailed",
")",
")",
":",
"# WWW-Authenticate header for 401 responses, else coerce to 4... | Handle any exception that occurs, by returning an appropriate response,
or re-raising the error. | [
"Handle",
"any",
"exception",
"that",
"occurs",
"by",
"returning",
"an",
"appropriate",
"response",
"or",
"re",
"-",
"raising",
"the",
"error",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L413-L437 |
243,493 | ronaldguillen/wave | wave/views.py | RestView.options | def options(self, request, *args, **kwargs):
"""
Handler method for HTTP 'OPTIONS' request.
"""
if self.metadata_class is None:
return self.http_method_not_allowed(request, *args, **kwargs)
data = self.metadata_class().determine_metadata(request, self)
return ... | python | def options(self, request, *args, **kwargs):
"""
Handler method for HTTP 'OPTIONS' request.
"""
if self.metadata_class is None:
return self.http_method_not_allowed(request, *args, **kwargs)
data = self.metadata_class().determine_metadata(request, self)
return ... | [
"def",
"options",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"metadata_class",
"is",
"None",
":",
"return",
"self",
".",
"http_method_not_allowed",
"(",
"request",
",",
"*",
"args",
",",
"*",
... | Handler method for HTTP 'OPTIONS' request. | [
"Handler",
"method",
"for",
"HTTP",
"OPTIONS",
"request",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L471-L478 |
243,494 | rfk/regobj | regobj.py | Key.get_subkey | def get_subkey(self,name):
"""Retreive the subkey with the specified name.
If the named subkey is not found, AttributeError is raised;
this is for consistency with the attribute-based access notation.
"""
subkey = Key(name,self)
try:
hkey = subkey.hkey
... | python | def get_subkey(self,name):
"""Retreive the subkey with the specified name.
If the named subkey is not found, AttributeError is raised;
this is for consistency with the attribute-based access notation.
"""
subkey = Key(name,self)
try:
hkey = subkey.hkey
... | [
"def",
"get_subkey",
"(",
"self",
",",
"name",
")",
":",
"subkey",
"=",
"Key",
"(",
"name",
",",
"self",
")",
"try",
":",
"hkey",
"=",
"subkey",
".",
"hkey",
"except",
"WindowsError",
":",
"raise",
"AttributeError",
"(",
"\"subkey '%s' does not exist\"",
"... | Retreive the subkey with the specified name.
If the named subkey is not found, AttributeError is raised;
this is for consistency with the attribute-based access notation. | [
"Retreive",
"the",
"subkey",
"with",
"the",
"specified",
"name",
"."
] | 7edd46be28aa3e1427be263911e111c4ca2dfa4f | https://github.com/rfk/regobj/blob/7edd46be28aa3e1427be263911e111c4ca2dfa4f/regobj.py#L241-L252 |
243,495 | rfk/regobj | regobj.py | Key.set_subkey | def set_subkey(self,name,value=None):
"""Create the named subkey and set its value.
There are several different ways to specify the new contents of
the named subkey:
* if 'value' is the Key class, a subclass thereof, or None, then
the subkey is created but not populated w... | python | def set_subkey(self,name,value=None):
"""Create the named subkey and set its value.
There are several different ways to specify the new contents of
the named subkey:
* if 'value' is the Key class, a subclass thereof, or None, then
the subkey is created but not populated w... | [
"def",
"set_subkey",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"self",
".",
"sam",
"|=",
"KEY_CREATE_SUB_KEY",
"subkey",
"=",
"Key",
"(",
"name",
",",
"self",
")",
"try",
":",
"subkey",
"=",
"self",
".",
"get_subkey",
"(",
"name"... | Create the named subkey and set its value.
There are several different ways to specify the new contents of
the named subkey:
* if 'value' is the Key class, a subclass thereof, or None, then
the subkey is created but not populated with any data.
* if 'value' is a key ins... | [
"Create",
"the",
"named",
"subkey",
"and",
"set",
"its",
"value",
"."
] | 7edd46be28aa3e1427be263911e111c4ca2dfa4f | https://github.com/rfk/regobj/blob/7edd46be28aa3e1427be263911e111c4ca2dfa4f/regobj.py#L254-L301 |
243,496 | rfk/regobj | regobj.py | Key.del_subkey | def del_subkey(self,name):
"""Delete the named subkey, and any values or keys it contains."""
self.sam |= KEY_WRITE
subkey = self.get_subkey(name)
subkey.clear()
_winreg.DeleteKey(subkey.parent.hkey,subkey.name) | python | def del_subkey(self,name):
"""Delete the named subkey, and any values or keys it contains."""
self.sam |= KEY_WRITE
subkey = self.get_subkey(name)
subkey.clear()
_winreg.DeleteKey(subkey.parent.hkey,subkey.name) | [
"def",
"del_subkey",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"sam",
"|=",
"KEY_WRITE",
"subkey",
"=",
"self",
".",
"get_subkey",
"(",
"name",
")",
"subkey",
".",
"clear",
"(",
")",
"_winreg",
".",
"DeleteKey",
"(",
"subkey",
".",
"parent",
"... | Delete the named subkey, and any values or keys it contains. | [
"Delete",
"the",
"named",
"subkey",
"and",
"any",
"values",
"or",
"keys",
"it",
"contains",
"."
] | 7edd46be28aa3e1427be263911e111c4ca2dfa4f | https://github.com/rfk/regobj/blob/7edd46be28aa3e1427be263911e111c4ca2dfa4f/regobj.py#L303-L308 |
243,497 | rfk/regobj | regobj.py | Key.clear | def clear(self):
"""Remove all subkeys and values from this key."""
self.sam |= KEY_WRITE
for v in list(self.values()):
del self[v.name]
for k in list(self.subkeys()):
self.del_subkey(k.name) | python | def clear(self):
"""Remove all subkeys and values from this key."""
self.sam |= KEY_WRITE
for v in list(self.values()):
del self[v.name]
for k in list(self.subkeys()):
self.del_subkey(k.name) | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"sam",
"|=",
"KEY_WRITE",
"for",
"v",
"in",
"list",
"(",
"self",
".",
"values",
"(",
")",
")",
":",
"del",
"self",
"[",
"v",
".",
"name",
"]",
"for",
"k",
"in",
"list",
"(",
"self",
".",
"su... | Remove all subkeys and values from this key. | [
"Remove",
"all",
"subkeys",
"and",
"values",
"from",
"this",
"key",
"."
] | 7edd46be28aa3e1427be263911e111c4ca2dfa4f | https://github.com/rfk/regobj/blob/7edd46be28aa3e1427be263911e111c4ca2dfa4f/regobj.py#L426-L432 |
243,498 | urbn/Caesium | caesium/document.py | AsyncRevisionStackManager.publish | def publish(self):
"""
Iterate over the scheduler collections and apply any actions found
"""
try:
for collection in self.settings.get("scheduler").get("collections"):
yield self.publish_for_collection(collection)
except Exception as ex:
... | python | def publish(self):
"""
Iterate over the scheduler collections and apply any actions found
"""
try:
for collection in self.settings.get("scheduler").get("collections"):
yield self.publish_for_collection(collection)
except Exception as ex:
... | [
"def",
"publish",
"(",
"self",
")",
":",
"try",
":",
"for",
"collection",
"in",
"self",
".",
"settings",
".",
"get",
"(",
"\"scheduler\"",
")",
".",
"get",
"(",
"\"collections\"",
")",
":",
"yield",
"self",
".",
"publish_for_collection",
"(",
"collection",... | Iterate over the scheduler collections and apply any actions found | [
"Iterate",
"over",
"the",
"scheduler",
"collections",
"and",
"apply",
"any",
"actions",
"found"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L36-L45 |
243,499 | urbn/Caesium | caesium/document.py | AsyncRevisionStackManager.set_all_revisions_to_in_process | def set_all_revisions_to_in_process(self, ids):
"""
Set all revisions found to in process, so that other threads will not pick them up.
:param list ids:
"""
predicate = {
"_id" : {
"$in" : [ ObjectId(id) for id in ids ]
}
}
... | python | def set_all_revisions_to_in_process(self, ids):
"""
Set all revisions found to in process, so that other threads will not pick them up.
:param list ids:
"""
predicate = {
"_id" : {
"$in" : [ ObjectId(id) for id in ids ]
}
}
... | [
"def",
"set_all_revisions_to_in_process",
"(",
"self",
",",
"ids",
")",
":",
"predicate",
"=",
"{",
"\"_id\"",
":",
"{",
"\"$in\"",
":",
"[",
"ObjectId",
"(",
"id",
")",
"for",
"id",
"in",
"ids",
"]",
"}",
"}",
"set",
"=",
"{",
"\"$set\"",
":",
"{",
... | Set all revisions found to in process, so that other threads will not pick them up.
:param list ids: | [
"Set",
"all",
"revisions",
"found",
"to",
"in",
"process",
"so",
"that",
"other",
"threads",
"will",
"not",
"pick",
"them",
"up",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L48-L63 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.