repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
networks-lab/metaknowledge | metaknowledge/recordCollection.py | makeNodeTuple | def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR):
"""Makes a tuple of idVal and a dict of the selected attributes"""
d = {}
if nodeInfo:
if nodeType == 'full':
if coreValues:
if citation in coreCites... | python | def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR):
"""Makes a tuple of idVal and a dict of the selected attributes"""
d = {}
if nodeInfo:
if nodeType == 'full':
if coreValues:
if citation in coreCites... | [
"def",
"makeNodeTuple",
"(",
"citation",
",",
"idVal",
",",
"nodeInfo",
",",
"fullInfo",
",",
"nodeType",
",",
"count",
",",
"coreCitesDict",
",",
"coreValues",
",",
"detailedValues",
",",
"addCR",
")",
":",
"d",
"=",
"{",
"}",
"if",
"nodeInfo",
":",
"if... | Makes a tuple of idVal and a dict of the selected attributes | [
"Makes",
"a",
"tuple",
"of",
"idVal",
"and",
"a",
"dict",
"of",
"the",
"selected",
"attributes"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1709-L1760 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | expandRecs | def expandRecs(G, RecCollect, nodeType, weighted):
"""Expand all the citations from _RecCollect_"""
for Rec in RecCollect:
fullCiteList = [makeID(c, nodeType) for c in Rec.createCitation(multiCite = True)]
if len(fullCiteList) > 1:
for i, citeID1 in enumerate(fullCiteList):
... | python | def expandRecs(G, RecCollect, nodeType, weighted):
"""Expand all the citations from _RecCollect_"""
for Rec in RecCollect:
fullCiteList = [makeID(c, nodeType) for c in Rec.createCitation(multiCite = True)]
if len(fullCiteList) > 1:
for i, citeID1 in enumerate(fullCiteList):
... | [
"def",
"expandRecs",
"(",
"G",
",",
"RecCollect",
",",
"nodeType",
",",
"weighted",
")",
":",
"for",
"Rec",
"in",
"RecCollect",
":",
"fullCiteList",
"=",
"[",
"makeID",
"(",
"c",
",",
"nodeType",
")",
"for",
"c",
"in",
"Rec",
".",
"createCitation",
"("... | Expand all the citations from _RecCollect_ | [
"Expand",
"all",
"the",
"citations",
"from",
"_RecCollect_"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1792-L1812 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.dropNonJournals | def dropNonJournals(self, ptVal = 'J', dropBad = True, invert = False):
"""Drops the non journal type `Records` from the collection, this is done by checking _ptVal_ against the PT tag
# Parameters
_ptVal_ : `optional [str]`
> Default `'J'`, The value of the PT tag to be kept, default... | python | def dropNonJournals(self, ptVal = 'J', dropBad = True, invert = False):
"""Drops the non journal type `Records` from the collection, this is done by checking _ptVal_ against the PT tag
# Parameters
_ptVal_ : `optional [str]`
> Default `'J'`, The value of the PT tag to be kept, default... | [
"def",
"dropNonJournals",
"(",
"self",
",",
"ptVal",
"=",
"'J'",
",",
"dropBad",
"=",
"True",
",",
"invert",
"=",
"False",
")",
":",
"if",
"dropBad",
":",
"self",
".",
"dropBadEntries",
"(",
")",
"if",
"invert",
":",
"self",
".",
"_collection",
"=",
... | Drops the non journal type `Records` from the collection, this is done by checking _ptVal_ against the PT tag
# Parameters
_ptVal_ : `optional [str]`
> Default `'J'`, The value of the PT tag to be kept, default is `'J'` the journal tag, other tags can be substituted.
_dropBad_ : `opt... | [
"Drops",
"the",
"non",
"journal",
"type",
"Records",
"from",
"the",
"collection",
"this",
"is",
"done",
"by",
"checking",
"_ptVal_",
"against",
"the",
"PT",
"tag"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L192-L214 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.writeFile | def writeFile(self, fname = None):
"""Writes the `RecordCollection` to a file, the written file's format is identical to those download from WOS. The order of `Records` written is random.
# Parameters
_fname_ : `optional [str]`
> Default `None`, if given the output file will written t... | python | def writeFile(self, fname = None):
"""Writes the `RecordCollection` to a file, the written file's format is identical to those download from WOS. The order of `Records` written is random.
# Parameters
_fname_ : `optional [str]`
> Default `None`, if given the output file will written t... | [
"def",
"writeFile",
"(",
"self",
",",
"fname",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"_collectedTypes",
")",
"<",
"2",
":",
"recEncoding",
"=",
"self",
".",
"peek",
"(",
")",
".",
"encoding",
"(",
")",
"else",
":",
"recEncoding",
"=... | Writes the `RecordCollection` to a file, the written file's format is identical to those download from WOS. The order of `Records` written is random.
# Parameters
_fname_ : `optional [str]`
> Default `None`, if given the output file will written to _fanme_, if `None` the `RecordCollection`'s ... | [
"Writes",
"the",
"RecordCollection",
"to",
"a",
"file",
"the",
"written",
"file",
"s",
"format",
"is",
"identical",
"to",
"those",
"download",
"from",
"WOS",
".",
"The",
"order",
"of",
"Records",
"written",
"is",
"random",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L216-L245 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.writeBib | def writeBib(self, fname = None, maxStringLength = 1000, wosMode = False, reducedOutput = False, niceIDs = True):
"""Writes a bibTex entry to _fname_ for each `Record` in the collection.
If the Record is of a journal article (PT J) the bibtext type is set to `'article'`, otherwise it is set to `'misc'`... | python | def writeBib(self, fname = None, maxStringLength = 1000, wosMode = False, reducedOutput = False, niceIDs = True):
"""Writes a bibTex entry to _fname_ for each `Record` in the collection.
If the Record is of a journal article (PT J) the bibtext type is set to `'article'`, otherwise it is set to `'misc'`... | [
"def",
"writeBib",
"(",
"self",
",",
"fname",
"=",
"None",
",",
"maxStringLength",
"=",
"1000",
",",
"wosMode",
"=",
"False",
",",
"reducedOutput",
"=",
"False",
",",
"niceIDs",
"=",
"True",
")",
":",
"if",
"fname",
":",
"f",
"=",
"open",
"(",
"fname... | Writes a bibTex entry to _fname_ for each `Record` in the collection.
If the Record is of a journal article (PT J) the bibtext type is set to `'article'`, otherwise it is set to `'misc'`. The ID of the entry is the WOS number and all the Record's fields are given as entries with their long names.
**No... | [
"Writes",
"a",
"bibTex",
"entry",
"to",
"_fname_",
"for",
"each",
"Record",
"in",
"the",
"collection",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L373-L418 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.makeDict | def makeDict(self, onlyTheseTags = None, longNames = False, raw = False, numAuthors = True, genderCounts = True):
"""Returns a dict with each key a tag and the values being lists of the values for each of the Records in the collection, `None` is given when there is no value and they are in the same order across... | python | def makeDict(self, onlyTheseTags = None, longNames = False, raw = False, numAuthors = True, genderCounts = True):
"""Returns a dict with each key a tag and the values being lists of the values for each of the Records in the collection, `None` is given when there is no value and they are in the same order across... | [
"def",
"makeDict",
"(",
"self",
",",
"onlyTheseTags",
"=",
"None",
",",
"longNames",
"=",
"False",
",",
"raw",
"=",
"False",
",",
"numAuthors",
"=",
"True",
",",
"genderCounts",
"=",
"True",
")",
":",
"if",
"onlyTheseTags",
":",
"for",
"i",
"in",
"rang... | Returns a dict with each key a tag and the values being lists of the values for each of the Records in the collection, `None` is given when there is no value and they are in the same order across each tag.
When used with pandas: `pandas.DataFrame(RC.makeDict())` returns a data frame with each column a tag and ... | [
"Returns",
"a",
"dict",
"with",
"each",
"key",
"a",
"tag",
"and",
"the",
"values",
"being",
"lists",
"of",
"the",
"values",
"for",
"each",
"of",
"the",
"Records",
"in",
"the",
"collection",
"None",
"is",
"given",
"when",
"there",
"is",
"no",
"value",
"... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L698-L753 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.getCitations | def getCitations(self, field = None, values = None, pandasFriendly = True, counts = True):
"""Creates a pandas ready dict with each row a different citation the contained Records and columns containing the original string, year, journal, author's name and the number of times it occured.
There are also ... | python | def getCitations(self, field = None, values = None, pandasFriendly = True, counts = True):
"""Creates a pandas ready dict with each row a different citation the contained Records and columns containing the original string, year, journal, author's name and the number of times it occured.
There are also ... | [
"def",
"getCitations",
"(",
"self",
",",
"field",
"=",
"None",
",",
"values",
"=",
"None",
",",
"pandasFriendly",
"=",
"True",
",",
"counts",
"=",
"True",
")",
":",
"retCites",
"=",
"[",
"]",
"if",
"values",
"is",
"not",
"None",
":",
"if",
"isinstanc... | Creates a pandas ready dict with each row a different citation the contained Records and columns containing the original string, year, journal, author's name and the number of times it occured.
There are also options to filter the output citations with _field_ and _values_
# Parameters
_field... | [
"Creates",
"a",
"pandas",
"ready",
"dict",
"with",
"each",
"row",
"a",
"different",
"citation",
"the",
"contained",
"Records",
"and",
"columns",
"containing",
"the",
"original",
"string",
"year",
"journal",
"author",
"s",
"name",
"and",
"the",
"number",
"of",
... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L900-L940 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.networkCoCitation | def networkCoCitation(self, dropAnon = True, nodeType = "full", nodeInfo = True, fullInfo = False, weighted = True, dropNonJournals = False, count = True, keyWords = None, detailedCore = True, detailedCoreAttributes = False, coreOnly = False, expandedCore = False, addCR = False):
"""Creates a co-citation networ... | python | def networkCoCitation(self, dropAnon = True, nodeType = "full", nodeInfo = True, fullInfo = False, weighted = True, dropNonJournals = False, count = True, keyWords = None, detailedCore = True, detailedCoreAttributes = False, coreOnly = False, expandedCore = False, addCR = False):
"""Creates a co-citation networ... | [
"def",
"networkCoCitation",
"(",
"self",
",",
"dropAnon",
"=",
"True",
",",
"nodeType",
"=",
"\"full\"",
",",
"nodeInfo",
"=",
"True",
",",
"fullInfo",
"=",
"False",
",",
"weighted",
"=",
"True",
",",
"dropNonJournals",
"=",
"False",
",",
"count",
"=",
"... | Creates a co-citation network for the RecordCollection.
# Parameters
_nodeType_ : `optional [str]`
> One of `"full"`, `"original"`, `"author"`, `"journal"` or `"year"`. Specifies the value of the nodes in the graph. The default `"full"` causes the citations to be compared holistically using t... | [
"Creates",
"a",
"co",
"-",
"citation",
"network",
"for",
"the",
"RecordCollection",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1075-L1177 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.networkBibCoupling | def networkBibCoupling(self, weighted = True, fullInfo = False, addCR = False):
"""Creates a bibliographic coupling network based on citations for the RecordCollection.
# Parameters
_weighted_ : `optional bool`
> Default `True`, if `True` the weight of the edges will be added to the n... | python | def networkBibCoupling(self, weighted = True, fullInfo = False, addCR = False):
"""Creates a bibliographic coupling network based on citations for the RecordCollection.
# Parameters
_weighted_ : `optional bool`
> Default `True`, if `True` the weight of the edges will be added to the n... | [
"def",
"networkBibCoupling",
"(",
"self",
",",
"weighted",
"=",
"True",
",",
"fullInfo",
"=",
"False",
",",
"addCR",
"=",
"False",
")",
":",
"progArgs",
"=",
"(",
"0",
",",
"\"Make a citation network for coupling\"",
")",
"if",
"metaknowledge",
".",
"VERBOSE_M... | Creates a bibliographic coupling network based on citations for the RecordCollection.
# Parameters
_weighted_ : `optional bool`
> Default `True`, if `True` the weight of the edges will be added to the network
_fullInfo_ : `optional bool`
> Default `False`, if `True` the full... | [
"Creates",
"a",
"bibliographic",
"coupling",
"network",
"based",
"on",
"citations",
"for",
"the",
"RecordCollection",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1294-L1348 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.yearSplit | def yearSplit(self, startYear, endYear, dropMissingYears = True):
"""Creates a RecordCollection of Records from the years between _startYear_ and _endYear_ inclusive.
# Parameters
_startYear_ : `int`
> The smallest year to be included in the returned RecordCollection
_endYear... | python | def yearSplit(self, startYear, endYear, dropMissingYears = True):
"""Creates a RecordCollection of Records from the years between _startYear_ and _endYear_ inclusive.
# Parameters
_startYear_ : `int`
> The smallest year to be included in the returned RecordCollection
_endYear... | [
"def",
"yearSplit",
"(",
"self",
",",
"startYear",
",",
"endYear",
",",
"dropMissingYears",
"=",
"True",
")",
":",
"recordsInRange",
"=",
"set",
"(",
")",
"for",
"R",
"in",
"self",
":",
"try",
":",
"if",
"R",
".",
"get",
"(",
"'year'",
")",
">=",
"... | Creates a RecordCollection of Records from the years between _startYear_ and _endYear_ inclusive.
# Parameters
_startYear_ : `int`
> The smallest year to be included in the returned RecordCollection
_endYear_ : `int`
> The largest year to be included in the returned RecordCo... | [
"Creates",
"a",
"RecordCollection",
"of",
"Records",
"from",
"the",
"years",
"between",
"_startYear_",
"and",
"_endYear_",
"inclusive",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1362-L1397 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.localCiteStats | def localCiteStats(self, pandasFriendly = False, keyType = "citation"):
"""Returns a dict with all the citations in the CR field as keys and the number of times they occur as the values
# Parameters
_pandasFriendly_ : `optional [bool]`
> default `False`, makes the output be a dict wit... | python | def localCiteStats(self, pandasFriendly = False, keyType = "citation"):
"""Returns a dict with all the citations in the CR field as keys and the number of times they occur as the values
# Parameters
_pandasFriendly_ : `optional [bool]`
> default `False`, makes the output be a dict wit... | [
"def",
"localCiteStats",
"(",
"self",
",",
"pandasFriendly",
"=",
"False",
",",
"keyType",
"=",
"\"citation\"",
")",
":",
"count",
"=",
"0",
"recCount",
"=",
"len",
"(",
"self",
")",
"progArgs",
"=",
"(",
"0",
",",
"\"Starting to get the local stats on {}s.\""... | Returns a dict with all the citations in the CR field as keys and the number of times they occur as the values
# Parameters
_pandasFriendly_ : `optional [bool]`
> default `False`, makes the output be a dict with two keys one `'Citations'` is the citations the other is their occurrence counts ... | [
"Returns",
"a",
"dict",
"with",
"all",
"the",
"citations",
"in",
"the",
"CR",
"field",
"as",
"keys",
"and",
"the",
"number",
"of",
"times",
"they",
"occur",
"as",
"the",
"values"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1399-L1457 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.localCitesOf | def localCitesOf(self, rec):
"""Takes in a Record, WOS string, citation string or Citation and returns a RecordCollection of all records that cite it.
# Parameters
_rec_ : `Record, str or Citation`
> The object that is being cited
# Returns
`RecordCollection`
... | python | def localCitesOf(self, rec):
"""Takes in a Record, WOS string, citation string or Citation and returns a RecordCollection of all records that cite it.
# Parameters
_rec_ : `Record, str or Citation`
> The object that is being cited
# Returns
`RecordCollection`
... | [
"def",
"localCitesOf",
"(",
"self",
",",
"rec",
")",
":",
"localCites",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"rec",
",",
"Record",
")",
":",
"recCite",
"=",
"rec",
".",
"createCitation",
"(",
")",
"if",
"isinstance",
"(",
"rec",
",",
"str",
")",
... | Takes in a Record, WOS string, citation string or Citation and returns a RecordCollection of all records that cite it.
# Parameters
_rec_ : `Record, str or Citation`
> The object that is being cited
# Returns
`RecordCollection`
> A `RecordCollection` containing only... | [
"Takes",
"in",
"a",
"Record",
"WOS",
"string",
"citation",
"string",
"or",
"Citation",
"and",
"returns",
"a",
"RecordCollection",
"of",
"all",
"records",
"that",
"cite",
"it",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1459-L1501 | train |
networks-lab/metaknowledge | metaknowledge/recordCollection.py | RecordCollection.citeFilter | def citeFilter(self, keyString = '', field = 'all', reverse = False, caseSensitive = False):
"""Filters `Records` by some string, _keyString_, in their citations and returns all `Records` with at least one citation possessing _keyString_ in the field given by _field_.
# Parameters
_keyString_ ... | python | def citeFilter(self, keyString = '', field = 'all', reverse = False, caseSensitive = False):
"""Filters `Records` by some string, _keyString_, in their citations and returns all `Records` with at least one citation possessing _keyString_ in the field given by _field_.
# Parameters
_keyString_ ... | [
"def",
"citeFilter",
"(",
"self",
",",
"keyString",
"=",
"''",
",",
"field",
"=",
"'all'",
",",
"reverse",
"=",
"False",
",",
"caseSensitive",
"=",
"False",
")",
":",
"retRecs",
"=",
"[",
"]",
"keyString",
"=",
"str",
"(",
"keyString",
")",
"for",
"R... | Filters `Records` by some string, _keyString_, in their citations and returns all `Records` with at least one citation possessing _keyString_ in the field given by _field_.
# Parameters
_keyString_ : `optional [str]`
> Default `''`, gives the string to be searched for, if it is is blank then ... | [
"Filters",
"Records",
"by",
"some",
"string",
"_keyString_",
"in",
"their",
"citations",
"and",
"returns",
"all",
"Records",
"with",
"at",
"least",
"one",
"citation",
"possessing",
"_keyString_",
"in",
"the",
"field",
"given",
"by",
"_field_",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/recordCollection.py#L1503-L1615 | train |
networks-lab/metaknowledge | metaknowledge/citation.py | filterNonJournals | def filterNonJournals(citesLst, invert = False):
"""Removes the `Citations` from _citesLst_ that are not journals
# Parameters
_citesLst_ : `list [Citation]`
> A list of citations to be filtered
_invert_ : `optional [bool]`
> Default `False`, if `True` non-journals will be kept instead of j... | python | def filterNonJournals(citesLst, invert = False):
"""Removes the `Citations` from _citesLst_ that are not journals
# Parameters
_citesLst_ : `list [Citation]`
> A list of citations to be filtered
_invert_ : `optional [bool]`
> Default `False`, if `True` non-journals will be kept instead of j... | [
"def",
"filterNonJournals",
"(",
"citesLst",
",",
"invert",
"=",
"False",
")",
":",
"retCites",
"=",
"[",
"]",
"for",
"c",
"in",
"citesLst",
":",
"if",
"c",
".",
"isJournal",
"(",
")",
":",
"if",
"not",
"invert",
":",
"retCites",
".",
"append",
"(",
... | Removes the `Citations` from _citesLst_ that are not journals
# Parameters
_citesLst_ : `list [Citation]`
> A list of citations to be filtered
_invert_ : `optional [bool]`
> Default `False`, if `True` non-journals will be kept instead of journals
# Returns
`list [Citation]`
> A f... | [
"Removes",
"the",
"Citations",
"from",
"_citesLst_",
"that",
"are",
"not",
"journals"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/citation.py#L364-L391 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.add | def add(self, elem):
""" Adds _elem_ to the collection.
# Parameters
_elem_ : `object`
> The object to be added
"""
if isinstance(elem, self._allowedTypes):
self._collection.add(elem)
self._collectedTypes.add(type(elem).__name__)
else:
... | python | def add(self, elem):
""" Adds _elem_ to the collection.
# Parameters
_elem_ : `object`
> The object to be added
"""
if isinstance(elem, self._allowedTypes):
self._collection.add(elem)
self._collectedTypes.add(type(elem).__name__)
else:
... | [
"def",
"add",
"(",
"self",
",",
"elem",
")",
":",
"if",
"isinstance",
"(",
"elem",
",",
"self",
".",
"_allowedTypes",
")",
":",
"self",
".",
"_collection",
".",
"add",
"(",
"elem",
")",
"self",
".",
"_collectedTypes",
".",
"add",
"(",
"type",
"(",
... | Adds _elem_ to the collection.
# Parameters
_elem_ : `object`
> The object to be added | [
"Adds",
"_elem_",
"to",
"the",
"collection",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L120-L133 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.remove | def remove(self, elem):
"""Removes _elem_ from the collection, will raise a KeyError is _elem_ is missing
# Parameters
_elem_ : `object`
> The object to be removed
"""
try:
return self._collection.remove(elem)
except KeyError:
raise KeyE... | python | def remove(self, elem):
"""Removes _elem_ from the collection, will raise a KeyError is _elem_ is missing
# Parameters
_elem_ : `object`
> The object to be removed
"""
try:
return self._collection.remove(elem)
except KeyError:
raise KeyE... | [
"def",
"remove",
"(",
"self",
",",
"elem",
")",
":",
"try",
":",
"return",
"self",
".",
"_collection",
".",
"remove",
"(",
"elem",
")",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"'{}' was not found in the {}: '{}'.\"",
".",
"format",
"(",
"elem"... | Removes _elem_ from the collection, will raise a KeyError is _elem_ is missing
# Parameters
_elem_ : `object`
> The object to be removed | [
"Removes",
"_elem_",
"from",
"the",
"collection",
"will",
"raise",
"a",
"KeyError",
"is",
"_elem_",
"is",
"missing"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L147-L159 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.clear | def clear(self):
""""Removes all elements from the collection and resets the error handling
"""
self.bad = False
self.errors = {}
self._collection.clear() | python | def clear(self):
""""Removes all elements from the collection and resets the error handling
"""
self.bad = False
self.errors = {}
self._collection.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"bad",
"=",
"False",
"self",
".",
"errors",
"=",
"{",
"}",
"self",
".",
"_collection",
".",
"clear",
"(",
")"
] | Removes all elements from the collection and resets the error handling | [
"Removes",
"all",
"elements",
"from",
"the",
"collection",
"and",
"resets",
"the",
"error",
"handling"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L161-L166 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.pop | def pop(self):
"""Removes a random element from the collection and returns it
# Returns
`object`
> A random object from the collection
"""
try:
return self._collection.pop()
except KeyError:
raise KeyError("Nothing left in the {}: '{}'."... | python | def pop(self):
"""Removes a random element from the collection and returns it
# Returns
`object`
> A random object from the collection
"""
try:
return self._collection.pop()
except KeyError:
raise KeyError("Nothing left in the {}: '{}'."... | [
"def",
"pop",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_collection",
".",
"pop",
"(",
")",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"Nothing left in the {}: '{}'.\"",
".",
"format",
"(",
"type",
"(",
"self",
")",
".",
"__n... | Removes a random element from the collection and returns it
# Returns
`object`
> A random object from the collection | [
"Removes",
"a",
"random",
"element",
"from",
"the",
"collection",
"and",
"returns",
"it"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L168-L180 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.copy | def copy(self):
"""Creates a shallow copy of the collection
# Returns
`Collection`
> A copy of the `Collection`
"""
collectedCopy = copy.copy(self)
collectedCopy._collection = copy.copy(collectedCopy._collection)
self._collectedTypes = copy.copy(self._c... | python | def copy(self):
"""Creates a shallow copy of the collection
# Returns
`Collection`
> A copy of the `Collection`
"""
collectedCopy = copy.copy(self)
collectedCopy._collection = copy.copy(collectedCopy._collection)
self._collectedTypes = copy.copy(self._c... | [
"def",
"copy",
"(",
"self",
")",
":",
"collectedCopy",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"collectedCopy",
".",
"_collection",
"=",
"copy",
".",
"copy",
"(",
"collectedCopy",
".",
"_collection",
")",
"self",
".",
"_collectedTypes",
"=",
"copy",
... | Creates a shallow copy of the collection
# Returns
`Collection`
> A copy of the `Collection` | [
"Creates",
"a",
"shallow",
"copy",
"of",
"the",
"collection"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L279-L293 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.chunk | def chunk(self, maxSize):
"""Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all m... | python | def chunk(self, maxSize):
"""Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all m... | [
"def",
"chunk",
"(",
"self",
",",
"maxSize",
")",
":",
"chunks",
"=",
"[",
"]",
"currentSize",
"=",
"maxSize",
"+",
"1",
"for",
"i",
"in",
"self",
":",
"if",
"currentSize",
">=",
"maxSize",
":",
"currentSize",
"=",
"0",
"chunks",
".",
"append",
"(",
... | Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all merged (`|` operator) would create the... | [
"Splits",
"the",
"Collection",
"into",
"_maxSize_",
"size",
"or",
"smaller",
"Collections"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L309-L334 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | Collection.split | def split(self, maxSize):
"""Destructively, splits the `Collection` into _maxSize_ size or smaller `Collections`. The source `Collection` will be empty after this operation
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
... | python | def split(self, maxSize):
"""Destructively, splits the `Collection` into _maxSize_ size or smaller `Collections`. The source `Collection` will be empty after this operation
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
... | [
"def",
"split",
"(",
"self",
",",
"maxSize",
")",
":",
"chunks",
"=",
"[",
"]",
"currentSize",
"=",
"maxSize",
"+",
"1",
"try",
":",
"while",
"True",
":",
"if",
"currentSize",
">=",
"maxSize",
":",
"currentSize",
"=",
"0",
"chunks",
".",
"append",
"(... | Destructively, splits the `Collection` into _maxSize_ size or smaller `Collections`. The source `Collection` will be empty after this operation
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> ... | [
"Destructively",
"splits",
"the",
"Collection",
"into",
"_maxSize_",
"size",
"or",
"smaller",
"Collections",
".",
"The",
"source",
"Collection",
"will",
"be",
"empty",
"after",
"this",
"operation"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L336-L364 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.containsID | def containsID(self, idVal):
"""Checks if the collected items contains the give _idVal_
# Parameters
_idVal_ : `str`
> The queried id string
# Returns
`bool`
> `True` if the item is in the collection
"""
for i in self:
if i.id == ... | python | def containsID(self, idVal):
"""Checks if the collected items contains the give _idVal_
# Parameters
_idVal_ : `str`
> The queried id string
# Returns
`bool`
> `True` if the item is in the collection
"""
for i in self:
if i.id == ... | [
"def",
"containsID",
"(",
"self",
",",
"idVal",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"i",
".",
"id",
"==",
"idVal",
":",
"return",
"True",
"return",
"False"
] | Checks if the collected items contains the give _idVal_
# Parameters
_idVal_ : `str`
> The queried id string
# Returns
`bool`
> `True` if the item is in the collection | [
"Checks",
"if",
"the",
"collected",
"items",
"contains",
"the",
"give",
"_idVal_"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L420-L438 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.discardID | def discardID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and discards it if it is found, will not raise an exception if item is not found
# Parameters
_idVal_ : `str`
> The discarded id string
"""
for i in self:
if i.id == idVa... | python | def discardID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and discards it if it is found, will not raise an exception if item is not found
# Parameters
_idVal_ : `str`
> The discarded id string
"""
for i in self:
if i.id == idVa... | [
"def",
"discardID",
"(",
"self",
",",
"idVal",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"i",
".",
"id",
"==",
"idVal",
":",
"self",
".",
"_collection",
".",
"discard",
"(",
"i",
")",
"return"
] | Checks if the collected items contains the give _idVal_ and discards it if it is found, will not raise an exception if item is not found
# Parameters
_idVal_ : `str`
> The discarded id string | [
"Checks",
"if",
"the",
"collected",
"items",
"contains",
"the",
"give",
"_idVal_",
"and",
"discards",
"it",
"if",
"it",
"is",
"found",
"will",
"not",
"raise",
"an",
"exception",
"if",
"item",
"is",
"not",
"found"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L440-L452 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.removeID | def removeID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and removes it if it is found, will raise a `KeyError` if item is not found
# Parameters
_idVal_ : `str`
> The removed id string
"""
for i in self:
if i.id == idVal:
... | python | def removeID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and removes it if it is found, will raise a `KeyError` if item is not found
# Parameters
_idVal_ : `str`
> The removed id string
"""
for i in self:
if i.id == idVal:
... | [
"def",
"removeID",
"(",
"self",
",",
"idVal",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"i",
".",
"id",
"==",
"idVal",
":",
"self",
".",
"_collection",
".",
"remove",
"(",
"i",
")",
"return",
"raise",
"KeyError",
"(",
"\"A Record with the ID '{}' ... | Checks if the collected items contains the give _idVal_ and removes it if it is found, will raise a `KeyError` if item is not found
# Parameters
_idVal_ : `str`
> The removed id string | [
"Checks",
"if",
"the",
"collected",
"items",
"contains",
"the",
"give",
"_idVal_",
"and",
"removes",
"it",
"if",
"it",
"is",
"found",
"will",
"raise",
"a",
"KeyError",
"if",
"item",
"is",
"not",
"found"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L454-L467 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.badEntries | def badEntries(self):
"""Creates a new collection of the same type with only the bad entries
# Returns
`CollectionWithIDs`
> A collection of only the bad entries
"""
badEntries = set()
for i in self:
if i.bad:
badEntries.add(i)
... | python | def badEntries(self):
"""Creates a new collection of the same type with only the bad entries
# Returns
`CollectionWithIDs`
> A collection of only the bad entries
"""
badEntries = set()
for i in self:
if i.bad:
badEntries.add(i)
... | [
"def",
"badEntries",
"(",
"self",
")",
":",
"badEntries",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"self",
":",
"if",
"i",
".",
"bad",
":",
"badEntries",
".",
"add",
"(",
"i",
")",
"return",
"type",
"(",
"self",
")",
"(",
"badEntries",
",",
"quiet... | Creates a new collection of the same type with only the bad entries
# Returns
`CollectionWithIDs`
> A collection of only the bad entries | [
"Creates",
"a",
"new",
"collection",
"of",
"the",
"same",
"type",
"with",
"only",
"the",
"bad",
"entries"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L489-L502 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.dropBadEntries | def dropBadEntries(self):
"""Removes all the bad entries from the collection
"""
self._collection = set((i for i in self if not i.bad))
self.bad = False
self.errors = {} | python | def dropBadEntries(self):
"""Removes all the bad entries from the collection
"""
self._collection = set((i for i in self if not i.bad))
self.bad = False
self.errors = {} | [
"def",
"dropBadEntries",
"(",
"self",
")",
":",
"self",
".",
"_collection",
"=",
"set",
"(",
"(",
"i",
"for",
"i",
"in",
"self",
"if",
"not",
"i",
".",
"bad",
")",
")",
"self",
".",
"bad",
"=",
"False",
"self",
".",
"errors",
"=",
"{",
"}"
] | Removes all the bad entries from the collection | [
"Removes",
"all",
"the",
"bad",
"entries",
"from",
"the",
"collection"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L504-L509 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.tags | def tags(self):
"""Creates a list of all the tags of the contained items
# Returns
`list [str]`
> A list of all the tags
"""
tags = set()
for i in self:
tags |= set(i.keys())
return tags | python | def tags(self):
"""Creates a list of all the tags of the contained items
# Returns
`list [str]`
> A list of all the tags
"""
tags = set()
for i in self:
tags |= set(i.keys())
return tags | [
"def",
"tags",
"(",
"self",
")",
":",
"tags",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"self",
":",
"tags",
"|=",
"set",
"(",
"i",
".",
"keys",
"(",
")",
")",
"return",
"tags"
] | Creates a list of all the tags of the contained items
# Returns
`list [str]`
> A list of all the tags | [
"Creates",
"a",
"list",
"of",
"all",
"the",
"tags",
"of",
"the",
"contained",
"items"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L511-L523 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.rankedSeries | def rankedSeries(self, tag, outputFile = None, giveCounts = True, giveRanks = False, greatestFirst = True, pandasMode = True, limitTo = None):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by their number of occurrences. A list can also be returned with the the counts... | python | def rankedSeries(self, tag, outputFile = None, giveCounts = True, giveRanks = False, greatestFirst = True, pandasMode = True, limitTo = None):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by their number of occurrences. A list can also be returned with the the counts... | [
"def",
"rankedSeries",
"(",
"self",
",",
"tag",
",",
"outputFile",
"=",
"None",
",",
"giveCounts",
"=",
"True",
",",
"giveRanks",
"=",
"False",
",",
"greatestFirst",
"=",
"True",
",",
"pandasMode",
"=",
"True",
",",
"limitTo",
"=",
"None",
")",
":",
"i... | Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by their number of occurrences. A list can also be returned with the the counts or ranks added or it can be written to a file.
# Parameters
_tag_ : `str`
> The tag to be ranked
_outputFile_ : `opti... | [
"Creates",
"an",
"pandas",
"dict",
"of",
"the",
"ordered",
"list",
"of",
"all",
"the",
"values",
"of",
"_tag_",
"with",
"and",
"ranked",
"by",
"their",
"number",
"of",
"occurrences",
".",
"A",
"list",
"can",
"also",
"be",
"returned",
"with",
"the",
"the"... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L569-L663 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.timeSeries | def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list c... | python | def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list c... | [
"def",
"timeSeries",
"(",
"self",
",",
"tag",
"=",
"None",
",",
"outputFile",
"=",
"None",
",",
"giveYears",
"=",
"True",
",",
"greatestFirst",
"=",
"True",
",",
"limitTo",
"=",
"False",
",",
"pandasMode",
"=",
"True",
")",
":",
"seriesDict",
"=",
"{",... | Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list can also be returned with the the counts or years added or it can be written to a file.
If no _tag_ is given the `Records` in the co... | [
"Creates",
"an",
"pandas",
"dict",
"of",
"the",
"ordered",
"list",
"of",
"all",
"the",
"values",
"of",
"_tag_",
"with",
"and",
"ranked",
"by",
"the",
"year",
"the",
"occurred",
"in",
"multiple",
"year",
"occurrences",
"will",
"create",
"multiple",
"entries",... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L665-L747 | train |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | CollectionWithIDs.cooccurrenceCounts | def cooccurrenceCounts(self, keyTag, *countedTags):
"""Counts the number of times values from any of the _countedTags_ occurs with _keyTag_. The counts are retuned as a dictionary with the values of _keyTag_ mapping to dictionaries with each of the _countedTags_ values mapping to thier counts.
# Parame... | python | def cooccurrenceCounts(self, keyTag, *countedTags):
"""Counts the number of times values from any of the _countedTags_ occurs with _keyTag_. The counts are retuned as a dictionary with the values of _keyTag_ mapping to dictionaries with each of the _countedTags_ values mapping to thier counts.
# Parame... | [
"def",
"cooccurrenceCounts",
"(",
"self",
",",
"keyTag",
",",
"*",
"countedTags",
")",
":",
"if",
"not",
"isinstance",
"(",
"keyTag",
",",
"str",
")",
":",
"raise",
"TagError",
"(",
"\"'{}' is not a string it cannot be used as a tag.\"",
".",
"format",
"(",
"key... | Counts the number of times values from any of the _countedTags_ occurs with _keyTag_. The counts are retuned as a dictionary with the values of _keyTag_ mapping to dictionaries with each of the _countedTags_ values mapping to thier counts.
# Parameters
_keyTag_ : `str`
> The tag used as the k... | [
"Counts",
"the",
"number",
"of",
"times",
"values",
"from",
"any",
"of",
"the",
"_countedTags_",
"occurs",
"with",
"_keyTag_",
".",
"The",
"counts",
"are",
"retuned",
"as",
"a",
"dictionary",
"with",
"the",
"values",
"of",
"_keyTag_",
"mapping",
"to",
"dicti... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L749-L806 | train |
networks-lab/metaknowledge | metaknowledge/diffusion.py | makeNodeID | def makeNodeID(Rec, ndType, extras = None):
"""Helper to make a node ID, extras is currently not used"""
if ndType == 'raw':
recID = Rec
else:
recID = Rec.get(ndType)
if recID is None:
pass
elif isinstance(recID, list):
recID = tuple(recID)
else:
recID = r... | python | def makeNodeID(Rec, ndType, extras = None):
"""Helper to make a node ID, extras is currently not used"""
if ndType == 'raw':
recID = Rec
else:
recID = Rec.get(ndType)
if recID is None:
pass
elif isinstance(recID, list):
recID = tuple(recID)
else:
recID = r... | [
"def",
"makeNodeID",
"(",
"Rec",
",",
"ndType",
",",
"extras",
"=",
"None",
")",
":",
"if",
"ndType",
"==",
"'raw'",
":",
"recID",
"=",
"Rec",
"else",
":",
"recID",
"=",
"Rec",
".",
"get",
"(",
"ndType",
")",
"if",
"recID",
"is",
"None",
":",
"pa... | Helper to make a node ID, extras is currently not used | [
"Helper",
"to",
"make",
"a",
"node",
"ID",
"extras",
"is",
"currently",
"not",
"used"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/diffusion.py#L351-L370 | train |
networks-lab/metaknowledge | docs/mkdsupport.py | pandoc_process | def pandoc_process(app, what, name, obj, options, lines):
""""Convert docstrings in Markdown into reStructureText using pandoc
"""
if not lines:
return None
input_format = app.config.mkdsupport_use_parser
output_format = 'rst'
# Since default encoding for sphinx.ext.autodoc is unicode... | python | def pandoc_process(app, what, name, obj, options, lines):
""""Convert docstrings in Markdown into reStructureText using pandoc
"""
if not lines:
return None
input_format = app.config.mkdsupport_use_parser
output_format = 'rst'
# Since default encoding for sphinx.ext.autodoc is unicode... | [
"def",
"pandoc_process",
"(",
"app",
",",
"what",
",",
"name",
",",
"obj",
",",
"options",
",",
"lines",
")",
":",
"if",
"not",
"lines",
":",
"return",
"None",
"input_format",
"=",
"app",
".",
"config",
".",
"mkdsupport_use_parser",
"output_format",
"=",
... | Convert docstrings in Markdown into reStructureText using pandoc | [
"Convert",
"docstrings",
"in",
"Markdown",
"into",
"reStructureText",
"using",
"pandoc"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/docs/mkdsupport.py#L26-L43 | train |
networks-lab/metaknowledge | metaknowledge/medline/tagProcessing/specialFunctions.py | beginningPage | def beginningPage(R):
"""As pages may not be given as numbers this is the most accurate this function can be"""
p = R['PG']
if p.startswith('suppl '):
p = p[6:]
return p.split(' ')[0].split('-')[0].replace(';', '') | python | def beginningPage(R):
"""As pages may not be given as numbers this is the most accurate this function can be"""
p = R['PG']
if p.startswith('suppl '):
p = p[6:]
return p.split(' ')[0].split('-')[0].replace(';', '') | [
"def",
"beginningPage",
"(",
"R",
")",
":",
"p",
"=",
"R",
"[",
"'PG'",
"]",
"if",
"p",
".",
"startswith",
"(",
"'suppl '",
")",
":",
"p",
"=",
"p",
"[",
"6",
":",
"]",
"return",
"p",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
".",
"spli... | As pages may not be given as numbers this is the most accurate this function can be | [
"As",
"pages",
"may",
"not",
"be",
"given",
"as",
"numbers",
"this",
"is",
"the",
"most",
"accurate",
"this",
"function",
"can",
"be"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/medline/tagProcessing/specialFunctions.py#L27-L32 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | Record.copy | def copy(self):
"""Correctly copies the `Record`
# Returns
`Record`
> A completely decoupled copy of the original
"""
c = copy.copy(self)
c._fieldDict = c._fieldDict.copy()
return c | python | def copy(self):
"""Correctly copies the `Record`
# Returns
`Record`
> A completely decoupled copy of the original
"""
c = copy.copy(self)
c._fieldDict = c._fieldDict.copy()
return c | [
"def",
"copy",
"(",
"self",
")",
":",
"c",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"c",
".",
"_fieldDict",
"=",
"c",
".",
"_fieldDict",
".",
"copy",
"(",
")",
"return",
"c"
] | Correctly copies the `Record`
# Returns
`Record`
> A completely decoupled copy of the original | [
"Correctly",
"copies",
"the",
"Record"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L202-L213 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | ExtendedRecord.values | def values(self, raw = False):
"""Like `values` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `ValuesView` contains the raw values
# Returns
`ValuesView`
> The values of the record
"""
... | python | def values(self, raw = False):
"""Like `values` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `ValuesView` contains the raw values
# Returns
`ValuesView`
> The values of the record
"""
... | [
"def",
"values",
"(",
"self",
",",
"raw",
"=",
"False",
")",
":",
"if",
"raw",
":",
"return",
"self",
".",
"_fieldDict",
".",
"values",
"(",
")",
"else",
":",
"return",
"collections",
".",
"abc",
".",
"Mapping",
".",
"values",
"(",
"self",
")"
] | Like `values` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `ValuesView` contains the raw values
# Returns
`ValuesView`
> The values of the record | [
"Like",
"values",
"for",
"dicts",
"but",
"with",
"a",
"raw",
"option"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L402-L420 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | ExtendedRecord.items | def items(self, raw = False):
"""Like `items` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `KeysView` contains the raw values as the values
# Returns
`KeysView`
> The key-value pairs of the record
... | python | def items(self, raw = False):
"""Like `items` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `KeysView` contains the raw values as the values
# Returns
`KeysView`
> The key-value pairs of the record
... | [
"def",
"items",
"(",
"self",
",",
"raw",
"=",
"False",
")",
":",
"if",
"raw",
":",
"return",
"self",
".",
"_fieldDict",
".",
"items",
"(",
")",
"else",
":",
"return",
"collections",
".",
"abc",
".",
"Mapping",
".",
"items",
"(",
"self",
")"
] | Like `items` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `KeysView` contains the raw values as the values
# Returns
`KeysView`
> The key-value pairs of the record | [
"Like",
"items",
"for",
"dicts",
"but",
"with",
"a",
"raw",
"option"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L424-L442 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | ExtendedRecord.getCitations | def getCitations(self, field = None, values = None, pandasFriendly = True):
"""Creates a pandas ready dict with each row a different citation and columns containing the original string, year, journal and author's name.
There are also options to filter the output citations with _field_ and _values_
... | python | def getCitations(self, field = None, values = None, pandasFriendly = True):
"""Creates a pandas ready dict with each row a different citation and columns containing the original string, year, journal and author's name.
There are also options to filter the output citations with _field_ and _values_
... | [
"def",
"getCitations",
"(",
"self",
",",
"field",
"=",
"None",
",",
"values",
"=",
"None",
",",
"pandasFriendly",
"=",
"True",
")",
":",
"retCites",
"=",
"[",
"]",
"if",
"values",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"values",
",",
"(",... | Creates a pandas ready dict with each row a different citation and columns containing the original string, year, journal and author's name.
There are also options to filter the output citations with _field_ and _values_
# Parameters
_field_ : `optional str`
> Default `None`, if given... | [
"Creates",
"a",
"pandas",
"ready",
"dict",
"with",
"each",
"row",
"a",
"different",
"citation",
"and",
"columns",
"containing",
"the",
"original",
"string",
"year",
"journal",
"and",
"author",
"s",
"name",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L546-L589 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | ExtendedRecord.subDict | def subDict(self, tags, raw = False):
"""Creates a dict of values of _tags_ from the Record. The tags are the keys and the values are the values. If the tag is missing the value will be `None`.
# Parameters
_tags_ : `list[str]`
> The list of tags requested
_raw_ : `optional [... | python | def subDict(self, tags, raw = False):
"""Creates a dict of values of _tags_ from the Record. The tags are the keys and the values are the values. If the tag is missing the value will be `None`.
# Parameters
_tags_ : `list[str]`
> The list of tags requested
_raw_ : `optional [... | [
"def",
"subDict",
"(",
"self",
",",
"tags",
",",
"raw",
"=",
"False",
")",
":",
"retDict",
"=",
"{",
"}",
"for",
"tag",
"in",
"tags",
":",
"retDict",
"[",
"tag",
"]",
"=",
"self",
".",
"get",
"(",
"tag",
",",
"raw",
"=",
"raw",
")",
"return",
... | Creates a dict of values of _tags_ from the Record. The tags are the keys and the values are the values. If the tag is missing the value will be `None`.
# Parameters
_tags_ : `list[str]`
> The list of tags requested
_raw_ : `optional [bool]`
>default `False` if `True` the re... | [
"Creates",
"a",
"dict",
"of",
"values",
"of",
"_tags_",
"from",
"the",
"Record",
".",
"The",
"tags",
"are",
"the",
"keys",
"and",
"the",
"values",
"are",
"the",
"values",
".",
"If",
"the",
"tag",
"is",
"missing",
"the",
"value",
"will",
"be",
"None",
... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L591-L613 | train |
networks-lab/metaknowledge | metaknowledge/mkRecord.py | ExtendedRecord.authGenders | def authGenders(self, countsOnly = False, fractionsMode = False, _countsTuple = False):
"""Creates a dict mapping `'Male'`, `'Female'` and `'Unknown'` to lists of the names of all the authors.
# Parameters
_countsOnly_ : `optional bool`
> Default `False`, if `True` the counts (lengths... | python | def authGenders(self, countsOnly = False, fractionsMode = False, _countsTuple = False):
"""Creates a dict mapping `'Male'`, `'Female'` and `'Unknown'` to lists of the names of all the authors.
# Parameters
_countsOnly_ : `optional bool`
> Default `False`, if `True` the counts (lengths... | [
"def",
"authGenders",
"(",
"self",
",",
"countsOnly",
"=",
"False",
",",
"fractionsMode",
"=",
"False",
",",
"_countsTuple",
"=",
"False",
")",
":",
"authDict",
"=",
"recordGenders",
"(",
"self",
")",
"if",
"_countsTuple",
"or",
"countsOnly",
"or",
"fraction... | Creates a dict mapping `'Male'`, `'Female'` and `'Unknown'` to lists of the names of all the authors.
# Parameters
_countsOnly_ : `optional bool`
> Default `False`, if `True` the counts (lengths of the lists) will be given instead of the lists of names
_fractionsMode_ : `optional boo... | [
"Creates",
"a",
"dict",
"mapping",
"Male",
"Female",
"and",
"Unknown",
"to",
"lists",
"of",
"the",
"names",
"of",
"all",
"the",
"authors",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkRecord.py#L660-L695 | train |
networks-lab/metaknowledge | metaknowledge/proquest/proQuestHandlers.py | proQuestParser | def proQuestParser(proFile):
"""Parses a ProQuest file, _proFile_, to extract the individual entries.
A ProQuest file has three sections, first a list of the contained entries, second the full metadata and finally a bibtex formatted entry for the record. This parser only uses the first two as the bibtex contai... | python | def proQuestParser(proFile):
"""Parses a ProQuest file, _proFile_, to extract the individual entries.
A ProQuest file has three sections, first a list of the contained entries, second the full metadata and finally a bibtex formatted entry for the record. This parser only uses the first two as the bibtex contai... | [
"def",
"proQuestParser",
"(",
"proFile",
")",
":",
"nameDict",
"=",
"{",
"}",
"recSet",
"=",
"set",
"(",
")",
"error",
"=",
"None",
"lineNum",
"=",
"0",
"try",
":",
"with",
"open",
"(",
"proFile",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"... | Parses a ProQuest file, _proFile_, to extract the individual entries.
A ProQuest file has three sections, first a list of the contained entries, second the full metadata and finally a bibtex formatted entry for the record. This parser only uses the first two as the bibtex contains no information the second section... | [
"Parses",
"a",
"ProQuest",
"file",
"_proFile_",
"to",
"extract",
"the",
"individual",
"entries",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/proquest/proQuestHandlers.py#L42-L100 | train |
networks-lab/metaknowledge | metaknowledge/grants/nsfGrant.py | NSFGrant.getInvestigators | def getInvestigators(self, tags = None, seperator = ";", _getTag = False):
"""Returns a list of the names of investigators. The optional arguments are ignored.
# Returns
`list [str]`
> A list of all the found investigator's names
"""
if tags is None:
tags =... | python | def getInvestigators(self, tags = None, seperator = ";", _getTag = False):
"""Returns a list of the names of investigators. The optional arguments are ignored.
# Returns
`list [str]`
> A list of all the found investigator's names
"""
if tags is None:
tags =... | [
"def",
"getInvestigators",
"(",
"self",
",",
"tags",
"=",
"None",
",",
"seperator",
"=",
"\";\"",
",",
"_getTag",
"=",
"False",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"'Investigator'",
"]",
"elif",
"isinstance",
"(",
"tags",
",",
... | Returns a list of the names of investigators. The optional arguments are ignored.
# Returns
`list [str]`
> A list of all the found investigator's names | [
"Returns",
"a",
"list",
"of",
"the",
"names",
"of",
"investigators",
".",
"The",
"optional",
"arguments",
"are",
"ignored",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/grants/nsfGrant.py#L22-L37 | train |
networks-lab/metaknowledge | metaknowledge/genders/nameGender.py | nameStringGender | def nameStringGender(s, noExcept = False):
"""Expects `first, last`"""
global mappingDict
try:
first = s.split(', ')[1].split(' ')[0].title()
except IndexError:
if noExcept:
return 'Unknown'
else:
return GenderException("The given String: '{}' does not hav... | python | def nameStringGender(s, noExcept = False):
"""Expects `first, last`"""
global mappingDict
try:
first = s.split(', ')[1].split(' ')[0].title()
except IndexError:
if noExcept:
return 'Unknown'
else:
return GenderException("The given String: '{}' does not hav... | [
"def",
"nameStringGender",
"(",
"s",
",",
"noExcept",
"=",
"False",
")",
":",
"global",
"mappingDict",
"try",
":",
"first",
"=",
"s",
".",
"split",
"(",
"', '",
")",
"[",
"1",
"]",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
".",
"title",
"(",
... | Expects `first, last` | [
"Expects",
"first",
"last"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/genders/nameGender.py#L54-L66 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | j9urlGenerator | def j9urlGenerator(nameDict = False):
"""How to get all the urls for the WOS Journal Title Abbreviations. Each is varies by only a few characters. These are the currently in use urls they may change.
They are of the form:
> "https://images.webofknowledge.com/images/help/WOS/{VAL}_abrvjt.html"
> Where ... | python | def j9urlGenerator(nameDict = False):
"""How to get all the urls for the WOS Journal Title Abbreviations. Each is varies by only a few characters. These are the currently in use urls they may change.
They are of the form:
> "https://images.webofknowledge.com/images/help/WOS/{VAL}_abrvjt.html"
> Where ... | [
"def",
"j9urlGenerator",
"(",
"nameDict",
"=",
"False",
")",
":",
"start",
"=",
"\"https://images.webofknowledge.com/images/help/WOS/\"",
"end",
"=",
"\"_abrvjt.html\"",
"if",
"nameDict",
":",
"urls",
"=",
"{",
"\"0-9\"",
":",
"start",
"+",
"\"0-9\"",
"+",
"end",
... | How to get all the urls for the WOS Journal Title Abbreviations. Each is varies by only a few characters. These are the currently in use urls they may change.
They are of the form:
> "https://images.webofknowledge.com/images/help/WOS/{VAL}_abrvjt.html"
> Where {VAL} is a capital letter or the string "0-9"... | [
"How",
"to",
"get",
"all",
"the",
"urls",
"for",
"the",
"WOS",
"Journal",
"Title",
"Abbreviations",
".",
"Each",
"is",
"varies",
"by",
"only",
"a",
"few",
"characters",
".",
"These",
"are",
"the",
"currently",
"in",
"use",
"urls",
"they",
"may",
"change"... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L14-L38 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | _j9SaveCurrent | def _j9SaveCurrent(sDir = '.'):
"""Downloads and saves all the webpages
For Backend
"""
dname = os.path.normpath(sDir + '/' + datetime.datetime.now().strftime("%Y-%m-%d_J9_AbbreviationDocs"))
if not os.path.isdir(dname):
os.mkdir(dname)
os.chdir(dname)
else:
os.chdir(dn... | python | def _j9SaveCurrent(sDir = '.'):
"""Downloads and saves all the webpages
For Backend
"""
dname = os.path.normpath(sDir + '/' + datetime.datetime.now().strftime("%Y-%m-%d_J9_AbbreviationDocs"))
if not os.path.isdir(dname):
os.mkdir(dname)
os.chdir(dname)
else:
os.chdir(dn... | [
"def",
"_j9SaveCurrent",
"(",
"sDir",
"=",
"'.'",
")",
":",
"dname",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"sDir",
"+",
"'/'",
"+",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d_J9_AbbreviationDocs\"",
")",
... | Downloads and saves all the webpages
For Backend | [
"Downloads",
"and",
"saves",
"all",
"the",
"webpages"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L40-L54 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | _getDict | def _getDict(j9Page):
"""Parses a Journal Title Abbreviations page
Note the pages are not well formatted html as the <DT> tags are not closes so html parses (Beautiful Soup) do not work. This is a simple parser that only works on the webpages and may fail if they are changed
For Backend
"""
slines... | python | def _getDict(j9Page):
"""Parses a Journal Title Abbreviations page
Note the pages are not well formatted html as the <DT> tags are not closes so html parses (Beautiful Soup) do not work. This is a simple parser that only works on the webpages and may fail if they are changed
For Backend
"""
slines... | [
"def",
"_getDict",
"(",
"j9Page",
")",
":",
"slines",
"=",
"j9Page",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"split",
"(",
"'\\n'",
")",
"while",
"slines",
".",
"pop",
"(",
"0",
")",
"!=",
"\"<DL>\"",
":",
"pass",
"currentNa... | Parses a Journal Title Abbreviations page
Note the pages are not well formatted html as the <DT> tags are not closes so html parses (Beautiful Soup) do not work. This is a simple parser that only works on the webpages and may fail if they are changed
For Backend | [
"Parses",
"a",
"Journal",
"Title",
"Abbreviations",
"page"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L56-L79 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | _getCurrentj9Dict | def _getCurrentj9Dict():
"""Downloads and parses all the webpages
For Backend
"""
urls = j9urlGenerator()
j9Dict = {}
for url in urls:
d = _getDict(urllib.request.urlopen(url))
if len(d) == 0:
raise RuntimeError("Parsing failed, this is could require an update of the... | python | def _getCurrentj9Dict():
"""Downloads and parses all the webpages
For Backend
"""
urls = j9urlGenerator()
j9Dict = {}
for url in urls:
d = _getDict(urllib.request.urlopen(url))
if len(d) == 0:
raise RuntimeError("Parsing failed, this is could require an update of the... | [
"def",
"_getCurrentj9Dict",
"(",
")",
":",
"urls",
"=",
"j9urlGenerator",
"(",
")",
"j9Dict",
"=",
"{",
"}",
"for",
"url",
"in",
"urls",
":",
"d",
"=",
"_getDict",
"(",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"url",
")",
")",
"if",
"len",
"(... | Downloads and parses all the webpages
For Backend | [
"Downloads",
"and",
"parses",
"all",
"the",
"webpages"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L81-L93 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | updatej9DB | def updatej9DB(dbname = abrevDBname, saveRawHTML = False):
"""Updates the database of Journal Title Abbreviations. Requires an internet connection. The data base is saved relative to the source file not the working directory.
# Parameters
_dbname_ : `optional [str]`
> The name of the database file, d... | python | def updatej9DB(dbname = abrevDBname, saveRawHTML = False):
"""Updates the database of Journal Title Abbreviations. Requires an internet connection. The data base is saved relative to the source file not the working directory.
# Parameters
_dbname_ : `optional [str]`
> The name of the database file, d... | [
"def",
"updatej9DB",
"(",
"dbname",
"=",
"abrevDBname",
",",
"saveRawHTML",
"=",
"False",
")",
":",
"if",
"saveRawHTML",
":",
"rawDir",
"=",
"'{}/j9Raws'",
".",
"format",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"if",
"not",
"... | Updates the database of Journal Title Abbreviations. Requires an internet connection. The data base is saved relative to the source file not the working directory.
# Parameters
_dbname_ : `optional [str]`
> The name of the database file, default is "j9Abbreviations.db"
_saveRawHTML_ : `optional [boo... | [
"Updates",
"the",
"database",
"of",
"Journal",
"Title",
"Abbreviations",
".",
"Requires",
"an",
"internet",
"connection",
".",
"The",
"data",
"base",
"is",
"saved",
"relative",
"to",
"the",
"source",
"file",
"not",
"the",
"working",
"directory",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L95-L128 | train |
networks-lab/metaknowledge | metaknowledge/journalAbbreviations/backend.py | getj9dict | def getj9dict(dbname = abrevDBname, manualDB = manualDBname, returnDict ='both'):
"""Returns the dictionary of journal abbreviations mapping to a list of the associated journal names. By default the local database is used. The database is in the file _dbname_ in the same directory as this source file
# Paramet... | python | def getj9dict(dbname = abrevDBname, manualDB = manualDBname, returnDict ='both'):
"""Returns the dictionary of journal abbreviations mapping to a list of the associated journal names. By default the local database is used. The database is in the file _dbname_ in the same directory as this source file
# Paramet... | [
"def",
"getj9dict",
"(",
"dbname",
"=",
"abrevDBname",
",",
"manualDB",
"=",
"manualDBname",
",",
"returnDict",
"=",
"'both'",
")",
":",
"dbLoc",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")"... | Returns the dictionary of journal abbreviations mapping to a list of the associated journal names. By default the local database is used. The database is in the file _dbname_ in the same directory as this source file
# Parameters
_dbname_ : `optional [str]`
> The name of the downloaded database file, the... | [
"Returns",
"the",
"dictionary",
"of",
"journal",
"abbreviations",
"mapping",
"to",
"a",
"list",
"of",
"the",
"associated",
"journal",
"names",
".",
"By",
"default",
"the",
"local",
"database",
"is",
"used",
".",
"The",
"database",
"is",
"in",
"the",
"file",
... | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/journalAbbreviations/backend.py#L130-L172 | train |
networks-lab/metaknowledge | metaknowledge/WOS/tagProcessing/funcDicts.py | normalizeToTag | def normalizeToTag(val):
"""Converts tags or full names to 2 character tags, case insensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The short name of _val_
"""
try:
val = val.upper()
except AttributeErro... | python | def normalizeToTag(val):
"""Converts tags or full names to 2 character tags, case insensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The short name of _val_
"""
try:
val = val.upper()
except AttributeErro... | [
"def",
"normalizeToTag",
"(",
"val",
")",
":",
"try",
":",
"val",
"=",
"val",
".",
"upper",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"KeyError",
"(",
"\"{} is not a tag or name string\"",
".",
"format",
"(",
"val",
")",
")",
"if",
"val",
"not",
... | Converts tags or full names to 2 character tags, case insensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The short name of _val_ | [
"Converts",
"tags",
"or",
"full",
"names",
"to",
"2",
"character",
"tags",
"case",
"insensitive"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/WOS/tagProcessing/funcDicts.py#L41-L66 | train |
networks-lab/metaknowledge | metaknowledge/WOS/tagProcessing/funcDicts.py | normalizeToName | def normalizeToName(val):
"""Converts tags or full names to full names, case sensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The full name of _val_
"""
if val not in tagsAndNameSet:
raise KeyError("{} is not... | python | def normalizeToName(val):
"""Converts tags or full names to full names, case sensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The full name of _val_
"""
if val not in tagsAndNameSet:
raise KeyError("{} is not... | [
"def",
"normalizeToName",
"(",
"val",
")",
":",
"if",
"val",
"not",
"in",
"tagsAndNameSet",
":",
"raise",
"KeyError",
"(",
"\"{} is not a tag or name string\"",
".",
"format",
"(",
"val",
")",
")",
"else",
":",
"try",
":",
"return",
"tagToFullDict",
"[",
"va... | Converts tags or full names to full names, case sensitive
# Parameters
_val_: `str`
> A two character string giving the tag or its full name
# Returns
`str`
> The full name of _val_ | [
"Converts",
"tags",
"or",
"full",
"names",
"to",
"full",
"names",
"case",
"sensitive"
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/WOS/tagProcessing/funcDicts.py#L68-L89 | train |
networks-lab/metaknowledge | metaknowledge/grants/baseGrant.py | Grant.update | def update(self, other):
"""Adds all the tag-entry pairs from _other_ to the `Grant`. If there is a conflict _other_ takes precedence.
# Parameters
_other_ : `Grant`
> Another `Grant` of the same type as _self_
"""
if type(self) != type(other):
return NotIm... | python | def update(self, other):
"""Adds all the tag-entry pairs from _other_ to the `Grant`. If there is a conflict _other_ takes precedence.
# Parameters
_other_ : `Grant`
> Another `Grant` of the same type as _self_
"""
if type(self) != type(other):
return NotIm... | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"self",
")",
"!=",
"type",
"(",
"other",
")",
":",
"return",
"NotImplemented",
"else",
":",
"if",
"other",
".",
"bad",
":",
"self",
".",
"error",
"=",
"other",
".",
"error",
... | Adds all the tag-entry pairs from _other_ to the `Grant`. If there is a conflict _other_ takes precedence.
# Parameters
_other_ : `Grant`
> Another `Grant` of the same type as _self_ | [
"Adds",
"all",
"the",
"tag",
"-",
"entry",
"pairs",
"from",
"_other_",
"to",
"the",
"Grant",
".",
"If",
"there",
"is",
"a",
"conflict",
"_other_",
"takes",
"precedence",
"."
] | 8162bf95e66bb6f9916081338e6e2a6132faff75 | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/grants/baseGrant.py#L99-L114 | train |
kxgames/glooey | glooey/widget.py | EventDispatcher.relay_events_from | def relay_events_from(self, originator, event_type, *more_event_types):
"""
Configure this handler to re-dispatch events from another handler.
This method configures this handler dispatch an event of type
*event_type* whenever *originator* dispatches events of the same type
or... | python | def relay_events_from(self, originator, event_type, *more_event_types):
"""
Configure this handler to re-dispatch events from another handler.
This method configures this handler dispatch an event of type
*event_type* whenever *originator* dispatches events of the same type
or... | [
"def",
"relay_events_from",
"(",
"self",
",",
"originator",
",",
"event_type",
",",
"*",
"more_event_types",
")",
":",
"handlers",
"=",
"{",
"event_type",
":",
"lambda",
"*",
"args",
",",
"**",
"kwargs",
":",
"self",
".",
"dispatch_event",
"(",
"event_type",... | Configure this handler to re-dispatch events from another handler.
This method configures this handler dispatch an event of type
*event_type* whenever *originator* dispatches events of the same type
or any of the types in *more_event_types*. Any arguments passed to the
original even... | [
"Configure",
"this",
"handler",
"to",
"re",
"-",
"dispatch",
"events",
"from",
"another",
"handler",
"."
] | f0125c1f218b05cfb2efb52a88d80f54eae007a0 | https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/widget.py#L25-L44 | train |
kxgames/glooey | glooey/widget.py | EventDispatcher.start_event | def start_event(self, event_type, *args, dt=1/60):
"""
Begin dispatching the given event at the given frequency.
Calling this method will cause an event of type *event_type* with
arguments *args* to be dispatched every *dt* seconds. This will
continue until `stop_event()` is ... | python | def start_event(self, event_type, *args, dt=1/60):
"""
Begin dispatching the given event at the given frequency.
Calling this method will cause an event of type *event_type* with
arguments *args* to be dispatched every *dt* seconds. This will
continue until `stop_event()` is ... | [
"def",
"start_event",
"(",
"self",
",",
"event_type",
",",
"*",
"args",
",",
"dt",
"=",
"1",
"/",
"60",
")",
":",
"if",
"not",
"any",
"(",
"self",
".",
"__yield_handlers",
"(",
"event_type",
")",
")",
":",
"return",
"def",
"on_time_interval",
"(",
"d... | Begin dispatching the given event at the given frequency.
Calling this method will cause an event of type *event_type* with
arguments *args* to be dispatched every *dt* seconds. This will
continue until `stop_event()` is called for the same event.
These continuously firing events ar... | [
"Begin",
"dispatching",
"the",
"given",
"event",
"at",
"the",
"given",
"frequency",
"."
] | f0125c1f218b05cfb2efb52a88d80f54eae007a0 | https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/widget.py#L46-L72 | train |
kxgames/glooey | glooey/widget.py | EventDispatcher.stop_event | def stop_event(self, event_type):
"""
Stop dispatching the given event.
It is not an error to attempt to stop an event that was never started,
the request will just be silently ignored.
"""
if event_type in self.__timers:
pyglet.clock.unschedule(self.__timer... | python | def stop_event(self, event_type):
"""
Stop dispatching the given event.
It is not an error to attempt to stop an event that was never started,
the request will just be silently ignored.
"""
if event_type in self.__timers:
pyglet.clock.unschedule(self.__timer... | [
"def",
"stop_event",
"(",
"self",
",",
"event_type",
")",
":",
"if",
"event_type",
"in",
"self",
".",
"__timers",
":",
"pyglet",
".",
"clock",
".",
"unschedule",
"(",
"self",
".",
"__timers",
"[",
"event_type",
"]",
")"
] | Stop dispatching the given event.
It is not an error to attempt to stop an event that was never started,
the request will just be silently ignored. | [
"Stop",
"dispatching",
"the",
"given",
"event",
"."
] | f0125c1f218b05cfb2efb52a88d80f54eae007a0 | https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/widget.py#L74-L82 | train |
kxgames/glooey | glooey/widget.py | EventDispatcher.__yield_handlers | def __yield_handlers(self, event_type):
"""
Yield all the handlers registered for the given event type.
"""
if event_type not in self.event_types:
raise ValueError("%r not found in %r.event_types == %r" % (event_type, self, self.event_types))
# Search handler stack f... | python | def __yield_handlers(self, event_type):
"""
Yield all the handlers registered for the given event type.
"""
if event_type not in self.event_types:
raise ValueError("%r not found in %r.event_types == %r" % (event_type, self, self.event_types))
# Search handler stack f... | [
"def",
"__yield_handlers",
"(",
"self",
",",
"event_type",
")",
":",
"if",
"event_type",
"not",
"in",
"self",
".",
"event_types",
":",
"raise",
"ValueError",
"(",
"\"%r not found in %r.event_types == %r\"",
"%",
"(",
"event_type",
",",
"self",
",",
"self",
".",
... | Yield all the handlers registered for the given event type. | [
"Yield",
"all",
"the",
"handlers",
"registered",
"for",
"the",
"given",
"event",
"type",
"."
] | f0125c1f218b05cfb2efb52a88d80f54eae007a0 | https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/widget.py#L84-L98 | train |
kxgames/glooey | glooey/helpers.py | HoldUpdatesMixin._filter_pending_updates | def _filter_pending_updates(self):
"""
Return all the updates that need to be applied, from a list of all the
updates that were called while the hold was active. This method is
meant to be overridden by subclasses that want to customize how held
updates are applied.
... | python | def _filter_pending_updates(self):
"""
Return all the updates that need to be applied, from a list of all the
updates that were called while the hold was active. This method is
meant to be overridden by subclasses that want to customize how held
updates are applied.
... | [
"def",
"_filter_pending_updates",
"(",
"self",
")",
":",
"from",
"more_itertools",
"import",
"unique_everseen",
"as",
"unique",
"yield",
"from",
"reversed",
"(",
"list",
"(",
"unique",
"(",
"reversed",
"(",
"self",
".",
"_pending_updates",
")",
")",
")",
")"
] | Return all the updates that need to be applied, from a list of all the
updates that were called while the hold was active. This method is
meant to be overridden by subclasses that want to customize how held
updates are applied.
The `self._pending_updates` member variable is a list c... | [
"Return",
"all",
"the",
"updates",
"that",
"need",
"to",
"be",
"applied",
"from",
"a",
"list",
"of",
"all",
"the",
"updates",
"that",
"were",
"called",
"while",
"the",
"hold",
"was",
"active",
".",
"This",
"method",
"is",
"meant",
"to",
"be",
"overridden... | f0125c1f218b05cfb2efb52a88d80f54eae007a0 | https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/helpers.py#L59-L79 | train |
csurfer/gitsuggest | gitsuggest/utilities.py | ReposToHTML.get_html | def get_html(self):
"""Method to convert the repository list to a search results page."""
here = path.abspath(path.dirname(__file__))
env = Environment(loader=FileSystemLoader(path.join(here, "res/")))
suggest = env.get_template("suggest.htm.j2")
return suggest.render(
... | python | def get_html(self):
"""Method to convert the repository list to a search results page."""
here = path.abspath(path.dirname(__file__))
env = Environment(loader=FileSystemLoader(path.join(here, "res/")))
suggest = env.get_template("suggest.htm.j2")
return suggest.render(
... | [
"def",
"get_html",
"(",
"self",
")",
":",
"here",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"FileSystemLoader",
"(",
"path",
".",
"join",
"(",
"here",
",",
"\"r... | Method to convert the repository list to a search results page. | [
"Method",
"to",
"convert",
"the",
"repository",
"list",
"to",
"a",
"search",
"results",
"page",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/utilities.py#L26-L37 | train |
csurfer/gitsuggest | gitsuggest/utilities.py | ReposToHTML.to_html | def to_html(self, write_to):
"""Method to convert the repository list to a search results page and
write it to a HTML file.
:param write_to: File/Path to write the html file to.
"""
page_html = self.get_html()
with open(write_to, "wb") as writefile:
writefil... | python | def to_html(self, write_to):
"""Method to convert the repository list to a search results page and
write it to a HTML file.
:param write_to: File/Path to write the html file to.
"""
page_html = self.get_html()
with open(write_to, "wb") as writefile:
writefil... | [
"def",
"to_html",
"(",
"self",
",",
"write_to",
")",
":",
"page_html",
"=",
"self",
".",
"get_html",
"(",
")",
"with",
"open",
"(",
"write_to",
",",
"\"wb\"",
")",
"as",
"writefile",
":",
"writefile",
".",
"write",
"(",
"page_html",
".",
"encode",
"(",... | Method to convert the repository list to a search results page and
write it to a HTML file.
:param write_to: File/Path to write the html file to. | [
"Method",
"to",
"convert",
"the",
"repository",
"list",
"to",
"a",
"search",
"results",
"page",
"and",
"write",
"it",
"to",
"a",
"HTML",
"file",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/utilities.py#L39-L48 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.get_unique_repositories | def get_unique_repositories(repo_list):
"""Method to create unique list of repositories from the list of
repositories given.
:param repo_list: List of repositories which might contain duplicates.
:return: List of repositories with no duplicate in them.
"""
unique_list = ... | python | def get_unique_repositories(repo_list):
"""Method to create unique list of repositories from the list of
repositories given.
:param repo_list: List of repositories which might contain duplicates.
:return: List of repositories with no duplicate in them.
"""
unique_list = ... | [
"def",
"get_unique_repositories",
"(",
"repo_list",
")",
":",
"unique_list",
"=",
"list",
"(",
")",
"included",
"=",
"defaultdict",
"(",
"lambda",
":",
"False",
")",
"for",
"repo",
"in",
"repo_list",
":",
"if",
"not",
"included",
"[",
"repo",
".",
"full_na... | Method to create unique list of repositories from the list of
repositories given.
:param repo_list: List of repositories which might contain duplicates.
:return: List of repositories with no duplicate in them. | [
"Method",
"to",
"create",
"unique",
"list",
"of",
"repositories",
"from",
"the",
"list",
"of",
"repositories",
"given",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L74-L87 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.minus | def minus(repo_list_a, repo_list_b):
"""Method to create a list of repositories such that the repository
belongs to repo list a but not repo list b.
In an ideal scenario we should be able to do this by set(a) - set(b)
but as GithubRepositories have shown that set() on them is not reliab... | python | def minus(repo_list_a, repo_list_b):
"""Method to create a list of repositories such that the repository
belongs to repo list a but not repo list b.
In an ideal scenario we should be able to do this by set(a) - set(b)
but as GithubRepositories have shown that set() on them is not reliab... | [
"def",
"minus",
"(",
"repo_list_a",
",",
"repo_list_b",
")",
":",
"included",
"=",
"defaultdict",
"(",
"lambda",
":",
"False",
")",
"for",
"repo",
"in",
"repo_list_b",
":",
"included",
"[",
"repo",
".",
"full_name",
"]",
"=",
"True",
"a_minus_b",
"=",
"l... | Method to create a list of repositories such that the repository
belongs to repo list a but not repo list b.
In an ideal scenario we should be able to do this by set(a) - set(b)
but as GithubRepositories have shown that set() on them is not reliable
resort to this until it is all sorted... | [
"Method",
"to",
"create",
"a",
"list",
"of",
"repositories",
"such",
"that",
"the",
"repository",
"belongs",
"to",
"repo",
"list",
"a",
"but",
"not",
"repo",
"list",
"b",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L90-L112 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__populate_repositories_of_interest | def __populate_repositories_of_interest(self, username):
"""Method to populate repositories which will be used to suggest
repositories for the user. For this purpose we use two kinds of
repositories.
1. Repositories starred by user him/herself.
2. Repositories starred by the use... | python | def __populate_repositories_of_interest(self, username):
"""Method to populate repositories which will be used to suggest
repositories for the user. For this purpose we use two kinds of
repositories.
1. Repositories starred by user him/herself.
2. Repositories starred by the use... | [
"def",
"__populate_repositories_of_interest",
"(",
"self",
",",
"username",
")",
":",
"user",
"=",
"self",
".",
"github",
".",
"get_user",
"(",
"username",
")",
"self",
".",
"user_starred_repositories",
".",
"extend",
"(",
"user",
".",
"get_starred",
"(",
")",... | Method to populate repositories which will be used to suggest
repositories for the user. For this purpose we use two kinds of
repositories.
1. Repositories starred by user him/herself.
2. Repositories starred by the users followed by the user.
:param username: Username for the ... | [
"Method",
"to",
"populate",
"repositories",
"which",
"will",
"be",
"used",
"to",
"suggest",
"repositories",
"for",
"the",
"user",
".",
"For",
"this",
"purpose",
"we",
"use",
"two",
"kinds",
"of",
"repositories",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L114-L136 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__get_interests | def __get_interests(self):
"""Method to procure description of repositories the authenticated user
is interested in.
We currently attribute interest to:
1. The repositories the authenticated user has starred.
2. The repositories the users the authenticated user follows have
... | python | def __get_interests(self):
"""Method to procure description of repositories the authenticated user
is interested in.
We currently attribute interest to:
1. The repositories the authenticated user has starred.
2. The repositories the users the authenticated user follows have
... | [
"def",
"__get_interests",
"(",
"self",
")",
":",
"repos_of_interest",
"=",
"itertools",
".",
"chain",
"(",
"self",
".",
"user_starred_repositories",
",",
"self",
".",
"user_following_starred_repositories",
",",
")",
"repo_descriptions",
"=",
"[",
"repo",
".",
"des... | Method to procure description of repositories the authenticated user
is interested in.
We currently attribute interest to:
1. The repositories the authenticated user has starred.
2. The repositories the users the authenticated user follows have
starred.
:return: List of... | [
"Method",
"to",
"procure",
"description",
"of",
"repositories",
"the",
"authenticated",
"user",
"is",
"interested",
"in",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L138-L157 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__get_words_to_ignore | def __get_words_to_ignore(self):
"""Compiles list of all words to ignore.
:return: List of words to ignore.
"""
# Stop words in English.
english_stopwords = stopwords.words("english")
here = path.abspath(path.dirname(__file__))
# Languages in git repositories.
... | python | def __get_words_to_ignore(self):
"""Compiles list of all words to ignore.
:return: List of words to ignore.
"""
# Stop words in English.
english_stopwords = stopwords.words("english")
here = path.abspath(path.dirname(__file__))
# Languages in git repositories.
... | [
"def",
"__get_words_to_ignore",
"(",
"self",
")",
":",
"english_stopwords",
"=",
"stopwords",
".",
"words",
"(",
"\"english\"",
")",
"here",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"git_languages",
"=",
"[",
"]"... | Compiles list of all words to ignore.
:return: List of words to ignore. | [
"Compiles",
"list",
"of",
"all",
"words",
"to",
"ignore",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L159-L181 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__clean_and_tokenize | def __clean_and_tokenize(self, doc_list):
"""Method to clean and tokenize the document list.
:param doc_list: Document list to clean and tokenize.
:return: Cleaned and tokenized document list.
"""
# Some repositories fill entire documentation in description. We ignore
# ... | python | def __clean_and_tokenize(self, doc_list):
"""Method to clean and tokenize the document list.
:param doc_list: Document list to clean and tokenize.
:return: Cleaned and tokenized document list.
"""
# Some repositories fill entire documentation in description. We ignore
# ... | [
"def",
"__clean_and_tokenize",
"(",
"self",
",",
"doc_list",
")",
":",
"doc_list",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
"and",
"len",
"(",
"x",
")",
"<=",
"GitSuggest",
".",
"MAX_DESC_LEN",
",",
"doc_list",
",",
")",
"clean... | Method to clean and tokenize the document list.
:param doc_list: Document list to clean and tokenize.
:return: Cleaned and tokenized document list. | [
"Method",
"to",
"clean",
"and",
"tokenize",
"the",
"document",
"list",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L190-L233 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__construct_lda_model | def __construct_lda_model(self):
"""Method to create LDA model to procure list of topics from.
We do that by first fetching the descriptions of repositories user has
shown interest in. We tokenize the hence fetched descriptions to
procure list of cleaned tokens by dropping all the stop ... | python | def __construct_lda_model(self):
"""Method to create LDA model to procure list of topics from.
We do that by first fetching the descriptions of repositories user has
shown interest in. We tokenize the hence fetched descriptions to
procure list of cleaned tokens by dropping all the stop ... | [
"def",
"__construct_lda_model",
"(",
"self",
")",
":",
"repos_of_interest",
"=",
"self",
".",
"__get_interests",
"(",
")",
"cleaned_tokens",
"=",
"self",
".",
"__clean_and_tokenize",
"(",
"repos_of_interest",
")",
"if",
"not",
"cleaned_tokens",
":",
"cleaned_tokens"... | Method to create LDA model to procure list of topics from.
We do that by first fetching the descriptions of repositories user has
shown interest in. We tokenize the hence fetched descriptions to
procure list of cleaned tokens by dropping all the stop words and
language names from it.
... | [
"Method",
"to",
"create",
"LDA",
"model",
"to",
"procure",
"list",
"of",
"topics",
"from",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L235-L267 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.__get_query_for_repos | def __get_query_for_repos(self, term_count=5):
"""Method to procure query based on topics authenticated user is
interested in.
:param term_count: Count of terms in query.
:return: Query string.
"""
repo_query_terms = list()
for term in self.lda_model.get_topic_te... | python | def __get_query_for_repos(self, term_count=5):
"""Method to procure query based on topics authenticated user is
interested in.
:param term_count: Count of terms in query.
:return: Query string.
"""
repo_query_terms = list()
for term in self.lda_model.get_topic_te... | [
"def",
"__get_query_for_repos",
"(",
"self",
",",
"term_count",
"=",
"5",
")",
":",
"repo_query_terms",
"=",
"list",
"(",
")",
"for",
"term",
"in",
"self",
".",
"lda_model",
".",
"get_topic_terms",
"(",
"0",
",",
"topn",
"=",
"term_count",
")",
":",
"rep... | Method to procure query based on topics authenticated user is
interested in.
:param term_count: Count of terms in query.
:return: Query string. | [
"Method",
"to",
"procure",
"query",
"based",
"on",
"topics",
"authenticated",
"user",
"is",
"interested",
"in",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L269-L279 | train |
csurfer/gitsuggest | gitsuggest/suggest.py | GitSuggest.get_suggested_repositories | def get_suggested_repositories(self):
"""Method to procure suggested repositories for the user.
:return: Iterator to procure suggested repositories for the user.
"""
if self.suggested_repositories is None:
# Procure repositories to suggest to user.
repository_set... | python | def get_suggested_repositories(self):
"""Method to procure suggested repositories for the user.
:return: Iterator to procure suggested repositories for the user.
"""
if self.suggested_repositories is None:
# Procure repositories to suggest to user.
repository_set... | [
"def",
"get_suggested_repositories",
"(",
"self",
")",
":",
"if",
"self",
".",
"suggested_repositories",
"is",
"None",
":",
"repository_set",
"=",
"list",
"(",
")",
"for",
"term_count",
"in",
"range",
"(",
"5",
",",
"2",
",",
"-",
"1",
")",
":",
"query",... | Method to procure suggested repositories for the user.
:return: Iterator to procure suggested repositories for the user. | [
"Method",
"to",
"procure",
"suggested",
"repositories",
"for",
"the",
"user",
"."
] | 02efdbf50acb094e502aef9c139dde62676455ee | https://github.com/csurfer/gitsuggest/blob/02efdbf50acb094e502aef9c139dde62676455ee/gitsuggest/suggest.py#L296-L339 | train |
bcicen/wikitables | wikitables/util.py | guess_type | def guess_type(s):
""" attempt to convert string value into numeric type """
sc = s.replace(',', '') # remove comma from potential numbers
try:
return int(sc)
except ValueError:
pass
try:
return float(sc)
except ValueError:
pass
return s | python | def guess_type(s):
""" attempt to convert string value into numeric type """
sc = s.replace(',', '') # remove comma from potential numbers
try:
return int(sc)
except ValueError:
pass
try:
return float(sc)
except ValueError:
pass
return s | [
"def",
"guess_type",
"(",
"s",
")",
":",
"sc",
"=",
"s",
".",
"replace",
"(",
"','",
",",
"''",
")",
"try",
":",
"return",
"int",
"(",
"sc",
")",
"except",
"ValueError",
":",
"pass",
"try",
":",
"return",
"float",
"(",
"sc",
")",
"except",
"Value... | attempt to convert string value into numeric type | [
"attempt",
"to",
"convert",
"string",
"value",
"into",
"numeric",
"type"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/util.py#L15-L29 | train |
bcicen/wikitables | wikitables/readers.py | FieldReader.parse | def parse(self, node):
"""
Return generator yielding Field objects for a given node
"""
self._attrs = {}
vals = []
yielded = False
for x in self._read_parts(node):
if isinstance(x, Field):
yielded = True
x.attrs = self.... | python | def parse(self, node):
"""
Return generator yielding Field objects for a given node
"""
self._attrs = {}
vals = []
yielded = False
for x in self._read_parts(node):
if isinstance(x, Field):
yielded = True
x.attrs = self.... | [
"def",
"parse",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_attrs",
"=",
"{",
"}",
"vals",
"=",
"[",
"]",
"yielded",
"=",
"False",
"for",
"x",
"in",
"self",
".",
"_read_parts",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"F... | Return generator yielding Field objects for a given node | [
"Return",
"generator",
"yielding",
"Field",
"objects",
"for",
"a",
"given",
"node"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/readers.py#L21-L43 | train |
bcicen/wikitables | wikitables/readers.py | RowReader.parse | def parse(self, *nodes):
"""
Parse one or more `tr` nodes, yielding wikitables.Row objects
"""
for n in nodes:
if not n.contents:
continue
row = self._parse(n)
if not row.is_null:
yield row | python | def parse(self, *nodes):
"""
Parse one or more `tr` nodes, yielding wikitables.Row objects
"""
for n in nodes:
if not n.contents:
continue
row = self._parse(n)
if not row.is_null:
yield row | [
"def",
"parse",
"(",
"self",
",",
"*",
"nodes",
")",
":",
"for",
"n",
"in",
"nodes",
":",
"if",
"not",
"n",
".",
"contents",
":",
"continue",
"row",
"=",
"self",
".",
"_parse",
"(",
"n",
")",
"if",
"not",
"row",
".",
"is_null",
":",
"yield",
"r... | Parse one or more `tr` nodes, yielding wikitables.Row objects | [
"Parse",
"one",
"or",
"more",
"tr",
"nodes",
"yielding",
"wikitables",
".",
"Row",
"objects"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/readers.py#L102-L111 | train |
bcicen/wikitables | wikitables/__init__.py | WikiTable._find_header_row | def _find_header_row(self):
"""
Evaluate all rows and determine header position, based on
greatest number of 'th' tagged elements
"""
th_max = 0
header_idx = 0
for idx, tr in enumerate(self._tr_nodes):
th_count = len(tr.contents.filter_tags(matches=fta... | python | def _find_header_row(self):
"""
Evaluate all rows and determine header position, based on
greatest number of 'th' tagged elements
"""
th_max = 0
header_idx = 0
for idx, tr in enumerate(self._tr_nodes):
th_count = len(tr.contents.filter_tags(matches=fta... | [
"def",
"_find_header_row",
"(",
"self",
")",
":",
"th_max",
"=",
"0",
"header_idx",
"=",
"0",
"for",
"idx",
",",
"tr",
"in",
"enumerate",
"(",
"self",
".",
"_tr_nodes",
")",
":",
"th_count",
"=",
"len",
"(",
"tr",
".",
"contents",
".",
"filter_tags",
... | Evaluate all rows and determine header position, based on
greatest number of 'th' tagged elements | [
"Evaluate",
"all",
"rows",
"and",
"determine",
"header",
"position",
"based",
"on",
"greatest",
"number",
"of",
"th",
"tagged",
"elements"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/__init__.py#L92-L112 | train |
bcicen/wikitables | wikitables/__init__.py | WikiTable._make_default_header | def _make_default_header(self):
"""
Return a generic placeholder header based on the tables column count
"""
td_max = 0
for idx, tr in enumerate(self._tr_nodes):
td_count = len(tr.contents.filter_tags(matches=ftag('td')))
if td_count > td_max:
... | python | def _make_default_header(self):
"""
Return a generic placeholder header based on the tables column count
"""
td_max = 0
for idx, tr in enumerate(self._tr_nodes):
td_count = len(tr.contents.filter_tags(matches=ftag('td')))
if td_count > td_max:
... | [
"def",
"_make_default_header",
"(",
"self",
")",
":",
"td_max",
"=",
"0",
"for",
"idx",
",",
"tr",
"in",
"enumerate",
"(",
"self",
".",
"_tr_nodes",
")",
":",
"td_count",
"=",
"len",
"(",
"tr",
".",
"contents",
".",
"filter_tags",
"(",
"matches",
"=",
... | Return a generic placeholder header based on the tables column count | [
"Return",
"a",
"generic",
"placeholder",
"header",
"based",
"on",
"the",
"tables",
"column",
"count"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/__init__.py#L114-L126 | train |
bcicen/wikitables | wikitables/client.py | Client.fetch_page | def fetch_page(self, title, method='GET'):
""" Query for page by title """
params = { 'prop': 'revisions',
'format': 'json',
'action': 'query',
'explaintext': '',
'titles': title,
'rvprop': 'content' }
... | python | def fetch_page(self, title, method='GET'):
""" Query for page by title """
params = { 'prop': 'revisions',
'format': 'json',
'action': 'query',
'explaintext': '',
'titles': title,
'rvprop': 'content' }
... | [
"def",
"fetch_page",
"(",
"self",
",",
"title",
",",
"method",
"=",
"'GET'",
")",
":",
"params",
"=",
"{",
"'prop'",
":",
"'revisions'",
",",
"'format'",
":",
"'json'",
",",
"'action'",
":",
"'query'",
",",
"'explaintext'",
":",
"''",
",",
"'titles'",
... | Query for page by title | [
"Query",
"for",
"page",
"by",
"title"
] | 055cbabaa60762edbab78bf6a76ba19875f328f7 | https://github.com/bcicen/wikitables/blob/055cbabaa60762edbab78bf6a76ba19875f328f7/wikitables/client.py#L16-L32 | train |
wooparadog/pystack | pystack.py | print_stack | def print_stack(pid, include_greenlet=False, debugger=None, verbose=False):
"""Executes a file in a running Python process."""
# TextIOWrapper of Python 3 is so strange.
sys_stdout = getattr(sys.stdout, 'buffer', sys.stdout)
sys_stderr = getattr(sys.stderr, 'buffer', sys.stderr)
make_args = make_gd... | python | def print_stack(pid, include_greenlet=False, debugger=None, verbose=False):
"""Executes a file in a running Python process."""
# TextIOWrapper of Python 3 is so strange.
sys_stdout = getattr(sys.stdout, 'buffer', sys.stdout)
sys_stderr = getattr(sys.stderr, 'buffer', sys.stderr)
make_args = make_gd... | [
"def",
"print_stack",
"(",
"pid",
",",
"include_greenlet",
"=",
"False",
",",
"debugger",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"sys_stdout",
"=",
"getattr",
"(",
"sys",
".",
"stdout",
",",
"'buffer'",
",",
"sys",
".",
"stdout",
")",
"sy... | Executes a file in a running Python process. | [
"Executes",
"a",
"file",
"in",
"a",
"running",
"Python",
"process",
"."
] | 1ee5bb0ab516f60dd407d7b18d2faa752a8e289c | https://github.com/wooparadog/pystack/blob/1ee5bb0ab516f60dd407d7b18d2faa752a8e289c/pystack.py#L77-L116 | train |
wooparadog/pystack | pystack.py | cli_main | def cli_main(pid, include_greenlet, debugger, verbose):
'''Print stack of python process.
$ pystack <pid>
'''
try:
print_stack(pid, include_greenlet, debugger, verbose)
except DebuggerNotFound as e:
click.echo('DebuggerNotFound: %s' % e.args[0], err=True)
click.get_current_c... | python | def cli_main(pid, include_greenlet, debugger, verbose):
'''Print stack of python process.
$ pystack <pid>
'''
try:
print_stack(pid, include_greenlet, debugger, verbose)
except DebuggerNotFound as e:
click.echo('DebuggerNotFound: %s' % e.args[0], err=True)
click.get_current_c... | [
"def",
"cli_main",
"(",
"pid",
",",
"include_greenlet",
",",
"debugger",
",",
"verbose",
")",
":",
"try",
":",
"print_stack",
"(",
"pid",
",",
"include_greenlet",
",",
"debugger",
",",
"verbose",
")",
"except",
"DebuggerNotFound",
"as",
"e",
":",
"click",
... | Print stack of python process.
$ pystack <pid> | [
"Print",
"stack",
"of",
"python",
"process",
"."
] | 1ee5bb0ab516f60dd407d7b18d2faa752a8e289c | https://github.com/wooparadog/pystack/blob/1ee5bb0ab516f60dd407d7b18d2faa752a8e289c/pystack.py#L131-L140 | train |
rahul13ramesh/hidden_markov | hidden_markov/hmm_class.py | hmm.forward_algo | def forward_algo(self,observations):
""" Finds the probability of an observation sequence for given model parameters
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A... | python | def forward_algo(self,observations):
""" Finds the probability of an observation sequence for given model parameters
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A... | [
"def",
"forward_algo",
"(",
"self",
",",
"observations",
")",
":",
"total_stages",
"=",
"len",
"(",
"observations",
")",
"ob_ind",
"=",
"self",
".",
"obs_map",
"[",
"observations",
"[",
"0",
"]",
"]",
"alpha",
"=",
"np",
".",
"multiply",
"(",
"np",
"."... | Finds the probability of an observation sequence for given model parameters
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A list or tuple
:return: The probability ... | [
"Finds",
"the",
"probability",
"of",
"an",
"observation",
"sequence",
"for",
"given",
"model",
"parameters"
] | 6ba6012665f9e09c980ff70901604d051ba57dcc | https://github.com/rahul13ramesh/hidden_markov/blob/6ba6012665f9e09c980ff70901604d051ba57dcc/hidden_markov/hmm_class.py#L144-L190 | train |
rahul13ramesh/hidden_markov | hidden_markov/hmm_class.py | hmm.viterbi | def viterbi(self,observations):
""" The probability of occurence of the observation sequence
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A list or tuple
... | python | def viterbi(self,observations):
""" The probability of occurence of the observation sequence
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A list or tuple
... | [
"def",
"viterbi",
"(",
"self",
",",
"observations",
")",
":",
"total_stages",
"=",
"len",
"(",
"observations",
")",
"num_states",
"=",
"len",
"(",
"self",
".",
"states",
")",
"old_path",
"=",
"np",
".",
"zeros",
"(",
"(",
"total_stages",
",",
"num_states... | The probability of occurence of the observation sequence
**Arguments**:
:param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object.
:type observations: A list or tuple
:return: Returns a list of hidden states.
... | [
"The",
"probability",
"of",
"occurence",
"of",
"the",
"observation",
"sequence"
] | 6ba6012665f9e09c980ff70901604d051ba57dcc | https://github.com/rahul13ramesh/hidden_markov/blob/6ba6012665f9e09c980ff70901604d051ba57dcc/hidden_markov/hmm_class.py#L194-L277 | train |
rahul13ramesh/hidden_markov | hidden_markov/hmm_class.py | hmm.train_hmm | def train_hmm(self,observation_list, iterations, quantities):
""" Runs the Baum Welch Algorithm and finds the new model parameters
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
... | python | def train_hmm(self,observation_list, iterations, quantities):
""" Runs the Baum Welch Algorithm and finds the new model parameters
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
... | [
"def",
"train_hmm",
"(",
"self",
",",
"observation_list",
",",
"iterations",
",",
"quantities",
")",
":",
"obs_size",
"=",
"len",
"(",
"observation_list",
")",
"prob",
"=",
"float",
"(",
"'inf'",
")",
"q",
"=",
"quantities",
"for",
"i",
"in",
"range",
"(... | Runs the Baum Welch Algorithm and finds the new model parameters
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
:param iterations: Maximum number of iterations for the algorithm
... | [
"Runs",
"the",
"Baum",
"Welch",
"Algorithm",
"and",
"finds",
"the",
"new",
"model",
"parameters"
] | 6ba6012665f9e09c980ff70901604d051ba57dcc | https://github.com/rahul13ramesh/hidden_markov/blob/6ba6012665f9e09c980ff70901604d051ba57dcc/hidden_markov/hmm_class.py#L281-L363 | train |
rahul13ramesh/hidden_markov | hidden_markov/hmm_class.py | hmm.log_prob | def log_prob(self,observations_list, quantities):
""" Finds Weighted log probability of a list of observation sequences
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
:param ... | python | def log_prob(self,observations_list, quantities):
""" Finds Weighted log probability of a list of observation sequences
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
:param ... | [
"def",
"log_prob",
"(",
"self",
",",
"observations_list",
",",
"quantities",
")",
":",
"prob",
"=",
"0",
"for",
"q",
",",
"obs",
"in",
"enumerate",
"(",
"observations_list",
")",
":",
"temp",
",",
"c_scale",
"=",
"self",
".",
"_alpha_cal",
"(",
"obs",
... | Finds Weighted log probability of a list of observation sequences
**Arguments**:
:param observation_list: A nested list, or a list of lists
:type observation_list: Contains a list multiple observation sequences.
:param quantities: Number of times, each corresponding item in 'obser... | [
"Finds",
"Weighted",
"log",
"probability",
"of",
"a",
"list",
"of",
"observation",
"sequences"
] | 6ba6012665f9e09c980ff70901604d051ba57dcc | https://github.com/rahul13ramesh/hidden_markov/blob/6ba6012665f9e09c980ff70901604d051ba57dcc/hidden_markov/hmm_class.py#L513-L555 | train |
mortada/fredapi | fredapi/fred.py | Fred.__fetch_data | def __fetch_data(self, url):
"""
helper function for fetching data given a request URL
"""
url += '&api_key=' + self.api_key
try:
response = urlopen(url)
root = ET.fromstring(response.read())
except HTTPError as exc:
root = ET.fromstrin... | python | def __fetch_data(self, url):
"""
helper function for fetching data given a request URL
"""
url += '&api_key=' + self.api_key
try:
response = urlopen(url)
root = ET.fromstring(response.read())
except HTTPError as exc:
root = ET.fromstrin... | [
"def",
"__fetch_data",
"(",
"self",
",",
"url",
")",
":",
"url",
"+=",
"'&api_key='",
"+",
"self",
".",
"api_key",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
")",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"response",
".",
"read",
"(",
")",
... | helper function for fetching data given a request URL | [
"helper",
"function",
"for",
"fetching",
"data",
"given",
"a",
"request",
"URL"
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L58-L69 | train |
mortada/fredapi | fredapi/fred.py | Fred._parse | def _parse(self, date_str, format='%Y-%m-%d'):
"""
helper function for parsing FRED date string into datetime
"""
rv = pd.to_datetime(date_str, format=format)
if hasattr(rv, 'to_pydatetime'):
rv = rv.to_pydatetime()
return rv | python | def _parse(self, date_str, format='%Y-%m-%d'):
"""
helper function for parsing FRED date string into datetime
"""
rv = pd.to_datetime(date_str, format=format)
if hasattr(rv, 'to_pydatetime'):
rv = rv.to_pydatetime()
return rv | [
"def",
"_parse",
"(",
"self",
",",
"date_str",
",",
"format",
"=",
"'%Y-%m-%d'",
")",
":",
"rv",
"=",
"pd",
".",
"to_datetime",
"(",
"date_str",
",",
"format",
"=",
"format",
")",
"if",
"hasattr",
"(",
"rv",
",",
"'to_pydatetime'",
")",
":",
"rv",
"=... | helper function for parsing FRED date string into datetime | [
"helper",
"function",
"for",
"parsing",
"FRED",
"date",
"string",
"into",
"datetime"
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L71-L78 | train |
mortada/fredapi | fredapi/fred.py | Fred.get_series_first_release | def get_series_first_release(self, series_id):
"""
Get first-release data for a Fred series id. This ignores any revision to the data series. For instance,
The US GDP for Q1 2014 was first released to be 17149.6, and then later revised to 17101.3, and 17016.0.
This will ignore revisions ... | python | def get_series_first_release(self, series_id):
"""
Get first-release data for a Fred series id. This ignores any revision to the data series. For instance,
The US GDP for Q1 2014 was first released to be 17149.6, and then later revised to 17101.3, and 17016.0.
This will ignore revisions ... | [
"def",
"get_series_first_release",
"(",
"self",
",",
"series_id",
")",
":",
"df",
"=",
"self",
".",
"get_series_all_releases",
"(",
"series_id",
")",
"first_release",
"=",
"df",
".",
"groupby",
"(",
"'date'",
")",
".",
"head",
"(",
"1",
")",
"data",
"=",
... | Get first-release data for a Fred series id. This ignores any revision to the data series. For instance,
The US GDP for Q1 2014 was first released to be 17149.6, and then later revised to 17101.3, and 17016.0.
This will ignore revisions after the first release.
Parameters
----------
... | [
"Get",
"first",
"-",
"release",
"data",
"for",
"a",
"Fred",
"series",
"id",
".",
"This",
"ignores",
"any",
"revision",
"to",
"the",
"data",
"series",
".",
"For",
"instance",
"The",
"US",
"GDP",
"for",
"Q1",
"2014",
"was",
"first",
"released",
"to",
"be... | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L160-L179 | train |
mortada/fredapi | fredapi/fred.py | Fred.get_series_as_of_date | def get_series_as_of_date(self, series_id, as_of_date):
"""
Get latest data for a Fred series id as known on a particular date. This includes any revision to the data series
before or on as_of_date, but ignores any revision on dates after as_of_date.
Parameters
----------
... | python | def get_series_as_of_date(self, series_id, as_of_date):
"""
Get latest data for a Fred series id as known on a particular date. This includes any revision to the data series
before or on as_of_date, but ignores any revision on dates after as_of_date.
Parameters
----------
... | [
"def",
"get_series_as_of_date",
"(",
"self",
",",
"series_id",
",",
"as_of_date",
")",
":",
"as_of_date",
"=",
"pd",
".",
"to_datetime",
"(",
"as_of_date",
")",
"df",
"=",
"self",
".",
"get_series_all_releases",
"(",
"series_id",
")",
"data",
"=",
"df",
"[",... | Get latest data for a Fred series id as known on a particular date. This includes any revision to the data series
before or on as_of_date, but ignores any revision on dates after as_of_date.
Parameters
----------
series_id : str
Fred series id such as 'GDP'
as_of_dat... | [
"Get",
"latest",
"data",
"for",
"a",
"Fred",
"series",
"id",
"as",
"known",
"on",
"a",
"particular",
"date",
".",
"This",
"includes",
"any",
"revision",
"to",
"the",
"data",
"series",
"before",
"or",
"on",
"as_of_date",
"but",
"ignores",
"any",
"revision",... | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L181-L201 | train |
mortada/fredapi | fredapi/fred.py | Fred.get_series_vintage_dates | def get_series_vintage_dates(self, series_id):
"""
Get a list of vintage dates for a series. Vintage dates are the dates in history when a
series' data values were revised or new data values were released.
Parameters
----------
series_id : str
Fred series id ... | python | def get_series_vintage_dates(self, series_id):
"""
Get a list of vintage dates for a series. Vintage dates are the dates in history when a
series' data values were revised or new data values were released.
Parameters
----------
series_id : str
Fred series id ... | [
"def",
"get_series_vintage_dates",
"(",
"self",
",",
"series_id",
")",
":",
"url",
"=",
"\"%s/series/vintagedates?series_id=%s\"",
"%",
"(",
"self",
".",
"root_url",
",",
"series_id",
")",
"root",
"=",
"self",
".",
"__fetch_data",
"(",
"url",
")",
"if",
"root"... | Get a list of vintage dates for a series. Vintage dates are the dates in history when a
series' data values were revised or new data values were released.
Parameters
----------
series_id : str
Fred series id such as 'CPIAUCSL'
Returns
-------
dates :... | [
"Get",
"a",
"list",
"of",
"vintage",
"dates",
"for",
"a",
"series",
".",
"Vintage",
"dates",
"are",
"the",
"dates",
"in",
"history",
"when",
"a",
"series",
"data",
"values",
"were",
"revised",
"or",
"new",
"data",
"values",
"were",
"released",
"."
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L250-L272 | train |
mortada/fredapi | fredapi/fred.py | Fred.__do_series_search | def __do_series_search(self, url):
"""
helper function for making one HTTP request for data, and parsing the returned results into a DataFrame
"""
root = self.__fetch_data(url)
series_ids = []
data = {}
num_results_returned = 0 # number of results returned in t... | python | def __do_series_search(self, url):
"""
helper function for making one HTTP request for data, and parsing the returned results into a DataFrame
"""
root = self.__fetch_data(url)
series_ids = []
data = {}
num_results_returned = 0 # number of results returned in t... | [
"def",
"__do_series_search",
"(",
"self",
",",
"url",
")",
":",
"root",
"=",
"self",
".",
"__fetch_data",
"(",
"url",
")",
"series_ids",
"=",
"[",
"]",
"data",
"=",
"{",
"}",
"num_results_returned",
"=",
"0",
"num_results_total",
"=",
"int",
"(",
"root",... | helper function for making one HTTP request for data, and parsing the returned results into a DataFrame | [
"helper",
"function",
"for",
"making",
"one",
"HTTP",
"request",
"for",
"data",
"and",
"parsing",
"the",
"returned",
"results",
"into",
"a",
"DataFrame"
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L274-L305 | train |
mortada/fredapi | fredapi/fred.py | Fred.__get_search_results | def __get_search_results(self, url, limit, order_by, sort_order, filter):
"""
helper function for getting search results up to specified limit on the number of results. The Fred HTTP API
truncates to 1000 results per request, so this may issue multiple HTTP requests to obtain more available data... | python | def __get_search_results(self, url, limit, order_by, sort_order, filter):
"""
helper function for getting search results up to specified limit on the number of results. The Fred HTTP API
truncates to 1000 results per request, so this may issue multiple HTTP requests to obtain more available data... | [
"def",
"__get_search_results",
"(",
"self",
",",
"url",
",",
"limit",
",",
"order_by",
",",
"sort_order",
",",
"filter",
")",
":",
"order_by_options",
"=",
"[",
"'search_rank'",
",",
"'series_id'",
",",
"'title'",
",",
"'units'",
",",
"'frequency'",
",",
"'s... | helper function for getting search results up to specified limit on the number of results. The Fred HTTP API
truncates to 1000 results per request, so this may issue multiple HTTP requests to obtain more available data. | [
"helper",
"function",
"for",
"getting",
"search",
"results",
"up",
"to",
"specified",
"limit",
"on",
"the",
"number",
"of",
"results",
".",
"The",
"Fred",
"HTTP",
"API",
"truncates",
"to",
"1000",
"results",
"per",
"request",
"so",
"this",
"may",
"issue",
... | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L307-L349 | train |
mortada/fredapi | fredapi/fred.py | Fred.search | def search(self, text, limit=1000, order_by=None, sort_order=None, filter=None):
"""
Do a fulltext search for series in the Fred dataset. Returns information about matching series in a DataFrame.
Parameters
----------
text : str
text to do fulltext search on, e.g., '... | python | def search(self, text, limit=1000, order_by=None, sort_order=None, filter=None):
"""
Do a fulltext search for series in the Fred dataset. Returns information about matching series in a DataFrame.
Parameters
----------
text : str
text to do fulltext search on, e.g., '... | [
"def",
"search",
"(",
"self",
",",
"text",
",",
"limit",
"=",
"1000",
",",
"order_by",
"=",
"None",
",",
"sort_order",
"=",
"None",
",",
"filter",
"=",
"None",
")",
":",
"url",
"=",
"\"%s/series/search?search_text=%s&\"",
"%",
"(",
"self",
".",
"root_url... | Do a fulltext search for series in the Fred dataset. Returns information about matching series in a DataFrame.
Parameters
----------
text : str
text to do fulltext search on, e.g., 'Real GDP'
limit : int, optional
limit the number of results to this value. If lim... | [
"Do",
"a",
"fulltext",
"search",
"for",
"series",
"in",
"the",
"Fred",
"dataset",
".",
"Returns",
"information",
"about",
"matching",
"series",
"in",
"a",
"DataFrame",
"."
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L351-L379 | train |
mortada/fredapi | fredapi/fred.py | Fred.search_by_release | def search_by_release(self, release_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a release id. Returns information about matching series in a DataFrame.
Parameters
----------
release_id : int
release id, e.g., 151
... | python | def search_by_release(self, release_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a release id. Returns information about matching series in a DataFrame.
Parameters
----------
release_id : int
release id, e.g., 151
... | [
"def",
"search_by_release",
"(",
"self",
",",
"release_id",
",",
"limit",
"=",
"0",
",",
"order_by",
"=",
"None",
",",
"sort_order",
"=",
"None",
",",
"filter",
"=",
"None",
")",
":",
"url",
"=",
"\"%s/release/series?release_id=%d\"",
"%",
"(",
"self",
"."... | Search for series that belongs to a release id. Returns information about matching series in a DataFrame.
Parameters
----------
release_id : int
release id, e.g., 151
limit : int, optional
limit the number of results to this value. If limit is 0, it means fetchin... | [
"Search",
"for",
"series",
"that",
"belongs",
"to",
"a",
"release",
"id",
".",
"Returns",
"information",
"about",
"matching",
"series",
"in",
"a",
"DataFrame",
"."
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L381-L410 | train |
mortada/fredapi | fredapi/fred.py | Fred.search_by_category | def search_by_category(self, category_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a category id. Returns information about matching series in a DataFrame.
Parameters
----------
category_id : int
category id, e.g., ... | python | def search_by_category(self, category_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a category id. Returns information about matching series in a DataFrame.
Parameters
----------
category_id : int
category id, e.g., ... | [
"def",
"search_by_category",
"(",
"self",
",",
"category_id",
",",
"limit",
"=",
"0",
",",
"order_by",
"=",
"None",
",",
"sort_order",
"=",
"None",
",",
"filter",
"=",
"None",
")",
":",
"url",
"=",
"\"%s/category/series?category_id=%d&\"",
"%",
"(",
"self",
... | Search for series that belongs to a category id. Returns information about matching series in a DataFrame.
Parameters
----------
category_id : int
category id, e.g., 32145
limit : int, optional
limit the number of results to this value. If limit is 0, it means fe... | [
"Search",
"for",
"series",
"that",
"belongs",
"to",
"a",
"category",
"id",
".",
"Returns",
"information",
"about",
"matching",
"series",
"in",
"a",
"DataFrame",
"."
] | d3ca79efccb9525f2752a0d6da90e793e87c3fd8 | https://github.com/mortada/fredapi/blob/d3ca79efccb9525f2752a0d6da90e793e87c3fd8/fredapi/fred.py#L412-L442 | train |
mathiasertl/django-ca | ca/django_ca/managers.py | CertificateManager.init | def init(self, ca, csr, **kwargs):
"""Create a signed certificate from a CSR and store it to the database.
All parameters are passed on to :py:func:`Certificate.objects.sign_cert()
<django_ca.managers.CertificateManager.sign_cert>`.
"""
c = self.model(ca=ca)
c.x509, csr... | python | def init(self, ca, csr, **kwargs):
"""Create a signed certificate from a CSR and store it to the database.
All parameters are passed on to :py:func:`Certificate.objects.sign_cert()
<django_ca.managers.CertificateManager.sign_cert>`.
"""
c = self.model(ca=ca)
c.x509, csr... | [
"def",
"init",
"(",
"self",
",",
"ca",
",",
"csr",
",",
"**",
"kwargs",
")",
":",
"c",
"=",
"self",
".",
"model",
"(",
"ca",
"=",
"ca",
")",
"c",
".",
"x509",
",",
"csr",
"=",
"self",
".",
"sign_cert",
"(",
"ca",
",",
"csr",
",",
"**",
"kwa... | Create a signed certificate from a CSR and store it to the database.
All parameters are passed on to :py:func:`Certificate.objects.sign_cert()
<django_ca.managers.CertificateManager.sign_cert>`. | [
"Create",
"a",
"signed",
"certificate",
"from",
"a",
"CSR",
"and",
"store",
"it",
"to",
"the",
"database",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/managers.py#L442-L455 | train |
mathiasertl/django-ca | ca/django_ca/admin.py | CertificateMixin.download_bundle_view | def download_bundle_view(self, request, pk):
"""A view that allows the user to download a certificate bundle in PEM format."""
return self._download_response(request, pk, bundle=True) | python | def download_bundle_view(self, request, pk):
"""A view that allows the user to download a certificate bundle in PEM format."""
return self._download_response(request, pk, bundle=True) | [
"def",
"download_bundle_view",
"(",
"self",
",",
"request",
",",
"pk",
")",
":",
"return",
"self",
".",
"_download_response",
"(",
"request",
",",
"pk",
",",
"bundle",
"=",
"True",
")"
] | A view that allows the user to download a certificate bundle in PEM format. | [
"A",
"view",
"that",
"allows",
"the",
"user",
"to",
"download",
"a",
"certificate",
"bundle",
"in",
"PEM",
"format",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/admin.py#L118-L121 | train |
mathiasertl/django-ca | ca/django_ca/admin.py | CertificateMixin.get_actions | def get_actions(self, request):
"""Disable the "delete selected" admin action.
Otherwise the action is present even though has_delete_permission is False, it just doesn't
work.
"""
actions = super(CertificateMixin, self).get_actions(request)
actions.pop('delete_selected'... | python | def get_actions(self, request):
"""Disable the "delete selected" admin action.
Otherwise the action is present even though has_delete_permission is False, it just doesn't
work.
"""
actions = super(CertificateMixin, self).get_actions(request)
actions.pop('delete_selected'... | [
"def",
"get_actions",
"(",
"self",
",",
"request",
")",
":",
"actions",
"=",
"super",
"(",
"CertificateMixin",
",",
"self",
")",
".",
"get_actions",
"(",
"request",
")",
"actions",
".",
"pop",
"(",
"'delete_selected'",
",",
"''",
")",
"return",
"actions"
] | Disable the "delete selected" admin action.
Otherwise the action is present even though has_delete_permission is False, it just doesn't
work. | [
"Disable",
"the",
"delete",
"selected",
"admin",
"action",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/admin.py#L126-L134 | train |
mathiasertl/django-ca | ca/django_ca/profiles.py | get_cert_profile_kwargs | def get_cert_profile_kwargs(name=None):
"""Get kwargs suitable for get_cert X509 keyword arguments from the given profile."""
if name is None:
name = ca_settings.CA_DEFAULT_PROFILE
profile = deepcopy(ca_settings.CA_PROFILES[name])
kwargs = {
'cn_in_san': profile['cn_in_san'],
'... | python | def get_cert_profile_kwargs(name=None):
"""Get kwargs suitable for get_cert X509 keyword arguments from the given profile."""
if name is None:
name = ca_settings.CA_DEFAULT_PROFILE
profile = deepcopy(ca_settings.CA_PROFILES[name])
kwargs = {
'cn_in_san': profile['cn_in_san'],
'... | [
"def",
"get_cert_profile_kwargs",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"ca_settings",
".",
"CA_DEFAULT_PROFILE",
"profile",
"=",
"deepcopy",
"(",
"ca_settings",
".",
"CA_PROFILES",
"[",
"name",
"]",
")",
"kwargs",... | Get kwargs suitable for get_cert X509 keyword arguments from the given profile. | [
"Get",
"kwargs",
"suitable",
"for",
"get_cert",
"X509",
"keyword",
"arguments",
"from",
"the",
"given",
"profile",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/profiles.py#L25-L49 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | format_name | def format_name(subject):
"""Convert a subject into the canonical form for distinguished names.
This function does not take care of sorting the subject in any meaningful order.
Examples::
>>> format_name([('CN', 'example.com'), ])
'/CN=example.com'
>>> format_name([('CN', 'example... | python | def format_name(subject):
"""Convert a subject into the canonical form for distinguished names.
This function does not take care of sorting the subject in any meaningful order.
Examples::
>>> format_name([('CN', 'example.com'), ])
'/CN=example.com'
>>> format_name([('CN', 'example... | [
"def",
"format_name",
"(",
"subject",
")",
":",
"if",
"isinstance",
"(",
"subject",
",",
"x509",
".",
"Name",
")",
":",
"subject",
"=",
"[",
"(",
"OID_NAME_MAPPINGS",
"[",
"s",
".",
"oid",
"]",
",",
"s",
".",
"value",
")",
"for",
"s",
"in",
"subjec... | Convert a subject into the canonical form for distinguished names.
This function does not take care of sorting the subject in any meaningful order.
Examples::
>>> format_name([('CN', 'example.com'), ])
'/CN=example.com'
>>> format_name([('CN', 'example.com'), ('O', "My Organization"),... | [
"Convert",
"a",
"subject",
"into",
"the",
"canonical",
"form",
"for",
"distinguished",
"names",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L125-L140 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | format_general_name | def format_general_name(name):
"""Format a single general name.
>>> import ipaddress
>>> format_general_name(x509.DNSName('example.com'))
'DNS:example.com'
>>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1')))
'IP:127.0.0.1'
"""
if isinstance(name, x509.DirectoryN... | python | def format_general_name(name):
"""Format a single general name.
>>> import ipaddress
>>> format_general_name(x509.DNSName('example.com'))
'DNS:example.com'
>>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1')))
'IP:127.0.0.1'
"""
if isinstance(name, x509.DirectoryN... | [
"def",
"format_general_name",
"(",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"x509",
".",
"DirectoryName",
")",
":",
"value",
"=",
"format_name",
"(",
"name",
".",
"value",
")",
"else",
":",
"value",
"=",
"name",
".",
"value",
"return",
"... | Format a single general name.
>>> import ipaddress
>>> format_general_name(x509.DNSName('example.com'))
'DNS:example.com'
>>> format_general_name(x509.IPAddress(ipaddress.IPv4Address('127.0.0.1')))
'IP:127.0.0.1' | [
"Format",
"a",
"single",
"general",
"name",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L143-L157 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | add_colons | def add_colons(s):
"""Add colons after every second digit.
This function is used in functions to prettify serials.
>>> add_colons('teststring')
'te:st:st:ri:ng'
"""
return ':'.join([s[i:i + 2] for i in range(0, len(s), 2)]) | python | def add_colons(s):
"""Add colons after every second digit.
This function is used in functions to prettify serials.
>>> add_colons('teststring')
'te:st:st:ri:ng'
"""
return ':'.join([s[i:i + 2] for i in range(0, len(s), 2)]) | [
"def",
"add_colons",
"(",
"s",
")",
":",
"return",
"':'",
".",
"join",
"(",
"[",
"s",
"[",
"i",
":",
"i",
"+",
"2",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"s",
")",
",",
"2",
")",
"]",
")"
] | Add colons after every second digit.
This function is used in functions to prettify serials.
>>> add_colons('teststring')
'te:st:st:ri:ng' | [
"Add",
"colons",
"after",
"every",
"second",
"digit",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L200-L208 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | int_to_hex | def int_to_hex(i):
"""Create a hex-representation of the given serial.
>>> int_to_hex(12345678)
'BC:61:4E'
"""
s = hex(i)[2:].upper()
if six.PY2 is True and isinstance(i, long): # pragma: only py2 # NOQA
# Strip the "L" suffix, since hex(1L) -> 0x1L.
# NOTE: Do not convert to ... | python | def int_to_hex(i):
"""Create a hex-representation of the given serial.
>>> int_to_hex(12345678)
'BC:61:4E'
"""
s = hex(i)[2:].upper()
if six.PY2 is True and isinstance(i, long): # pragma: only py2 # NOQA
# Strip the "L" suffix, since hex(1L) -> 0x1L.
# NOTE: Do not convert to ... | [
"def",
"int_to_hex",
"(",
"i",
")",
":",
"s",
"=",
"hex",
"(",
"i",
")",
"[",
"2",
":",
"]",
".",
"upper",
"(",
")",
"if",
"six",
".",
"PY2",
"is",
"True",
"and",
"isinstance",
"(",
"i",
",",
"long",
")",
":",
"s",
"=",
"s",
"[",
":",
"-"... | Create a hex-representation of the given serial.
>>> int_to_hex(12345678)
'BC:61:4E' | [
"Create",
"a",
"hex",
"-",
"representation",
"of",
"the",
"given",
"serial",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L211-L222 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | parse_name | def parse_name(name):
"""Parses a subject string as used in OpenSSLs command line utilities.
The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example
``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient
on devi... | python | def parse_name(name):
"""Parses a subject string as used in OpenSSLs command line utilities.
The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example
``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient
on devi... | [
"def",
"parse_name",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"if",
"not",
"name",
":",
"return",
"[",
"]",
"try",
":",
"items",
"=",
"[",
"(",
"NAME_CASE_MAPPINGS",
"[",
"t",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"]... | Parses a subject string as used in OpenSSLs command line utilities.
The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example
``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient
on deviations from the format, objec... | [
"Parses",
"a",
"subject",
"string",
"as",
"used",
"in",
"OpenSSLs",
"command",
"line",
"utilities",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L245-L301 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | parse_general_name | def parse_general_name(name):
"""Parse a general name from user input.
This function will do its best to detect the intended type of any value passed to it:
>>> parse_general_name('example.com')
<DNSName(value='example.com')>
>>> parse_general_name('*.example.com')
<DNSName(value='*.example.co... | python | def parse_general_name(name):
"""Parse a general name from user input.
This function will do its best to detect the intended type of any value passed to it:
>>> parse_general_name('example.com')
<DNSName(value='example.com')>
>>> parse_general_name('*.example.com')
<DNSName(value='*.example.co... | [
"def",
"parse_general_name",
"(",
"name",
")",
":",
"name",
"=",
"force_text",
"(",
"name",
")",
"typ",
"=",
"None",
"match",
"=",
"GENERAL_NAME_RE",
".",
"match",
"(",
"name",
")",
"if",
"match",
"is",
"not",
"None",
":",
"typ",
",",
"name",
"=",
"m... | Parse a general name from user input.
This function will do its best to detect the intended type of any value passed to it:
>>> parse_general_name('example.com')
<DNSName(value='example.com')>
>>> parse_general_name('*.example.com')
<DNSName(value='*.example.com')>
>>> parse_general_name('.exa... | [
"Parse",
"a",
"general",
"name",
"from",
"user",
"input",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L345-L490 | train |
mathiasertl/django-ca | ca/django_ca/utils.py | parse_hash_algorithm | def parse_hash_algorithm(value=None):
"""Parse a hash algorithm value.
The most common use case is to pass a str naming a class in
:py:mod:`~cg:cryptography.hazmat.primitives.hashes`.
For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM
<settings-ca-digest-algorithm... | python | def parse_hash_algorithm(value=None):
"""Parse a hash algorithm value.
The most common use case is to pass a str naming a class in
:py:mod:`~cg:cryptography.hazmat.primitives.hashes`.
For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM
<settings-ca-digest-algorithm... | [
"def",
"parse_hash_algorithm",
"(",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"ca_settings",
".",
"CA_DIGEST_ALGORITHM",
"elif",
"isinstance",
"(",
"value",
",",
"type",
")",
"and",
"issubclass",
"(",
"value",
",",
"hashes",... | Parse a hash algorithm value.
The most common use case is to pass a str naming a class in
:py:mod:`~cg:cryptography.hazmat.primitives.hashes`.
For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM
<settings-ca-digest-algorithm>`, and passing an
:py:class:`~cg:cryptog... | [
"Parse",
"a",
"hash",
"algorithm",
"value",
"."
] | 976d7ea05276320f20daed2a6d59c8f5660fe976 | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L493-L555 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.