repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
zhemao/funktown | funktown/vector.py | ImmutableVector.pop | def pop(self):
'''Return a new ImmutableVector with the last item removed.'''
if self._length == 0:
raise IndexError()
newvec = ImmutableVector()
newvec.tree = self.tree.remove(self._length-1)
newvec._length = self._length-1
return newvec | python | def pop(self):
'''Return a new ImmutableVector with the last item removed.'''
if self._length == 0:
raise IndexError()
newvec = ImmutableVector()
newvec.tree = self.tree.remove(self._length-1)
newvec._length = self._length-1
return newvec | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_length",
"==",
"0",
":",
"raise",
"IndexError",
"(",
")",
"newvec",
"=",
"ImmutableVector",
"(",
")",
"newvec",
".",
"tree",
"=",
"self",
".",
"tree",
".",
"remove",
"(",
"self",
".",
"_leng... | Return a new ImmutableVector with the last item removed. | [
"Return",
"a",
"new",
"ImmutableVector",
"with",
"the",
"last",
"item",
"removed",
"."
] | 8d5c5a8bdad2b85b33b4cea3febd820c2657c375 | https://github.com/zhemao/funktown/blob/8d5c5a8bdad2b85b33b4cea3febd820c2657c375/funktown/vector.py#L35-L42 | train | Return a new ImmutableVector with the last item removed. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.read | def read(self, identifier, path):
""" Retrieve and parse a text given an identifier
:param identifier: Identifier of the text
:type identifier: str
:param path: Path of the text
:type path: str
:return: Parsed Text
:rtype: CapitainsCtsText
"""
wit... | python | def read(self, identifier, path):
""" Retrieve and parse a text given an identifier
:param identifier: Identifier of the text
:type identifier: str
:param path: Path of the text
:type path: str
:return: Parsed Text
:rtype: CapitainsCtsText
"""
wit... | [
"def",
"read",
"(",
"self",
",",
"identifier",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"o",
"=",
"self",
".",
"classes",
"[",
"\"text\"",
"]",
"(",
"urn",
"=",
"identifier",
",",
"resource",
"=",
"self",
".",
"xml... | Retrieve and parse a text given an identifier
:param identifier: Identifier of the text
:type identifier: str
:param path: Path of the text
:type path: str
:return: Parsed Text
:rtype: CapitainsCtsText | [
"Retrieve",
"and",
"parse",
"a",
"text",
"given",
"an",
"identifier"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L111-L123 | train | Retrieve and parse a text given an identifier |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._parse_textgroup_wrapper | def _parse_textgroup_wrapper(self, cts_file):
""" Wraps with a Try/Except the textgroup parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata
"""
try:
return self._parse_textgroup(cts_file)
exc... | python | def _parse_textgroup_wrapper(self, cts_file):
""" Wraps with a Try/Except the textgroup parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata
"""
try:
return self._parse_textgroup(cts_file)
exc... | [
"def",
"_parse_textgroup_wrapper",
"(",
"self",
",",
"cts_file",
")",
":",
"try",
":",
"return",
"self",
".",
"_parse_textgroup",
"(",
"cts_file",
")",
"except",
"Exception",
"as",
"E",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Error parsing %s \"",
... | Wraps with a Try/Except the textgroup parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata | [
"Wraps",
"with",
"a",
"Try",
"/",
"Except",
"the",
"textgroup",
"parsing",
"from",
"a",
"cts",
"file"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L125-L137 | train | Wraps with a Try / Except the textgroup parsing from a cts file containing the CtsTextgroupMetadata. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._parse_textgroup | def _parse_textgroup(self, cts_file):
""" Parses a textgroup from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata and Current file
"""
with io.open(cts_file) as __xml__:
return self.classes["textgroup"].parse... | python | def _parse_textgroup(self, cts_file):
""" Parses a textgroup from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata and Current file
"""
with io.open(cts_file) as __xml__:
return self.classes["textgroup"].parse... | [
"def",
"_parse_textgroup",
"(",
"self",
",",
"cts_file",
")",
":",
"with",
"io",
".",
"open",
"(",
"cts_file",
")",
"as",
"__xml__",
":",
"return",
"self",
".",
"classes",
"[",
"\"textgroup\"",
"]",
".",
"parse",
"(",
"resource",
"=",
"__xml__",
")",
"... | Parses a textgroup from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:return: CtsTextgroupMetadata and Current file | [
"Parses",
"a",
"textgroup",
"from",
"a",
"cts",
"file"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L139-L149 | train | Parses a textgroup from a CTS file and returns a CtsTextgroupMetadata and Current file |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._parse_work_wrapper | def _parse_work_wrapper(self, cts_file, textgroup):
""" Wraps with a Try/Except the Work parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:re... | python | def _parse_work_wrapper(self, cts_file, textgroup):
""" Wraps with a Try/Except the Work parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:re... | [
"def",
"_parse_work_wrapper",
"(",
"self",
",",
"cts_file",
",",
"textgroup",
")",
":",
"try",
":",
"return",
"self",
".",
"_parse_work",
"(",
"cts_file",
",",
"textgroup",
")",
"except",
"Exception",
"as",
"E",
":",
"self",
".",
"logger",
".",
"error",
... | Wraps with a Try/Except the Work parsing from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:return: Parsed Work and the Texts, as well as the current file dir... | [
"Wraps",
"with",
"a",
"Try",
"/",
"Except",
"the",
"Work",
"parsing",
"from",
"a",
"cts",
"file"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L151-L165 | train | Wraps with a Try - Except the Work parsing from a CTS file and returns a Parsed Work and the Texts as well as the current file directory. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._parse_work | def _parse_work(self, cts_file, textgroup):
""" Parses a work from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:return: Parsed Work and the Texts, as... | python | def _parse_work(self, cts_file, textgroup):
""" Parses a work from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:return: Parsed Work and the Texts, as... | [
"def",
"_parse_work",
"(",
"self",
",",
"cts_file",
",",
"textgroup",
")",
":",
"with",
"io",
".",
"open",
"(",
"cts_file",
")",
"as",
"__xml__",
":",
"work",
",",
"texts",
"=",
"self",
".",
"classes",
"[",
"\"work\"",
"]",
".",
"parse",
"(",
"resour... | Parses a work from a cts file
:param cts_file: Path to the CTS File
:type cts_file: str
:param textgroup: Textgroup to which the Work is a part of
:type textgroup: CtsTextgroupMetadata
:return: Parsed Work and the Texts, as well as the current file directory | [
"Parses",
"a",
"work",
"from",
"a",
"cts",
"file"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L167-L183 | train | Parses a Work from a CTS file and returns a list of work and texts as well as the current file directory |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._parse_text | def _parse_text(self, text, directory):
""" Complete the TextMetadata object with its citation scheme by parsing the original text
:param text: Text Metadata collection
:type text: XmlCtsTextMetadata
:param directory: Directory in which the metadata was found and where the text file sho... | python | def _parse_text(self, text, directory):
""" Complete the TextMetadata object with its citation scheme by parsing the original text
:param text: Text Metadata collection
:type text: XmlCtsTextMetadata
:param directory: Directory in which the metadata was found and where the text file sho... | [
"def",
"_parse_text",
"(",
"self",
",",
"text",
",",
"directory",
")",
":",
"text_id",
",",
"text_metadata",
"=",
"text",
".",
"id",
",",
"text",
"text_metadata",
".",
"path",
"=",
"\"{directory}/{textgroup}.{work}.{version}.xml\"",
".",
"format",
"(",
"director... | Complete the TextMetadata object with its citation scheme by parsing the original text
:param text: Text Metadata collection
:type text: XmlCtsTextMetadata
:param directory: Directory in which the metadata was found and where the text file should be
:type directory: str
:returns... | [
"Complete",
"the",
"TextMetadata",
"object",
"with",
"its",
"citation",
"scheme",
"by",
"parsing",
"the",
"original",
"text"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L185-L235 | train | Complete the TextMetadata object with its citation scheme by parsing the original text. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._dispatch | def _dispatch(self, textgroup, directory):
""" Run the dispatcher over a textgroup.
:param textgroup: Textgroup object that needs to be dispatched
:param directory: Directory in which the textgroup was found
"""
if textgroup.id in self.dispatcher.collection:
self.dis... | python | def _dispatch(self, textgroup, directory):
""" Run the dispatcher over a textgroup.
:param textgroup: Textgroup object that needs to be dispatched
:param directory: Directory in which the textgroup was found
"""
if textgroup.id in self.dispatcher.collection:
self.dis... | [
"def",
"_dispatch",
"(",
"self",
",",
"textgroup",
",",
"directory",
")",
":",
"if",
"textgroup",
".",
"id",
"in",
"self",
".",
"dispatcher",
".",
"collection",
":",
"self",
".",
"dispatcher",
".",
"collection",
"[",
"textgroup",
".",
"id",
"]",
".",
"... | Run the dispatcher over a textgroup.
:param textgroup: Textgroup object that needs to be dispatched
:param directory: Directory in which the textgroup was found | [
"Run",
"the",
"dispatcher",
"over",
"a",
"textgroup",
"."
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L237-L250 | train | Dispatches a given textgroup over a directory. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver._dispatch_container | def _dispatch_container(self, textgroup, directory):
""" Run the dispatcher over a textgroup within a try/except block
.. note:: This extraction allows to change the dispatch routine \
without having to care for the error dispatching
:param textgroup: Textgroup object that needs to... | python | def _dispatch_container(self, textgroup, directory):
""" Run the dispatcher over a textgroup within a try/except block
.. note:: This extraction allows to change the dispatch routine \
without having to care for the error dispatching
:param textgroup: Textgroup object that needs to... | [
"def",
"_dispatch_container",
"(",
"self",
",",
"textgroup",
",",
"directory",
")",
":",
"try",
":",
"self",
".",
"_dispatch",
"(",
"textgroup",
",",
"directory",
")",
"except",
"UndispatchedTextError",
"as",
"E",
":",
"self",
".",
"logger",
".",
"error",
... | Run the dispatcher over a textgroup within a try/except block
.. note:: This extraction allows to change the dispatch routine \
without having to care for the error dispatching
:param textgroup: Textgroup object that needs to be dispatched
:param directory: Directory in which the t... | [
"Run",
"the",
"dispatcher",
"over",
"a",
"textgroup",
"within",
"a",
"try",
"/",
"except",
"block"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L252-L266 | train | Dispatches the given textgroup into the specified directory. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.parse | def parse(self, resource):
""" Parse a list of directories and reads it into a collection
:param resource: List of folders
:return: An inventory resource and a list of CtsTextMetadata metadata-objects
"""
textgroups = []
texts = []
invalids = []
for fold... | python | def parse(self, resource):
""" Parse a list of directories and reads it into a collection
:param resource: List of folders
:return: An inventory resource and a list of CtsTextMetadata metadata-objects
"""
textgroups = []
texts = []
invalids = []
for fold... | [
"def",
"parse",
"(",
"self",
",",
"resource",
")",
":",
"textgroups",
"=",
"[",
"]",
"texts",
"=",
"[",
"]",
"invalids",
"=",
"[",
"]",
"for",
"folder",
"in",
"resource",
":",
"cts_files",
"=",
"glob",
"(",
"\"{base_folder}/data/*/__cts__.xml\"",
".",
"f... | Parse a list of directories and reads it into a collection
:param resource: List of folders
:return: An inventory resource and a list of CtsTextMetadata metadata-objects | [
"Parse",
"a",
"list",
"of",
"directories",
"and",
"reads",
"it",
"into",
"a",
"collection"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L276-L312 | train | Parse a list of directories and reads it into a collection
|
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.pagination | def pagination(page, limit, length):
""" Help for pagination
:param page: Provided Page
:param limit: Number of item to show
:param length: Length of the list to paginate
:return: (Start Index, End Index, Page Number, Item Count)
"""
realpage = page
page =... | python | def pagination(page, limit, length):
""" Help for pagination
:param page: Provided Page
:param limit: Number of item to show
:param length: Length of the list to paginate
:return: (Start Index, End Index, Page Number, Item Count)
"""
realpage = page
page =... | [
"def",
"pagination",
"(",
"page",
",",
"limit",
",",
"length",
")",
":",
"realpage",
"=",
"page",
"page",
"=",
"page",
"or",
"CtsCapitainsLocalResolver",
".",
"DEFAULT_PAGE",
"limit",
"=",
"limit",
"or",
"CtsCapitainsLocalResolver",
".",
"PER_PAGE",
"[",
"1",
... | Help for pagination
:param page: Provided Page
:param limit: Number of item to show
:param length: Length of the list to paginate
:return: (Start Index, End Index, Page Number, Item Count) | [
"Help",
"for",
"pagination",
":",
"param",
"page",
":",
"Provided",
"Page",
":",
"param",
"limit",
":",
"Number",
"of",
"item",
"to",
"show",
":",
"param",
"length",
":",
"Length",
"of",
"the",
"list",
"to",
"paginate",
":",
"return",
":",
"(",
"Start"... | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L399-L424 | train | Help for pagination of the items in a list of items. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.getMetadata | def getMetadata(self, objectId=None, **filters):
""" Request metadata about a text or a collection
:param objectId: Object Identifier to filter on
:type objectId: str
:param filters: Kwargs parameters.
:type filters: dict
:return: Collection
"""
if object... | python | def getMetadata(self, objectId=None, **filters):
""" Request metadata about a text or a collection
:param objectId: Object Identifier to filter on
:type objectId: str
:param filters: Kwargs parameters.
:type filters: dict
:return: Collection
"""
if object... | [
"def",
"getMetadata",
"(",
"self",
",",
"objectId",
"=",
"None",
",",
"*",
"*",
"filters",
")",
":",
"if",
"objectId",
"is",
"None",
":",
"return",
"self",
".",
"inventory",
"elif",
"objectId",
"in",
"self",
".",
"inventory",
".",
"children",
".",
"key... | Request metadata about a text or a collection
:param objectId: Object Identifier to filter on
:type objectId: str
:param filters: Kwargs parameters.
:type filters: dict
:return: Collection | [
"Request",
"metadata",
"about",
"a",
"text",
"or",
"a",
"collection"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L426-L470 | train | Request metadata about a text or a collection of objects. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.getTextualNode | def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False):
""" Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:param pre... | python | def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False):
""" Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:param pre... | [
"def",
"getTextualNode",
"(",
"self",
",",
"textId",
",",
"subreference",
"=",
"None",
",",
"prevnext",
"=",
"False",
",",
"metadata",
"=",
"False",
")",
":",
"text",
",",
"text_metadata",
"=",
"self",
".",
"__getText__",
"(",
"textId",
")",
"if",
"subre... | Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:param prevnext: Retrieve graph representing previous and next passage
:type prevnext: boolean
... | [
"Retrieve",
"a",
"text",
"node",
"from",
"the",
"API"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L472-L492 | train | Retrieve a text node from the API and return it |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.getSiblings | def getSiblings(self, textId, subreference: CtsReference):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:return: Tuple of references
... | python | def getSiblings(self, textId, subreference: CtsReference):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:return: Tuple of references
... | [
"def",
"getSiblings",
"(",
"self",
",",
"textId",
",",
"subreference",
":",
"CtsReference",
")",
":",
"text",
",",
"inventory",
"=",
"self",
".",
"__getText__",
"(",
"textId",
")",
"if",
"not",
"isinstance",
"(",
"subreference",
",",
"CtsReference",
")",
"... | Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:return: Tuple of references
:rtype: (str, str) | [
"Retrieve",
"the",
"siblings",
"of",
"a",
"textual",
"node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L494-L508 | train | Retrieve the siblings of a textual node. |
Capitains/MyCapytain | MyCapytain/resolvers/cts/local.py | CtsCapitainsLocalResolver.getReffs | def getReffs(self, textId, level=1, subreference=None):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage CtsReference
... | python | def getReffs(self, textId, level=1, subreference=None):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage CtsReference
... | [
"def",
"getReffs",
"(",
"self",
",",
"textId",
",",
"level",
"=",
"1",
",",
"subreference",
"=",
"None",
")",
":",
"passage",
",",
"inventory",
"=",
"self",
".",
"__getText__",
"(",
"textId",
")",
"if",
"subreference",
":",
"passage",
"=",
"passage",
"... | Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage CtsReference
:type subreference: str
:return: List of references
... | [
"Retrieve",
"the",
"siblings",
"of",
"a",
"textual",
"node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/local.py#L510-L525 | train | Retrieve the siblings of a textual node. |
SHDShim/pytheos | pytheos/conversion.py | velocities_to_moduli | def velocities_to_moduli(rho, v_phi, v_s):
"""
convert velocities to moduli
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: bulk sound speed in m/s
:param v_s: shear velocity in m/s
:return: K_s and G
"""
return v_phi * v_phi * rho, v_s * v_s * rho | python | def velocities_to_moduli(rho, v_phi, v_s):
"""
convert velocities to moduli
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: bulk sound speed in m/s
:param v_s: shear velocity in m/s
:return: K_s and G
"""
return v_phi * v_phi * rho, v_s * v_s * rho | [
"def",
"velocities_to_moduli",
"(",
"rho",
",",
"v_phi",
",",
"v_s",
")",
":",
"return",
"v_phi",
"*",
"v_phi",
"*",
"rho",
",",
"v_s",
"*",
"v_s",
"*",
"rho"
] | convert velocities to moduli
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: bulk sound speed in m/s
:param v_s: shear velocity in m/s
:return: K_s and G | [
"convert",
"velocities",
"to",
"moduli",
"mainly",
"to",
"support",
"Burnman",
"operations"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/conversion.py#L5-L15 | train | convert velocities to moduli
|
SHDShim/pytheos | pytheos/conversion.py | moduli_to_velocities | def moduli_to_velocities(rho, K_s, G):
"""
convert moduli to velocities
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: adiabatic bulk modulus in Pa
:param v_s: shear modulus in Pa
:return: bulk sound speed and shear velocity
"""
return np.sqrt(K_s /... | python | def moduli_to_velocities(rho, K_s, G):
"""
convert moduli to velocities
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: adiabatic bulk modulus in Pa
:param v_s: shear modulus in Pa
:return: bulk sound speed and shear velocity
"""
return np.sqrt(K_s /... | [
"def",
"moduli_to_velocities",
"(",
"rho",
",",
"K_s",
",",
"G",
")",
":",
"return",
"np",
".",
"sqrt",
"(",
"K_s",
"/",
"rho",
")",
",",
"np",
".",
"sqrt",
"(",
"G",
"/",
"rho",
")"
] | convert moduli to velocities
mainly to support Burnman operations
:param rho: density in kg/m^3
:param v_phi: adiabatic bulk modulus in Pa
:param v_s: shear modulus in Pa
:return: bulk sound speed and shear velocity | [
"convert",
"moduli",
"to",
"velocities",
"mainly",
"to",
"support",
"Burnman",
"operations"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/conversion.py#L18-L28 | train | convert moduli to velocities
|
SHDShim/pytheos | pytheos/eqn_jamieson.py | jamieson_pst | def jamieson_pst(v, v0, c0, s, gamma0, q, theta0, n, z, mass, c_v,
three_r=3. * constants.R, t_ref=300.):
"""
calculate static pressure at 300 K from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param ... | python | def jamieson_pst(v, v0, c0, s, gamma0, q, theta0, n, z, mass, c_v,
three_r=3. * constants.R, t_ref=300.):
"""
calculate static pressure at 300 K from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param ... | [
"def",
"jamieson_pst",
"(",
"v",
",",
"v0",
",",
"c0",
",",
"s",
",",
"gamma0",
",",
"q",
",",
"theta0",
",",
"n",
",",
"z",
",",
"mass",
",",
"c_v",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
",",
"t_ref",
"=",
"300.",
")",
":",
... | calculate static pressure at 300 K from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param gamma0: Gruneisen parameter at 1 bar
:param q: ... | [
"calculate",
"static",
"pressure",
"at",
"300",
"K",
"from",
"Hugoniot",
"data",
"using",
"the",
"constq",
"formulation"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_jamieson.py#L30-L59 | train | calculate static pressure at 300 K from Hugoniot data using the constq
|
SHDShim/pytheos | pytheos/eqn_jamieson.py | jamieson_pth | def jamieson_pth(v, v0, c0, s, gamma0, q, theta0, n, z, mass, c_v,
three_r=3. * constants.R, t_ref=300.):
"""
calculate thermal pressure from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param c0: velo... | python | def jamieson_pth(v, v0, c0, s, gamma0, q, theta0, n, z, mass, c_v,
three_r=3. * constants.R, t_ref=300.):
"""
calculate thermal pressure from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param c0: velo... | [
"def",
"jamieson_pth",
"(",
"v",
",",
"v0",
",",
"c0",
",",
"s",
",",
"gamma0",
",",
"q",
",",
"theta0",
",",
"n",
",",
"z",
",",
"mass",
",",
"c_v",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
",",
"t_ref",
"=",
"300.",
")",
":",
... | calculate thermal pressure from Hugoniot data using the constq
formulation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarith... | [
"calculate",
"thermal",
"pressure",
"from",
"Hugoniot",
"data",
"using",
"the",
"constq",
"formulation"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_jamieson.py#L62-L91 | train | calculate thermal pressure from Hugoniot data using constq_pth |
SHDShim/pytheos | pytheos/eqn_jamieson.py | hugoniot_p_nlin | def hugoniot_p_nlin(rho, rho0, a, b, c):
"""
calculate pressure along a Hugoniot throug nonlinear equations
presented in Jameison 1982
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param a: prefactor for nonlinear fit of Hugoniot data
:param b: prefactor for nonline... | python | def hugoniot_p_nlin(rho, rho0, a, b, c):
"""
calculate pressure along a Hugoniot throug nonlinear equations
presented in Jameison 1982
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param a: prefactor for nonlinear fit of Hugoniot data
:param b: prefactor for nonline... | [
"def",
"hugoniot_p_nlin",
"(",
"rho",
",",
"rho0",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"eta",
"=",
"1.",
"-",
"(",
"rho0",
"/",
"rho",
")",
"Up",
"=",
"np",
".",
"zeros_like",
"(",
"eta",
")",
"if",
"isuncertainties",
"(",
"[",
"rho",
",",
... | calculate pressure along a Hugoniot throug nonlinear equations
presented in Jameison 1982
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param a: prefactor for nonlinear fit of Hugoniot data
:param b: prefactor for nonlinear fit of Hugoniot data
:param c: prefactor for n... | [
"calculate",
"pressure",
"along",
"a",
"Hugoniot",
"throug",
"nonlinear",
"equations",
"presented",
"in",
"Jameison",
"1982"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_jamieson.py#L94-L118 | train | calculate pressure along a Hugoniot throug nonlinear equation in Jameison 1982 |
Capitains/MyCapytain | MyCapytain/common/reference/_dts_1.py | DtsCitation.ingest | def ingest(cls, resource, root=None, **kwargs):
""" Ingest a dictionary of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: dict
:pa... | python | def ingest(cls, resource, root=None, **kwargs):
""" Ingest a dictionary of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: dict
:pa... | [
"def",
"ingest",
"(",
"cls",
",",
"resource",
",",
"root",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"cite",
"=",
"cls",
"(",
"name",
"=",
"resource",
".",
"get",
"(",
"_cite_type_term",
",",
"[",
"{",
"\"@value\"",
":",
"None",
"}",
"]",
"... | Ingest a dictionary of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: dict
:param root: Root of the citation tree
:type root: Base... | [
"Ingest",
"a",
"dictionary",
"of",
"DTS",
"Citation",
"object",
"(",
"as",
"parsed",
"JSON",
"-",
"LD",
")",
"and",
"creates",
"the",
"Citation",
"Graph"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_dts_1.py#L79-L96 | train | Ingest a dictionary of DTS Citation objects into a new Citation Graph |
Capitains/MyCapytain | MyCapytain/common/reference/_dts_1.py | DtsCitationSet.ingest | def ingest(cls, resource):
""" Ingest a list of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: list
:return: Citation Graph
... | python | def ingest(cls, resource):
""" Ingest a list of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: list
:return: Citation Graph
... | [
"def",
"ingest",
"(",
"cls",
",",
"resource",
")",
":",
"_set",
"=",
"cls",
"(",
")",
"for",
"data",
"in",
"resource",
":",
"_set",
".",
"add_child",
"(",
"cls",
".",
"CitationClass",
".",
"ingest",
"(",
"data",
",",
"root",
"=",
"_set",
")",
")",
... | Ingest a list of DTS Citation object (as parsed JSON-LD) and
creates the Citation Graph
:param resource: List of Citation objects from the
DTS Collection Endpoint (as expanded JSON-LD)
:type resource: list
:return: Citation Graph | [
"Ingest",
"a",
"list",
"of",
"DTS",
"Citation",
"object",
"(",
"as",
"parsed",
"JSON",
"-",
"LD",
")",
"and",
"creates",
"the",
"Citation",
"Graph"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_dts_1.py#L130-L144 | train | Ingest a list of DTS Citation objects from the DTS Collection Endpoint and creates the Citation Graphical Set |
DemocracyClub/uk-geo-utils | uk_geo_utils/helpers.py | AddressFormatter.generate_address_label | def generate_address_label(self):
"""Construct a list for address label.
Non-empty premises elements are appended to the address label in the
order of organisation_name, department_name, po_box_number (which
must be prepended with 'PO Box', sub_building_name, building_name,
buil... | python | def generate_address_label(self):
"""Construct a list for address label.
Non-empty premises elements are appended to the address label in the
order of organisation_name, department_name, po_box_number (which
must be prepended with 'PO Box', sub_building_name, building_name,
buil... | [
"def",
"generate_address_label",
"(",
"self",
")",
":",
"if",
"self",
".",
"organisation_name",
":",
"self",
".",
"address_label",
".",
"append",
"(",
"self",
".",
"organisation_name",
")",
"if",
"self",
".",
"department_name",
":",
"self",
".",
"address_label... | Construct a list for address label.
Non-empty premises elements are appended to the address label in the
order of organisation_name, department_name, po_box_number (which
must be prepended with 'PO Box', sub_building_name, building_name,
building_number, then the rest of the elements ex... | [
"Construct",
"a",
"list",
"for",
"address",
"label",
"."
] | ea5513968c85e93f004a3079342a62662357c2c9 | https://github.com/DemocracyClub/uk-geo-utils/blob/ea5513968c85e93f004a3079342a62662357c2c9/uk_geo_utils/helpers.py#L82-L121 | train | Generate a list of address label for the current instance of the class. |
DemocracyClub/uk-geo-utils | uk_geo_utils/helpers.py | AddressFormatter._is_exception_rule | def _is_exception_rule(self, element):
""" Check for "exception rule".
Address elements will be appended onto a new line on the lable except
for when the penultimate lable line fulfils certain criteria, in which
case the element will be concatenated onto the penultimate line. This
... | python | def _is_exception_rule(self, element):
""" Check for "exception rule".
Address elements will be appended onto a new line on the lable except
for when the penultimate lable line fulfils certain criteria, in which
case the element will be concatenated onto the penultimate line. This
... | [
"def",
"_is_exception_rule",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
"and",
"element",
"[",
"-",
"1",
"]",
".",
"isdigit",
"(",
")",
":",
"return",
"True",
"if",
"len",
"(",
"element",
")",
... | Check for "exception rule".
Address elements will be appended onto a new line on the lable except
for when the penultimate lable line fulfils certain criteria, in which
case the element will be concatenated onto the penultimate line. This
method checks for those criteria.
i) Fi... | [
"Check",
"for",
"exception",
"rule",
"."
] | ea5513968c85e93f004a3079342a62662357c2c9 | https://github.com/DemocracyClub/uk-geo-utils/blob/ea5513968c85e93f004a3079342a62662357c2c9/uk_geo_utils/helpers.py#L123-L143 | train | Check if the element is an exception rule. |
DemocracyClub/uk-geo-utils | uk_geo_utils/helpers.py | AddressFormatter._append_to_label | def _append_to_label(self, element):
"""Append address element to the label.
Normally an element will be appended onto the list, except where the
existing last element fulfils the exception rule, in which case the
element will be concatenated onto the final list member.
"""
... | python | def _append_to_label(self, element):
"""Append address element to the label.
Normally an element will be appended onto the list, except where the
existing last element fulfils the exception rule, in which case the
element will be concatenated onto the final list member.
"""
... | [
"def",
"_append_to_label",
"(",
"self",
",",
"element",
")",
":",
"if",
"len",
"(",
"self",
".",
"address_label",
")",
">",
"0",
"and",
"self",
".",
"_is_exception_rule",
"(",
"self",
".",
"address_label",
"[",
"-",
"1",
"]",
")",
":",
"self",
".",
"... | Append address element to the label.
Normally an element will be appended onto the list, except where the
existing last element fulfils the exception rule, in which case the
element will be concatenated onto the final list member. | [
"Append",
"address",
"element",
"to",
"the",
"label",
"."
] | ea5513968c85e93f004a3079342a62662357c2c9 | https://github.com/DemocracyClub/uk-geo-utils/blob/ea5513968c85e93f004a3079342a62662357c2c9/uk_geo_utils/helpers.py#L145-L156 | train | Append an element to the label. |
projectshift/shift-schema | shiftschema/validators/multichoice.py | MultiChoice.validate | def validate(self, value, model=None, context=None):
"""
Validate
Perform value validation against validation settings and return
error object.
:param value: list, value to check
:param model: parent model being validated
:param context: ... | python | def validate(self, value, model=None, context=None):
"""
Validate
Perform value validation against validation settings and return
error object.
:param value: list, value to check
:param model: parent model being validated
:param context: ... | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"invalid",
"=",
"[",
"item",
"for",
"item",
"in",
"value",
"if",
"item",
"not",
"in",
"self",
".",
"choices",
"]",
"if",
"len",
"(",
"... | Validate
Perform value validation against validation settings and return
error object.
:param value: list, value to check
:param model: parent model being validated
:param context: object or None, validation context
:return: shi... | [
"Validate",
"Perform",
"value",
"validation",
"against",
"validation",
"settings",
"and",
"return",
"error",
"object",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/multichoice.py#L34-L53 | train | Validate the value of a key - value pair against the validation settings and return a new error object. |
weijia/djangoautoconf | djangoautoconf/django_zip_template_loader.py | load_template_source | def load_template_source(template_name, template_dirs=None):
"""Template loader that loads templates from a ZIP file."""
template_zipfiles = getattr(settings, "TEMPLATE_ZIP_FILES", [])
# Try each ZIP file in TEMPLATE_ZIP_FILES.
for fname in template_zipfiles:
try:
z = zipfile.ZipFil... | python | def load_template_source(template_name, template_dirs=None):
"""Template loader that loads templates from a ZIP file."""
template_zipfiles = getattr(settings, "TEMPLATE_ZIP_FILES", [])
# Try each ZIP file in TEMPLATE_ZIP_FILES.
for fname in template_zipfiles:
try:
z = zipfile.ZipFil... | [
"def",
"load_template_source",
"(",
"template_name",
",",
"template_dirs",
"=",
"None",
")",
":",
"template_zipfiles",
"=",
"getattr",
"(",
"settings",
",",
"\"TEMPLATE_ZIP_FILES\"",
",",
"[",
"]",
")",
"# Try each ZIP file in TEMPLATE_ZIP_FILES.",
"for",
"fname",
"in... | Template loader that loads templates from a ZIP file. | [
"Template",
"loader",
"that",
"loads",
"templates",
"from",
"a",
"ZIP",
"file",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/django_zip_template_loader.py#L6-L23 | train | Template loader that loads templates from a ZIP file. |
mangalam-research/selenic | selenic/remote/browserstack.py | sanitize_capabilities | def sanitize_capabilities(caps):
"""
Sanitize the capabilities we pass to Selenic so that they can
be consumed by Browserstack.
:param caps: The capabilities passed to Selenic. This dictionary
is modified.
:returns: The sanitized capabilities.
"""
platform = caps["platform"]
upper... | python | def sanitize_capabilities(caps):
"""
Sanitize the capabilities we pass to Selenic so that they can
be consumed by Browserstack.
:param caps: The capabilities passed to Selenic. This dictionary
is modified.
:returns: The sanitized capabilities.
"""
platform = caps["platform"]
upper... | [
"def",
"sanitize_capabilities",
"(",
"caps",
")",
":",
"platform",
"=",
"caps",
"[",
"\"platform\"",
"]",
"upper_platform",
"=",
"platform",
".",
"upper",
"(",
")",
"if",
"upper_platform",
".",
"startswith",
"(",
"\"WINDOWS 8\"",
")",
":",
"caps",
"[",
"\"pl... | Sanitize the capabilities we pass to Selenic so that they can
be consumed by Browserstack.
:param caps: The capabilities passed to Selenic. This dictionary
is modified.
:returns: The sanitized capabilities. | [
"Sanitize",
"the",
"capabilities",
"we",
"pass",
"to",
"Selenic",
"so",
"that",
"they",
"can",
"be",
"consumed",
"by",
"Browserstack",
"."
] | 2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad | https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/remote/browserstack.py#L154-L186 | train | Sanitize the capabilities passed to Selenic so that they can be consumed by Browserstack. |
pmacosta/pexdoc | docs/support/pinspect_example_1.py | my_func | def my_func(version): # noqa: D202
"""Enclosing function."""
class MyClass(object):
"""Enclosed class."""
if version == 2:
import docs.support.python2_module as pm
else:
import docs.support.python3_module as pm
def __init__(self, value):
se... | python | def my_func(version): # noqa: D202
"""Enclosing function."""
class MyClass(object):
"""Enclosed class."""
if version == 2:
import docs.support.python2_module as pm
else:
import docs.support.python3_module as pm
def __init__(self, value):
se... | [
"def",
"my_func",
"(",
"version",
")",
":",
"# noqa: D202",
"class",
"MyClass",
"(",
"object",
")",
":",
"\"\"\"Enclosed class.\"\"\"",
"if",
"version",
"==",
"2",
":",
"import",
"docs",
".",
"support",
".",
"python2_module",
"as",
"pm",
"else",
":",
"import... | Enclosing function. | [
"Enclosing",
"function",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/docs/support/pinspect_example_1.py#L10-L27 | train | This is a function that is used by the object constructor. |
mediawiki-utilities/python-mwpersistence | mwpersistence/state.py | persist_revision_once | def persist_revision_once(tokens, revision):
"""
This function makes sure that a revision is only marked as persisting
for a token once. This is important since some diff algorithms allow
tokens to be copied more than once in a revision. The id(token) should
unique to the in-memory representation ... | python | def persist_revision_once(tokens, revision):
"""
This function makes sure that a revision is only marked as persisting
for a token once. This is important since some diff algorithms allow
tokens to be copied more than once in a revision. The id(token) should
unique to the in-memory representation ... | [
"def",
"persist_revision_once",
"(",
"tokens",
",",
"revision",
")",
":",
"token_map",
"=",
"{",
"id",
"(",
"token",
")",
":",
"token",
"for",
"token",
"in",
"tokens",
"}",
"for",
"token",
"in",
"token_map",
".",
"values",
"(",
")",
":",
"token",
".",
... | This function makes sure that a revision is only marked as persisting
for a token once. This is important since some diff algorithms allow
tokens to be copied more than once in a revision. The id(token) should
unique to the in-memory representation of any object, so we use that as
unique token instanc... | [
"This",
"function",
"makes",
"sure",
"that",
"a",
"revision",
"is",
"only",
"marked",
"as",
"persisting",
"for",
"a",
"token",
"once",
".",
"This",
"is",
"important",
"since",
"some",
"diff",
"algorithms",
"allow",
"tokens",
"to",
"be",
"copied",
"more",
"... | 2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d | https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/state.py#L219-L229 | train | This function ensures that a revision is only persisted for a given list of tokens once. |
mediawiki-utilities/python-mwpersistence | mwpersistence/state.py | DiffState.update | def update(self, text, revision=None):
"""
Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
text : str
The text content of a revision
revision : `mixed`
Revisio... | python | def update(self, text, revision=None):
"""
Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
text : str
The text content of a revision
revision : `mixed`
Revisio... | [
"def",
"update",
"(",
"self",
",",
"text",
",",
"revision",
"=",
"None",
")",
":",
"return",
"self",
".",
"_update",
"(",
"text",
"=",
"text",
",",
"revision",
"=",
"revision",
")"
] | Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
text : str
The text content of a revision
revision : `mixed`
Revision metadata
:Returns:
A triple of lists... | [
"Modifies",
"the",
"internal",
"state",
"based",
"a",
"change",
"to",
"the",
"content",
"and",
"returns",
"the",
"sets",
"of",
"words",
"added",
"and",
"removed",
"."
] | 2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d | https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/state.py#L113-L135 | train | Updates the internal state based a change to the content and returns
the sets of words added and removed. |
mediawiki-utilities/python-mwpersistence | mwpersistence/state.py | DiffState.update_opdocs | def update_opdocs(self, checksum, opdocs, revision=None):
"""
Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
checksum : `hashable`
A checksum generated from the text of a revision
... | python | def update_opdocs(self, checksum, opdocs, revision=None):
"""
Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
checksum : `hashable`
A checksum generated from the text of a revision
... | [
"def",
"update_opdocs",
"(",
"self",
",",
"checksum",
",",
"opdocs",
",",
"revision",
"=",
"None",
")",
":",
"return",
"self",
".",
"_update",
"(",
"checksum",
"=",
"checksum",
",",
"opdocs",
"=",
"opdocs",
",",
"revision",
"=",
"revision",
")"
] | Modifies the internal state based a change to the content and returns
the sets of words added and removed.
:Parameters:
checksum : `hashable`
A checksum generated from the text of a revision
opdocs : `iterable` ( `dict` )
A sequence of operations ... | [
"Modifies",
"the",
"internal",
"state",
"based",
"a",
"change",
"to",
"the",
"content",
"and",
"returns",
"the",
"sets",
"of",
"words",
"added",
"and",
"removed",
"."
] | 2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d | https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/state.py#L137-L163 | train | Updates the internal state based a change to the content and returns the internal state based a change to the content and returns
|
AASHE/python-membersuite-api-client | membersuite_api_client/subscriptions/services.py | SubscriptionService.get_subscriptions | def get_subscriptions(self, publication_id=None, owner_id=None,
since_when=None, limit_to=200, max_calls=None,
start_record=0, verbose=False):
"""
Fetches all subscriptions from Membersuite of a particular
`publication_id` if set.
"""
... | python | def get_subscriptions(self, publication_id=None, owner_id=None,
since_when=None, limit_to=200, max_calls=None,
start_record=0, verbose=False):
"""
Fetches all subscriptions from Membersuite of a particular
`publication_id` if set.
"""
... | [
"def",
"get_subscriptions",
"(",
"self",
",",
"publication_id",
"=",
"None",
",",
"owner_id",
"=",
"None",
",",
"since_when",
"=",
"None",
",",
"limit_to",
"=",
"200",
",",
"max_calls",
"=",
"None",
",",
"start_record",
"=",
"0",
",",
"verbose",
"=",
"Fa... | Fetches all subscriptions from Membersuite of a particular
`publication_id` if set. | [
"Fetches",
"all",
"subscriptions",
"from",
"Membersuite",
"of",
"a",
"particular",
"publication_id",
"if",
"set",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/subscriptions/services.py#L27-L58 | train | Fetches all subscriptions from Membersuite of a particular publication_id. |
a1ezzz/wasp-general | wasp_general/network/clients/ftp.py | WFTPClient.connect | def connect(self):
""" :meth:`.WNetworkClientProto.connect` method implementation
"""
exceptions = list(__basic_ftp_exceptions__)
exceptions.append(OSError) # OSError for "no route to host" issue
exceptions.append(ConnectionRefusedError) # for unavailable service on a host
try:
self.ftp_client().conne... | python | def connect(self):
""" :meth:`.WNetworkClientProto.connect` method implementation
"""
exceptions = list(__basic_ftp_exceptions__)
exceptions.append(OSError) # OSError for "no route to host" issue
exceptions.append(ConnectionRefusedError) # for unavailable service on a host
try:
self.ftp_client().conne... | [
"def",
"connect",
"(",
"self",
")",
":",
"exceptions",
"=",
"list",
"(",
"__basic_ftp_exceptions__",
")",
"exceptions",
".",
"append",
"(",
"OSError",
")",
"# OSError for \"no route to host\" issue",
"exceptions",
".",
"append",
"(",
"ConnectionRefusedError",
")",
"... | :meth:`.WNetworkClientProto.connect` method implementation | [
":",
"meth",
":",
".",
"WNetworkClientProto",
".",
"connect",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/ftp.py#L72-L92 | train | :meth :. WNetworkClientProto. connect method implementation
|
a1ezzz/wasp-general | wasp_general/network/clients/ftp.py | WFTPClient.scheme_specification | def scheme_specification(cls):
""" :meth:`.WSchemeHandler.scheme_specification` method implementation
"""
return WSchemeSpecification(
'ftp',
WURIComponentVerifier(WURI.Component.username, WURIComponentVerifier.Requirement.optional),
WURIComponentVerifier(WURI.Component.password, WURIComponentVerifier.Re... | python | def scheme_specification(cls):
""" :meth:`.WSchemeHandler.scheme_specification` method implementation
"""
return WSchemeSpecification(
'ftp',
WURIComponentVerifier(WURI.Component.username, WURIComponentVerifier.Requirement.optional),
WURIComponentVerifier(WURI.Component.password, WURIComponentVerifier.Re... | [
"def",
"scheme_specification",
"(",
"cls",
")",
":",
"return",
"WSchemeSpecification",
"(",
"'ftp'",
",",
"WURIComponentVerifier",
"(",
"WURI",
".",
"Component",
".",
"username",
",",
"WURIComponentVerifier",
".",
"Requirement",
".",
"optional",
")",
",",
"WURICom... | :meth:`.WSchemeHandler.scheme_specification` method implementation | [
":",
"meth",
":",
".",
"WSchemeHandler",
".",
"scheme_specification",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/ftp.py#L100-L109 | train | returns a new instance of WSchemeSpecification |
a1ezzz/wasp-general | wasp_general/network/clients/ftp.py | WFTPClient.upload_file | def upload_file(self, file_name, file_obj, *args, **kwargs):
""" :meth:`.WNetworkClientProto.upload_file` method implementation
"""
self.ftp_client().storbinary('STOR ' + file_name, file_obj) | python | def upload_file(self, file_name, file_obj, *args, **kwargs):
""" :meth:`.WNetworkClientProto.upload_file` method implementation
"""
self.ftp_client().storbinary('STOR ' + file_name, file_obj) | [
"def",
"upload_file",
"(",
"self",
",",
"file_name",
",",
"file_obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"ftp_client",
"(",
")",
".",
"storbinary",
"(",
"'STOR '",
"+",
"file_name",
",",
"file_obj",
")"
] | :meth:`.WNetworkClientProto.upload_file` method implementation | [
":",
"meth",
":",
".",
"WNetworkClientProto",
".",
"upload_file",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/ftp.py#L150-L153 | train | method implementation
self. ftp_client. upload_file |
aychedee/unchained | unchained/fields.py | JSONField.get_prep_value | def get_prep_value(self, value):
'''The psycopg adaptor returns Python objects,
but we also have to handle conversion ourselves
'''
if isinstance(value, JSON.JsonDict):
return json.dumps(value, cls=JSON.Encoder)
if isinstance(value, JSON.JsonList):
ret... | python | def get_prep_value(self, value):
'''The psycopg adaptor returns Python objects,
but we also have to handle conversion ourselves
'''
if isinstance(value, JSON.JsonDict):
return json.dumps(value, cls=JSON.Encoder)
if isinstance(value, JSON.JsonList):
ret... | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"JSON",
".",
"JsonDict",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"value",
",",
"cls",
"=",
"JSON",
".",
"Encoder",
")",
"if",
"isinstance",
"(... | The psycopg adaptor returns Python objects,
but we also have to handle conversion ourselves | [
"The",
"psycopg",
"adaptor",
"returns",
"Python",
"objects",
"but",
"we",
"also",
"have",
"to",
"handle",
"conversion",
"ourselves"
] | 11d03451ee5247e66b3d6a454e1bde71f81ae357 | https://github.com/aychedee/unchained/blob/11d03451ee5247e66b3d6a454e1bde71f81ae357/unchained/fields.py#L152-L162 | train | The psycopg adaptor returns Python objects
but we also have to handle conversion ourselves |
sublee/etc | etc/helpers.py | registry | def registry(attr, base=type):
"""Generates a meta class to index sub classes by their keys."""
class Registry(base):
def __init__(cls, name, bases, attrs):
super(Registry, cls).__init__(name, bases, attrs)
if not hasattr(cls, '__registry__'):
cls.__registry__ = {... | python | def registry(attr, base=type):
"""Generates a meta class to index sub classes by their keys."""
class Registry(base):
def __init__(cls, name, bases, attrs):
super(Registry, cls).__init__(name, bases, attrs)
if not hasattr(cls, '__registry__'):
cls.__registry__ = {... | [
"def",
"registry",
"(",
"attr",
",",
"base",
"=",
"type",
")",
":",
"class",
"Registry",
"(",
"base",
")",
":",
"def",
"__init__",
"(",
"cls",
",",
"name",
",",
"bases",
",",
"attrs",
")",
":",
"super",
"(",
"Registry",
",",
"cls",
")",
".",
"__i... | Generates a meta class to index sub classes by their keys. | [
"Generates",
"a",
"meta",
"class",
"to",
"index",
"sub",
"classes",
"by",
"their",
"keys",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/helpers.py#L18-L34 | train | Generates a meta class to index sub classes by their keys. |
sublee/etc | etc/helpers.py | gen_repr | def gen_repr(cls, template, *args, **kwargs):
"""Generates a string for :func:`repr`."""
buf = io.StringIO()
buf.write(u'<')
buf.write(cls.__module__.decode() if kwargs.pop('full', False) else u'etc')
buf.write(u'.')
buf.write(cls.__name__.decode())
if not kwargs.pop('dense', False):
... | python | def gen_repr(cls, template, *args, **kwargs):
"""Generates a string for :func:`repr`."""
buf = io.StringIO()
buf.write(u'<')
buf.write(cls.__module__.decode() if kwargs.pop('full', False) else u'etc')
buf.write(u'.')
buf.write(cls.__name__.decode())
if not kwargs.pop('dense', False):
... | [
"def",
"gen_repr",
"(",
"cls",
",",
"template",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"buf",
"=",
"io",
".",
"StringIO",
"(",
")",
"buf",
".",
"write",
"(",
"u'<'",
")",
"buf",
".",
"write",
"(",
"cls",
".",
"__module__",
".",
"d... | Generates a string for :func:`repr`. | [
"Generates",
"a",
"string",
"for",
":",
"func",
":",
"repr",
"."
] | f2be64604da5af0d7739cfacf36f55712f0fc5cb | https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/helpers.py#L37-L52 | train | Generates a string for the class. |
OpenGov/og-python-utils | ogutils/loggers/default.py | build_default_logger | def build_default_logger(
logger_name='logger',
log_level=None,
log_dir=None,
console_enabled=True,
max_log_size=5*1024*1024,
max_backup_logs=5):
'''
Generates a logger that outputs messages in the same format as default Flask applications.
'''
old_logger_class = loggin... | python | def build_default_logger(
logger_name='logger',
log_level=None,
log_dir=None,
console_enabled=True,
max_log_size=5*1024*1024,
max_backup_logs=5):
'''
Generates a logger that outputs messages in the same format as default Flask applications.
'''
old_logger_class = loggin... | [
"def",
"build_default_logger",
"(",
"logger_name",
"=",
"'logger'",
",",
"log_level",
"=",
"None",
",",
"log_dir",
"=",
"None",
",",
"console_enabled",
"=",
"True",
",",
"max_log_size",
"=",
"5",
"*",
"1024",
"*",
"1024",
",",
"max_backup_logs",
"=",
"5",
... | Generates a logger that outputs messages in the same format as default Flask applications. | [
"Generates",
"a",
"logger",
"that",
"outputs",
"messages",
"in",
"the",
"same",
"format",
"as",
"default",
"Flask",
"applications",
"."
] | 00f44927383dd1bd6348f47302c4453d56963479 | https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/loggers/default.py#L117-L135 | train | Creates a logger that outputs messages in the same format as default Flask applications. |
OpenGov/og-python-utils | ogutils/loggers/default.py | DebugEvalLogger.debug_generate | def debug_generate(self, debug_generator, *gen_args, **gen_kwargs):
'''
Used for efficient debug logging, where the actual message isn't evaluated unless it
will actually be accepted by the logger.
'''
if self.isEnabledFor(logging.DEBUG):
message = debug_generat... | python | def debug_generate(self, debug_generator, *gen_args, **gen_kwargs):
'''
Used for efficient debug logging, where the actual message isn't evaluated unless it
will actually be accepted by the logger.
'''
if self.isEnabledFor(logging.DEBUG):
message = debug_generat... | [
"def",
"debug_generate",
"(",
"self",
",",
"debug_generator",
",",
"*",
"gen_args",
",",
"*",
"*",
"gen_kwargs",
")",
":",
"if",
"self",
".",
"isEnabledFor",
"(",
"logging",
".",
"DEBUG",
")",
":",
"message",
"=",
"debug_generator",
"(",
"*",
"gen_args",
... | Used for efficient debug logging, where the actual message isn't evaluated unless it
will actually be accepted by the logger. | [
"Used",
"for",
"efficient",
"debug",
"logging",
"where",
"the",
"actual",
"message",
"isn",
"t",
"evaluated",
"unless",
"it",
"will",
"actually",
"be",
"accepted",
"by",
"the",
"logger",
"."
] | 00f44927383dd1bd6348f47302c4453d56963479 | https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/loggers/default.py#L22-L31 | train | Used for efficient debugging logging where the actual message isn t evaluated unless it s actually accepted by the logger. |
projectshift/shift-schema | shiftschema/filters/digits.py | Digits.filter | def filter(self, value, model=None, context=None):
"""
Filter
Performs value filtering and returns filtered result.
:param value: input value
:param model: parent model being validated
:param context: object, filtering context
:return:... | python | def filter(self, value, model=None, context=None):
"""
Filter
Performs value filtering and returns filtered result.
:param value: input value
:param model: parent model being validated
:param context: object, filtering context
:return:... | [
"def",
"filter",
"(",
"self",
",",
"value",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"pattern",
"=",
"r'\\d+'",
"found",
"=",
"''",
".",
"join",
"(",
"re",
".",
"findall",
"(",
"pat... | Filter
Performs value filtering and returns filtered result.
:param value: input value
:param model: parent model being validated
:param context: object, filtering context
:return: filtered value | [
"Filter",
"Performs",
"value",
"filtering",
"and",
"returns",
"filtered",
"result",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/filters/digits.py#L20-L38 | train | Filter the value of a reservation key. |
weijia/djangoautoconf | djangoautoconf/django_autoconf.py | DjangoAutoConf.set_settings_env | def set_settings_env(executable_folder=None):
"""
Add all application folders
:param executable_folder: the folder that contains local and external_app_repos
:return:
"""
executable_folder = executable_folder or get_executable_folder()
# print "!!!!!!!!!!!!!! exec... | python | def set_settings_env(executable_folder=None):
"""
Add all application folders
:param executable_folder: the folder that contains local and external_app_repos
:return:
"""
executable_folder = executable_folder or get_executable_folder()
# print "!!!!!!!!!!!!!! exec... | [
"def",
"set_settings_env",
"(",
"executable_folder",
"=",
"None",
")",
":",
"executable_folder",
"=",
"executable_folder",
"or",
"get_executable_folder",
"(",
")",
"# print \"!!!!!!!!!!!!!! executable:\", executable_folder",
"if",
"os",
".",
"path",
".",
"exists",
"(",
... | Add all application folders
:param executable_folder: the folder that contains local and external_app_repos
:return: | [
"Add",
"all",
"application",
"folders",
":",
"param",
"executable_folder",
":",
"the",
"folder",
"that",
"contains",
"local",
"and",
"external_app_repos",
":",
"return",
":"
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/django_autoconf.py#L111-L127 | train | Set the environment variables that will be used to set the Django settings module. |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/token_verifying.py | verify_token | def verify_token(token, public_key_or_address, signing_algorithm="ES256K"):
""" A function for validating an individual token.
"""
decoded_token = decode_token(token)
decoded_token_payload = decoded_token["payload"]
if "subject" not in decoded_token_payload:
raise ValueError("Token doesn't ... | python | def verify_token(token, public_key_or_address, signing_algorithm="ES256K"):
""" A function for validating an individual token.
"""
decoded_token = decode_token(token)
decoded_token_payload = decoded_token["payload"]
if "subject" not in decoded_token_payload:
raise ValueError("Token doesn't ... | [
"def",
"verify_token",
"(",
"token",
",",
"public_key_or_address",
",",
"signing_algorithm",
"=",
"\"ES256K\"",
")",
":",
"decoded_token",
"=",
"decode_token",
"(",
"token",
")",
"decoded_token_payload",
"=",
"decoded_token",
"[",
"\"payload\"",
"]",
"if",
"\"subjec... | A function for validating an individual token. | [
"A",
"function",
"for",
"validating",
"an",
"individual",
"token",
"."
] | 103783798df78cf0f007801e79ec6298f00b2817 | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/token_verifying.py#L18-L74 | train | A function for validating an individual token. |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/token_verifying.py | verify_token_record | def verify_token_record(token_record, public_key_or_address,
signing_algorithm="ES256K"):
""" A function for validating an individual token record and extracting
the decoded token.
"""
if "token" not in token_record:
raise ValueError("Token record must have a token in... | python | def verify_token_record(token_record, public_key_or_address,
signing_algorithm="ES256K"):
""" A function for validating an individual token record and extracting
the decoded token.
"""
if "token" not in token_record:
raise ValueError("Token record must have a token in... | [
"def",
"verify_token_record",
"(",
"token_record",
",",
"public_key_or_address",
",",
"signing_algorithm",
"=",
"\"ES256K\"",
")",
":",
"if",
"\"token\"",
"not",
"in",
"token_record",
":",
"raise",
"ValueError",
"(",
"\"Token record must have a token inside it\"",
")",
... | A function for validating an individual token record and extracting
the decoded token. | [
"A",
"function",
"for",
"validating",
"an",
"individual",
"token",
"record",
"and",
"extracting",
"the",
"decoded",
"token",
"."
] | 103783798df78cf0f007801e79ec6298f00b2817 | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/token_verifying.py#L77-L99 | train | A function for validating an individual token record and extracting
the decoded token. |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/token_verifying.py | get_profile_from_tokens | def get_profile_from_tokens(token_records, public_key_or_address,
hierarchical_keys=False):
""" A function for extracting a profile from a list of tokens.
"""
if hierarchical_keys:
raise NotImplementedError("Hierarchical key support not implemented")
profile = {}
... | python | def get_profile_from_tokens(token_records, public_key_or_address,
hierarchical_keys=False):
""" A function for extracting a profile from a list of tokens.
"""
if hierarchical_keys:
raise NotImplementedError("Hierarchical key support not implemented")
profile = {}
... | [
"def",
"get_profile_from_tokens",
"(",
"token_records",
",",
"public_key_or_address",
",",
"hierarchical_keys",
"=",
"False",
")",
":",
"if",
"hierarchical_keys",
":",
"raise",
"NotImplementedError",
"(",
"\"Hierarchical key support not implemented\"",
")",
"profile",
"=",
... | A function for extracting a profile from a list of tokens. | [
"A",
"function",
"for",
"extracting",
"a",
"profile",
"from",
"a",
"list",
"of",
"tokens",
"."
] | 103783798df78cf0f007801e79ec6298f00b2817 | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/token_verifying.py#L102-L124 | train | A function for extracting a profile from a list of tokens. |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/zone_file_format.py | resolve_zone_file_to_profile | def resolve_zone_file_to_profile(zone_file, address_or_public_key):
""" Resolves a zone file to a profile and checks to makes sure the tokens
are signed with a key that corresponds to the address or public key
provided.
"""
if is_profile_in_legacy_format(zone_file):
return zone_file
... | python | def resolve_zone_file_to_profile(zone_file, address_or_public_key):
""" Resolves a zone file to a profile and checks to makes sure the tokens
are signed with a key that corresponds to the address or public key
provided.
"""
if is_profile_in_legacy_format(zone_file):
return zone_file
... | [
"def",
"resolve_zone_file_to_profile",
"(",
"zone_file",
",",
"address_or_public_key",
")",
":",
"if",
"is_profile_in_legacy_format",
"(",
"zone_file",
")",
":",
"return",
"zone_file",
"try",
":",
"token_file_url",
"=",
"get_token_file_url_from_zone_file",
"(",
"zone_file... | Resolves a zone file to a profile and checks to makes sure the tokens
are signed with a key that corresponds to the address or public key
provided. | [
"Resolves",
"a",
"zone",
"file",
"to",
"a",
"profile",
"and",
"checks",
"to",
"makes",
"sure",
"the",
"tokens",
"are",
"signed",
"with",
"a",
"key",
"that",
"corresponds",
"to",
"the",
"address",
"or",
"public",
"key",
"provided",
"."
] | 103783798df78cf0f007801e79ec6298f00b2817 | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/zone_file_format.py#L51-L80 | train | Resolves a zone file to a profile and checks to make sure the tokens
are signed with the address or public key that corresponds to the address or public key. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerWatchdog.__dog_started | def __dog_started(self):
""" Prepare watchdog for scheduled task starting
:return: None
"""
if self.__task is not None:
raise RuntimeError('Unable to start task. In order to start a new task - at first stop it')
self.__task = self.record().task()
if isinstance(self.__task, WScheduleTask) is False:
t... | python | def __dog_started(self):
""" Prepare watchdog for scheduled task starting
:return: None
"""
if self.__task is not None:
raise RuntimeError('Unable to start task. In order to start a new task - at first stop it')
self.__task = self.record().task()
if isinstance(self.__task, WScheduleTask) is False:
t... | [
"def",
"__dog_started",
"(",
"self",
")",
":",
"if",
"self",
".",
"__task",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Unable to start task. In order to start a new task - at first stop it'",
")",
"self",
".",
"__task",
"=",
"self",
".",
"record",
"... | Prepare watchdog for scheduled task starting
:return: None | [
"Prepare",
"watchdog",
"for",
"scheduled",
"task",
"starting"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L124-L135 | train | Prepare watchdog for scheduled task starting
is not None |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerWatchdog.__thread_started | def __thread_started(self):
""" Start a scheduled task
:return: None
"""
if self.__task is None:
raise RuntimeError('Unable to start thread without "start" method call')
self.__task.start()
self.__task.start_event().wait(self.__scheduled_task_startup_timeout__) | python | def __thread_started(self):
""" Start a scheduled task
:return: None
"""
if self.__task is None:
raise RuntimeError('Unable to start thread without "start" method call')
self.__task.start()
self.__task.start_event().wait(self.__scheduled_task_startup_timeout__) | [
"def",
"__thread_started",
"(",
"self",
")",
":",
"if",
"self",
".",
"__task",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Unable to start thread without \"start\" method call'",
")",
"self",
".",
"__task",
".",
"start",
"(",
")",
"self",
".",
"__task",
... | Start a scheduled task
:return: None | [
"Start",
"a",
"scheduled",
"task"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L138-L146 | train | Start a scheduled task
|
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerWatchdog._polling_iteration | def _polling_iteration(self):
""" Poll for scheduled task stop events
:return: None
"""
if self.__task is None:
self.ready_event().set()
elif self.__task.check_events() is True:
self.ready_event().set()
self.registry().task_finished(self) | python | def _polling_iteration(self):
""" Poll for scheduled task stop events
:return: None
"""
if self.__task is None:
self.ready_event().set()
elif self.__task.check_events() is True:
self.ready_event().set()
self.registry().task_finished(self) | [
"def",
"_polling_iteration",
"(",
"self",
")",
":",
"if",
"self",
".",
"__task",
"is",
"None",
":",
"self",
".",
"ready_event",
"(",
")",
".",
"set",
"(",
")",
"elif",
"self",
".",
"__task",
".",
"check_events",
"(",
")",
"is",
"True",
":",
"self",
... | Poll for scheduled task stop events
:return: None | [
"Poll",
"for",
"scheduled",
"task",
"stop",
"events"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L149-L158 | train | Poll for scheduled task stop events
self. ready_event. Set and call task_finished method. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerWatchdog.thread_stopped | def thread_stopped(self):
""" Stop scheduled task beacuse of watchdog stop
:return: None
"""
if self.__task is not None:
if self.__task.stop_event().is_set() is False:
self.__task.stop()
self.__task = None | python | def thread_stopped(self):
""" Stop scheduled task beacuse of watchdog stop
:return: None
"""
if self.__task is not None:
if self.__task.stop_event().is_set() is False:
self.__task.stop()
self.__task = None | [
"def",
"thread_stopped",
"(",
"self",
")",
":",
"if",
"self",
".",
"__task",
"is",
"not",
"None",
":",
"if",
"self",
".",
"__task",
".",
"stop_event",
"(",
")",
".",
"is_set",
"(",
")",
"is",
"False",
":",
"self",
".",
"__task",
".",
"stop",
"(",
... | Stop scheduled task beacuse of watchdog stop
:return: None | [
"Stop",
"scheduled",
"task",
"beacuse",
"of",
"watchdog",
"stop"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L161-L169 | train | Stop scheduled task beacuse of watchdog stop
|
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WRunningRecordRegistry.exec | def exec(self, record):
""" Start the given schedule record (no time checks are made by this method, task will be started as is)
:param record: schedule record to start
:return: None
"""
watchdog_cls = self.watchdog_class()
watchdog = watchdog_cls.create(record, self)
watchdog.start()
watchdog.start_e... | python | def exec(self, record):
""" Start the given schedule record (no time checks are made by this method, task will be started as is)
:param record: schedule record to start
:return: None
"""
watchdog_cls = self.watchdog_class()
watchdog = watchdog_cls.create(record, self)
watchdog.start()
watchdog.start_e... | [
"def",
"exec",
"(",
"self",
",",
"record",
")",
":",
"watchdog_cls",
"=",
"self",
".",
"watchdog_class",
"(",
")",
"watchdog",
"=",
"watchdog_cls",
".",
"create",
"(",
"record",
",",
"self",
")",
"watchdog",
".",
"start",
"(",
")",
"watchdog",
".",
"st... | Start the given schedule record (no time checks are made by this method, task will be started as is)
:param record: schedule record to start
:return: None | [
"Start",
"the",
"given",
"schedule",
"record",
"(",
"no",
"time",
"checks",
"are",
"made",
"by",
"this",
"method",
"task",
"will",
"be",
"started",
"as",
"is",
")"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L230-L241 | train | Start the given schedule record |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WRunningRecordRegistry.task_finished | def task_finished(self, watchdog):
""" Handle/process scheduled task stop
:param watchdog: watchdog of task that was stopped
:return: None
"""
if watchdog in self.__running_registry: # when cleanup hits stop
self.__running_registry.remove(watchdog)
self.__done_registry.append(watchdog)
self.cleanu... | python | def task_finished(self, watchdog):
""" Handle/process scheduled task stop
:param watchdog: watchdog of task that was stopped
:return: None
"""
if watchdog in self.__running_registry: # when cleanup hits stop
self.__running_registry.remove(watchdog)
self.__done_registry.append(watchdog)
self.cleanu... | [
"def",
"task_finished",
"(",
"self",
",",
"watchdog",
")",
":",
"if",
"watchdog",
"in",
"self",
".",
"__running_registry",
":",
"# when cleanup hits stop",
"self",
".",
"__running_registry",
".",
"remove",
"(",
"watchdog",
")",
"self",
".",
"__done_registry",
".... | Handle/process scheduled task stop
:param watchdog: watchdog of task that was stopped
:return: None | [
"Handle",
"/",
"process",
"scheduled",
"task",
"stop"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L261-L271 | train | Handle scheduled task that has finished |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WRunningRecordRegistry.cleanup | def cleanup(self):
""" Do cleanup (stop and remove watchdogs that are no longer needed)
:return: None
"""
for task in self.__done_registry:
task.stop()
self.__done_registry.clear()
self.cleanup_event().clear() | python | def cleanup(self):
""" Do cleanup (stop and remove watchdogs that are no longer needed)
:return: None
"""
for task in self.__done_registry:
task.stop()
self.__done_registry.clear()
self.cleanup_event().clear() | [
"def",
"cleanup",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"__done_registry",
":",
"task",
".",
"stop",
"(",
")",
"self",
".",
"__done_registry",
".",
"clear",
"(",
")",
"self",
".",
"cleanup_event",
"(",
")",
".",
"clear",
"(",
")"
] | Do cleanup (stop and remove watchdogs that are no longer needed)
:return: None | [
"Do",
"cleanup",
"(",
"stop",
"and",
"remove",
"watchdogs",
"that",
"are",
"no",
"longer",
"needed",
")"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L282-L290 | train | Stop and remove watchdogs that are no longer needed. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WRunningRecordRegistry.stop_running_tasks | def stop_running_tasks(self):
""" Terminate all the running tasks
:return: None
"""
for task in self.__running_registry:
task.stop()
self.__running_registry.clear() | python | def stop_running_tasks(self):
""" Terminate all the running tasks
:return: None
"""
for task in self.__running_registry:
task.stop()
self.__running_registry.clear() | [
"def",
"stop_running_tasks",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"__running_registry",
":",
"task",
".",
"stop",
"(",
")",
"self",
".",
"__running_registry",
".",
"clear",
"(",
")"
] | Terminate all the running tasks
:return: None | [
"Terminate",
"all",
"the",
"running",
"tasks"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L301-L308 | train | Terminate all the running tasks
|
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WPostponedRecordRegistry.postpone | def postpone(self, record):
""" Postpone (if required) the given task. The real action is depended on task postpone policy
:param record: record to postpone
:return: None
"""
maximum_records = self.maximum_records()
if maximum_records is not None and len(self.__records) >= maximum_records:
record.task_... | python | def postpone(self, record):
""" Postpone (if required) the given task. The real action is depended on task postpone policy
:param record: record to postpone
:return: None
"""
maximum_records = self.maximum_records()
if maximum_records is not None and len(self.__records) >= maximum_records:
record.task_... | [
"def",
"postpone",
"(",
"self",
",",
"record",
")",
":",
"maximum_records",
"=",
"self",
".",
"maximum_records",
"(",
")",
"if",
"maximum_records",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"__records",
")",
">=",
"maximum_records",
":",
"record... | Postpone (if required) the given task. The real action is depended on task postpone policy
:param record: record to postpone
:return: None | [
"Postpone",
"(",
"if",
"required",
")",
"the",
"given",
"task",
".",
"The",
"real",
"action",
"is",
"depended",
"on",
"task",
"postpone",
"policy"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L333-L386 | train | Postpone the given task. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WPostponedRecordRegistry.__search_record | def __search_record(self, task_group_id):
""" Search (iterate over) for tasks with the given task id
:param task_group_id: target id
:return: None
"""
for i in range(len(self.__records)):
record = self.__records[i]
if record.task_group_id() == task_group_id:
yield record, i | python | def __search_record(self, task_group_id):
""" Search (iterate over) for tasks with the given task id
:param task_group_id: target id
:return: None
"""
for i in range(len(self.__records)):
record = self.__records[i]
if record.task_group_id() == task_group_id:
yield record, i | [
"def",
"__search_record",
"(",
"self",
",",
"task_group_id",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__records",
")",
")",
":",
"record",
"=",
"self",
".",
"__records",
"[",
"i",
"]",
"if",
"record",
".",
"task_group_id",
... | Search (iterate over) for tasks with the given task id
:param task_group_id: target id
:return: None | [
"Search",
"(",
"iterate",
"over",
")",
"for",
"tasks",
"with",
"the",
"given",
"task",
"id"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L389-L399 | train | Search ( iterate over ) for tasks with the given task group id |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WTaskSourceRegistry.add_source | def add_source(self, task_source):
""" Add new tasks source
:param task_source:
:return: None
"""
next_start = task_source.next_start()
self.__sources[task_source] = next_start
self.__update(task_source) | python | def add_source(self, task_source):
""" Add new tasks source
:param task_source:
:return: None
"""
next_start = task_source.next_start()
self.__sources[task_source] = next_start
self.__update(task_source) | [
"def",
"add_source",
"(",
"self",
",",
"task_source",
")",
":",
"next_start",
"=",
"task_source",
".",
"next_start",
"(",
")",
"self",
".",
"__sources",
"[",
"task_source",
"]",
"=",
"next_start",
"self",
".",
"__update",
"(",
"task_source",
")"
] | Add new tasks source
:param task_source:
:return: None | [
"Add",
"new",
"tasks",
"source"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L452-L461 | train | Add new tasks from a task_source to the queue. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WTaskSourceRegistry.__update_all | def __update_all(self):
""" Recheck next start of records from all the sources
:return: None
"""
self.__next_start = None
self.__next_sources = []
for source in self.__sources:
self.__update(source) | python | def __update_all(self):
""" Recheck next start of records from all the sources
:return: None
"""
self.__next_start = None
self.__next_sources = []
for source in self.__sources:
self.__update(source) | [
"def",
"__update_all",
"(",
"self",
")",
":",
"self",
".",
"__next_start",
"=",
"None",
"self",
".",
"__next_sources",
"=",
"[",
"]",
"for",
"source",
"in",
"self",
".",
"__sources",
":",
"self",
".",
"__update",
"(",
"source",
")"
] | Recheck next start of records from all the sources
:return: None | [
"Recheck",
"next",
"start",
"of",
"records",
"from",
"all",
"the",
"sources"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L476-L485 | train | Recheck next start of records from all the sources |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WTaskSourceRegistry.__update | def __update(self, task_source):
""" Recheck next start of tasks from the given one only
:param task_source: source to check
:return: None
"""
next_start = task_source.next_start()
if next_start is not None:
if next_start.tzinfo is None or next_start.tzinfo != timezone.utc:
raise ValueError('Inval... | python | def __update(self, task_source):
""" Recheck next start of tasks from the given one only
:param task_source: source to check
:return: None
"""
next_start = task_source.next_start()
if next_start is not None:
if next_start.tzinfo is None or next_start.tzinfo != timezone.utc:
raise ValueError('Inval... | [
"def",
"__update",
"(",
"self",
",",
"task_source",
")",
":",
"next_start",
"=",
"task_source",
".",
"next_start",
"(",
")",
"if",
"next_start",
"is",
"not",
"None",
":",
"if",
"next_start",
".",
"tzinfo",
"is",
"None",
"or",
"next_start",
".",
"tzinfo",
... | Recheck next start of tasks from the given one only
:param task_source: source to check
:return: None | [
"Recheck",
"next",
"start",
"of",
"tasks",
"from",
"the",
"given",
"one",
"only"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L488-L505 | train | Updates the internal state of the only availabe object with the given task_source. |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WTaskSourceRegistry.check | def check(self):
""" Check if there are records that are ready to start and return them if there are any
:return: tuple of WScheduleRecord or None (if there are no tasks to start)
"""
if self.__next_start is not None:
utc_now = utc_datetime()
if utc_now >= self.__next_start:
result = []
for task... | python | def check(self):
""" Check if there are records that are ready to start and return them if there are any
:return: tuple of WScheduleRecord or None (if there are no tasks to start)
"""
if self.__next_start is not None:
utc_now = utc_datetime()
if utc_now >= self.__next_start:
result = []
for task... | [
"def",
"check",
"(",
"self",
")",
":",
"if",
"self",
".",
"__next_start",
"is",
"not",
"None",
":",
"utc_now",
"=",
"utc_datetime",
"(",
")",
"if",
"utc_now",
">=",
"self",
".",
"__next_start",
":",
"result",
"=",
"[",
"]",
"for",
"task_source",
"in",
... | Check if there are records that are ready to start and return them if there are any
:return: tuple of WScheduleRecord or None (if there are no tasks to start) | [
"Check",
"if",
"there",
"are",
"records",
"that",
"are",
"ready",
"to",
"start",
"and",
"return",
"them",
"if",
"there",
"are",
"any"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L507-L525 | train | Check if there are records that are ready to start and return them if there are no tasks to start and return them if there are no tasks to start and None if there are no tasks to start |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerService.thread_started | def thread_started(self):
""" Start required registries and start this scheduler
:return: None
"""
self.__running_record_registry.start()
self.__running_record_registry.start_event().wait()
WPollingThreadTask.thread_started(self) | python | def thread_started(self):
""" Start required registries and start this scheduler
:return: None
"""
self.__running_record_registry.start()
self.__running_record_registry.start_event().wait()
WPollingThreadTask.thread_started(self) | [
"def",
"thread_started",
"(",
"self",
")",
":",
"self",
".",
"__running_record_registry",
".",
"start",
"(",
")",
"self",
".",
"__running_record_registry",
".",
"start_event",
"(",
")",
".",
"wait",
"(",
")",
"WPollingThreadTask",
".",
"thread_started",
"(",
"... | Start required registries and start this scheduler
:return: None | [
"Start",
"required",
"registries",
"and",
"start",
"this",
"scheduler"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L657-L664 | train | Start required registries and start this scheduler
WPollingThreadTask |
a1ezzz/wasp-general | wasp_general/task/scheduler/scheduler.py | WSchedulerService._polling_iteration | def _polling_iteration(self):
""" Poll for different scheduler events like: there are tasks to run, there are tasks to postpone
there are postponed tasks that should be running
:return: None
"""
scheduled_tasks = self.__sources_registry.check()
has_postponed_tasks = self.__postponed_record_registry.has_rec... | python | def _polling_iteration(self):
""" Poll for different scheduler events like: there are tasks to run, there are tasks to postpone
there are postponed tasks that should be running
:return: None
"""
scheduled_tasks = self.__sources_registry.check()
has_postponed_tasks = self.__postponed_record_registry.has_rec... | [
"def",
"_polling_iteration",
"(",
"self",
")",
":",
"scheduled_tasks",
"=",
"self",
".",
"__sources_registry",
".",
"check",
"(",
")",
"has_postponed_tasks",
"=",
"self",
".",
"__postponed_record_registry",
".",
"has_records",
"(",
")",
"maximum_tasks",
"=",
"self... | Poll for different scheduler events like: there are tasks to run, there are tasks to postpone
there are postponed tasks that should be running
:return: None | [
"Poll",
"for",
"different",
"scheduler",
"events",
"like",
":",
"there",
"are",
"tasks",
"to",
"run",
"there",
"are",
"tasks",
"to",
"postpone",
"there",
"are",
"postponed",
"tasks",
"that",
"should",
"be",
"running"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L667-L698 | train | Poll for different scheduler events like |
Chilipp/model-organization | model_organization/utils.py | dir_contains | def dir_contains(dirname, path, exists=True):
"""Check if a file of directory is contained in another.
Parameters
----------
dirname: str
The base directory that should contain `path`
path: str
The name of a directory or file that should be in `dirname`
exists: bool
If T... | python | def dir_contains(dirname, path, exists=True):
"""Check if a file of directory is contained in another.
Parameters
----------
dirname: str
The base directory that should contain `path`
path: str
The name of a directory or file that should be in `dirname`
exists: bool
If T... | [
"def",
"dir_contains",
"(",
"dirname",
",",
"path",
",",
"exists",
"=",
"True",
")",
":",
"if",
"exists",
":",
"dirname",
"=",
"osp",
".",
"abspath",
"(",
"dirname",
")",
"path",
"=",
"osp",
".",
"abspath",
"(",
"path",
")",
"if",
"six",
".",
"PY2"... | Check if a file of directory is contained in another.
Parameters
----------
dirname: str
The base directory that should contain `path`
path: str
The name of a directory or file that should be in `dirname`
exists: bool
If True, the `path` and `dirname` must exist
Notes
... | [
"Check",
"if",
"a",
"file",
"of",
"directory",
"is",
"contained",
"in",
"another",
"."
] | 694d1219c7ed7e1b2b17153afa11bdc21169bca2 | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/utils.py#L11-L35 | train | Check if a file of directory is contained in another. |
Chilipp/model-organization | model_organization/utils.py | get_next_name | def get_next_name(old, fmt='%i'):
"""Return the next name that numerically follows `old`"""
nums = re.findall('\d+', old)
if not nums:
raise ValueError("Could not get the next name because the old name "
"has no numbers in it")
num0 = nums[-1]
num1 = str(int(num0) + ... | python | def get_next_name(old, fmt='%i'):
"""Return the next name that numerically follows `old`"""
nums = re.findall('\d+', old)
if not nums:
raise ValueError("Could not get the next name because the old name "
"has no numbers in it")
num0 = nums[-1]
num1 = str(int(num0) + ... | [
"def",
"get_next_name",
"(",
"old",
",",
"fmt",
"=",
"'%i'",
")",
":",
"nums",
"=",
"re",
".",
"findall",
"(",
"'\\d+'",
",",
"old",
")",
"if",
"not",
"nums",
":",
"raise",
"ValueError",
"(",
"\"Could not get the next name because the old name \"",
"\"has no n... | Return the next name that numerically follows `old` | [
"Return",
"the",
"next",
"name",
"that",
"numerically",
"follows",
"old"
] | 694d1219c7ed7e1b2b17153afa11bdc21169bca2 | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/utils.py#L42-L50 | train | Return the next name that numerically follows old |
Chilipp/model-organization | model_organization/utils.py | go_through_dict | def go_through_dict(key, d, setdefault=None):
"""
Split up the `key` by . and get the value from the base dictionary `d`
Parameters
----------
key: str
The key in the `config` configuration. %(get_value_note)s
d: dict
The configuration dictionary containing the key
setdefaul... | python | def go_through_dict(key, d, setdefault=None):
"""
Split up the `key` by . and get the value from the base dictionary `d`
Parameters
----------
key: str
The key in the `config` configuration. %(get_value_note)s
d: dict
The configuration dictionary containing the key
setdefaul... | [
"def",
"go_through_dict",
"(",
"key",
",",
"d",
",",
"setdefault",
"=",
"None",
")",
":",
"patt",
"=",
"re",
".",
"compile",
"(",
"r'(?<!\\\\)\\.'",
")",
"sub_d",
"=",
"d",
"splitted",
"=",
"patt",
".",
"split",
"(",
"key",
")",
"n",
"=",
"len",
"(... | Split up the `key` by . and get the value from the base dictionary `d`
Parameters
----------
key: str
The key in the `config` configuration. %(get_value_note)s
d: dict
The configuration dictionary containing the key
setdefault: callable
If not None and an item is not existen... | [
"Split",
"up",
"the",
"key",
"by",
".",
"and",
"get",
"the",
"value",
"from",
"the",
"base",
"dictionary",
"d"
] | 694d1219c7ed7e1b2b17153afa11bdc21169bca2 | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/utils.py#L61-L93 | train | Split up the key by. and get the value from the base dictionary d. |
Felspar/django-fost-authn | fost_authn/signature.py | sha1_hmac | def sha1_hmac(secret, document):
"""
Calculate the Base 64 encoding of the HMAC for the given document.
"""
signature = hmac.new(secret, document, hashlib.sha1).digest().encode("base64")[:-1]
return signature | python | def sha1_hmac(secret, document):
"""
Calculate the Base 64 encoding of the HMAC for the given document.
"""
signature = hmac.new(secret, document, hashlib.sha1).digest().encode("base64")[:-1]
return signature | [
"def",
"sha1_hmac",
"(",
"secret",
",",
"document",
")",
":",
"signature",
"=",
"hmac",
".",
"new",
"(",
"secret",
",",
"document",
",",
"hashlib",
".",
"sha1",
")",
".",
"digest",
"(",
")",
".",
"encode",
"(",
"\"base64\"",
")",
"[",
":",
"-",
"1"... | Calculate the Base 64 encoding of the HMAC for the given document. | [
"Calculate",
"the",
"Base",
"64",
"encoding",
"of",
"the",
"HMAC",
"for",
"the",
"given",
"document",
"."
] | 31623fa9f77570fe9b99962595da12f67f24c409 | https://github.com/Felspar/django-fost-authn/blob/31623fa9f77570fe9b99962595da12f67f24c409/fost_authn/signature.py#L6-L11 | train | Calculate the Base 64 encoding of the HMAC for the given document. |
Felspar/django-fost-authn | fost_authn/signature.py | filter_query_string | def filter_query_string(query):
"""
Return a version of the query string with the _e, _k and _s values
removed.
"""
return '&'.join([q for q in query.split('&')
if not (q.startswith('_k=') or q.startswith('_e=') or q.startswith('_s'))]) | python | def filter_query_string(query):
"""
Return a version of the query string with the _e, _k and _s values
removed.
"""
return '&'.join([q for q in query.split('&')
if not (q.startswith('_k=') or q.startswith('_e=') or q.startswith('_s'))]) | [
"def",
"filter_query_string",
"(",
"query",
")",
":",
"return",
"'&'",
".",
"join",
"(",
"[",
"q",
"for",
"q",
"in",
"query",
".",
"split",
"(",
"'&'",
")",
"if",
"not",
"(",
"q",
".",
"startswith",
"(",
"'_k='",
")",
"or",
"q",
".",
"startswith",
... | Return a version of the query string with the _e, _k and _s values
removed. | [
"Return",
"a",
"version",
"of",
"the",
"query",
"string",
"with",
"the",
"_e",
"_k",
"and",
"_s",
"values",
"removed",
"."
] | 31623fa9f77570fe9b99962595da12f67f24c409 | https://github.com/Felspar/django-fost-authn/blob/31623fa9f77570fe9b99962595da12f67f24c409/fost_authn/signature.py#L14-L20 | train | Filter the query string to remove the _e _k and _s values
removed. |
Felspar/django-fost-authn | fost_authn/signature.py | fost_hmac_url_signature | def fost_hmac_url_signature(
key, secret, host, path, query_string, expires):
"""
Return a signature that corresponds to the signed URL.
"""
if query_string:
document = '%s%s?%s\n%s' % (host, path, query_string, expires)
else:
document = '%s%s\n%s' % (host, path, expires)
... | python | def fost_hmac_url_signature(
key, secret, host, path, query_string, expires):
"""
Return a signature that corresponds to the signed URL.
"""
if query_string:
document = '%s%s?%s\n%s' % (host, path, query_string, expires)
else:
document = '%s%s\n%s' % (host, path, expires)
... | [
"def",
"fost_hmac_url_signature",
"(",
"key",
",",
"secret",
",",
"host",
",",
"path",
",",
"query_string",
",",
"expires",
")",
":",
"if",
"query_string",
":",
"document",
"=",
"'%s%s?%s\\n%s'",
"%",
"(",
"host",
",",
"path",
",",
"query_string",
",",
"ex... | Return a signature that corresponds to the signed URL. | [
"Return",
"a",
"signature",
"that",
"corresponds",
"to",
"the",
"signed",
"URL",
"."
] | 31623fa9f77570fe9b99962595da12f67f24c409 | https://github.com/Felspar/django-fost-authn/blob/31623fa9f77570fe9b99962595da12f67f24c409/fost_authn/signature.py#L23-L33 | train | Return a signature that corresponds to the signed URL. |
Felspar/django-fost-authn | fost_authn/signature.py | fost_hmac_request_signature | def fost_hmac_request_signature(
secret, method, path, timestamp, headers = {}, body = ''):
"""
Calculate the signature for the given secret and arguments.
"""
signed_headers, header_values = 'X-FOST-Headers', []
for header, value in headers.items():
signed_headers += ' ' + header
... | python | def fost_hmac_request_signature(
secret, method, path, timestamp, headers = {}, body = ''):
"""
Calculate the signature for the given secret and arguments.
"""
signed_headers, header_values = 'X-FOST-Headers', []
for header, value in headers.items():
signed_headers += ' ' + header
... | [
"def",
"fost_hmac_request_signature",
"(",
"secret",
",",
"method",
",",
"path",
",",
"timestamp",
",",
"headers",
"=",
"{",
"}",
",",
"body",
"=",
"''",
")",
":",
"signed_headers",
",",
"header_values",
"=",
"'X-FOST-Headers'",
",",
"[",
"]",
"for",
"head... | Calculate the signature for the given secret and arguments. | [
"Calculate",
"the",
"signature",
"for",
"the",
"given",
"secret",
"and",
"arguments",
"."
] | 31623fa9f77570fe9b99962595da12f67f24c409 | https://github.com/Felspar/django-fost-authn/blob/31623fa9f77570fe9b99962595da12f67f24c409/fost_authn/signature.py#L36-L47 | train | Calculate the signature for the given secret and arguments. |
Felspar/django-fost-authn | fost_authn/signature.py | fost_hmac_request_signature_with_headers | def fost_hmac_request_signature_with_headers(
secret, method, path, timestamp, headers, body):
"""
Calculate the signature for the given secret and other arguments.
The headers must be the correct header value list in the proper order.
"""
document = "%s %s\n%s\n%s\n%s" % (
meth... | python | def fost_hmac_request_signature_with_headers(
secret, method, path, timestamp, headers, body):
"""
Calculate the signature for the given secret and other arguments.
The headers must be the correct header value list in the proper order.
"""
document = "%s %s\n%s\n%s\n%s" % (
meth... | [
"def",
"fost_hmac_request_signature_with_headers",
"(",
"secret",
",",
"method",
",",
"path",
",",
"timestamp",
",",
"headers",
",",
"body",
")",
":",
"document",
"=",
"\"%s %s\\n%s\\n%s\\n%s\"",
"%",
"(",
"method",
",",
"path",
",",
"timestamp",
",",
"'\\n'",
... | Calculate the signature for the given secret and other arguments.
The headers must be the correct header value list in the proper order. | [
"Calculate",
"the",
"signature",
"for",
"the",
"given",
"secret",
"and",
"other",
"arguments",
"."
] | 31623fa9f77570fe9b99962595da12f67f24c409 | https://github.com/Felspar/django-fost-authn/blob/31623fa9f77570fe9b99962595da12f67f24c409/fost_authn/signature.py#L50-L64 | train | Calculate the signature for the given secret and other arguments. |
AASHE/python-membersuite-api-client | membersuite_api_client/orders/services.py | get_order | def get_order(membersuite_id, client=None):
"""Get an Order by ID.
"""
if not membersuite_id:
return None
client = client or get_new_client(request_session=True)
if not client.session_id:
client.request_session()
object_query = "SELECT Object() FROM ORDER WHERE ID = '{}'".forma... | python | def get_order(membersuite_id, client=None):
"""Get an Order by ID.
"""
if not membersuite_id:
return None
client = client or get_new_client(request_session=True)
if not client.session_id:
client.request_session()
object_query = "SELECT Object() FROM ORDER WHERE ID = '{}'".forma... | [
"def",
"get_order",
"(",
"membersuite_id",
",",
"client",
"=",
"None",
")",
":",
"if",
"not",
"membersuite_id",
":",
"return",
"None",
"client",
"=",
"client",
"or",
"get_new_client",
"(",
"request_session",
"=",
"True",
")",
"if",
"not",
"client",
".",
"s... | Get an Order by ID. | [
"Get",
"an",
"Order",
"by",
"ID",
"."
] | 221f5ed8bc7d4424237a4669c5af9edc11819ee9 | https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/orders/services.py#L6-L29 | train | Get an Order by ID. |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.__set_private_key | def __set_private_key(self, pk):
""" Internal method that sets the specified private key
:param pk: private key to set
:return: None
"""
self.__private_key = pk
self.__public_key = pk.public_key() | python | def __set_private_key(self, pk):
""" Internal method that sets the specified private key
:param pk: private key to set
:return: None
"""
self.__private_key = pk
self.__public_key = pk.public_key() | [
"def",
"__set_private_key",
"(",
"self",
",",
"pk",
")",
":",
"self",
".",
"__private_key",
"=",
"pk",
"self",
".",
"__public_key",
"=",
"pk",
".",
"public_key",
"(",
")"
] | Internal method that sets the specified private key
:param pk: private key to set
:return: None | [
"Internal",
"method",
"that",
"sets",
"the",
"specified",
"private",
"key",
":",
"param",
"pk",
":",
"private",
"key",
"to",
"set",
":",
"return",
":",
"None"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L52-L58 | train | Internal method that sets the specified private key to the specified public key. |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.generate_private_key | def generate_private_key(self, key_size=2048, public_exponent=65537):
""" Generate a private (and a corresponding public) key
:return: None
"""
self.__set_private_key(
rsa.generate_private_key(
public_exponent=public_exponent, key_size=key_size, backend=default_backend()
)
) | python | def generate_private_key(self, key_size=2048, public_exponent=65537):
""" Generate a private (and a corresponding public) key
:return: None
"""
self.__set_private_key(
rsa.generate_private_key(
public_exponent=public_exponent, key_size=key_size, backend=default_backend()
)
) | [
"def",
"generate_private_key",
"(",
"self",
",",
"key_size",
"=",
"2048",
",",
"public_exponent",
"=",
"65537",
")",
":",
"self",
".",
"__set_private_key",
"(",
"rsa",
".",
"generate_private_key",
"(",
"public_exponent",
"=",
"public_exponent",
",",
"key_size",
... | Generate a private (and a corresponding public) key
:return: None | [
"Generate",
"a",
"private",
"(",
"and",
"a",
"corresponding",
"public",
")",
"key"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L94-L103 | train | Generate a private key and a corresponding public key |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.export_private_key | def export_private_key(self, password=None):
""" Export a private key in PEM-format
:param password: If it is not None, then result will be encrypt with given password
:return: bytes
"""
if self.__private_key is None:
raise ValueError('Unable to call this method. Private key must be set')
if password ... | python | def export_private_key(self, password=None):
""" Export a private key in PEM-format
:param password: If it is not None, then result will be encrypt with given password
:return: bytes
"""
if self.__private_key is None:
raise ValueError('Unable to call this method. Private key must be set')
if password ... | [
"def",
"export_private_key",
"(",
"self",
",",
"password",
"=",
"None",
")",
":",
"if",
"self",
".",
"__private_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Unable to call this method. Private key must be set'",
")",
"if",
"password",
"is",
"not",
"None"... | Export a private key in PEM-format
:param password: If it is not None, then result will be encrypt with given password
:return: bytes | [
"Export",
"a",
"private",
"key",
"in",
"PEM",
"-",
"format"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L106-L128 | train | This method returns a private key in PEM - format |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.export_public_key | def export_public_key(self):
""" Export a public key in PEM-format
:return: bytes
"""
if self.__public_key is None:
raise ValueError('Unable to call this method. Public key must be set')
return self.__public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.Su... | python | def export_public_key(self):
""" Export a public key in PEM-format
:return: bytes
"""
if self.__public_key is None:
raise ValueError('Unable to call this method. Public key must be set')
return self.__public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.Su... | [
"def",
"export_public_key",
"(",
"self",
")",
":",
"if",
"self",
".",
"__public_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Unable to call this method. Public key must be set'",
")",
"return",
"self",
".",
"__public_key",
".",
"public_bytes",
"(",
"encodi... | Export a public key in PEM-format
:return: bytes | [
"Export",
"a",
"public",
"key",
"in",
"PEM",
"-",
"format"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L130-L141 | train | Export a public key in PEM - format and return the public key in bytes. |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.import_private_key | def import_private_key(self, pem_text, password=None):
""" Import a private key from data in PEM-format
:param pem_text: text with private key
:param password: If it is not None, then result will be decrypt with the given password
:return: None
"""
if isinstance(pem_text, str) is True:
pem_text = pem_te... | python | def import_private_key(self, pem_text, password=None):
""" Import a private key from data in PEM-format
:param pem_text: text with private key
:param password: If it is not None, then result will be decrypt with the given password
:return: None
"""
if isinstance(pem_text, str) is True:
pem_text = pem_te... | [
"def",
"import_private_key",
"(",
"self",
",",
"pem_text",
",",
"password",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"pem_text",
",",
"str",
")",
"is",
"True",
":",
"pem_text",
"=",
"pem_text",
".",
"encode",
"(",
")",
"if",
"password",
"is",
"n... | Import a private key from data in PEM-format
:param pem_text: text with private key
:param password: If it is not None, then result will be decrypt with the given password
:return: None | [
"Import",
"a",
"private",
"key",
"from",
"data",
"in",
"PEM",
"-",
"format"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L144-L158 | train | This method imports a private key from data in PEM - format and sets the private key in the object |
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.import_public_key | def import_public_key(self, pem_text):
""" Import a public key from data in PEM-format
:param pem_text: text with public key
:return: None
"""
if isinstance(pem_text, str) is True:
pem_text = pem_text.encode()
self.__set_public_key(
serialization.load_pem_public_key(pem_text, backend=default_backend()... | python | def import_public_key(self, pem_text):
""" Import a public key from data in PEM-format
:param pem_text: text with public key
:return: None
"""
if isinstance(pem_text, str) is True:
pem_text = pem_text.encode()
self.__set_public_key(
serialization.load_pem_public_key(pem_text, backend=default_backend()... | [
"def",
"import_public_key",
"(",
"self",
",",
"pem_text",
")",
":",
"if",
"isinstance",
"(",
"pem_text",
",",
"str",
")",
"is",
"True",
":",
"pem_text",
"=",
"pem_text",
".",
"encode",
"(",
")",
"self",
".",
"__set_public_key",
"(",
"serialization",
".",
... | Import a public key from data in PEM-format
:param pem_text: text with public key
:return: None | [
"Import",
"a",
"public",
"key",
"from",
"data",
"in",
"PEM",
"-",
"format",
":",
"param",
"pem_text",
":",
"text",
"with",
"public",
"key",
":",
"return",
":",
"None"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L161-L170 | train | Import a public key from data in PEM - format
|
a1ezzz/wasp-general | wasp_general/crypto/rsa.py | WRSA.decrypt | def decrypt(self, data, oaep_hash_fn_name=None, mgf1_hash_fn_name=None):
""" Decrypt a data that used PKCS1 OAEP protocol
:param data: data to decrypt
:param oaep_hash_fn_name: hash function name to use with OAEP
:param mgf1_hash_fn_name: hash function name to use with MGF1 padding
:return: bytes
"""
if... | python | def decrypt(self, data, oaep_hash_fn_name=None, mgf1_hash_fn_name=None):
""" Decrypt a data that used PKCS1 OAEP protocol
:param data: data to decrypt
:param oaep_hash_fn_name: hash function name to use with OAEP
:param mgf1_hash_fn_name: hash function name to use with MGF1 padding
:return: bytes
"""
if... | [
"def",
"decrypt",
"(",
"self",
",",
"data",
",",
"oaep_hash_fn_name",
"=",
"None",
",",
"mgf1_hash_fn_name",
"=",
"None",
")",
":",
"if",
"self",
".",
"__private_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Unable to call this method. Private key must be... | Decrypt a data that used PKCS1 OAEP protocol
:param data: data to decrypt
:param oaep_hash_fn_name: hash function name to use with OAEP
:param mgf1_hash_fn_name: hash function name to use with MGF1 padding
:return: bytes | [
"Decrypt",
"a",
"data",
"that",
"used",
"PKCS1",
"OAEP",
"protocol"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/rsa.py#L208-L236 | train | Decrypt a data that used PKCS1 OAEP protocol |
projectshift/shift-schema | shiftschema/validators/length.py | Length.validate | def validate(self, value, model=None, context=None):
"""
Validate
Perform value validation against validation settings and return
simple result object
:param value: str, value to check
:param model: parent model being validated
:param context:... | python | def validate(self, value, model=None, context=None):
"""
Validate
Perform value validation against validation settings and return
simple result object
:param value: str, value to check
:param model: parent model being validated
:param context:... | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"length",
"=",
"len",
"(",
"str",
"(",
"value",
")",
")",
"params",
"=",
"dict",
"(",
"min",
"=",
"self",
".",
"min",
",",
"max",
"=... | Validate
Perform value validation against validation settings and return
simple result object
:param value: str, value to check
:param model: parent model being validated
:param context: object or None, validation context
:return: ... | [
"Validate",
"Perform",
"value",
"validation",
"against",
"validation",
"settings",
"and",
"return",
"simple",
"result",
"object"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/length.py#L34-L65 | train | Validate the value against the validation settings and return a SimpleResult object. |
olitheolix/qtmacs | qtmacs/base_macro.py | QtmacsMacro.qteSaveMacroData | def qteSaveMacroData(self, data, widgetObj: QtGui.QWidget=None):
"""
Associate arbitrary ``data`` with ``widgetObj``.
This is a convenience method to easily store applet/widget
specific information in between calls.
If ``widgetObj`` is **None** then the calling widget
`... | python | def qteSaveMacroData(self, data, widgetObj: QtGui.QWidget=None):
"""
Associate arbitrary ``data`` with ``widgetObj``.
This is a convenience method to easily store applet/widget
specific information in between calls.
If ``widgetObj`` is **None** then the calling widget
`... | [
"def",
"qteSaveMacroData",
"(",
"self",
",",
"data",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
")",
":",
"# Check type of input arguments.",
"if",
"not",
"hasattr",
"(",
"widgetObj",
",",
"'_qteAdmin'",
")",
"and",
"(",
"widgetObj",
"is",
... | Associate arbitrary ``data`` with ``widgetObj``.
This is a convenience method to easily store applet/widget
specific information in between calls.
If ``widgetObj`` is **None** then the calling widget
``self.qteWidget`` will be used.
Note that this function overwrites any previ... | [
"Associate",
"arbitrary",
"data",
"with",
"widgetObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_macro.py#L216-L256 | train | Save the supplied data to the applet specific macro storage. |
olitheolix/qtmacs | qtmacs/base_macro.py | QtmacsMacro.qteMacroData | def qteMacroData(self, widgetObj: QtGui.QWidget=None):
"""
Retrieve ``widgetObj`` specific data previously saved with
``qteSaveMacroData``.
If no data has been stored previously then **None** is
returned.
If ``widgetObj`` is **None** then the calling widget
``se... | python | def qteMacroData(self, widgetObj: QtGui.QWidget=None):
"""
Retrieve ``widgetObj`` specific data previously saved with
``qteSaveMacroData``.
If no data has been stored previously then **None** is
returned.
If ``widgetObj`` is **None** then the calling widget
``se... | [
"def",
"qteMacroData",
"(",
"self",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
")",
":",
"# Check type of input arguments.",
"if",
"not",
"hasattr",
"(",
"widgetObj",
",",
"'_qteAdmin'",
")",
"and",
"(",
"widgetObj",
"is",
"not",
"None",
")... | Retrieve ``widgetObj`` specific data previously saved with
``qteSaveMacroData``.
If no data has been stored previously then **None** is
returned.
If ``widgetObj`` is **None** then the calling widget
``self.qteWidget`` will be used.
|Args|
* ``widgetObj`` (**QW... | [
"Retrieve",
"widgetObj",
"specific",
"data",
"previously",
"saved",
"with",
"qteSaveMacroData",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_macro.py#L259-L306 | train | Return the macro data associated with the given widgetObj. |
olitheolix/qtmacs | qtmacs/base_macro.py | QtmacsMacro.qteSetAppletSignature | def qteSetAppletSignature(self, appletSignatures: (str, tuple, list)):
"""
Specify the applet signatures with which this macro is compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular applet, as specified by
the applet's ... | python | def qteSetAppletSignature(self, appletSignatures: (str, tuple, list)):
"""
Specify the applet signatures with which this macro is compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular applet, as specified by
the applet's ... | [
"def",
"qteSetAppletSignature",
"(",
"self",
",",
"appletSignatures",
":",
"(",
"str",
",",
"tuple",
",",
"list",
")",
")",
":",
"# Convert the argument to a tuple if it is not already a tuple",
"# or list.",
"if",
"not",
"isinstance",
"(",
"appletSignatures",
",",
"(... | Specify the applet signatures with which this macro is compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular applet, as specified by
the applet's signature. Note that this function overwrites
all previously set values.
|... | [
"Specify",
"the",
"applet",
"signatures",
"with",
"which",
"this",
"macro",
"is",
"compatible",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_macro.py#L343-L377 | train | Set applet signatures for this macro at run time. |
olitheolix/qtmacs | qtmacs/base_macro.py | QtmacsMacro.qteSetWidgetSignature | def qteSetWidgetSignature(self, widgetSignatures: (str, tuple, list)):
"""
Specify the widget signatures with which this macro is
compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular widget, as specified by
the w... | python | def qteSetWidgetSignature(self, widgetSignatures: (str, tuple, list)):
"""
Specify the widget signatures with which this macro is
compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular widget, as specified by
the w... | [
"def",
"qteSetWidgetSignature",
"(",
"self",
",",
"widgetSignatures",
":",
"(",
"str",
",",
"tuple",
",",
"list",
")",
")",
":",
"# Convert the argument to a tuple if it is not already a tuple",
"# or list.",
"if",
"not",
"isinstance",
"(",
"widgetSignatures",
",",
"(... | Specify the widget signatures with which this macro is
compatible.
Qtmacs uses this information at run time to determine if this
macro is compatible with a particular widget, as specified by
the widget's signature. Note that this function overwrites all
previously set values.
... | [
"Specify",
"the",
"widget",
"signatures",
"with",
"which",
"this",
"macro",
"is",
"compatible",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_macro.py#L380-L416 | train | Set the widget signatures for this macro. |
olitheolix/qtmacs | qtmacs/base_macro.py | QtmacsMacro.qtePrepareToRun | def qtePrepareToRun(self):
"""
This method is called by Qtmacs to prepare the macro for
execution.
It is probably a bad idea to overload this method as it only
administrates the macro execution and calls the ``qteRun``
method (which *should* be overloaded by the macro pr... | python | def qtePrepareToRun(self):
"""
This method is called by Qtmacs to prepare the macro for
execution.
It is probably a bad idea to overload this method as it only
administrates the macro execution and calls the ``qteRun``
method (which *should* be overloaded by the macro pr... | [
"def",
"qtePrepareToRun",
"(",
"self",
")",
":",
"# Report the execution attempt.",
"msgObj",
"=",
"QtmacsMessage",
"(",
"(",
"self",
".",
"qteMacroName",
"(",
")",
",",
"self",
".",
"qteWidget",
")",
",",
"None",
")",
"msgObj",
".",
"setSignalName",
"(",
"'... | This method is called by Qtmacs to prepare the macro for
execution.
It is probably a bad idea to overload this method as it only
administrates the macro execution and calls the ``qteRun``
method (which *should* be overloaded by the macro programmer
in order for the macro to do s... | [
"This",
"method",
"is",
"called",
"by",
"Qtmacs",
"to",
"prepare",
"the",
"macro",
"for",
"execution",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_macro.py#L418-L469 | train | Prepare to execute the macro for the current entry point. |
weijia/djangoautoconf | djangoautoconf/class_based_views/detail_with_inline_view.py | all_valid | def all_valid(formsets):
"""Returns true if every formset in formsets is valid."""
valid = True
for formset in formsets:
if not formset.is_valid():
valid = False
return valid | python | def all_valid(formsets):
"""Returns true if every formset in formsets is valid."""
valid = True
for formset in formsets:
if not formset.is_valid():
valid = False
return valid | [
"def",
"all_valid",
"(",
"formsets",
")",
":",
"valid",
"=",
"True",
"for",
"formset",
"in",
"formsets",
":",
"if",
"not",
"formset",
".",
"is_valid",
"(",
")",
":",
"valid",
"=",
"False",
"return",
"valid"
] | Returns true if every formset in formsets is valid. | [
"Returns",
"true",
"if",
"every",
"formset",
"in",
"formsets",
"is",
"valid",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/detail_with_inline_view.py#L7-L13 | train | Returns true if every formset in formsets is valid. |
weijia/djangoautoconf | djangoautoconf/class_based_views/detail_with_inline_view.py | DetailWithInlineView.forms_valid | def forms_valid(self, inlines):
"""
If the form and formsets are valid, save the associated models.
"""
for formset in inlines:
formset.save()
return HttpResponseRedirect(self.get_success_url()) | python | def forms_valid(self, inlines):
"""
If the form and formsets are valid, save the associated models.
"""
for formset in inlines:
formset.save()
return HttpResponseRedirect(self.get_success_url()) | [
"def",
"forms_valid",
"(",
"self",
",",
"inlines",
")",
":",
"for",
"formset",
"in",
"inlines",
":",
"formset",
".",
"save",
"(",
")",
"return",
"HttpResponseRedirect",
"(",
"self",
".",
"get_success_url",
"(",
")",
")"
] | If the form and formsets are valid, save the associated models. | [
"If",
"the",
"form",
"and",
"formsets",
"are",
"valid",
"save",
"the",
"associated",
"models",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/detail_with_inline_view.py#L34-L40 | train | The form and formsets are valid save the associated models. |
weijia/djangoautoconf | djangoautoconf/class_based_views/detail_with_inline_view.py | DetailWithInlineView.post | def post(self, request, *args, **kwargs):
"""
Handles POST requests, instantiating a form and formset instances with the passed
POST variables and then checked for validity.
"""
self.object = self.get_object()
self.get_context_data()
inlines = self.construct_inlin... | python | def post(self, request, *args, **kwargs):
"""
Handles POST requests, instantiating a form and formset instances with the passed
POST variables and then checked for validity.
"""
self.object = self.get_object()
self.get_context_data()
inlines = self.construct_inlin... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"self",
".",
"get_context_data",
"(",
")",
"inlines",
"=",
"self",
".",
"construct_inlin... | Handles POST requests, instantiating a form and formset instances with the passed
POST variables and then checked for validity. | [
"Handles",
"POST",
"requests",
"instantiating",
"a",
"form",
"and",
"formset",
"instances",
"with",
"the",
"passed",
"POST",
"variables",
"and",
"then",
"checked",
"for",
"validity",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/detail_with_inline_view.py#L60-L71 | train | Handles POST requests. Returns a list of forms that can be used to create a new instance of the formset. |
weijia/djangoautoconf | djangoautoconf/class_based_views/detail_with_inline_view.py | DetailWithInlineView.get_success_url | def get_success_url(self):
"""
Returns the supplied success URL.
"""
if self.success_url:
# Forcing possible reverse_lazy evaluation
url = force_text(self.success_url)
else:
raise ImproperlyConfigured(
"No URL to redirect to. Pr... | python | def get_success_url(self):
"""
Returns the supplied success URL.
"""
if self.success_url:
# Forcing possible reverse_lazy evaluation
url = force_text(self.success_url)
else:
raise ImproperlyConfigured(
"No URL to redirect to. Pr... | [
"def",
"get_success_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"success_url",
":",
"# Forcing possible reverse_lazy evaluation",
"url",
"=",
"force_text",
"(",
"self",
".",
"success_url",
")",
"else",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"No URL to redi... | Returns the supplied success URL. | [
"Returns",
"the",
"supplied",
"success",
"URL",
"."
] | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/detail_with_inline_view.py#L78-L88 | train | Returns the supplied success URL. |
olitheolix/qtmacs | qtmacs/applets/statusbar.py | StatusBar.displayStatusMessage | def displayStatusMessage(self, msgObj):
"""
Display the last status message and partially completed key sequences.
|Args|
* ``msgObj`` (**QtmacsMessage**): the data supplied by the hook.
|Returns|
* **None**
|Raises|
* **None**
"""
#... | python | def displayStatusMessage(self, msgObj):
"""
Display the last status message and partially completed key sequences.
|Args|
* ``msgObj`` (**QtmacsMessage**): the data supplied by the hook.
|Returns|
* **None**
|Raises|
* **None**
"""
#... | [
"def",
"displayStatusMessage",
"(",
"self",
",",
"msgObj",
")",
":",
"# Ensure the message ends with a newline character.",
"msg",
"=",
"msgObj",
".",
"data",
"if",
"not",
"msg",
".",
"endswith",
"(",
"'\\n'",
")",
":",
"msg",
"=",
"msg",
"+",
"'\\n'",
"# Disp... | Display the last status message and partially completed key sequences.
|Args|
* ``msgObj`` (**QtmacsMessage**): the data supplied by the hook.
|Returns|
* **None**
|Raises|
* **None** | [
"Display",
"the",
"last",
"status",
"message",
"and",
"partially",
"completed",
"key",
"sequences",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/statusbar.py#L78-L101 | train | Display the last status message and partially completed key sequences. |
olitheolix/qtmacs | qtmacs/applets/logviewer.py | LogViewer.qteUpdateLogSlot | def qteUpdateLogSlot(self):
"""
Fetch and display the next batch of log messages.
"""
# Fetch all log records that have arrived since the last
# fetch() call and update the record counter.
log = self.logHandler.fetch(start=self.qteLogCnt)
self.qteLogCnt += len(lo... | python | def qteUpdateLogSlot(self):
"""
Fetch and display the next batch of log messages.
"""
# Fetch all log records that have arrived since the last
# fetch() call and update the record counter.
log = self.logHandler.fetch(start=self.qteLogCnt)
self.qteLogCnt += len(lo... | [
"def",
"qteUpdateLogSlot",
"(",
"self",
")",
":",
"# Fetch all log records that have arrived since the last",
"# fetch() call and update the record counter.",
"log",
"=",
"self",
".",
"logHandler",
".",
"fetch",
"(",
"start",
"=",
"self",
".",
"qteLogCnt",
")",
"self",
... | Fetch and display the next batch of log messages. | [
"Fetch",
"and",
"display",
"the",
"next",
"batch",
"of",
"log",
"messages",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/logviewer.py#L196-L246 | train | Update the slot in the log buffer. |
olitheolix/qtmacs | qtmacs/applets/logviewer.py | LogViewer.qteMoveToEndOfBuffer | def qteMoveToEndOfBuffer(self):
"""
Move cursor to the end of the buffer to facilitate auto
scrolling.
Technically, this is exactly the 'endOfBuffer' macro but to
avoid swamping Qtmacs with 'qteRunMacroStarted' messages to no
avail it was implemented here natively.
... | python | def qteMoveToEndOfBuffer(self):
"""
Move cursor to the end of the buffer to facilitate auto
scrolling.
Technically, this is exactly the 'endOfBuffer' macro but to
avoid swamping Qtmacs with 'qteRunMacroStarted' messages to no
avail it was implemented here natively.
... | [
"def",
"qteMoveToEndOfBuffer",
"(",
"self",
")",
":",
"tc",
"=",
"self",
".",
"qteText",
".",
"textCursor",
"(",
")",
"tc",
".",
"movePosition",
"(",
"QtGui",
".",
"QTextCursor",
".",
"End",
")",
"self",
".",
"qteText",
".",
"setTextCursor",
"(",
"tc",
... | Move cursor to the end of the buffer to facilitate auto
scrolling.
Technically, this is exactly the 'endOfBuffer' macro but to
avoid swamping Qtmacs with 'qteRunMacroStarted' messages to no
avail it was implemented here natively. | [
"Move",
"cursor",
"to",
"the",
"end",
"of",
"the",
"buffer",
"to",
"facilitate",
"auto",
"scrolling",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/logviewer.py#L248-L259 | train | Move cursor to the end of the buffer. |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/token_signing.py | sign_token_records | def sign_token_records(profile_components, parent_private_key,
signing_algorithm="ES256K"):
""" Function for iterating through a list of profile components and
signing separate individual profile tokens.
"""
if signing_algorithm != "ES256K":
raise ValueError("Signing ... | python | def sign_token_records(profile_components, parent_private_key,
signing_algorithm="ES256K"):
""" Function for iterating through a list of profile components and
signing separate individual profile tokens.
"""
if signing_algorithm != "ES256K":
raise ValueError("Signing ... | [
"def",
"sign_token_records",
"(",
"profile_components",
",",
"parent_private_key",
",",
"signing_algorithm",
"=",
"\"ES256K\"",
")",
":",
"if",
"signing_algorithm",
"!=",
"\"ES256K\"",
":",
"raise",
"ValueError",
"(",
"\"Signing algorithm not supported\"",
")",
"token_rec... | Function for iterating through a list of profile components and
signing separate individual profile tokens. | [
"Function",
"for",
"iterating",
"through",
"a",
"list",
"of",
"profile",
"components",
"and",
"signing",
"separate",
"individual",
"profile",
"tokens",
"."
] | 103783798df78cf0f007801e79ec6298f00b2817 | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/token_signing.py#L46-L69 | train | Function for iterating through a list of profile components and signing separate individual profile tokens. |
projectshift/shift-schema | shiftschema/translator.py | Translator.normalize_locale | def normalize_locale(locale):
"""
Normalize locale
Extracts language code from passed in locale string to be used later
for dictionaries loading.
:param locale: string, locale (en, en_US)
:return: string, language code
"""
import r... | python | def normalize_locale(locale):
"""
Normalize locale
Extracts language code from passed in locale string to be used later
for dictionaries loading.
:param locale: string, locale (en, en_US)
:return: string, language code
"""
import r... | [
"def",
"normalize_locale",
"(",
"locale",
")",
":",
"import",
"re",
"match",
"=",
"re",
".",
"match",
"(",
"r'^[a-z]+'",
",",
"locale",
".",
"lower",
"(",
")",
")",
"if",
"match",
":",
"return",
"match",
".",
"group",
"(",
")"
] | Normalize locale
Extracts language code from passed in locale string to be used later
for dictionaries loading.
:param locale: string, locale (en, en_US)
:return: string, language code | [
"Normalize",
"locale",
"Extracts",
"language",
"code",
"from",
"passed",
"in",
"locale",
"string",
"to",
"be",
"used",
"later",
"for",
"dictionaries",
"loading",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/translator.py#L22-L34 | train | Normalizes locale string to be used later
for dictionaries loading. |
projectshift/shift-schema | shiftschema/translator.py | Translator.get_translations | def get_translations(self, locale):
"""
Get translation dictionary
Returns a dictionary for locale or raises an exception if such can't
be located. If a dictionary for locale was previously loaded returns
that, otherwise goes through registered locations and merges any
fo... | python | def get_translations(self, locale):
"""
Get translation dictionary
Returns a dictionary for locale or raises an exception if such can't
be located. If a dictionary for locale was previously loaded returns
that, otherwise goes through registered locations and merges any
fo... | [
"def",
"get_translations",
"(",
"self",
",",
"locale",
")",
":",
"locale",
"=",
"self",
".",
"normalize_locale",
"(",
"locale",
")",
"if",
"locale",
"in",
"self",
".",
"translations",
":",
"return",
"self",
".",
"translations",
"[",
"locale",
"]",
"transla... | Get translation dictionary
Returns a dictionary for locale or raises an exception if such can't
be located. If a dictionary for locale was previously loaded returns
that, otherwise goes through registered locations and merges any
found custom dictionaries with defaults.
:param l... | [
"Get",
"translation",
"dictionary",
"Returns",
"a",
"dictionary",
"for",
"locale",
"or",
"raises",
"an",
"exception",
"if",
"such",
"can",
"t",
"be",
"located",
".",
"If",
"a",
"dictionary",
"for",
"locale",
"was",
"previously",
"loaded",
"returns",
"that",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/translator.py#L51-L89 | train | Get translation dictionary for locale |
projectshift/shift-schema | shiftschema/translator.py | Translator.translate | def translate(self, message, locale):
"""
Translate
Translates a message to the given locale language. Will return original
message if no translation exists for the message.
:param message: str, a message to translate
:param locale: str, locale or langua... | python | def translate(self, message, locale):
"""
Translate
Translates a message to the given locale language. Will return original
message if no translation exists for the message.
:param message: str, a message to translate
:param locale: str, locale or langua... | [
"def",
"translate",
"(",
"self",
",",
"message",
",",
"locale",
")",
":",
"translations",
"=",
"self",
".",
"get_translations",
"(",
"locale",
")",
"if",
"message",
"in",
"translations",
":",
"return",
"translations",
"[",
"message",
"]",
"# return untranslate... | Translate
Translates a message to the given locale language. Will return original
message if no translation exists for the message.
:param message: str, a message to translate
:param locale: str, locale or language code
:return: str, translated (i... | [
"Translate",
"Translates",
"a",
"message",
"to",
"the",
"given",
"locale",
"language",
".",
"Will",
"return",
"original",
"message",
"if",
"no",
"translation",
"exists",
"for",
"the",
"message",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/translator.py#L93-L108 | train | Translate a message to the given locale. Will return original message if no translation exists for the message. |
weijia/djangoautoconf | djangoautoconf/class_based_views/create_view_factory.py | create_ajaxable_view_from_model_inherit_parent_class | def create_ajaxable_view_from_model_inherit_parent_class(model_class, parent_class_list, operation="Create"):
"""
:param model_class: the django model class
:param operation: "Create" or "Update"
:param ajax_mixin: user may pass a sub class of AjaxableResponseMixin to put more info in the ajax response
... | python | def create_ajaxable_view_from_model_inherit_parent_class(model_class, parent_class_list, operation="Create"):
"""
:param model_class: the django model class
:param operation: "Create" or "Update"
:param ajax_mixin: user may pass a sub class of AjaxableResponseMixin to put more info in the ajax response
... | [
"def",
"create_ajaxable_view_from_model_inherit_parent_class",
"(",
"model_class",
",",
"parent_class_list",
",",
"operation",
"=",
"\"Create\"",
")",
":",
"generic_module",
"=",
"importlib",
".",
"import_module",
"(",
"\"django.views.generic\"",
")",
"view_class_name",
"="... | :param model_class: the django model class
:param operation: "Create" or "Update"
:param ajax_mixin: user may pass a sub class of AjaxableResponseMixin to put more info in the ajax response
:return: dynamically generated class based view. The instance of the view class has as_view method. | [
":",
"param",
"model_class",
":",
"the",
"django",
"model",
"class",
":",
"param",
"operation",
":",
"Create",
"or",
"Update",
":",
"param",
"ajax_mixin",
":",
"user",
"may",
"pass",
"a",
"sub",
"class",
"of",
"AjaxableResponseMixin",
"to",
"put",
"more",
... | b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0 | https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/create_view_factory.py#L33-L53 | train | create a dynamically generated class based view from a Django model class inheriting the parent class. |
Addvilz/hemp | hemp/release.py | release_local | def release_local(url, version='patch', base='master', integration=None, default_version='0.0.1', use_prefix=None):
# type: (str, str, str, str, str, str) -> str
"""
Tag given repository with a new semver tag (bump version),
optionally merging a integration branch.
This will:
- clone the re... | python | def release_local(url, version='patch', base='master', integration=None, default_version='0.0.1', use_prefix=None):
# type: (str, str, str, str, str, str) -> str
"""
Tag given repository with a new semver tag (bump version),
optionally merging a integration branch.
This will:
- clone the re... | [
"def",
"release_local",
"(",
"url",
",",
"version",
"=",
"'patch'",
",",
"base",
"=",
"'master'",
",",
"integration",
"=",
"None",
",",
"default_version",
"=",
"'0.0.1'",
",",
"use_prefix",
"=",
"None",
")",
":",
"# type: (str, str, str, str, str, str) -> str",
... | Tag given repository with a new semver tag (bump version),
optionally merging a integration branch.
This will:
- clone the repository to temporary directory
- checkout branch indicated via base argument
- retrieve all the tags, sort them in natural order
- retrieve the last tag ... | [
"Tag",
"given",
"repository",
"with",
"a",
"new",
"semver",
"tag",
"(",
"bump",
"version",
")",
"optionally",
"merging",
"a",
"integration",
"branch",
"."
] | 80d189f15ba20068a61efc2591070c80549c9d06 | https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/release.py#L11-L123 | train | Release a new version from a local repository. |
casouri/launchdman | launchdman/__init__.py | flatten | def flatten(l):
'''Flatten a multi-deminision list and return a iterable
Note that dict and str will not be expanded, instead, they will be kept as a single element.
Args:
l (list): The list needs to be flattened
Returns:
A iterable of flattened list. To have a list instead use ``list... | python | def flatten(l):
'''Flatten a multi-deminision list and return a iterable
Note that dict and str will not be expanded, instead, they will be kept as a single element.
Args:
l (list): The list needs to be flattened
Returns:
A iterable of flattened list. To have a list instead use ``list... | [
"def",
"flatten",
"(",
"l",
")",
":",
"for",
"el",
"in",
"l",
":",
"# I don;t want dict to be flattened",
"if",
"isinstance",
"(",
"el",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"el",
",",
"(",
"str",
",",
"bytes",
")",
")",
"and",
"not",... | Flatten a multi-deminision list and return a iterable
Note that dict and str will not be expanded, instead, they will be kept as a single element.
Args:
l (list): The list needs to be flattened
Returns:
A iterable of flattened list. To have a list instead use ``list(flatten(l))`` | [
"Flatten",
"a",
"multi",
"-",
"deminision",
"list",
"and",
"return",
"a",
"iterable"
] | c83840e640cb075fab2534049f1e25fac6933c64 | https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L33-L50 | train | Flatten a multi - deminision list and return a iterable
|
casouri/launchdman | launchdman/__init__.py | crossCombine | def crossCombine(l):
''' Taken a list of lists, returns a big list of lists contain all the possibilities of elements of sublist combining together.
It is basically a Combinatorics of list. For example:
>>> crossCombine([[a,a1,a2,...], [b,b1,b2,...]])
>>> [[a,b], [a,b1], [a,b2], [a1,b], [a1,b1... | python | def crossCombine(l):
''' Taken a list of lists, returns a big list of lists contain all the possibilities of elements of sublist combining together.
It is basically a Combinatorics of list. For example:
>>> crossCombine([[a,a1,a2,...], [b,b1,b2,...]])
>>> [[a,b], [a,b1], [a,b2], [a1,b], [a1,b1... | [
"def",
"crossCombine",
"(",
"l",
")",
":",
"resultList",
"=",
"[",
"]",
"firstList",
"=",
"l",
"[",
"0",
"]",
"rest",
"=",
"l",
"[",
"1",
":",
"]",
"if",
"len",
"(",
"rest",
")",
"==",
"0",
":",
"return",
"firstList",
"for",
"e",
"in",
"firstLi... | Taken a list of lists, returns a big list of lists contain all the possibilities of elements of sublist combining together.
It is basically a Combinatorics of list. For example:
>>> crossCombine([[a,a1,a2,...], [b,b1,b2,...]])
>>> [[a,b], [a,b1], [a,b2], [a1,b], [a1,b1], [a1, b2], [a2,b], [a2,b1],... | [
"Taken",
"a",
"list",
"of",
"lists",
"returns",
"a",
"big",
"list",
"of",
"lists",
"contain",
"all",
"the",
"possibilities",
"of",
"elements",
"of",
"sublist",
"combining",
"together",
"."
] | c83840e640cb075fab2534049f1e25fac6933c64 | https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L53-L82 | train | Takes a list of lists returns a big list of lists containing all the possibilities of elements of sublist combining together. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.