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,500 | urbn/Caesium | caesium/document.py | AsyncRevisionStackManager.__get_pending_revisions | def __get_pending_revisions(self):
"""
Get all the pending revisions after the current time
:return: A list of revisions
:rtype: list
"""
dttime = time.mktime(datetime.datetime.now().timetuple())
changes = yield self.revisions.find({
"toa" : {
... | python | def __get_pending_revisions(self):
"""
Get all the pending revisions after the current time
:return: A list of revisions
:rtype: list
"""
dttime = time.mktime(datetime.datetime.now().timetuple())
changes = yield self.revisions.find({
"toa" : {
... | [
"def",
"__get_pending_revisions",
"(",
"self",
")",
":",
"dttime",
"=",
"time",
".",
"mktime",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"timetuple",
"(",
")",
")",
"changes",
"=",
"yield",
"self",
".",
"revisions",
".",
"find",
"(",... | Get all the pending revisions after the current time
:return: A list of revisions
:rtype: list | [
"Get",
"all",
"the",
"pending",
"revisions",
"after",
"the",
"current",
"time"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L67-L86 |
243,501 | urbn/Caesium | caesium/document.py | AsyncRevisionStackManager.publish_for_collection | def publish_for_collection(self, collection_name):
"""
Run the publishing operations for a given collection
:param str collection_name:
"""
self.revisions = BaseAsyncMotorDocument("%s_revisions" % collection_name, self.settings)
changes = yield self.__get_pending_revisi... | python | def publish_for_collection(self, collection_name):
"""
Run the publishing operations for a given collection
:param str collection_name:
"""
self.revisions = BaseAsyncMotorDocument("%s_revisions" % collection_name, self.settings)
changes = yield self.__get_pending_revisi... | [
"def",
"publish_for_collection",
"(",
"self",
",",
"collection_name",
")",
":",
"self",
".",
"revisions",
"=",
"BaseAsyncMotorDocument",
"(",
"\"%s_revisions\"",
"%",
"collection_name",
",",
"self",
".",
"settings",
")",
"changes",
"=",
"yield",
"self",
".",
"__... | Run the publishing operations for a given collection
:param str collection_name: | [
"Run",
"the",
"publishing",
"operations",
"for",
"a",
"given",
"collection"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L89-L118 |
243,502 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.__update_action | def __update_action(self, revision):
"""Update a master document and revision history document
:param dict revision: The revision dictionary
"""
patch = revision.get("patch")
if patch.get("_id"):
del patch["_id"]
update_response = yield self.collection.patc... | python | def __update_action(self, revision):
"""Update a master document and revision history document
:param dict revision: The revision dictionary
"""
patch = revision.get("patch")
if patch.get("_id"):
del patch["_id"]
update_response = yield self.collection.patc... | [
"def",
"__update_action",
"(",
"self",
",",
"revision",
")",
":",
"patch",
"=",
"revision",
".",
"get",
"(",
"\"patch\"",
")",
"if",
"patch",
".",
"get",
"(",
"\"_id\"",
")",
":",
"del",
"patch",
"[",
"\"_id\"",
"]",
"update_response",
"=",
"yield",
"s... | Update a master document and revision history document
:param dict revision: The revision dictionary | [
"Update",
"a",
"master",
"document",
"and",
"revision",
"history",
"document"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L181-L194 |
243,503 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.__insert_action | def __insert_action(self, revision):
"""
Handle the insert action type.
Creates new document to be created in this collection.
This allows you to stage a creation of an object
:param dict revision: The revision dictionary
"""
revision["patch"]["_id"] = ObjectI... | python | def __insert_action(self, revision):
"""
Handle the insert action type.
Creates new document to be created in this collection.
This allows you to stage a creation of an object
:param dict revision: The revision dictionary
"""
revision["patch"]["_id"] = ObjectI... | [
"def",
"__insert_action",
"(",
"self",
",",
"revision",
")",
":",
"revision",
"[",
"\"patch\"",
"]",
"[",
"\"_id\"",
"]",
"=",
"ObjectId",
"(",
"revision",
".",
"get",
"(",
"\"master_id\"",
")",
")",
"insert_response",
"=",
"yield",
"self",
".",
"collectio... | Handle the insert action type.
Creates new document to be created in this collection.
This allows you to stage a creation of an object
:param dict revision: The revision dictionary | [
"Handle",
"the",
"insert",
"action",
"type",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L197-L213 |
243,504 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.__delete_action | def __delete_action(self, revision):
"""
Handle a delete action to a partiular master id via the revision.
:param dict revision:
:return:
"""
delete_response = yield self.collection.delete(revision.get("master_id"))
if delete_response.get("n") == 0:
r... | python | def __delete_action(self, revision):
"""
Handle a delete action to a partiular master id via the revision.
:param dict revision:
:return:
"""
delete_response = yield self.collection.delete(revision.get("master_id"))
if delete_response.get("n") == 0:
r... | [
"def",
"__delete_action",
"(",
"self",
",",
"revision",
")",
":",
"delete_response",
"=",
"yield",
"self",
".",
"collection",
".",
"delete",
"(",
"revision",
".",
"get",
"(",
"\"master_id\"",
")",
")",
"if",
"delete_response",
".",
"get",
"(",
"\"n\"",
")"... | Handle a delete action to a partiular master id via the revision.
:param dict revision:
:return: | [
"Handle",
"a",
"delete",
"action",
"to",
"a",
"partiular",
"master",
"id",
"via",
"the",
"revision",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L216-L225 |
243,505 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.pop | def pop(self):
"""Pop the top revision off the stack back onto the collection at the given id. This method applies the action.
Note: This assumes you don't have two revisions scheduled closer than a single scheduling cycle.
"""
revisions = yield self.list()
if len(revisions) >... | python | def pop(self):
"""Pop the top revision off the stack back onto the collection at the given id. This method applies the action.
Note: This assumes you don't have two revisions scheduled closer than a single scheduling cycle.
"""
revisions = yield self.list()
if len(revisions) >... | [
"def",
"pop",
"(",
"self",
")",
":",
"revisions",
"=",
"yield",
"self",
".",
"list",
"(",
")",
"if",
"len",
"(",
"revisions",
")",
">",
"0",
":",
"revision",
"=",
"revisions",
"[",
"0",
"]",
"# Update type action",
"if",
"revision",
".",
"get",
"(",
... | Pop the top revision off the stack back onto the collection at the given id. This method applies the action.
Note: This assumes you don't have two revisions scheduled closer than a single scheduling cycle. | [
"Pop",
"the",
"top",
"revision",
"off",
"the",
"stack",
"back",
"onto",
"the",
"collection",
"at",
"the",
"given",
"id",
".",
"This",
"method",
"applies",
"the",
"action",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L228-L285 |
243,506 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.__make_patch_storeable | def __make_patch_storeable(self, patch):
"""Replace all dots with pipes in key names, mongo doesn't like to store keys with dots.
:param dict patch: The patch that needs to be made storeable and applied in the future
"""
new_patch = {}
for key in patch:
new_patch[key... | python | def __make_patch_storeable(self, patch):
"""Replace all dots with pipes in key names, mongo doesn't like to store keys with dots.
:param dict patch: The patch that needs to be made storeable and applied in the future
"""
new_patch = {}
for key in patch:
new_patch[key... | [
"def",
"__make_patch_storeable",
"(",
"self",
",",
"patch",
")",
":",
"new_patch",
"=",
"{",
"}",
"for",
"key",
"in",
"patch",
":",
"new_patch",
"[",
"key",
".",
"replace",
"(",
"\".\"",
",",
"\"|\"",
")",
"]",
"=",
"patch",
"[",
"key",
"]",
"return"... | Replace all dots with pipes in key names, mongo doesn't like to store keys with dots.
:param dict patch: The patch that needs to be made storeable and applied in the future | [
"Replace",
"all",
"dots",
"with",
"pipes",
"in",
"key",
"names",
"mongo",
"doesn",
"t",
"like",
"to",
"store",
"keys",
"with",
"dots",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L287-L296 |
243,507 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.push | def push(self, patch=None, toa=None, meta=None):
"""Push a change on to the revision stack for this ObjectId. Pushing onto the stack is how you
get revisions to be staged and scheduled for some future time.
:param dict patch: None Denotes Delete
:param int toa: Time of action
:... | python | def push(self, patch=None, toa=None, meta=None):
"""Push a change on to the revision stack for this ObjectId. Pushing onto the stack is how you
get revisions to be staged and scheduled for some future time.
:param dict patch: None Denotes Delete
:param int toa: Time of action
:... | [
"def",
"push",
"(",
"self",
",",
"patch",
"=",
"None",
",",
"toa",
"=",
"None",
",",
"meta",
"=",
"None",
")",
":",
"if",
"not",
"meta",
":",
"meta",
"=",
"{",
"}",
"if",
"not",
"toa",
":",
"toa",
"=",
"time",
".",
"mktime",
"(",
"datetime",
... | Push a change on to the revision stack for this ObjectId. Pushing onto the stack is how you
get revisions to be staged and scheduled for some future time.
:param dict patch: None Denotes Delete
:param int toa: Time of action
:param dict meta: The meta data for this action | [
"Push",
"a",
"change",
"on",
"to",
"the",
"revision",
"stack",
"for",
"this",
"ObjectId",
".",
"Pushing",
"onto",
"the",
"stack",
"is",
"how",
"you",
"get",
"revisions",
"to",
"be",
"staged",
"and",
"scheduled",
"for",
"some",
"future",
"time",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L312-L370 |
243,508 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.list | def list(self, toa=None, show_history=False):
"""Return all revisions for this stack
:param int toa: The time of action as a UTC timestamp
:param bool show_history: Whether to show historical revisions
"""
if not toa:
toa = time.mktime(datetime.datetime.now().timetup... | python | def list(self, toa=None, show_history=False):
"""Return all revisions for this stack
:param int toa: The time of action as a UTC timestamp
:param bool show_history: Whether to show historical revisions
"""
if not toa:
toa = time.mktime(datetime.datetime.now().timetup... | [
"def",
"list",
"(",
"self",
",",
"toa",
"=",
"None",
",",
"show_history",
"=",
"False",
")",
":",
"if",
"not",
"toa",
":",
"toa",
"=",
"time",
".",
"mktime",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"timetuple",
"(",
")",
")",... | Return all revisions for this stack
:param int toa: The time of action as a UTC timestamp
:param bool show_history: Whether to show historical revisions | [
"Return",
"all",
"revisions",
"for",
"this",
"stack"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L373-L395 |
243,509 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack._lazy_migration | def _lazy_migration(self, patch=None, meta=None, toa=None):
"""
Handle when a revision scheduling is turned onto a collection that was previously not scheduleable.
This method will create the first revision for each object before its every used in the context of scheduling.
:param dict ... | python | def _lazy_migration(self, patch=None, meta=None, toa=None):
"""
Handle when a revision scheduling is turned onto a collection that was previously not scheduleable.
This method will create the first revision for each object before its every used in the context of scheduling.
:param dict ... | [
"def",
"_lazy_migration",
"(",
"self",
",",
"patch",
"=",
"None",
",",
"meta",
"=",
"None",
",",
"toa",
"=",
"None",
")",
":",
"objects",
"=",
"yield",
"self",
".",
"revisions",
".",
"find",
"(",
"{",
"\"master_id\"",
":",
"self",
".",
"master_id",
"... | Handle when a revision scheduling is turned onto a collection that was previously not scheduleable.
This method will create the first revision for each object before its every used in the context of scheduling.
:param dict patch: The patch that should be used
:param dict meta: Meta data for thi... | [
"Handle",
"when",
"a",
"revision",
"scheduling",
"is",
"turned",
"onto",
"a",
"collection",
"that",
"was",
"previously",
"not",
"scheduleable",
".",
"This",
"method",
"will",
"create",
"the",
"first",
"revision",
"for",
"each",
"object",
"before",
"its",
"ever... | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L399-L451 |
243,510 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.__create_preview_object_base | def __create_preview_object_base(self, dct):
"""
The starting point for a preview of a future object.
This is the object which will have future revisions iterated and applied to.
:param dict dct: The starting object dictionary
:return: The preview object id
:rtype: str
... | python | def __create_preview_object_base(self, dct):
"""
The starting point for a preview of a future object.
This is the object which will have future revisions iterated and applied to.
:param dict dct: The starting object dictionary
:return: The preview object id
:rtype: str
... | [
"def",
"__create_preview_object_base",
"(",
"self",
",",
"dct",
")",
":",
"if",
"dct",
".",
"get",
"(",
"\"_id\"",
")",
":",
"del",
"dct",
"[",
"\"_id\"",
"]",
"preview_object_id",
"=",
"yield",
"self",
".",
"previews",
".",
"insert",
"(",
"dct",
")",
... | The starting point for a preview of a future object.
This is the object which will have future revisions iterated and applied to.
:param dict dct: The starting object dictionary
:return: The preview object id
:rtype: str | [
"The",
"starting",
"point",
"for",
"a",
"preview",
"of",
"a",
"future",
"object",
".",
"This",
"is",
"the",
"object",
"which",
"will",
"have",
"future",
"revisions",
"iterated",
"and",
"applied",
"to",
"."
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L454-L469 |
243,511 | urbn/Caesium | caesium/document.py | AsyncSchedulableDocumentRevisionStack.preview | def preview(self, revision_id):
"""Get an ephemeral preview of a revision with all revisions applied between it and the current state
:param str revision_id: The ID of the revision state you want to preview the master id at.
:return: A snapshot of a future state of the object
:rtype: di... | python | def preview(self, revision_id):
"""Get an ephemeral preview of a revision with all revisions applied between it and the current state
:param str revision_id: The ID of the revision state you want to preview the master id at.
:return: A snapshot of a future state of the object
:rtype: di... | [
"def",
"preview",
"(",
"self",
",",
"revision_id",
")",
":",
"target_revision",
"=",
"yield",
"self",
".",
"revisions",
".",
"find_one_by_id",
"(",
"revision_id",
")",
"if",
"isinstance",
"(",
"target_revision",
".",
"get",
"(",
"\"snapshot\"",
")",
",",
"di... | Get an ephemeral preview of a revision with all revisions applied between it and the current state
:param str revision_id: The ID of the revision state you want to preview the master id at.
:return: A snapshot of a future state of the object
:rtype: dict | [
"Get",
"an",
"ephemeral",
"preview",
"of",
"a",
"revision",
"with",
"all",
"revisions",
"applied",
"between",
"it",
"and",
"the",
"current",
"state"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L472-L540 |
243,512 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.insert | def insert(self, dct, toa=None, comment=""):
"""Create a document
:param dict dct:
:param toa toa: Optional time of action, triggers this to be handled as a future insert action for a new document
:param str comment: A comment
:rtype str:
:returns string bson id:
... | python | def insert(self, dct, toa=None, comment=""):
"""Create a document
:param dict dct:
:param toa toa: Optional time of action, triggers this to be handled as a future insert action for a new document
:param str comment: A comment
:rtype str:
:returns string bson id:
... | [
"def",
"insert",
"(",
"self",
",",
"dct",
",",
"toa",
"=",
"None",
",",
"comment",
"=",
"\"\"",
")",
":",
"if",
"self",
".",
"schema",
":",
"jsonschema",
".",
"validate",
"(",
"dct",
",",
"self",
".",
"schema",
")",
"bson_obj",
"=",
"yield",
"self"... | Create a document
:param dict dct:
:param toa toa: Optional time of action, triggers this to be handled as a future insert action for a new document
:param str comment: A comment
:rtype str:
:returns string bson id: | [
"Create",
"a",
"document"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L583-L597 |
243,513 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.upsert | def upsert(self, _id, dct, attribute="_id"):
"""Update or Insert a new document
:param str _id: The document id
:param dict dct: The dictionary to set on the document
:param str attribute: The attribute to query for to find the object to set this data on
:returns: JSON Mongo cli... | python | def upsert(self, _id, dct, attribute="_id"):
"""Update or Insert a new document
:param str _id: The document id
:param dict dct: The dictionary to set on the document
:param str attribute: The attribute to query for to find the object to set this data on
:returns: JSON Mongo cli... | [
"def",
"upsert",
"(",
"self",
",",
"_id",
",",
"dct",
",",
"attribute",
"=",
"\"_id\"",
")",
":",
"mongo_response",
"=",
"yield",
"self",
".",
"update",
"(",
"_id",
",",
"dct",
",",
"upsert",
"=",
"True",
",",
"attribute",
"=",
"attribute",
")",
"rai... | Update or Insert a new document
:param str _id: The document id
:param dict dct: The dictionary to set on the document
:param str attribute: The attribute to query for to find the object to set this data on
:returns: JSON Mongo client response including the "n" key to show number of obj... | [
"Update",
"or",
"Insert",
"a",
"new",
"document"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L600-L611 |
243,514 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.update | def update(self, predicate_value, dct, upsert=False, attribute="_id"):
"""Update an existing document
:param predicate_value: The value of the predicate
:param dict dct: The dictionary to update with
:param bool upsert: Whether this is an upsert action
:param str attribute: The ... | python | def update(self, predicate_value, dct, upsert=False, attribute="_id"):
"""Update an existing document
:param predicate_value: The value of the predicate
:param dict dct: The dictionary to update with
:param bool upsert: Whether this is an upsert action
:param str attribute: The ... | [
"def",
"update",
"(",
"self",
",",
"predicate_value",
",",
"dct",
",",
"upsert",
"=",
"False",
",",
"attribute",
"=",
"\"_id\"",
")",
":",
"if",
"self",
".",
"schema",
":",
"jsonschema",
".",
"validate",
"(",
"dct",
",",
"self",
".",
"schema",
")",
"... | Update an existing document
:param predicate_value: The value of the predicate
:param dict dct: The dictionary to update with
:param bool upsert: Whether this is an upsert action
:param str attribute: The attribute to query for to find the object to set this data ond
:returns: J... | [
"Update",
"an",
"existing",
"document"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L614-L636 |
243,515 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.delete | def delete(self, _id):
"""Delete a document or create a DELETE revision
:param str _id: The ID of the document to be deleted
:returns: JSON Mongo client response including the "n" key to show number of objects effected
"""
mongo_response = yield self.collection.remove({"_id": Ob... | python | def delete(self, _id):
"""Delete a document or create a DELETE revision
:param str _id: The ID of the document to be deleted
:returns: JSON Mongo client response including the "n" key to show number of objects effected
"""
mongo_response = yield self.collection.remove({"_id": Ob... | [
"def",
"delete",
"(",
"self",
",",
"_id",
")",
":",
"mongo_response",
"=",
"yield",
"self",
".",
"collection",
".",
"remove",
"(",
"{",
"\"_id\"",
":",
"ObjectId",
"(",
"_id",
")",
"}",
")",
"raise",
"Return",
"(",
"mongo_response",
")"
] | Delete a document or create a DELETE revision
:param str _id: The ID of the document to be deleted
:returns: JSON Mongo client response including the "n" key to show number of objects effected | [
"Delete",
"a",
"document",
"or",
"create",
"a",
"DELETE",
"revision"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L666-L674 |
243,516 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.find_one | def find_one(self, query):
"""Find one wrapper with conversion to dictionary
:param dict query: A Mongo query
"""
mongo_response = yield self.collection.find_one(query)
raise Return(self._obj_cursor_to_dictionary(mongo_response)) | python | def find_one(self, query):
"""Find one wrapper with conversion to dictionary
:param dict query: A Mongo query
"""
mongo_response = yield self.collection.find_one(query)
raise Return(self._obj_cursor_to_dictionary(mongo_response)) | [
"def",
"find_one",
"(",
"self",
",",
"query",
")",
":",
"mongo_response",
"=",
"yield",
"self",
".",
"collection",
".",
"find_one",
"(",
"query",
")",
"raise",
"Return",
"(",
"self",
".",
"_obj_cursor_to_dictionary",
"(",
"mongo_response",
")",
")"
] | Find one wrapper with conversion to dictionary
:param dict query: A Mongo query | [
"Find",
"one",
"wrapper",
"with",
"conversion",
"to",
"dictionary"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L677-L683 |
243,517 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.find | def find(self, query, orderby=None, order_by_direction=1, page=0, limit=0):
"""Find a document by any criteria
:param dict query: The query to perform
:param str orderby: The attribute to order results by
:param int order_by_direction: 1 or -1
:param int page: The page to return... | python | def find(self, query, orderby=None, order_by_direction=1, page=0, limit=0):
"""Find a document by any criteria
:param dict query: The query to perform
:param str orderby: The attribute to order results by
:param int order_by_direction: 1 or -1
:param int page: The page to return... | [
"def",
"find",
"(",
"self",
",",
"query",
",",
"orderby",
"=",
"None",
",",
"order_by_direction",
"=",
"1",
",",
"page",
"=",
"0",
",",
"limit",
"=",
"0",
")",
":",
"cursor",
"=",
"self",
".",
"collection",
".",
"find",
"(",
"query",
")",
"if",
"... | Find a document by any criteria
:param dict query: The query to perform
:param str orderby: The attribute to order results by
:param int order_by_direction: 1 or -1
:param int page: The page to return
:param int limit: Number of results per page
:returns: A list of resul... | [
"Find",
"a",
"document",
"by",
"any",
"criteria"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L686-L710 |
243,518 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.find_one_by_id | def find_one_by_id(self, _id):
"""
Find a single document by id
:param str _id: BSON string repreentation of the Id
:return: a signle object
:rtype: dict
"""
document = (yield self.collection.find_one({"_id": ObjectId(_id)}))
raise Return(self._obj_curso... | python | def find_one_by_id(self, _id):
"""
Find a single document by id
:param str _id: BSON string repreentation of the Id
:return: a signle object
:rtype: dict
"""
document = (yield self.collection.find_one({"_id": ObjectId(_id)}))
raise Return(self._obj_curso... | [
"def",
"find_one_by_id",
"(",
"self",
",",
"_id",
")",
":",
"document",
"=",
"(",
"yield",
"self",
".",
"collection",
".",
"find_one",
"(",
"{",
"\"_id\"",
":",
"ObjectId",
"(",
"_id",
")",
"}",
")",
")",
"raise",
"Return",
"(",
"self",
".",
"_obj_cu... | Find a single document by id
:param str _id: BSON string repreentation of the Id
:return: a signle object
:rtype: dict | [
"Find",
"a",
"single",
"document",
"by",
"id"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L713-L723 |
243,519 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.create_index | def create_index(self, index, index_type=GEO2D):
"""Create an index on a given attribute
:param str index: Attribute to set index on
:param str index_type: See PyMongo index types for further information, defaults to GEO2D index.
"""
self.logger.info("Adding %s index to stores o... | python | def create_index(self, index, index_type=GEO2D):
"""Create an index on a given attribute
:param str index: Attribute to set index on
:param str index_type: See PyMongo index types for further information, defaults to GEO2D index.
"""
self.logger.info("Adding %s index to stores o... | [
"def",
"create_index",
"(",
"self",
",",
"index",
",",
"index_type",
"=",
"GEO2D",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Adding %s index to stores on attribute: %s\"",
"%",
"(",
"index_type",
",",
"index",
")",
")",
"yield",
"self",
".",
"col... | Create an index on a given attribute
:param str index: Attribute to set index on
:param str index_type: See PyMongo index types for further information, defaults to GEO2D index. | [
"Create",
"an",
"index",
"on",
"a",
"given",
"attribute"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L726-L733 |
243,520 | urbn/Caesium | caesium/document.py | BaseAsyncMotorDocument.location_based_search | def location_based_search(self, lng, lat, distance, unit="miles", attribute_map=None, page=0, limit=50):
"""Search based on location and other attribute filters
:param long lng: Longitude parameter
:param long lat: Latitude parameter
:param int distance: The radius of the query
... | python | def location_based_search(self, lng, lat, distance, unit="miles", attribute_map=None, page=0, limit=50):
"""Search based on location and other attribute filters
:param long lng: Longitude parameter
:param long lat: Latitude parameter
:param int distance: The radius of the query
... | [
"def",
"location_based_search",
"(",
"self",
",",
"lng",
",",
"lat",
",",
"distance",
",",
"unit",
"=",
"\"miles\"",
",",
"attribute_map",
"=",
"None",
",",
"page",
"=",
"0",
",",
"limit",
"=",
"50",
")",
":",
"#Determine what type of radian conversion you wan... | Search based on location and other attribute filters
:param long lng: Longitude parameter
:param long lat: Latitude parameter
:param int distance: The radius of the query
:param str unit: The unit of measure for the query, defaults to miles
:param dict attribute_map: Additional ... | [
"Search",
"based",
"on",
"location",
"and",
"other",
"attribute",
"filters"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L736-L770 |
243,521 | urbn/Caesium | caesium/document.py | BSONEncoder.default | def default(self, obj, **kwargs):
"""Handles the adapting of special types from mongo"""
if isinstance(obj, datetime.datetime):
return time.mktime(obj.timetuple())
if isinstance(obj, Timestamp):
return obj.time
if isinstance(obj, ObjectId):
return ob... | python | def default(self, obj, **kwargs):
"""Handles the adapting of special types from mongo"""
if isinstance(obj, datetime.datetime):
return time.mktime(obj.timetuple())
if isinstance(obj, Timestamp):
return obj.time
if isinstance(obj, ObjectId):
return ob... | [
"def",
"default",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"time",
".",
"mktime",
"(",
"obj",
".",
"timetuple",
"(",
")",
")",
"if",
"isinstanc... | Handles the adapting of special types from mongo | [
"Handles",
"the",
"adapting",
"of",
"special",
"types",
"from",
"mongo"
] | 2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1 | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L813-L824 |
243,522 | etcher-be/emiz | emiz/avwx/remarks.py | _tdec | def _tdec(code: str, unit: str = 'C') -> str:
"""
Translates a 4-digit decimal temperature representation
Ex: 1045 -> -4.5°C 0237 -> 23.7°C
"""
ret = f"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}"
if unit:
ret += f'°{unit}'
return ret | python | def _tdec(code: str, unit: str = 'C') -> str:
"""
Translates a 4-digit decimal temperature representation
Ex: 1045 -> -4.5°C 0237 -> 23.7°C
"""
ret = f"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}"
if unit:
ret += f'°{unit}'
return ret | [
"def",
"_tdec",
"(",
"code",
":",
"str",
",",
"unit",
":",
"str",
"=",
"'C'",
")",
"->",
"str",
":",
"ret",
"=",
"f\"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}\"",
"if",
"unit",
":",
"ret",
"+=",
"f'°{unit}'",
"return",
"ret"
] | Translates a 4-digit decimal temperature representation
Ex: 1045 -> -4.5°C 0237 -> 23.7°C | [
"Translates",
"a",
"4",
"-",
"digit",
"decimal",
"temperature",
"representation"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L11-L20 |
243,523 | etcher-be/emiz | emiz/avwx/remarks.py | pressure_tendency | def pressure_tendency(code: str, unit: str = 'mb') -> str:
"""
Translates a 5-digit pressure outlook code
Ex: 50123 -> 12.3 mb: Increasing, then decreasing
"""
width, precision = int(code[2:4]), code[4]
return ('3-hour pressure difference: +/- '
f'{width}.{precision} {unit} - {PRESS... | python | def pressure_tendency(code: str, unit: str = 'mb') -> str:
"""
Translates a 5-digit pressure outlook code
Ex: 50123 -> 12.3 mb: Increasing, then decreasing
"""
width, precision = int(code[2:4]), code[4]
return ('3-hour pressure difference: +/- '
f'{width}.{precision} {unit} - {PRESS... | [
"def",
"pressure_tendency",
"(",
"code",
":",
"str",
",",
"unit",
":",
"str",
"=",
"'mb'",
")",
"->",
"str",
":",
"width",
",",
"precision",
"=",
"int",
"(",
"code",
"[",
"2",
":",
"4",
"]",
")",
",",
"code",
"[",
"4",
"]",
"return",
"(",
"'3-h... | Translates a 5-digit pressure outlook code
Ex: 50123 -> 12.3 mb: Increasing, then decreasing | [
"Translates",
"a",
"5",
"-",
"digit",
"pressure",
"outlook",
"code"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L31-L39 |
243,524 | etcher-be/emiz | emiz/avwx/remarks.py | parse | def parse(rmk: str) -> RemarksData:
"""
Finds temperature and dewpoint decimal values from the remarks
"""
rmkdata = {}
for item in rmk.split(' '):
if len(item) in [5, 9] and item[0] == 'T' and item[1:].isdigit():
rmkdata['temperature_decimal'] = core.make_number(_tdec(item[1:5],... | python | def parse(rmk: str) -> RemarksData:
"""
Finds temperature and dewpoint decimal values from the remarks
"""
rmkdata = {}
for item in rmk.split(' '):
if len(item) in [5, 9] and item[0] == 'T' and item[1:].isdigit():
rmkdata['temperature_decimal'] = core.make_number(_tdec(item[1:5],... | [
"def",
"parse",
"(",
"rmk",
":",
"str",
")",
"->",
"RemarksData",
":",
"rmkdata",
"=",
"{",
"}",
"for",
"item",
"in",
"rmk",
".",
"split",
"(",
"' '",
")",
":",
"if",
"len",
"(",
"item",
")",
"in",
"[",
"5",
",",
"9",
"]",
"and",
"item",
"[",... | Finds temperature and dewpoint decimal values from the remarks | [
"Finds",
"temperature",
"and",
"dewpoint",
"decimal",
"values",
"from",
"the",
"remarks"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L74-L83 |
243,525 | etcher-be/emiz | emiz/avwx/remarks.py | translate | def translate(remarks: str) -> typing.Dict[str, str]: # noqa
"""
Translates elements in the remarks string
"""
ret = {}
# Add and replace static multi-word elements
for key in REMARKS_GROUPS:
if key in remarks:
ret[key.strip()] = REMARKS_GROUPS[key]
remarks.repla... | python | def translate(remarks: str) -> typing.Dict[str, str]: # noqa
"""
Translates elements in the remarks string
"""
ret = {}
# Add and replace static multi-word elements
for key in REMARKS_GROUPS:
if key in remarks:
ret[key.strip()] = REMARKS_GROUPS[key]
remarks.repla... | [
"def",
"translate",
"(",
"remarks",
":",
"str",
")",
"->",
"typing",
".",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"# noqa",
"ret",
"=",
"{",
"}",
"# Add and replace static multi-word elements",
"for",
"key",
"in",
"REMARKS_GROUPS",
":",
"if",
"key",
"in"... | Translates elements in the remarks string | [
"Translates",
"elements",
"in",
"the",
"remarks",
"string"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L86-L123 |
243,526 | sahilchinoy/django-irs-filings | irs/management/commands/loadIRS.py | RowParser.parse_row | def parse_row(self):
"""
Parses a row, cell-by-cell, returning a dict of field names
to the cleaned field values.
"""
fields = self.mapping
for i, cell in enumerate(self.row[0:len(fields)]):
field_name, field_type = fields[str(i)]
parsed_cell = sel... | python | def parse_row(self):
"""
Parses a row, cell-by-cell, returning a dict of field names
to the cleaned field values.
"""
fields = self.mapping
for i, cell in enumerate(self.row[0:len(fields)]):
field_name, field_type = fields[str(i)]
parsed_cell = sel... | [
"def",
"parse_row",
"(",
"self",
")",
":",
"fields",
"=",
"self",
".",
"mapping",
"for",
"i",
",",
"cell",
"in",
"enumerate",
"(",
"self",
".",
"row",
"[",
"0",
":",
"len",
"(",
"fields",
")",
"]",
")",
":",
"field_name",
",",
"field_type",
"=",
... | Parses a row, cell-by-cell, returning a dict of field names
to the cleaned field values. | [
"Parses",
"a",
"row",
"cell",
"-",
"by",
"-",
"cell",
"returning",
"a",
"dict",
"of",
"field",
"names",
"to",
"the",
"cleaned",
"field",
"values",
"."
] | efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b | https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L78-L87 |
243,527 | sahilchinoy/django-irs-filings | irs/management/commands/loadIRS.py | Command.build_mappings | def build_mappings(self):
"""
Uses CSV files of field names and positions for
different filing types to load mappings into memory,
for use in parsing different types of rows.
"""
self.mappings = {}
for record_type in ('sa', 'sb', 'F8872'):
path = os.pa... | python | def build_mappings(self):
"""
Uses CSV files of field names and positions for
different filing types to load mappings into memory,
for use in parsing different types of rows.
"""
self.mappings = {}
for record_type in ('sa', 'sb', 'F8872'):
path = os.pa... | [
"def",
"build_mappings",
"(",
"self",
")",
":",
"self",
".",
"mappings",
"=",
"{",
"}",
"for",
"record_type",
"in",
"(",
"'sa'",
",",
"'sb'",
",",
"'F8872'",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dir... | Uses CSV files of field names and positions for
different filing types to load mappings into memory,
for use in parsing different types of rows. | [
"Uses",
"CSV",
"files",
"of",
"field",
"names",
"and",
"positions",
"for",
"different",
"filing",
"types",
"to",
"load",
"mappings",
"into",
"memory",
"for",
"use",
"in",
"parsing",
"different",
"types",
"of",
"rows",
"."
] | efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b | https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L244-L266 |
243,528 | jic-dtool/dtool-info | dtool_info/dataset.py | diff | def diff(full, dataset_uri, reference_dataset_uri):
"""Report the difference between two datasets.
1. Checks that the identifiers are identicial
2. Checks that the sizes are identical
3. Checks that the hashes are identical, if the '--full' option is used
If a differences is detected in step 1, st... | python | def diff(full, dataset_uri, reference_dataset_uri):
"""Report the difference between two datasets.
1. Checks that the identifiers are identicial
2. Checks that the sizes are identical
3. Checks that the hashes are identical, if the '--full' option is used
If a differences is detected in step 1, st... | [
"def",
"diff",
"(",
"full",
",",
"dataset_uri",
",",
"reference_dataset_uri",
")",
":",
"def",
"echo_header",
"(",
"desc",
",",
"ds_name",
",",
"ref_ds_name",
",",
"prop",
")",
":",
"click",
".",
"secho",
"(",
"\"Different {}\"",
".",
"format",
"(",
"desc"... | Report the difference between two datasets.
1. Checks that the identifiers are identicial
2. Checks that the sizes are identical
3. Checks that the hashes are identical, if the '--full' option is used
If a differences is detected in step 1, steps 2 and 3 will not be carried
out. Similarly if a dif... | [
"Report",
"the",
"difference",
"between",
"two",
"datasets",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L38-L90 |
243,529 | jic-dtool/dtool-info | dtool_info/dataset.py | identifiers | def identifiers(dataset_uri):
"""List the item identifiers in the dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
for i in dataset.identifiers:
click.secho(i) | python | def identifiers(dataset_uri):
"""List the item identifiers in the dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
for i in dataset.identifiers:
click.secho(i) | [
"def",
"identifiers",
"(",
"dataset_uri",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"for",
"i",
"in",
"dataset",
".",
"identifiers",
":",
"click",
".",
"secho",
"(",
"i",
")"
] | List the item identifiers in the dataset. | [
"List",
"the",
"item",
"identifiers",
"in",
"the",
"dataset",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L178-L182 |
243,530 | jic-dtool/dtool-info | dtool_info/dataset.py | summary | def summary(dataset_uri, format):
"""Report summary information about a dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
creator_username = dataset._admin_metadata["creator_username"]
frozen_at = dataset._admin_metadata["frozen_at"]
num_items = len(dataset.identifiers)
tot_size = su... | python | def summary(dataset_uri, format):
"""Report summary information about a dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
creator_username = dataset._admin_metadata["creator_username"]
frozen_at = dataset._admin_metadata["frozen_at"]
num_items = len(dataset.identifiers)
tot_size = su... | [
"def",
"summary",
"(",
"dataset_uri",
",",
"format",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"creator_username",
"=",
"dataset",
".",
"_admin_metadata",
"[",
"\"creator_username\"",
"]",
"frozen_at",
"=",
... | Report summary information about a dataset. | [
"Report",
"summary",
"information",
"about",
"a",
"dataset",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L193-L231 |
243,531 | jic-dtool/dtool-info | dtool_info/dataset.py | properties | def properties(dataset_uri, item_identifier):
"""Report item properties."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
try:
props = dataset.item_properties(item_identifier)
except KeyError:
click.secho(
"No such item in dataset: {}".format(item_identifier),
... | python | def properties(dataset_uri, item_identifier):
"""Report item properties."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
try:
props = dataset.item_properties(item_identifier)
except KeyError:
click.secho(
"No such item in dataset: {}".format(item_identifier),
... | [
"def",
"properties",
"(",
"dataset_uri",
",",
"item_identifier",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"try",
":",
"props",
"=",
"dataset",
".",
"item_properties",
"(",
"item_identifier",
")",
"except"... | Report item properties. | [
"Report",
"item",
"properties",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L244-L270 |
243,532 | jic-dtool/dtool-info | dtool_info/dataset.py | relpath | def relpath(dataset_uri, item_identifier):
"""Return relpath associated with the item.
"""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
try:
props = dataset.item_properties(item_identifier)
except KeyError:
click.secho(
"No such item in dataset: {}".format(item_ident... | python | def relpath(dataset_uri, item_identifier):
"""Return relpath associated with the item.
"""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
try:
props = dataset.item_properties(item_identifier)
except KeyError:
click.secho(
"No such item in dataset: {}".format(item_ident... | [
"def",
"relpath",
"(",
"dataset_uri",
",",
"item_identifier",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"try",
":",
"props",
"=",
"dataset",
".",
"item_properties",
"(",
"item_identifier",
")",
"except",
... | Return relpath associated with the item. | [
"Return",
"relpath",
"associated",
"with",
"the",
"item",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L318-L331 |
243,533 | jic-dtool/dtool-info | dtool_info/dataset.py | verify | def verify(full, dataset_uri):
"""Verify the integrity of a dataset.
"""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
all_okay = True
generated_manifest = dataset.generate_manifest()
generated_identifiers = set(generated_manifest["items"].keys())
manifest_identifiers = set(dataset.iden... | python | def verify(full, dataset_uri):
"""Verify the integrity of a dataset.
"""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
all_okay = True
generated_manifest = dataset.generate_manifest()
generated_identifiers = set(generated_manifest["items"].keys())
manifest_identifiers = set(dataset.iden... | [
"def",
"verify",
"(",
"full",
",",
"dataset_uri",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"all_okay",
"=",
"True",
"generated_manifest",
"=",
"dataset",
".",
"generate_manifest",
"(",
")",
"generated_ide... | Verify the integrity of a dataset. | [
"Verify",
"the",
"integrity",
"of",
"a",
"dataset",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L342-L394 |
243,534 | jic-dtool/dtool-info | dtool_info/dataset.py | uuid | def uuid(dataset_uri):
"""Return the UUID of the dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
click.secho(dataset.uuid) | python | def uuid(dataset_uri):
"""Return the UUID of the dataset."""
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
click.secho(dataset.uuid) | [
"def",
"uuid",
"(",
"dataset_uri",
")",
":",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"dataset_uri",
")",
"click",
".",
"secho",
"(",
"dataset",
".",
"uuid",
")"
] | Return the UUID of the dataset. | [
"Return",
"the",
"UUID",
"of",
"the",
"dataset",
"."
] | 3c6c7755f4c142e548bbfdf3b38230612fd4060a | https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L399-L402 |
243,535 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetBlock.split_data | def split_data(self):
"""Splits the list of SeqRecordExpanded objects into lists, which are
kept into a bigger list.
If the file_format is Nexus, then it is only partitioned by gene. If it
is FASTA, then it needs partitioning by codon positions if required.
Example:
... | python | def split_data(self):
"""Splits the list of SeqRecordExpanded objects into lists, which are
kept into a bigger list.
If the file_format is Nexus, then it is only partitioned by gene. If it
is FASTA, then it needs partitioning by codon positions if required.
Example:
... | [
"def",
"split_data",
"(",
"self",
")",
":",
"this_gene_code",
"=",
"None",
"for",
"seq_record",
"in",
"self",
".",
"data",
".",
"seq_records",
":",
"if",
"this_gene_code",
"is",
"None",
"or",
"this_gene_code",
"!=",
"seq_record",
".",
"gene_code",
":",
"this... | Splits the list of SeqRecordExpanded objects into lists, which are
kept into a bigger list.
If the file_format is Nexus, then it is only partitioned by gene. If it
is FASTA, then it needs partitioning by codon positions if required.
Example:
>>> blocks = [
... ... | [
"Splits",
"the",
"list",
"of",
"SeqRecordExpanded",
"objects",
"into",
"lists",
"which",
"are",
"kept",
"into",
"a",
"bigger",
"list",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L61-L84 |
243,536 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetBlock.convert_to_string | def convert_to_string(self, block):
"""Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code.
Override this function if the dataset block needs to be different
due to file format.
This block will need to be split further if the dataset is FASTA or
TNT an... | python | def convert_to_string(self, block):
"""Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code.
Override this function if the dataset block needs to be different
due to file format.
This block will need to be split further if the dataset is FASTA or
TNT an... | [
"def",
"convert_to_string",
"(",
"self",
",",
"block",
")",
":",
"if",
"self",
".",
"partitioning",
"!=",
"'1st-2nd, 3rd'",
":",
"return",
"self",
".",
"make_datablock_by_gene",
"(",
"block",
")",
"else",
":",
"if",
"self",
".",
"format",
"==",
"'FASTA'",
... | Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code.
Override this function if the dataset block needs to be different
due to file format.
This block will need to be split further if the dataset is FASTA or
TNT and the partitioning scheme is 1st-2nd, 3rd.
... | [
"Makes",
"gene_block",
"as",
"str",
"from",
"list",
"of",
"SeqRecordExpanded",
"objects",
"of",
"a",
"gene_code",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L86-L105 |
243,537 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetBlock.convert_block_dicts_to_string | def convert_block_dicts_to_string(self, block_1st2nd, block_1st, block_2nd, block_3rd):
"""Takes into account whether we need to output all codon positions."""
out = ""
# We need 1st and 2nd positions
if self.codon_positions in ['ALL', '1st-2nd']:
for gene_code, seqs in block... | python | def convert_block_dicts_to_string(self, block_1st2nd, block_1st, block_2nd, block_3rd):
"""Takes into account whether we need to output all codon positions."""
out = ""
# We need 1st and 2nd positions
if self.codon_positions in ['ALL', '1st-2nd']:
for gene_code, seqs in block... | [
"def",
"convert_block_dicts_to_string",
"(",
"self",
",",
"block_1st2nd",
",",
"block_1st",
",",
"block_2nd",
",",
"block_3rd",
")",
":",
"out",
"=",
"\"\"",
"# We need 1st and 2nd positions",
"if",
"self",
".",
"codon_positions",
"in",
"[",
"'ALL'",
",",
"'1st-2n... | Takes into account whether we need to output all codon positions. | [
"Takes",
"into",
"account",
"whether",
"we",
"need",
"to",
"output",
"all",
"codon",
"positions",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L139-L165 |
243,538 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetFooter.make_charsets | def make_charsets(self):
"""
Override this function for Phylip dataset as the content is different and
goes into a separate file.
"""
count_start = 1
out = ''
for gene_code, lengths in self.data.gene_codes_and_lengths.items():
count_end = lengths[0] + ... | python | def make_charsets(self):
"""
Override this function for Phylip dataset as the content is different and
goes into a separate file.
"""
count_start = 1
out = ''
for gene_code, lengths in self.data.gene_codes_and_lengths.items():
count_end = lengths[0] + ... | [
"def",
"make_charsets",
"(",
"self",
")",
":",
"count_start",
"=",
"1",
"out",
"=",
"''",
"for",
"gene_code",
",",
"lengths",
"in",
"self",
".",
"data",
".",
"gene_codes_and_lengths",
".",
"items",
"(",
")",
":",
"count_end",
"=",
"lengths",
"[",
"0",
... | Override this function for Phylip dataset as the content is different and
goes into a separate file. | [
"Override",
"this",
"function",
"for",
"Phylip",
"dataset",
"as",
"the",
"content",
"is",
"different",
"and",
"goes",
"into",
"a",
"separate",
"file",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L308-L319 |
243,539 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetFooter.make_slash_number | def make_slash_number(self):
"""
Charset lines have \2 or \3 depending on type of partitioning and codon
positions requested for our dataset.
:return:
"""
if self.partitioning == 'by codon position' and self.codon_positions == '1st-2nd':
return '\\2'
... | python | def make_slash_number(self):
"""
Charset lines have \2 or \3 depending on type of partitioning and codon
positions requested for our dataset.
:return:
"""
if self.partitioning == 'by codon position' and self.codon_positions == '1st-2nd':
return '\\2'
... | [
"def",
"make_slash_number",
"(",
"self",
")",
":",
"if",
"self",
".",
"partitioning",
"==",
"'by codon position'",
"and",
"self",
".",
"codon_positions",
"==",
"'1st-2nd'",
":",
"return",
"'\\\\2'",
"elif",
"self",
".",
"partitioning",
"in",
"[",
"'by codon posi... | Charset lines have \2 or \3 depending on type of partitioning and codon
positions requested for our dataset.
:return: | [
"Charset",
"lines",
"have",
"\\",
"2",
"or",
"\\",
"3",
"depending",
"on",
"type",
"of",
"partitioning",
"and",
"codon",
"positions",
"requested",
"for",
"our",
"dataset",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L332-L344 |
243,540 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetFooter.add_suffixes_to_gene_codes | def add_suffixes_to_gene_codes(self):
"""Appends pos1, pos2, etc to the gene_code if needed."""
out = []
for gene_code in self.data.gene_codes:
for sufix in self.make_gene_code_suffixes():
out.append('{0}{1}'.format(gene_code, sufix))
return out | python | def add_suffixes_to_gene_codes(self):
"""Appends pos1, pos2, etc to the gene_code if needed."""
out = []
for gene_code in self.data.gene_codes:
for sufix in self.make_gene_code_suffixes():
out.append('{0}{1}'.format(gene_code, sufix))
return out | [
"def",
"add_suffixes_to_gene_codes",
"(",
"self",
")",
":",
"out",
"=",
"[",
"]",
"for",
"gene_code",
"in",
"self",
".",
"data",
".",
"gene_codes",
":",
"for",
"sufix",
"in",
"self",
".",
"make_gene_code_suffixes",
"(",
")",
":",
"out",
".",
"append",
"(... | Appends pos1, pos2, etc to the gene_code if needed. | [
"Appends",
"pos1",
"pos2",
"etc",
"to",
"the",
"gene_code",
"if",
"needed",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L385-L391 |
243,541 | carlosp420/dataset-creator | dataset_creator/base_dataset.py | DatasetFooter.get_outgroup | def get_outgroup(self):
"""Generates the outgroup line from the voucher code specified by the
user.
"""
if self.outgroup is not None:
outgroup_taxonomy = ''
for i in self.data.seq_records:
if self.outgroup == i.voucher_code:
out... | python | def get_outgroup(self):
"""Generates the outgroup line from the voucher code specified by the
user.
"""
if self.outgroup is not None:
outgroup_taxonomy = ''
for i in self.data.seq_records:
if self.outgroup == i.voucher_code:
out... | [
"def",
"get_outgroup",
"(",
"self",
")",
":",
"if",
"self",
".",
"outgroup",
"is",
"not",
"None",
":",
"outgroup_taxonomy",
"=",
"''",
"for",
"i",
"in",
"self",
".",
"data",
".",
"seq_records",
":",
"if",
"self",
".",
"outgroup",
"==",
"i",
".",
"vou... | Generates the outgroup line from the voucher code specified by the
user. | [
"Generates",
"the",
"outgroup",
"line",
"from",
"the",
"voucher",
"code",
"specified",
"by",
"the",
"user",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L413-L428 |
243,542 | etcher-be/emiz | emiz/mission_time.py | MissionTime.from_string | def from_string(input_str) -> 'MissionTime':
# noinspection SpellCheckingInspection
"""
Creates a MissionTime instance from a string
Format: YYYYMMDDHHMMSS
Args:
input_str: string to parse
Returns: MissionTime instance
"""
match = RE_INPUT_... | python | def from_string(input_str) -> 'MissionTime':
# noinspection SpellCheckingInspection
"""
Creates a MissionTime instance from a string
Format: YYYYMMDDHHMMSS
Args:
input_str: string to parse
Returns: MissionTime instance
"""
match = RE_INPUT_... | [
"def",
"from_string",
"(",
"input_str",
")",
"->",
"'MissionTime'",
":",
"# noinspection SpellCheckingInspection",
"match",
"=",
"RE_INPUT_STRING",
".",
"match",
"(",
"input_str",
")",
"if",
"not",
"match",
":",
"raise",
"ValueError",
"(",
"f'badly formatted date/time... | Creates a MissionTime instance from a string
Format: YYYYMMDDHHMMSS
Args:
input_str: string to parse
Returns: MissionTime instance | [
"Creates",
"a",
"MissionTime",
"instance",
"from",
"a",
"string"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/mission_time.py#L51-L77 |
243,543 | dossier/dossier.models | dossier/models/report.py | ReportGenerator.run | def run(self, output):
'''Generate the report to the given output.
:param output: writable file-like object or file path
'''
# Ensure folder exists.
if self.folder_id not in self.folders.folders(self.user):
print("E: folder not found: %s" % self.folder_name,
... | python | def run(self, output):
'''Generate the report to the given output.
:param output: writable file-like object or file path
'''
# Ensure folder exists.
if self.folder_id not in self.folders.folders(self.user):
print("E: folder not found: %s" % self.folder_name,
... | [
"def",
"run",
"(",
"self",
",",
"output",
")",
":",
"# Ensure folder exists.",
"if",
"self",
".",
"folder_id",
"not",
"in",
"self",
".",
"folders",
".",
"folders",
"(",
"self",
".",
"user",
")",
":",
"print",
"(",
"\"E: folder not found: %s\"",
"%",
"self"... | Generate the report to the given output.
:param output: writable file-like object or file path | [
"Generate",
"the",
"report",
"to",
"the",
"given",
"output",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L84-L140 |
243,544 | dossier/dossier.models | dossier/models/report.py | ReportGenerator._generate_report_all | def _generate_report_all(self):
'''Generate report for all subfolders contained by self.folder_id.'''
assert self.workbook is not None
count = 0
# Do all subfolders
for sid in self.folders.subfolders(self.folder_id, self.user):
count += 1
self._generate_f... | python | def _generate_report_all(self):
'''Generate report for all subfolders contained by self.folder_id.'''
assert self.workbook is not None
count = 0
# Do all subfolders
for sid in self.folders.subfolders(self.folder_id, self.user):
count += 1
self._generate_f... | [
"def",
"_generate_report_all",
"(",
"self",
")",
":",
"assert",
"self",
".",
"workbook",
"is",
"not",
"None",
"count",
"=",
"0",
"# Do all subfolders",
"for",
"sid",
"in",
"self",
".",
"folders",
".",
"subfolders",
"(",
"self",
".",
"folder_id",
",",
"self... | Generate report for all subfolders contained by self.folder_id. | [
"Generate",
"report",
"for",
"all",
"subfolders",
"contained",
"by",
"self",
".",
"folder_id",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L142-L153 |
243,545 | dossier/dossier.models | dossier/models/report.py | ReportGenerator._generate_report_single | def _generate_report_single(self, sid):
'''Generate report for subfolder given by sid .
The main purpose of this method is to make sure the subfolder given by
sid does indeed exist. All real work is delegated to
_generate_for_subfolder.
:param sid: The subfolder id
Pr... | python | def _generate_report_single(self, sid):
'''Generate report for subfolder given by sid .
The main purpose of this method is to make sure the subfolder given by
sid does indeed exist. All real work is delegated to
_generate_for_subfolder.
:param sid: The subfolder id
Pr... | [
"def",
"_generate_report_single",
"(",
"self",
",",
"sid",
")",
":",
"assert",
"self",
".",
"workbook",
"is",
"not",
"None",
"assert",
"sid",
"is",
"not",
"None",
"# Ensure subfolder exists",
"if",
"not",
"sid",
"in",
"self",
".",
"folders",
".",
"subfolders... | Generate report for subfolder given by sid .
The main purpose of this method is to make sure the subfolder given by
sid does indeed exist. All real work is delegated to
_generate_for_subfolder.
:param sid: The subfolder id
Private method. | [
"Generate",
"report",
"for",
"subfolder",
"given",
"by",
"sid",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L155-L175 |
243,546 | dossier/dossier.models | dossier/models/report.py | ReportGenerator._generate_for_subfolder | def _generate_for_subfolder(self, sid):
''' Generate report for a subfolder.
:param sid: The subfolder id; assumed valid
'''
# TODO: the following assumes subfolder names can be constructed from a
# subfolder id, which might not be the case in the future.
name = self._sa... | python | def _generate_for_subfolder(self, sid):
''' Generate report for a subfolder.
:param sid: The subfolder id; assumed valid
'''
# TODO: the following assumes subfolder names can be constructed from a
# subfolder id, which might not be the case in the future.
name = self._sa... | [
"def",
"_generate_for_subfolder",
"(",
"self",
",",
"sid",
")",
":",
"# TODO: the following assumes subfolder names can be constructed from a",
"# subfolder id, which might not be the case in the future.",
"name",
"=",
"self",
".",
"_sanitise_sheetname",
"(",
"uni",
"(",
"Folders... | Generate report for a subfolder.
:param sid: The subfolder id; assumed valid | [
"Generate",
"report",
"for",
"a",
"subfolder",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L177-L211 |
243,547 | dossier/dossier.models | dossier/models/report.py | Item.construct | def construct(generator, subtopic):
'''Method constructor of Item-derived classes.
Given a subtopic tuple, this method attempts to construct an
Item-derived class, currently either ItemText or ItemImage, from the
subtopic's type, found in its 4th element.
:param generator: Refe... | python | def construct(generator, subtopic):
'''Method constructor of Item-derived classes.
Given a subtopic tuple, this method attempts to construct an
Item-derived class, currently either ItemText or ItemImage, from the
subtopic's type, found in its 4th element.
:param generator: Refe... | [
"def",
"construct",
"(",
"generator",
",",
"subtopic",
")",
":",
"type",
"=",
"subtopic",
"[",
"3",
"]",
"if",
"type",
"not",
"in",
"Item",
".",
"constructors",
":",
"raise",
"LookupError",
"(",
"type",
")",
"# perhaps customise this exception?",
"return",
"... | Method constructor of Item-derived classes.
Given a subtopic tuple, this method attempts to construct an
Item-derived class, currently either ItemText or ItemImage, from the
subtopic's type, found in its 4th element.
:param generator: Reference to the owning ReportGenerator instance
... | [
"Method",
"constructor",
"of",
"Item",
"-",
"derived",
"classes",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L229-L247 |
243,548 | dossier/dossier.models | dossier/models/report.py | ItemImage.resize_image | def resize_image(self, data):
'''Resize image if height over 50 pixels and convert to JPEG.
Given a ByteIO or StringIO data input, this method ensures that the
image is not over 50 pixels high. If it is over 50 pixels high, the
image is resized to precisely 50 pixels in height and the ... | python | def resize_image(self, data):
'''Resize image if height over 50 pixels and convert to JPEG.
Given a ByteIO or StringIO data input, this method ensures that the
image is not over 50 pixels high. If it is over 50 pixels high, the
image is resized to precisely 50 pixels in height and the ... | [
"def",
"resize_image",
"(",
"self",
",",
"data",
")",
":",
"image",
"=",
"Image",
".",
"open",
"(",
"data",
")",
"stream_out",
"=",
"BytesIO",
"(",
")",
"width",
",",
"height",
"=",
"image",
".",
"size",
"[",
":",
"]",
"if",
"height",
">",
"50",
... | Resize image if height over 50 pixels and convert to JPEG.
Given a ByteIO or StringIO data input, this method ensures that the
image is not over 50 pixels high. If it is over 50 pixels high, the
image is resized to precisely 50 pixels in height and the width is
adjusted accordingly in ... | [
"Resize",
"image",
"if",
"height",
"over",
"50",
"pixels",
"and",
"convert",
"to",
"JPEG",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L316-L341 |
243,549 | bfontaine/p7magma | magma/courses.py | Course.desc | def desc(self):
"""
A textual description of this course
"""
if 'ects' in self:
fmt = '%s (%s, S%d) [%s, %.2f ECTS]'
fields = ('title', 'code', 'semester', 'status', 'ects')
else:
fmt = '%s'
fields = ('title',)
s = fmt % tu... | python | def desc(self):
"""
A textual description of this course
"""
if 'ects' in self:
fmt = '%s (%s, S%d) [%s, %.2f ECTS]'
fields = ('title', 'code', 'semester', 'status', 'ects')
else:
fmt = '%s'
fields = ('title',)
s = fmt % tu... | [
"def",
"desc",
"(",
"self",
")",
":",
"if",
"'ects'",
"in",
"self",
":",
"fmt",
"=",
"'%s (%s, S%d) [%s, %.2f ECTS]'",
"fields",
"=",
"(",
"'title'",
",",
"'code'",
",",
"'semester'",
",",
"'status'",
",",
"'ects'",
")",
"else",
":",
"fmt",
"=",
"'%s'",
... | A textual description of this course | [
"A",
"textual",
"description",
"of",
"this",
"course"
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L28-L48 |
243,550 | bfontaine/p7magma | magma/courses.py | CoursesList._populate | def _populate(self, soup):
"""
Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object.
"""
tables = soup.select('table[rules=all]')
if not tables:
return
trs = tables[0].select('tr')[1:]
if len(trs[0]) == 5:
# M1
se... | python | def _populate(self, soup):
"""
Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object.
"""
tables = soup.select('table[rules=all]')
if not tables:
return
trs = tables[0].select('tr')[1:]
if len(trs[0]) == 5:
# M1
se... | [
"def",
"_populate",
"(",
"self",
",",
"soup",
")",
":",
"tables",
"=",
"soup",
".",
"select",
"(",
"'table[rules=all]'",
")",
"if",
"not",
"tables",
":",
"return",
"trs",
"=",
"tables",
"[",
"0",
"]",
".",
"select",
"(",
"'tr'",
")",
"[",
"1",
":",... | Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object. | [
"Populate",
"the",
"list",
"assuming",
"soup",
"is",
"a",
"BeautifulSoup",
"object",
"."
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L70-L84 |
243,551 | pip-services3-python/pip-services3-components-python | pip_services3_components/connect/ConnectionParams.py | ConnectionParams.get_host | def get_host(self):
"""
Gets the host name or IP address.
:return: the host name or IP address.
"""
host = self.get_as_nullable_string("host")
host = host if host != None else self.get_as_nullable_string("ip")
return host | python | def get_host(self):
"""
Gets the host name or IP address.
:return: the host name or IP address.
"""
host = self.get_as_nullable_string("host")
host = host if host != None else self.get_as_nullable_string("ip")
return host | [
"def",
"get_host",
"(",
"self",
")",
":",
"host",
"=",
"self",
".",
"get_as_nullable_string",
"(",
"\"host\"",
")",
"host",
"=",
"host",
"if",
"host",
"!=",
"None",
"else",
"self",
".",
"get_as_nullable_string",
"(",
"\"ip\"",
")",
"return",
"host"
] | Gets the host name or IP address.
:return: the host name or IP address. | [
"Gets",
"the",
"host",
"name",
"or",
"IP",
"address",
"."
] | 1de9c1bb544cf1891111e9a5f5d67653f62c9b52 | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionParams.py#L103-L111 |
243,552 | etcher-be/emiz | emiz/weather/awc/awc.py | AWC.query_icao | def query_icao(icao: str):
"""
Queries AWC for the METAR of a given station
Args:
icao: station ID as a four letters-digits ICAO code
Returns: AWC result for the station
"""
params = {
'dataSource': 'metars',
'requestType': 'retrieve... | python | def query_icao(icao: str):
"""
Queries AWC for the METAR of a given station
Args:
icao: station ID as a four letters-digits ICAO code
Returns: AWC result for the station
"""
params = {
'dataSource': 'metars',
'requestType': 'retrieve... | [
"def",
"query_icao",
"(",
"icao",
":",
"str",
")",
":",
"params",
"=",
"{",
"'dataSource'",
":",
"'metars'",
",",
"'requestType'",
":",
"'retrieve'",
",",
"'format'",
":",
"'csv'",
",",
"'hoursBeforeNow'",
":",
"24",
",",
"}",
"AWC",
".",
"_validate_icao",... | Queries AWC for the METAR of a given station
Args:
icao: station ID as a four letters-digits ICAO code
Returns: AWC result for the station | [
"Queries",
"AWC",
"for",
"the",
"METAR",
"of",
"a",
"given",
"station"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/awc/awc.py#L48-L69 |
243,553 | canonical-web-and-design/asset-mapper | ubuntudesign/__init__.py | AssetMapper.create | def create(self, asset_content, friendly_name, tags='', optimize=False):
"""
Create an asset on the server
You must provide the asset with a friendly name
for the server to generate a path from.
"""
return self._create_asset({
'asset': b64encode(asset_content... | python | def create(self, asset_content, friendly_name, tags='', optimize=False):
"""
Create an asset on the server
You must provide the asset with a friendly name
for the server to generate a path from.
"""
return self._create_asset({
'asset': b64encode(asset_content... | [
"def",
"create",
"(",
"self",
",",
"asset_content",
",",
"friendly_name",
",",
"tags",
"=",
"''",
",",
"optimize",
"=",
"False",
")",
":",
"return",
"self",
".",
"_create_asset",
"(",
"{",
"'asset'",
":",
"b64encode",
"(",
"asset_content",
")",
",",
"'fr... | Create an asset on the server
You must provide the asset with a friendly name
for the server to generate a path from. | [
"Create",
"an",
"asset",
"on",
"the",
"server",
"You",
"must",
"provide",
"the",
"asset",
"with",
"a",
"friendly",
"name",
"for",
"the",
"server",
"to",
"generate",
"a",
"path",
"from",
"."
] | 5dc438a9cb3290cf54c5607913be02ed9d58b02d | https://github.com/canonical-web-and-design/asset-mapper/blob/5dc438a9cb3290cf54c5607913be02ed9d58b02d/ubuntudesign/__init__.py#L64-L77 |
243,554 | canonical-web-and-design/asset-mapper | ubuntudesign/__init__.py | AssetMapper.create_at_path | def create_at_path(self, asset_content, url_path, tags=''):
"""
Create asset at a specific URL path on the server
"""
return self._create_asset({
'asset': b64encode(asset_content),
'url-path': url_path,
'tags': tags,
'type': 'base64'
... | python | def create_at_path(self, asset_content, url_path, tags=''):
"""
Create asset at a specific URL path on the server
"""
return self._create_asset({
'asset': b64encode(asset_content),
'url-path': url_path,
'tags': tags,
'type': 'base64'
... | [
"def",
"create_at_path",
"(",
"self",
",",
"asset_content",
",",
"url_path",
",",
"tags",
"=",
"''",
")",
":",
"return",
"self",
".",
"_create_asset",
"(",
"{",
"'asset'",
":",
"b64encode",
"(",
"asset_content",
")",
",",
"'url-path'",
":",
"url_path",
","... | Create asset at a specific URL path on the server | [
"Create",
"asset",
"at",
"a",
"specific",
"URL",
"path",
"on",
"the",
"server"
] | 5dc438a9cb3290cf54c5607913be02ed9d58b02d | https://github.com/canonical-web-and-design/asset-mapper/blob/5dc438a9cb3290cf54c5607913be02ed9d58b02d/ubuntudesign/__init__.py#L79-L89 |
243,555 | lwcook/horsetail-matching | horsetailmatching/hm.py | _matrix_integration | def _matrix_integration(q, h, t):
''' Returns the dp metric for a single horsetail
curve at a given value of the epistemic uncertainties'''
N = len(q)
# correction if CDF has gone out of trapezium range
if h[-1] < 0.9: h[-1] = 1.0
W = np.zeros([N, N])
for i in range(N):
W[i, i] = ... | python | def _matrix_integration(q, h, t):
''' Returns the dp metric for a single horsetail
curve at a given value of the epistemic uncertainties'''
N = len(q)
# correction if CDF has gone out of trapezium range
if h[-1] < 0.9: h[-1] = 1.0
W = np.zeros([N, N])
for i in range(N):
W[i, i] = ... | [
"def",
"_matrix_integration",
"(",
"q",
",",
"h",
",",
"t",
")",
":",
"N",
"=",
"len",
"(",
"q",
")",
"# correction if CDF has gone out of trapezium range",
"if",
"h",
"[",
"-",
"1",
"]",
"<",
"0.9",
":",
"h",
"[",
"-",
"1",
"]",
"=",
"1.0",
"W",
"... | Returns the dp metric for a single horsetail
curve at a given value of the epistemic uncertainties | [
"Returns",
"the",
"dp",
"metric",
"for",
"a",
"single",
"horsetail",
"curve",
"at",
"a",
"given",
"value",
"of",
"the",
"epistemic",
"uncertainties"
] | f3d5f8d01249debbca978f412ce4eae017458119 | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L921-L936 |
243,556 | lwcook/horsetail-matching | horsetailmatching/hm.py | _matrix_grad | def _matrix_grad(q, h, h_dx, t, t_prime):
''' Returns the gradient with respect to a single variable'''
N = len(q)
W = np.zeros([N, N])
Wprime = np.zeros([N, N])
for i in range(N):
W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)])
Wprime[i, i] = \
0.5*(h_dx[min(i+1, N-1)... | python | def _matrix_grad(q, h, h_dx, t, t_prime):
''' Returns the gradient with respect to a single variable'''
N = len(q)
W = np.zeros([N, N])
Wprime = np.zeros([N, N])
for i in range(N):
W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)])
Wprime[i, i] = \
0.5*(h_dx[min(i+1, N-1)... | [
"def",
"_matrix_grad",
"(",
"q",
",",
"h",
",",
"h_dx",
",",
"t",
",",
"t_prime",
")",
":",
"N",
"=",
"len",
"(",
"q",
")",
"W",
"=",
"np",
".",
"zeros",
"(",
"[",
"N",
",",
"N",
"]",
")",
"Wprime",
"=",
"np",
".",
"zeros",
"(",
"[",
"N",... | Returns the gradient with respect to a single variable | [
"Returns",
"the",
"gradient",
"with",
"respect",
"to",
"a",
"single",
"variable"
] | f3d5f8d01249debbca978f412ce4eae017458119 | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L938-L954 |
243,557 | lwcook/horsetail-matching | horsetailmatching/hm.py | HorsetailMatching.evalMetric | def evalMetric(self, x, method=None):
'''Evaluates the horsetail matching metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param str method: method to use to evaluate... | python | def evalMetric(self, x, method=None):
'''Evaluates the horsetail matching metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param str method: method to use to evaluate... | [
"def",
"evalMetric",
"(",
"self",
",",
"x",
",",
"method",
"=",
"None",
")",
":",
"# Make sure dimensions are correct",
"# u_sample_dimensions = self._processDimensions()",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"'----------'",
")",
"print",
"(",
"'... | Evaluates the horsetail matching metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param str method: method to use to evaluate the metric ('empirical' or
'kernel')... | [
"Evaluates",
"the",
"horsetail",
"matching",
"metric",
"at",
"given",
"values",
"of",
"the",
"design",
"variables",
"."
] | f3d5f8d01249debbca978f412ce4eae017458119 | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L328-L363 |
243,558 | lwcook/horsetail-matching | horsetailmatching/hm.py | HorsetailMatching.evalMetricFromSamples | def evalMetricFromSamples(self, q_samples, grad_samples=None, method=None):
'''Evaluates the horsetail matching metric from given samples of the quantity
of interest and gradient instead of evaluating them at a design.
:param np.ndarray q_samples: samples of the quantity of interest,
... | python | def evalMetricFromSamples(self, q_samples, grad_samples=None, method=None):
'''Evaluates the horsetail matching metric from given samples of the quantity
of interest and gradient instead of evaluating them at a design.
:param np.ndarray q_samples: samples of the quantity of interest,
... | [
"def",
"evalMetricFromSamples",
"(",
"self",
",",
"q_samples",
",",
"grad_samples",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"# Make sure dimensions are correct",
"# u_sample_dimensions = self._processDimensions()",
"q_samples",
"=",
"np",
".",
"array",
... | Evaluates the horsetail matching metric from given samples of the quantity
of interest and gradient instead of evaluating them at a design.
:param np.ndarray q_samples: samples of the quantity of interest,
size (M_int, M_prob)
:param np.ndarray grad_samples: samples of the gradien,
... | [
"Evaluates",
"the",
"horsetail",
"matching",
"metric",
"from",
"given",
"samples",
"of",
"the",
"quantity",
"of",
"interest",
"and",
"gradient",
"instead",
"of",
"evaluating",
"them",
"at",
"a",
"design",
"."
] | f3d5f8d01249debbca978f412ce4eae017458119 | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L365-L402 |
243,559 | lwcook/horsetail-matching | horsetailmatching/hm.py | HorsetailMatching.getHorsetail | def getHorsetail(self):
'''Function that gets vectors of the horsetail plot at the last design
evaluated.
:return: upper_curve, lower_curve, CDFs - returns three parameters,
the first two are tuples containing pairs of x/y vectors of the
upper and lower bounds on the CDF... | python | def getHorsetail(self):
'''Function that gets vectors of the horsetail plot at the last design
evaluated.
:return: upper_curve, lower_curve, CDFs - returns three parameters,
the first two are tuples containing pairs of x/y vectors of the
upper and lower bounds on the CDF... | [
"def",
"getHorsetail",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_ql'",
")",
":",
"ql",
",",
"qu",
",",
"hl",
",",
"hu",
"=",
"self",
".",
"_ql",
",",
"self",
".",
"_qu",
",",
"self",
".",
"_hl",
",",
"self",
".",
"_hu",
"qh... | Function that gets vectors of the horsetail plot at the last design
evaluated.
:return: upper_curve, lower_curve, CDFs - returns three parameters,
the first two are tuples containing pairs of x/y vectors of the
upper and lower bounds on the CDFs (the horsetail plot). The
... | [
"Function",
"that",
"gets",
"vectors",
"of",
"the",
"horsetail",
"plot",
"at",
"the",
"last",
"design",
"evaluated",
"."
] | f3d5f8d01249debbca978f412ce4eae017458119 | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L405-L450 |
243,560 | goldhand/django-nupages | nupages/views.py | PageList.get_queryset | def get_queryset(self):
'''
If MultiTenantMiddleware is used, filter queryset by request.site_id
'''
queryset = super(PageList, self).get_queryset()
if hasattr(self.request, 'site_id'):
queryset = queryset.filter(site_id=self.request.site_id)
return queryset | python | def get_queryset(self):
'''
If MultiTenantMiddleware is used, filter queryset by request.site_id
'''
queryset = super(PageList, self).get_queryset()
if hasattr(self.request, 'site_id'):
queryset = queryset.filter(site_id=self.request.site_id)
return queryset | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"queryset",
"=",
"super",
"(",
"PageList",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"if",
"hasattr",
"(",
"self",
".",
"request",
",",
"'site_id'",
")",
":",
"queryset",
"=",
"queryset",
".",
"filte... | If MultiTenantMiddleware is used, filter queryset by request.site_id | [
"If",
"MultiTenantMiddleware",
"is",
"used",
"filter",
"queryset",
"by",
"request",
".",
"site_id"
] | 4e54fae7e057f9530c22dc30c03812fd660cb7f4 | https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/views.py#L54-L61 |
243,561 | etcher-be/emiz | emiz/weather/noaa/__init__.py | retrieve_taf | def retrieve_taf(station_icao) -> typing.Tuple[typing.Union[str, None], typing.Union[str, None]]:
"""
Retrieves a TAF string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str
"""
url = _BASE_TAF_URL.format(station=station_icao)
... | python | def retrieve_taf(station_icao) -> typing.Tuple[typing.Union[str, None], typing.Union[str, None]]:
"""
Retrieves a TAF string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str
"""
url = _BASE_TAF_URL.format(station=station_icao)
... | [
"def",
"retrieve_taf",
"(",
"station_icao",
")",
"->",
"typing",
".",
"Tuple",
"[",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
",",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
"]",
":",
"url",
"=",
"_BASE_TAF_URL",
".",
"format",... | Retrieves a TAF string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str | [
"Retrieves",
"a",
"TAF",
"string",
"from",
"an",
"online",
"database"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/noaa/__init__.py#L13-L29 |
243,562 | etcher-be/emiz | emiz/weather/noaa/__init__.py | retrieve_metar | def retrieve_metar(station_icao) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]:
"""
Retrieves a METAR string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str
"""
url = _BASE_METAR_URL.format(station=station_icao)
... | python | def retrieve_metar(station_icao) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]:
"""
Retrieves a METAR string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str
"""
url = _BASE_METAR_URL.format(station=station_icao)
... | [
"def",
"retrieve_metar",
"(",
"station_icao",
")",
"->",
"typing",
".",
"Tuple",
"[",
"typing",
".",
"Optional",
"[",
"str",
"]",
",",
"typing",
".",
"Optional",
"[",
"str",
"]",
"]",
":",
"url",
"=",
"_BASE_METAR_URL",
".",
"format",
"(",
"station",
"... | Retrieves a METAR string from an online database
Args:
station_icao: ICAO of the station
Returns:
tuple of error, metar_str | [
"Retrieves",
"a",
"METAR",
"string",
"from",
"an",
"online",
"database"
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/noaa/__init__.py#L32-L48 |
243,563 | etcher-be/emiz | emiz/weather/custom_metar/custom_metar_pressure.py | CustomPressure.value | def value(self, units=None):
"""Return the pressure in the specified units."""
if units is None:
return self._value
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("unrecognized pressure unit: '" + units + "'")
units = units.upper()
i... | python | def value(self, units=None):
"""Return the pressure in the specified units."""
if units is None:
return self._value
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("unrecognized pressure unit: '" + units + "'")
units = units.upper()
i... | [
"def",
"value",
"(",
"self",
",",
"units",
"=",
"None",
")",
":",
"if",
"units",
"is",
"None",
":",
"return",
"self",
".",
"_value",
"if",
"not",
"units",
".",
"upper",
"(",
")",
"in",
"CustomPressure",
".",
"legal_units",
":",
"raise",
"UnitsError",
... | Return the pressure in the specified units. | [
"Return",
"the",
"pressure",
"in",
"the",
"specified",
"units",
"."
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/custom_metar/custom_metar_pressure.py#L16-L39 |
243,564 | etcher-be/emiz | emiz/weather/custom_metar/custom_metar_pressure.py | CustomPressure.string | def string(self, units: typing.Optional[str] = None) -> str:
"""Return a string representation of the pressure, using the given units."""
if not units:
_units: str = self._units
else:
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("un... | python | def string(self, units: typing.Optional[str] = None) -> str:
"""Return a string representation of the pressure, using the given units."""
if not units:
_units: str = self._units
else:
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("un... | [
"def",
"string",
"(",
"self",
",",
"units",
":",
"typing",
".",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"not",
"units",
":",
"_units",
":",
"str",
"=",
"self",
".",
"_units",
"else",
":",
"if",
"not",
"units",
".",
... | Return a string representation of the pressure, using the given units. | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"pressure",
"using",
"the",
"given",
"units",
"."
] | 1c3e32711921d7e600e85558ffe5d337956372de | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/custom_metar/custom_metar_pressure.py#L41-L59 |
243,565 | toastdriven/alligator | alligator/utils.py | determine_name | def determine_name(func):
"""
Given a function, returns the name of the function.
Ex::
from random import choice
determine_name(choice) # Returns 'choice'
:param func: The callable
:type func: function
:returns: Name string
"""
if hasattr(func, '__name__'):
re... | python | def determine_name(func):
"""
Given a function, returns the name of the function.
Ex::
from random import choice
determine_name(choice) # Returns 'choice'
:param func: The callable
:type func: function
:returns: Name string
"""
if hasattr(func, '__name__'):
re... | [
"def",
"determine_name",
"(",
"func",
")",
":",
"if",
"hasattr",
"(",
"func",
",",
"'__name__'",
")",
":",
"return",
"func",
".",
"__name__",
"elif",
"hasattr",
"(",
"func",
",",
"'__class__'",
")",
":",
"return",
"func",
".",
"__class__",
".",
"__name__... | Given a function, returns the name of the function.
Ex::
from random import choice
determine_name(choice) # Returns 'choice'
:param func: The callable
:type func: function
:returns: Name string | [
"Given",
"a",
"function",
"returns",
"the",
"name",
"of",
"the",
"function",
"."
] | f18bcb35b350fc6b0886393f5246d69c892b36c7 | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L24-L46 |
243,566 | toastdriven/alligator | alligator/utils.py | import_module | def import_module(module_name):
"""
Given a dotted Python path, imports & returns the module.
If not found, raises ``UnknownModuleError``.
Ex::
mod = import_module('random')
:param module_name: The dotted Python path
:type module_name: string
:returns: module
"""
try:
... | python | def import_module(module_name):
"""
Given a dotted Python path, imports & returns the module.
If not found, raises ``UnknownModuleError``.
Ex::
mod = import_module('random')
:param module_name: The dotted Python path
:type module_name: string
:returns: module
"""
try:
... | [
"def",
"import_module",
"(",
"module_name",
")",
":",
"try",
":",
"return",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"except",
"ImportError",
"as",
"err",
":",
"raise",
"UnknownModuleError",
"(",
"str",
"(",
"err",
")",
")"
] | Given a dotted Python path, imports & returns the module.
If not found, raises ``UnknownModuleError``.
Ex::
mod = import_module('random')
:param module_name: The dotted Python path
:type module_name: string
:returns: module | [
"Given",
"a",
"dotted",
"Python",
"path",
"imports",
"&",
"returns",
"the",
"module",
"."
] | f18bcb35b350fc6b0886393f5246d69c892b36c7 | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L49-L67 |
243,567 | toastdriven/alligator | alligator/utils.py | import_attr | def import_attr(module_name, attr_name):
"""
Given a dotted Python path & an attribute name, imports the module &
returns the attribute.
If not found, raises ``UnknownCallableError``.
Ex::
choice = import_attr('random', 'choice')
:param module_name: The dotted Python path
:type m... | python | def import_attr(module_name, attr_name):
"""
Given a dotted Python path & an attribute name, imports the module &
returns the attribute.
If not found, raises ``UnknownCallableError``.
Ex::
choice = import_attr('random', 'choice')
:param module_name: The dotted Python path
:type m... | [
"def",
"import_attr",
"(",
"module_name",
",",
"attr_name",
")",
":",
"module",
"=",
"import_module",
"(",
"module_name",
")",
"try",
":",
"return",
"getattr",
"(",
"module",
",",
"attr_name",
")",
"except",
"AttributeError",
"as",
"err",
":",
"raise",
"Unkn... | Given a dotted Python path & an attribute name, imports the module &
returns the attribute.
If not found, raises ``UnknownCallableError``.
Ex::
choice = import_attr('random', 'choice')
:param module_name: The dotted Python path
:type module_name: string
:param attr_name: The attribu... | [
"Given",
"a",
"dotted",
"Python",
"path",
"&",
"an",
"attribute",
"name",
"imports",
"the",
"module",
"&",
"returns",
"the",
"attribute",
"."
] | f18bcb35b350fc6b0886393f5246d69c892b36c7 | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L70-L94 |
243,568 | nefarioustim/parker | parker/configloader.py | load_site_config | def load_site_config(name):
"""Load and return site configuration as a dict."""
return _load_config_json(
os.path.join(
CONFIG_PATH,
CONFIG_SITES_PATH,
name + CONFIG_EXT
)
) | python | def load_site_config(name):
"""Load and return site configuration as a dict."""
return _load_config_json(
os.path.join(
CONFIG_PATH,
CONFIG_SITES_PATH,
name + CONFIG_EXT
)
) | [
"def",
"load_site_config",
"(",
"name",
")",
":",
"return",
"_load_config_json",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CONFIG_PATH",
",",
"CONFIG_SITES_PATH",
",",
"name",
"+",
"CONFIG_EXT",
")",
")"
] | Load and return site configuration as a dict. | [
"Load",
"and",
"return",
"site",
"configuration",
"as",
"a",
"dict",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/configloader.py#L37-L45 |
243,569 | carlosp420/dataset-creator | dataset_creator/phylip.py | PhylipDatasetFooter.make_charsets | def make_charsets(self):
"""
Overridden function for Phylip dataset as the content is different and
goes into a separate file.
"""
count_start = 1
out = ''
for gene_code, lengths in self.data.gene_codes_and_lengths.items():
count_end = lengths[0] + cou... | python | def make_charsets(self):
"""
Overridden function for Phylip dataset as the content is different and
goes into a separate file.
"""
count_start = 1
out = ''
for gene_code, lengths in self.data.gene_codes_and_lengths.items():
count_end = lengths[0] + cou... | [
"def",
"make_charsets",
"(",
"self",
")",
":",
"count_start",
"=",
"1",
"out",
"=",
"''",
"for",
"gene_code",
",",
"lengths",
"in",
"self",
".",
"data",
".",
"gene_codes_and_lengths",
".",
"items",
"(",
")",
":",
"count_end",
"=",
"lengths",
"[",
"0",
... | Overridden function for Phylip dataset as the content is different and
goes into a separate file. | [
"Overridden",
"function",
"for",
"Phylip",
"dataset",
"as",
"the",
"content",
"is",
"different",
"and",
"goes",
"into",
"a",
"separate",
"file",
"."
] | ea27340b145cb566a36c1836ff42263f1b2003a0 | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/phylip.py#L13-L26 |
243,570 | kstark/months | months/months.py | Month.from_date | def from_date(cls, date):
"""
Returns a Month instance from the given datetime.date or
datetime.datetime object
"""
try:
date = date.date()
except AttributeError:
pass
return cls(date.year, date.month) | python | def from_date(cls, date):
"""
Returns a Month instance from the given datetime.date or
datetime.datetime object
"""
try:
date = date.date()
except AttributeError:
pass
return cls(date.year, date.month) | [
"def",
"from_date",
"(",
"cls",
",",
"date",
")",
":",
"try",
":",
"date",
"=",
"date",
".",
"date",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"return",
"cls",
"(",
"date",
".",
"year",
",",
"date",
".",
"month",
")"
] | Returns a Month instance from the given datetime.date or
datetime.datetime object | [
"Returns",
"a",
"Month",
"instance",
"from",
"the",
"given",
"datetime",
".",
"date",
"or",
"datetime",
".",
"datetime",
"object"
] | 676910a7328c3204f7366558b038644057d34561 | https://github.com/kstark/months/blob/676910a7328c3204f7366558b038644057d34561/months/months.py#L66-L75 |
243,571 | mbodenhamer/syn | syn/tree/b/tree.py | Tree.rebuild | def rebuild(self, **kwargs):
'''Repopulate the node-tracking data structures. Shouldn't
really ever be needed.
'''
self.nodes = []
self.node_types = []
self.id_dict = {}
self.type_dict = {}
self.add_node(self.root) | python | def rebuild(self, **kwargs):
'''Repopulate the node-tracking data structures. Shouldn't
really ever be needed.
'''
self.nodes = []
self.node_types = []
self.id_dict = {}
self.type_dict = {}
self.add_node(self.root) | [
"def",
"rebuild",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"nodes",
"=",
"[",
"]",
"self",
".",
"node_types",
"=",
"[",
"]",
"self",
".",
"id_dict",
"=",
"{",
"}",
"self",
".",
"type_dict",
"=",
"{",
"}",
"self",
".",
"add_n... | Repopulate the node-tracking data structures. Shouldn't
really ever be needed. | [
"Repopulate",
"the",
"node",
"-",
"tracking",
"data",
"structures",
".",
"Shouldn",
"t",
"really",
"ever",
"be",
"needed",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/tree/b/tree.py#L125-L134 |
243,572 | mbodenhamer/syn | syn/tree/b/tree.py | Tree._check_search_kwarg_types | def _check_search_kwarg_types(self, kwargs):
'''Checks that every element of kwargs is a valid type in this tree.'''
for key in kwargs:
if key not in self.node_types:
raise TypeError("Invalid search type: {}".format(key)) | python | def _check_search_kwarg_types(self, kwargs):
'''Checks that every element of kwargs is a valid type in this tree.'''
for key in kwargs:
if key not in self.node_types:
raise TypeError("Invalid search type: {}".format(key)) | [
"def",
"_check_search_kwarg_types",
"(",
"self",
",",
"kwargs",
")",
":",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"self",
".",
"node_types",
":",
"raise",
"TypeError",
"(",
"\"Invalid search type: {}\"",
".",
"format",
"(",
"key",
")",
... | Checks that every element of kwargs is a valid type in this tree. | [
"Checks",
"that",
"every",
"element",
"of",
"kwargs",
"is",
"a",
"valid",
"type",
"in",
"this",
"tree",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/tree/b/tree.py#L147-L151 |
243,573 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | average | def average(x):
"""
Return a numpy array of column average.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column average
Examples
--------
... | python | def average(x):
"""
Return a numpy array of column average.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column average
Examples
--------
... | [
"def",
"average",
"(",
"x",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"return",
"np",
".",
"average",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"return",
"x"
] | Return a numpy array of column average.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column average
Examples
--------
>>> a = np.array([[1, 2, 3... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"average",
".",
"It",
"does",
"not",
"affect",
"if",
"the",
"array",
"is",
"one",
"dimension"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L8-L35 |
243,574 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | mean | def mean(x):
"""
Return a numpy array of column mean.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column mean
Examples
--------
>>> a =... | python | def mean(x):
"""
Return a numpy array of column mean.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column mean
Examples
--------
>>> a =... | [
"def",
"mean",
"(",
"x",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"return",
"np",
".",
"mean",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"return",
"x"
] | Return a numpy array of column mean.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column mean
Examples
--------
>>> a = np.array([[1, 2, 3], [4,... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"mean",
".",
"It",
"does",
"not",
"affect",
"if",
"the",
"array",
"is",
"one",
"dimension"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L37-L64 |
243,575 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | median | def median(x):
"""
Return a numpy array of column median.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column median
Examples
--------
>... | python | def median(x):
"""
Return a numpy array of column median.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column median
Examples
--------
>... | [
"def",
"median",
"(",
"x",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"return",
"np",
".",
"median",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"return",
"x"
] | Return a numpy array of column median.
It does not affect if the array is one dimension
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column median
Examples
--------
>>> a = np.array([[1, 2, 3],... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"median",
".",
"It",
"does",
"not",
"affect",
"if",
"the",
"array",
"is",
"one",
"dimension"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L66-L93 |
243,576 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | variance | def variance(x):
"""
Return a numpy array of column variance
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column variance
Examples
--------
>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]... | python | def variance(x):
"""
Return a numpy array of column variance
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column variance
Examples
--------
>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]... | [
"def",
"variance",
"(",
"x",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"return",
"np",
".",
"var",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"return",
"np",
".",
"var",
"(",
"x",
... | Return a numpy array of column variance
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column variance
Examples
--------
>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> np.testing.assert_... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"variance"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L95-L123 |
243,577 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | standard_deviation | def standard_deviation(x):
"""
Return a numpy array of column standard deviation
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column standard deviation
Examples
--------
>>> a = np.array([[... | python | def standard_deviation(x):
"""
Return a numpy array of column standard deviation
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column standard deviation
Examples
--------
>>> a = np.array([[... | [
"def",
"standard_deviation",
"(",
"x",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"return",
"np",
".",
"std",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"return",
"np",
".",
"std",
"(",... | Return a numpy array of column standard deviation
Parameters
----------
x : ndarray
A numpy array instance
Returns
-------
ndarray
A 1 x n numpy array instance of column standard deviation
Examples
--------
>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"standard",
"deviation"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L125-L153 |
243,578 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | confidential_interval | def confidential_interval(x, alpha=0.98):
"""
Return a numpy array of column confidential interval
Parameters
----------
x : ndarray
A numpy array instance
alpha : float
Alpha value of confidential interval
Returns
-------
ndarray
A 1 x n numpy array which i... | python | def confidential_interval(x, alpha=0.98):
"""
Return a numpy array of column confidential interval
Parameters
----------
x : ndarray
A numpy array instance
alpha : float
Alpha value of confidential interval
Returns
-------
ndarray
A 1 x n numpy array which i... | [
"def",
"confidential_interval",
"(",
"x",
",",
"alpha",
"=",
"0.98",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"t",
"if",
"x",
".",
"ndim",
"==",
"1",
":",
"df",
"=",
"len",
"(",
"x",
")",
"-",
"1",
"# calculate positive critical value of studen... | Return a numpy array of column confidential interval
Parameters
----------
x : ndarray
A numpy array instance
alpha : float
Alpha value of confidential interval
Returns
-------
ndarray
A 1 x n numpy array which indicate the each difference from sample
averag... | [
"Return",
"a",
"numpy",
"array",
"of",
"column",
"confidential",
"interval"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L155-L188 |
243,579 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | simple_moving_matrix | def simple_moving_matrix(x, n=10):
"""
Create simple moving matrix.
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A n x n numpy array which will be useful for calculating ... | python | def simple_moving_matrix(x, n=10):
"""
Create simple moving matrix.
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A n x n numpy array which will be useful for calculating ... | [
"def",
"simple_moving_matrix",
"(",
"x",
",",
"n",
"=",
"10",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"x",
"=",
"np",
".",
"average",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"h"... | Create simple moving matrix.
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A n x n numpy array which will be useful for calculating confidentail
interval of simple moving ... | [
"Create",
"simple",
"moving",
"matrix",
"."
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L190-L215 |
243,580 | lambdalisue/maidenhair | src/maidenhair/statistics/__init__.py | simple_moving_average | def simple_moving_average(x, n=10):
"""
Calculate simple moving average
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A 1 x n numpy array instance
"""
if x.ndim > ... | python | def simple_moving_average(x, n=10):
"""
Calculate simple moving average
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A 1 x n numpy array instance
"""
if x.ndim > ... | [
"def",
"simple_moving_average",
"(",
"x",
",",
"n",
"=",
"10",
")",
":",
"if",
"x",
".",
"ndim",
">",
"1",
"and",
"len",
"(",
"x",
"[",
"0",
"]",
")",
">",
"1",
":",
"x",
"=",
"np",
".",
"average",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"a... | Calculate simple moving average
Parameters
----------
x : ndarray
A numpy array
n : integer
The number of sample points used to make average
Returns
-------
ndarray
A 1 x n numpy array instance | [
"Calculate",
"simple",
"moving",
"average"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L217-L236 |
243,581 | rbarrois/volatildap | volatildap/server.py | find_available_port | def find_available_port():
"""Find an available port.
Simple trick: open a socket to localhost, see what port was allocated.
Could fail in highly concurrent setups, though.
"""
s = socket.socket()
s.bind(('localhost', 0))
_address, port = s.getsockname()
s.close()
return port | python | def find_available_port():
"""Find an available port.
Simple trick: open a socket to localhost, see what port was allocated.
Could fail in highly concurrent setups, though.
"""
s = socket.socket()
s.bind(('localhost', 0))
_address, port = s.getsockname()
s.close()
return port | [
"def",
"find_available_port",
"(",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
")",
"s",
".",
"bind",
"(",
"(",
"'localhost'",
",",
"0",
")",
")",
"_address",
",",
"port",
"=",
"s",
".",
"getsockname",
"(",
")",
"s",
".",
"close",
"(",
")",... | Find an available port.
Simple trick: open a socket to localhost, see what port was allocated.
Could fail in highly concurrent setups, though. | [
"Find",
"an",
"available",
"port",
"."
] | 08df9d5f2f65400e51eae7a50e64759bdbdce6f2 | https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L378-L389 |
243,582 | rbarrois/volatildap | volatildap/server.py | OpenLdapPaths._find_file | def _find_file(self, needle, candidates):
"""Find the first directory containing a given candidate file."""
for candidate in candidates:
fullpath = os.path.join(candidate, needle)
if os.path.isfile(fullpath):
return fullpath
raise PathError("Unable to loca... | python | def _find_file(self, needle, candidates):
"""Find the first directory containing a given candidate file."""
for candidate in candidates:
fullpath = os.path.join(candidate, needle)
if os.path.isfile(fullpath):
return fullpath
raise PathError("Unable to loca... | [
"def",
"_find_file",
"(",
"self",
",",
"needle",
",",
"candidates",
")",
":",
"for",
"candidate",
"in",
"candidates",
":",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"candidate",
",",
"needle",
")",
"if",
"os",
".",
"path",
".",
"isfile",
... | Find the first directory containing a given candidate file. | [
"Find",
"the",
"first",
"directory",
"containing",
"a",
"given",
"candidate",
"file",
"."
] | 08df9d5f2f65400e51eae7a50e64759bdbdce6f2 | https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L53-L59 |
243,583 | rbarrois/volatildap | volatildap/server.py | LdapServer._poll_slapd | def _poll_slapd(self, timeout=DEFAULT_STARTUP_DELAY):
"""Poll slapd port until available."""
begin = time.time()
time.sleep(0.5)
while time.time() < begin + timeout:
if self._process.poll() is not None:
raise RuntimeError("LDAP server has exited before starti... | python | def _poll_slapd(self, timeout=DEFAULT_STARTUP_DELAY):
"""Poll slapd port until available."""
begin = time.time()
time.sleep(0.5)
while time.time() < begin + timeout:
if self._process.poll() is not None:
raise RuntimeError("LDAP server has exited before starti... | [
"def",
"_poll_slapd",
"(",
"self",
",",
"timeout",
"=",
"DEFAULT_STARTUP_DELAY",
")",
":",
"begin",
"=",
"time",
".",
"time",
"(",
")",
"time",
".",
"sleep",
"(",
"0.5",
")",
"while",
"time",
".",
"time",
"(",
")",
"<",
"begin",
"+",
"timeout",
":",
... | Poll slapd port until available. | [
"Poll",
"slapd",
"port",
"until",
"available",
"."
] | 08df9d5f2f65400e51eae7a50e64759bdbdce6f2 | https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L335-L355 |
243,584 | collectiveacuity/labPack | labpack/databases/couchbase.py | syncGatewayClient.list_users | def list_users(self):
''' a method to list all the user ids of all users in the bucket '''
# construct url
url = self.bucket_url + '/_user/'
# send request and unwrap response
response = requests.get(url)
response = response.json()
return response | python | def list_users(self):
''' a method to list all the user ids of all users in the bucket '''
# construct url
url = self.bucket_url + '/_user/'
# send request and unwrap response
response = requests.get(url)
response = response.json()
return response | [
"def",
"list_users",
"(",
"self",
")",
":",
"# construct url",
"url",
"=",
"self",
".",
"bucket_url",
"+",
"'/_user/'",
"# send request and unwrap response",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"response",
"=",
"response",
".",
"json",
"(... | a method to list all the user ids of all users in the bucket | [
"a",
"method",
"to",
"list",
"all",
"the",
"user",
"ids",
"of",
"all",
"users",
"in",
"the",
"bucket"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L456-L467 |
243,585 | collectiveacuity/labPack | labpack/databases/couchbase.py | syncGatewayClient.create | def create(self, doc_details):
'''
a method to create a new document in the collection
:param doc_details: dictionary with document details and user id value
:return: dictionary with document details and _id and _rev values
'''
# https://developer.couchbase... | python | def create(self, doc_details):
'''
a method to create a new document in the collection
:param doc_details: dictionary with document details and user id value
:return: dictionary with document details and _id and _rev values
'''
# https://developer.couchbase... | [
"def",
"create",
"(",
"self",
",",
"doc_details",
")",
":",
"# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/document/post__db___doc_",
"title",
"=",
"'%s.create'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# va... | a method to create a new document in the collection
:param doc_details: dictionary with document details and user id value
:return: dictionary with document details and _id and _rev values | [
"a",
"method",
"to",
"create",
"a",
"new",
"document",
"in",
"the",
"collection"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L905-L936 |
243,586 | collectiveacuity/labPack | labpack/databases/couchbase.py | syncGatewayClient.remove | def remove(self):
'''
a method to remove the entire bucket from the database
:return: string with confirmation message
'''
# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/database/delete__db__
title =... | python | def remove(self):
'''
a method to remove the entire bucket from the database
:return: string with confirmation message
'''
# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/database/delete__db__
title =... | [
"def",
"remove",
"(",
"self",
")",
":",
"# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/database/delete__db__",
"title",
"=",
"'%s.remove'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate admin access",
"if... | a method to remove the entire bucket from the database
:return: string with confirmation message | [
"a",
"method",
"to",
"remove",
"the",
"entire",
"bucket",
"from",
"the",
"database"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L1083-L1125 |
243,587 | Zsailer/yerkes | yerkes/base.py | EmptyPalette.to_chart | def to_chart(self):
"""Write color palette to Altair Chart.
"""
encoding, properties = {}, {}
if self.orientation == "horizontal":
# Set the axis
encoding["x"] = alt.X(
"hex",
axis=None,
scale=alt.Scale(zero=False, ... | python | def to_chart(self):
"""Write color palette to Altair Chart.
"""
encoding, properties = {}, {}
if self.orientation == "horizontal":
# Set the axis
encoding["x"] = alt.X(
"hex",
axis=None,
scale=alt.Scale(zero=False, ... | [
"def",
"to_chart",
"(",
"self",
")",
":",
"encoding",
",",
"properties",
"=",
"{",
"}",
",",
"{",
"}",
"if",
"self",
".",
"orientation",
"==",
"\"horizontal\"",
":",
"# Set the axis",
"encoding",
"[",
"\"x\"",
"]",
"=",
"alt",
".",
"X",
"(",
"\"hex\"",... | Write color palette to Altair Chart. | [
"Write",
"color",
"palette",
"to",
"Altair",
"Chart",
"."
] | 0434e3b2ee124736e6ece63077430eac8eb6ac09 | https://github.com/Zsailer/yerkes/blob/0434e3b2ee124736e6ece63077430eac8eb6ac09/yerkes/base.py#L60-L98 |
243,588 | Zsailer/yerkes | yerkes/base.py | EmptyPalette._repr_mimebundle_ | def _repr_mimebundle_(self, *args, **kwargs):
"""Return a MIME bundle for display in Jupyter frontends."""
chart = self.to_chart()
dct = chart.to_dict()
return alt.renderers.get()(dct) | python | def _repr_mimebundle_(self, *args, **kwargs):
"""Return a MIME bundle for display in Jupyter frontends."""
chart = self.to_chart()
dct = chart.to_dict()
return alt.renderers.get()(dct) | [
"def",
"_repr_mimebundle_",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"chart",
"=",
"self",
".",
"to_chart",
"(",
")",
"dct",
"=",
"chart",
".",
"to_dict",
"(",
")",
"return",
"alt",
".",
"renderers",
".",
"get",
"(",
")",
... | Return a MIME bundle for display in Jupyter frontends. | [
"Return",
"a",
"MIME",
"bundle",
"for",
"display",
"in",
"Jupyter",
"frontends",
"."
] | 0434e3b2ee124736e6ece63077430eac8eb6ac09 | https://github.com/Zsailer/yerkes/blob/0434e3b2ee124736e6ece63077430eac8eb6ac09/yerkes/base.py#L100-L104 |
243,589 | jason2506/HTMLMinifier | HTMLMinifier/parser.py | Parser._enter_newline | def _enter_newline(self):
"""
Remove the trailing spaces in the current line, and then mark that the
leading spaces of the next line need to be removed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#white... | python | def _enter_newline(self):
"""
Remove the trailing spaces in the current line, and then mark that the
leading spaces of the next line need to be removed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#white... | [
"def",
"_enter_newline",
"(",
"self",
")",
":",
"last_text_idx",
"=",
"self",
".",
"_last_text_idx",
"if",
"last_text_idx",
">=",
"0",
":",
"buf",
"=",
"self",
".",
"_buffer",
"buf",
"[",
"last_text_idx",
"]",
"=",
"buf",
"[",
"last_text_idx",
"]",
".",
... | Remove the trailing spaces in the current line, and then mark that the
leading spaces of the next line need to be removed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#white-space-phase-2>`_ | [
"Remove",
"the",
"trailing",
"spaces",
"in",
"the",
"current",
"line",
"and",
"then",
"mark",
"that",
"the",
"leading",
"spaces",
"of",
"the",
"next",
"line",
"need",
"to",
"be",
"removed",
"."
] | 9a6a41834b7753ac465f301f0d6b470b90920fad | https://github.com/jason2506/HTMLMinifier/blob/9a6a41834b7753ac465f301f0d6b470b90920fad/HTMLMinifier/parser.py#L102-L117 |
243,590 | jason2506/HTMLMinifier | HTMLMinifier/parser.py | Parser.handle_comment | def handle_comment(self, comment):
"""
Remove comment except IE conditional comment.
.. seealso::
`About conditional comments
<http://msdn.microsoft.com/en-us/library/ms537512.ASPX>`_
"""
match = _COND_COMMENT_PATTERN.match(comment)
if match is no... | python | def handle_comment(self, comment):
"""
Remove comment except IE conditional comment.
.. seealso::
`About conditional comments
<http://msdn.microsoft.com/en-us/library/ms537512.ASPX>`_
"""
match = _COND_COMMENT_PATTERN.match(comment)
if match is no... | [
"def",
"handle_comment",
"(",
"self",
",",
"comment",
")",
":",
"match",
"=",
"_COND_COMMENT_PATTERN",
".",
"match",
"(",
"comment",
")",
"if",
"match",
"is",
"not",
"None",
":",
"cond",
"=",
"match",
".",
"group",
"(",
"1",
")",
"content",
"=",
"match... | Remove comment except IE conditional comment.
.. seealso::
`About conditional comments
<http://msdn.microsoft.com/en-us/library/ms537512.ASPX>`_ | [
"Remove",
"comment",
"except",
"IE",
"conditional",
"comment",
"."
] | 9a6a41834b7753ac465f301f0d6b470b90920fad | https://github.com/jason2506/HTMLMinifier/blob/9a6a41834b7753ac465f301f0d6b470b90920fad/HTMLMinifier/parser.py#L136-L156 |
243,591 | jason2506/HTMLMinifier | HTMLMinifier/parser.py | Parser.handle_data | def handle_data(self, data):
"""
Any space immediately following another collapsible space will be
collapsed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#egbidiwscollapse>`_
"""
tag_sta... | python | def handle_data(self, data):
"""
Any space immediately following another collapsible space will be
collapsed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#egbidiwscollapse>`_
"""
tag_sta... | [
"def",
"handle_data",
"(",
"self",
",",
"data",
")",
":",
"tag_stack",
"=",
"self",
".",
"_tag_stack",
"if",
"tag_stack",
"and",
"tag_stack",
"[",
"-",
"1",
"]",
"in",
"_RM_WS_ELEMENTS",
":",
"# just ignore the content of this element",
"assert",
"data",
".",
... | Any space immediately following another collapsible space will be
collapsed.
.. seealso::
`CSS Text Module Level 3 - The White Space Processing Rules
<http://www.w3.org/TR/css3-text/#egbidiwscollapse>`_ | [
"Any",
"space",
"immediately",
"following",
"another",
"collapsible",
"space",
"will",
"be",
"collapsed",
"."
] | 9a6a41834b7753ac465f301f0d6b470b90920fad | https://github.com/jason2506/HTMLMinifier/blob/9a6a41834b7753ac465f301f0d6b470b90920fad/HTMLMinifier/parser.py#L207-L241 |
243,592 | tommilligan/pypersonalassistant | pypersonalassistant/secure.py | secure.twilio_SMS | def twilio_SMS(self, from_, to, body):
"""
Send an SMS message from your `twilio`_ account.
.. _twilio: https://www.twilio.com/
Login will be performed using stored credentials.
* *stored credential name: TWILIO_ACCOUNT_SID*
* *stored credential name: TWILIO_AU... | python | def twilio_SMS(self, from_, to, body):
"""
Send an SMS message from your `twilio`_ account.
.. _twilio: https://www.twilio.com/
Login will be performed using stored credentials.
* *stored credential name: TWILIO_ACCOUNT_SID*
* *stored credential name: TWILIO_AU... | [
"def",
"twilio_SMS",
"(",
"self",
",",
"from_",
",",
"to",
",",
"body",
")",
":",
"logging",
".",
"debug",
"(",
"'Texting from Twilio'",
")",
"client",
"=",
"TwilioRestClient",
"(",
"self",
".",
"_credentials",
"[",
"'TWILIO_ACCOUNT_SID'",
"]",
",",
"self",
... | Send an SMS message from your `twilio`_ account.
.. _twilio: https://www.twilio.com/
Login will be performed using stored credentials.
* *stored credential name: TWILIO_ACCOUNT_SID*
* *stored credential name: TWILIO_AUTH_TOKEN*
:param string from_: The phone n... | [
"Send",
"an",
"SMS",
"message",
"from",
"your",
"twilio",
"_",
"account",
"."
] | 123903189be3f3d73a6f480de5e4442ffd099058 | https://github.com/tommilligan/pypersonalassistant/blob/123903189be3f3d73a6f480de5e4442ffd099058/pypersonalassistant/secure.py#L188-L211 |
243,593 | delfick/aws_syncr | aws_syncr/formatter.py | MergedOptionStringFormatter.special_get_field | def special_get_field(self, value, args, kwargs, format_spec=None):
"""Also take the spec into account"""
if value in self.chain:
raise BadOptionFormat("Recursive option", chain=self.chain + [value]) | python | def special_get_field(self, value, args, kwargs, format_spec=None):
"""Also take the spec into account"""
if value in self.chain:
raise BadOptionFormat("Recursive option", chain=self.chain + [value]) | [
"def",
"special_get_field",
"(",
"self",
",",
"value",
",",
"args",
",",
"kwargs",
",",
"format_spec",
"=",
"None",
")",
":",
"if",
"value",
"in",
"self",
".",
"chain",
":",
"raise",
"BadOptionFormat",
"(",
"\"Recursive option\"",
",",
"chain",
"=",
"self"... | Also take the spec into account | [
"Also",
"take",
"the",
"spec",
"into",
"account"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/formatter.py#L68-L71 |
243,594 | incuna/incuna-auth | incuna_auth/middleware/permission_feincms.py | FeinCMSPermissionMiddleware._get_page_from_path | def _get_page_from_path(self, path):
"""
Fetches the FeinCMS Page object that the path points to.
Override this to deal with different types of object from Page.
"""
from feincms.module.page.models import Page
try:
return Page.objects.best_match_for_path(path... | python | def _get_page_from_path(self, path):
"""
Fetches the FeinCMS Page object that the path points to.
Override this to deal with different types of object from Page.
"""
from feincms.module.page.models import Page
try:
return Page.objects.best_match_for_path(path... | [
"def",
"_get_page_from_path",
"(",
"self",
",",
"path",
")",
":",
"from",
"feincms",
".",
"module",
".",
"page",
".",
"models",
"import",
"Page",
"try",
":",
"return",
"Page",
".",
"objects",
".",
"best_match_for_path",
"(",
"path",
")",
"except",
"Page",
... | Fetches the FeinCMS Page object that the path points to.
Override this to deal with different types of object from Page. | [
"Fetches",
"the",
"FeinCMS",
"Page",
"object",
"that",
"the",
"path",
"points",
"to",
"."
] | 949ccd922da15a4b5de17b9595cc8f5114d5385c | https://github.com/incuna/incuna-auth/blob/949ccd922da15a4b5de17b9595cc8f5114d5385c/incuna_auth/middleware/permission_feincms.py#L31-L41 |
243,595 | incuna/incuna-auth | incuna_auth/middleware/permission_feincms.py | FeinCMSPermissionMiddleware._get_resource_access_state | def _get_resource_access_state(self, request):
"""
Returns the FeinCMS resource's access_state, following any INHERITed values.
Will return None if the resource has an access state that should never be
protected. It should not be possible to protect a resource with an access_state
... | python | def _get_resource_access_state(self, request):
"""
Returns the FeinCMS resource's access_state, following any INHERITed values.
Will return None if the resource has an access state that should never be
protected. It should not be possible to protect a resource with an access_state
... | [
"def",
"_get_resource_access_state",
"(",
"self",
",",
"request",
")",
":",
"feincms_page",
"=",
"self",
".",
"_get_page_from_path",
"(",
"request",
".",
"path_info",
".",
"lstrip",
"(",
"'/'",
")",
")",
"if",
"not",
"feincms_page",
":",
"return",
"None",
"#... | Returns the FeinCMS resource's access_state, following any INHERITed values.
Will return None if the resource has an access state that should never be
protected. It should not be possible to protect a resource with an access_state
of STATE_ALL_ALLOWED, or an access_state of STATE_INHERIT and no... | [
"Returns",
"the",
"FeinCMS",
"resource",
"s",
"access_state",
"following",
"any",
"INHERITed",
"values",
"."
] | 949ccd922da15a4b5de17b9595cc8f5114d5385c | https://github.com/incuna/incuna-auth/blob/949ccd922da15a4b5de17b9595cc8f5114d5385c/incuna_auth/middleware/permission_feincms.py#L43-L70 |
243,596 | incuna/incuna-auth | incuna_auth/middleware/permission_feincms.py | FeinCMSPermissionMiddleware.is_resource_protected | def is_resource_protected(self, request, **kwargs):
"""
Determines if a resource should be protected.
Returns true if and only if the resource's access_state matches an entry in
the return value of get_protected_states().
"""
access_state = self._get_resource_access_stat... | python | def is_resource_protected(self, request, **kwargs):
"""
Determines if a resource should be protected.
Returns true if and only if the resource's access_state matches an entry in
the return value of get_protected_states().
"""
access_state = self._get_resource_access_stat... | [
"def",
"is_resource_protected",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"access_state",
"=",
"self",
".",
"_get_resource_access_state",
"(",
"request",
")",
"protected_states",
"=",
"self",
".",
"get_protected_states",
"(",
")",
"return",... | Determines if a resource should be protected.
Returns true if and only if the resource's access_state matches an entry in
the return value of get_protected_states(). | [
"Determines",
"if",
"a",
"resource",
"should",
"be",
"protected",
"."
] | 949ccd922da15a4b5de17b9595cc8f5114d5385c | https://github.com/incuna/incuna-auth/blob/949ccd922da15a4b5de17b9595cc8f5114d5385c/incuna_auth/middleware/permission_feincms.py#L72-L81 |
243,597 | delfick/aws_syncr | aws_syncr/differ.py | Differ.compare_two_documents | def compare_two_documents(kls, doc1, doc2):
"""Compare two documents by converting them into json objects and back to strings and compare"""
first = doc1
if isinstance(doc1, string_types):
try:
first = json.loads(doc1)
except (ValueError, TypeError) as err... | python | def compare_two_documents(kls, doc1, doc2):
"""Compare two documents by converting them into json objects and back to strings and compare"""
first = doc1
if isinstance(doc1, string_types):
try:
first = json.loads(doc1)
except (ValueError, TypeError) as err... | [
"def",
"compare_two_documents",
"(",
"kls",
",",
"doc1",
",",
"doc2",
")",
":",
"first",
"=",
"doc1",
"if",
"isinstance",
"(",
"doc1",
",",
"string_types",
")",
":",
"try",
":",
"first",
"=",
"json",
".",
"loads",
"(",
"doc1",
")",
"except",
"(",
"Va... | Compare two documents by converting them into json objects and back to strings and compare | [
"Compare",
"two",
"documents",
"by",
"converting",
"them",
"into",
"json",
"objects",
"and",
"back",
"to",
"strings",
"and",
"compare"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/differ.py#L11-L62 |
243,598 | johnnoone/facts | facts/contribs/__init__.py | facter_info | def facter_info():
"""Returns data from facter.
"""
with suppress(FileNotFoundError): # facter may not be installed
proc = subprocess.Popen(['facter', '--yaml'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr =... | python | def facter_info():
"""Returns data from facter.
"""
with suppress(FileNotFoundError): # facter may not be installed
proc = subprocess.Popen(['facter', '--yaml'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr =... | [
"def",
"facter_info",
"(",
")",
":",
"with",
"suppress",
"(",
"FileNotFoundError",
")",
":",
"# facter may not be installed",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'facter'",
",",
"'--yaml'",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
... | Returns data from facter. | [
"Returns",
"data",
"from",
"facter",
"."
] | 82d38a46c15d9c01200445526f4c0d1825fc1e51 | https://github.com/johnnoone/facts/blob/82d38a46c15d9c01200445526f4c0d1825fc1e51/facts/contribs/__init__.py#L8-L19 |
243,599 | jrheard/madison_wcb | madison_wcb/wcb.py | get_color | def get_color(index):
"""Dips the brush in paint.
Arguments:
index - an integer between 0 and 7, inclusive. Tells the bot which color you want.
"""
if index in range(0, 8):
# Send the turtle to the top-left corner of the window to imitate the position of the WCB's brush.
state['... | python | def get_color(index):
"""Dips the brush in paint.
Arguments:
index - an integer between 0 and 7, inclusive. Tells the bot which color you want.
"""
if index in range(0, 8):
# Send the turtle to the top-left corner of the window to imitate the position of the WCB's brush.
state['... | [
"def",
"get_color",
"(",
"index",
")",
":",
"if",
"index",
"in",
"range",
"(",
"0",
",",
"8",
")",
":",
"# Send the turtle to the top-left corner of the window to imitate the position of the WCB's brush.",
"state",
"[",
"'turtle'",
"]",
".",
"goto",
"(",
"-",
"WCB_W... | Dips the brush in paint.
Arguments:
index - an integer between 0 and 7, inclusive. Tells the bot which color you want. | [
"Dips",
"the",
"brush",
"in",
"paint",
"."
] | 545e92e13c8fb46e0d805edef6b6146ab25373e9 | https://github.com/jrheard/madison_wcb/blob/545e92e13c8fb46e0d805edef6b6146ab25373e9/madison_wcb/wcb.py#L66-L85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.