hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | mapped_lun | <not_specific> | def mapped_lun(self, mapped_lun, tpg_lun=None, write_protect=None):
'''
Same as MappedLUN() but without the parent_nodeacl parameter.
'''
self._check_self()
return MappedLUN(self, mapped_lun=mapped_lun, tpg_lun=tpg_lun,
write_protect=write_protect) |
Same as MappedLUN() but without the parent_nodeacl parameter.
| Same as MappedLUN() but without the parent_nodeacl parameter. | [
"Same",
"as",
"MappedLUN",
"()",
"but",
"without",
"the",
"parent_nodeacl",
"parameter",
"."
] | def mapped_lun(self, mapped_lun, tpg_lun=None, write_protect=None):
self._check_self()
return MappedLUN(self, mapped_lun=mapped_lun, tpg_lun=tpg_lun,
write_protect=write_protect) | [
"def",
"mapped_lun",
"(",
"self",
",",
"mapped_lun",
",",
"tpg_lun",
"=",
"None",
",",
"write_protect",
"=",
"None",
")",
":",
"self",
".",
"_check_self",
"(",
")",
"return",
"MappedLUN",
"(",
"self",
",",
"mapped_lun",
"=",
"mapped_lun",
",",
"tpg_lun",
... | Same as MappedLUN() but without the parent_nodeacl parameter. | [
"Same",
"as",
"MappedLUN",
"()",
"but",
"without",
"the",
"parent_nodeacl",
"parameter",
"."
] | [
"'''\n Same as MappedLUN() but without the parent_nodeacl parameter.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "mapped_lun",
"type": null
},
{
"param": "tpg_lun",
"type": null
},
{
"param": "write_protect",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mapped_lun",
"type": null,
"docstring": null,
"docstring_toke... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | _get_prop | <not_specific> | def _get_prop(self, prop):
'''
Helper fn to use with partial() to support getting a
property value from the first member of the group.
(All members of the group should be identical.)
'''
return getattr(self._get_first_member(), prop) |
Helper fn to use with partial() to support getting a
property value from the first member of the group.
(All members of the group should be identical.)
| Helper fn to use with partial() to support getting a
property value from the first member of the group.
(All members of the group should be identical.) | [
"Helper",
"fn",
"to",
"use",
"with",
"partial",
"()",
"to",
"support",
"getting",
"a",
"property",
"value",
"from",
"the",
"first",
"member",
"of",
"the",
"group",
".",
"(",
"All",
"members",
"of",
"the",
"group",
"should",
"be",
"identical",
".",
")"
] | def _get_prop(self, prop):
return getattr(self._get_first_member(), prop) | [
"def",
"_get_prop",
"(",
"self",
",",
"prop",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"_get_first_member",
"(",
")",
",",
"prop",
")"
] | Helper fn to use with partial() to support getting a
property value from the first member of the group. | [
"Helper",
"fn",
"to",
"use",
"with",
"partial",
"()",
"to",
"support",
"getting",
"a",
"property",
"value",
"from",
"the",
"first",
"member",
"of",
"the",
"group",
"."
] | [
"'''\n Helper fn to use with partial() to support getting a\n property value from the first member of the group.\n (All members of the group should be identical.)\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "prop",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prop",
"type": null,
"docstring": null,
"docstring_tokens": [... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | _set_prop | null | def _set_prop(self, value, prop):
'''
Helper fn to use with partial() to support setting a
property value in all members of the group.
Caution: Arguments reversed!
This is so partial() can be used on property name.
'''
for mem in self._mem_func(self):
... |
Helper fn to use with partial() to support setting a
property value in all members of the group.
Caution: Arguments reversed!
This is so partial() can be used on property name.
| Helper fn to use with partial() to support setting a
property value in all members of the group.
Arguments reversed.
This is so partial() can be used on property name. | [
"Helper",
"fn",
"to",
"use",
"with",
"partial",
"()",
"to",
"support",
"setting",
"a",
"property",
"value",
"in",
"all",
"members",
"of",
"the",
"group",
".",
"Arguments",
"reversed",
".",
"This",
"is",
"so",
"partial",
"()",
"can",
"be",
"used",
"on",
... | def _set_prop(self, value, prop):
for mem in self._mem_func(self):
setattr(mem, prop, value) | [
"def",
"_set_prop",
"(",
"self",
",",
"value",
",",
"prop",
")",
":",
"for",
"mem",
"in",
"self",
".",
"_mem_func",
"(",
"self",
")",
":",
"setattr",
"(",
"mem",
",",
"prop",
",",
"value",
")"
] | Helper fn to use with partial() to support setting a
property value in all members of the group. | [
"Helper",
"fn",
"to",
"use",
"with",
"partial",
"()",
"to",
"support",
"setting",
"a",
"property",
"value",
"in",
"all",
"members",
"of",
"the",
"group",
"."
] | [
"'''\n Helper fn to use with partial() to support setting a\n property value in all members of the group.\n\n Caution: Arguments reversed!\n This is so partial() can be used on property name.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "prop",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | delete | null | def delete(self):
'''
Delete all members of the group.
'''
for mem in self._mem_func(self):
mem.delete() |
Delete all members of the group.
| Delete all members of the group. | [
"Delete",
"all",
"members",
"of",
"the",
"group",
"."
] | def delete(self):
for mem in self._mem_func(self):
mem.delete() | [
"def",
"delete",
"(",
"self",
")",
":",
"for",
"mem",
"in",
"self",
".",
"_mem_func",
"(",
"self",
")",
":",
"mem",
".",
"delete",
"(",
")"
] | Delete all members of the group. | [
"Delete",
"all",
"members",
"of",
"the",
"group",
"."
] | [
"'''\n Delete all members of the group.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | parent_tpg | <not_specific> | def parent_tpg(self):
'''
Get the parent TPG object.
'''
return self._parent_tpg |
Get the parent TPG object.
| Get the parent TPG object. | [
"Get",
"the",
"parent",
"TPG",
"object",
"."
] | def parent_tpg(self):
return self._parent_tpg | [
"def",
"parent_tpg",
"(",
"self",
")",
":",
"return",
"self",
".",
"_parent_tpg"
] | Get the parent TPG object. | [
"Get",
"the",
"parent",
"TPG",
"object",
"."
] | [
"'''\n Get the parent TPG object.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | add_acl | <not_specific> | def add_acl(self, node_wwn):
'''
Add a WWN to the NodeACLGroup. If a NodeACL already exists for this WWN,
its configuration will be changed to match the NodeACLGroup, except for its
auth parameters, which can vary among group members.
@param node_wwn: An initiator WWN
@ty... |
Add a WWN to the NodeACLGroup. If a NodeACL already exists for this WWN,
its configuration will be changed to match the NodeACLGroup, except for its
auth parameters, which can vary among group members.
@param node_wwn: An initiator WWN
@type node_wwn: string
| Add a WWN to the NodeACLGroup. If a NodeACL already exists for this WWN,
its configuration will be changed to match the NodeACLGroup, except for its
auth parameters, which can vary among group members. | [
"Add",
"a",
"WWN",
"to",
"the",
"NodeACLGroup",
".",
"If",
"a",
"NodeACL",
"already",
"exists",
"for",
"this",
"WWN",
"its",
"configuration",
"will",
"be",
"changed",
"to",
"match",
"the",
"NodeACLGroup",
"except",
"for",
"its",
"auth",
"parameters",
"which"... | def add_acl(self, node_wwn):
nacl = NodeACL(self.parent_tpg, node_wwn)
if nacl in self._node_acls:
return
try:
model = next(self._node_acls)
except StopIteration:
pass
else:
for mlun in nacl.mapped_luns:
mlun.delete(... | [
"def",
"add_acl",
"(",
"self",
",",
"node_wwn",
")",
":",
"nacl",
"=",
"NodeACL",
"(",
"self",
".",
"parent_tpg",
",",
"node_wwn",
")",
"if",
"nacl",
"in",
"self",
".",
"_node_acls",
":",
"return",
"try",
":",
"model",
"=",
"next",
"(",
"self",
".",
... | Add a WWN to the NodeACLGroup. | [
"Add",
"a",
"WWN",
"to",
"the",
"NodeACLGroup",
"."
] | [
"'''\n Add a WWN to the NodeACLGroup. If a NodeACL already exists for this WWN,\n its configuration will be changed to match the NodeACLGroup, except for its\n auth parameters, which can vary among group members.\n @param node_wwn: An initiator WWN\n @type node_wwn: string\n ... | [
{
"param": "self",
"type": null
},
{
"param": "node_wwn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node_wwn",
"type": null,
"docstring": "An initiator WWN",
"do... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | remove_acl | null | def remove_acl(self, node_wwn):
'''
Remove a WWN from the NodeACLGroup.
@param node_wwn: An initiator WWN
@type node_wwn: string
'''
nacl = NodeACL(self.parent_tpg, node_wwn, mode='lookup')
nacl.delete() |
Remove a WWN from the NodeACLGroup.
@param node_wwn: An initiator WWN
@type node_wwn: string
| Remove a WWN from the NodeACLGroup. | [
"Remove",
"a",
"WWN",
"from",
"the",
"NodeACLGroup",
"."
] | def remove_acl(self, node_wwn):
nacl = NodeACL(self.parent_tpg, node_wwn, mode='lookup')
nacl.delete() | [
"def",
"remove_acl",
"(",
"self",
",",
"node_wwn",
")",
":",
"nacl",
"=",
"NodeACL",
"(",
"self",
".",
"parent_tpg",
",",
"node_wwn",
",",
"mode",
"=",
"'lookup'",
")",
"nacl",
".",
"delete",
"(",
")"
] | Remove a WWN from the NodeACLGroup. | [
"Remove",
"a",
"WWN",
"from",
"the",
"NodeACLGroup",
"."
] | [
"'''\n Remove a WWN from the NodeACLGroup.\n @param node_wwn: An initiator WWN\n @type node_wwn: string\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "node_wwn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node_wwn",
"type": null,
"docstring": "An initiator WWN",
"do... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | _node_acls | null | def _node_acls(self):
'''
Gives access to the underlying NodeACLs within this group.
'''
for na in self.parent_tpg.node_acls:
if na.tag == self.name:
yield na |
Gives access to the underlying NodeACLs within this group.
| Gives access to the underlying NodeACLs within this group. | [
"Gives",
"access",
"to",
"the",
"underlying",
"NodeACLs",
"within",
"this",
"group",
"."
] | def _node_acls(self):
for na in self.parent_tpg.node_acls:
if na.tag == self.name:
yield na | [
"def",
"_node_acls",
"(",
"self",
")",
":",
"for",
"na",
"in",
"self",
".",
"parent_tpg",
".",
"node_acls",
":",
"if",
"na",
".",
"tag",
"==",
"self",
".",
"name",
":",
"yield",
"na"
] | Gives access to the underlying NodeACLs within this group. | [
"Gives",
"access",
"to",
"the",
"underlying",
"NodeACLs",
"within",
"this",
"group",
"."
] | [
"'''\n Gives access to the underlying NodeACLs within this group.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | wwns | <not_specific> | def wwns(self):
'''
Give the Node WWNs of members of this group.
'''
return (na.node_wwn for na in self._node_acls) |
Give the Node WWNs of members of this group.
| Give the Node WWNs of members of this group. | [
"Give",
"the",
"Node",
"WWNs",
"of",
"members",
"of",
"this",
"group",
"."
] | def wwns(self):
return (na.node_wwn for na in self._node_acls) | [
"def",
"wwns",
"(",
"self",
")",
":",
"return",
"(",
"na",
".",
"node_wwn",
"for",
"na",
"in",
"self",
".",
"_node_acls",
")"
] | Give the Node WWNs of members of this group. | [
"Give",
"the",
"Node",
"WWNs",
"of",
"members",
"of",
"this",
"group",
"."
] | [
"'''\n Give the Node WWNs of members of this group.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | has_feature | <not_specific> | def has_feature(self, feature):
'''
Whether or not this NodeACL has a certain feature.
'''
return self._parent_tpg.has_feature(feature) |
Whether or not this NodeACL has a certain feature.
| Whether or not this NodeACL has a certain feature. | [
"Whether",
"or",
"not",
"this",
"NodeACL",
"has",
"a",
"certain",
"feature",
"."
] | def has_feature(self, feature):
return self._parent_tpg.has_feature(feature) | [
"def",
"has_feature",
"(",
"self",
",",
"feature",
")",
":",
"return",
"self",
".",
"_parent_tpg",
".",
"has_feature",
"(",
"feature",
")"
] | Whether or not this NodeACL has a certain feature. | [
"Whether",
"or",
"not",
"this",
"NodeACL",
"has",
"a",
"certain",
"feature",
"."
] | [
"'''\n Whether or not this NodeACL has a certain feature.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "feature",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature",
"type": null,
"docstring": null,
"docstring_tokens"... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | mapped_lun_group | <not_specific> | def mapped_lun_group(self, mapped_lun, tpg_lun=None, write_protect=None):
'''
Add a mapped lun to all group members.
'''
return MappedLUNGroup(self, mapped_lun=mapped_lun, tpg_lun=tpg_lun,
write_protect=write_protect) |
Add a mapped lun to all group members.
| Add a mapped lun to all group members. | [
"Add",
"a",
"mapped",
"lun",
"to",
"all",
"group",
"members",
"."
] | def mapped_lun_group(self, mapped_lun, tpg_lun=None, write_protect=None):
return MappedLUNGroup(self, mapped_lun=mapped_lun, tpg_lun=tpg_lun,
write_protect=write_protect) | [
"def",
"mapped_lun_group",
"(",
"self",
",",
"mapped_lun",
",",
"tpg_lun",
"=",
"None",
",",
"write_protect",
"=",
"None",
")",
":",
"return",
"MappedLUNGroup",
"(",
"self",
",",
"mapped_lun",
"=",
"mapped_lun",
",",
"tpg_lun",
"=",
"tpg_lun",
",",
"write_pr... | Add a mapped lun to all group members. | [
"Add",
"a",
"mapped",
"lun",
"to",
"all",
"group",
"members",
"."
] | [
"'''\n Add a mapped lun to all group members.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "mapped_lun",
"type": null
},
{
"param": "tpg_lun",
"type": null
},
{
"param": "write_protect",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mapped_lun",
"type": null,
"docstring": null,
"docstring_toke... |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | mapped_lun_groups | <not_specific> | def mapped_lun_groups(self):
'''
Generates all MappedLUNGroup objects in this NodeACLGroup.
'''
try:
first = self._get_first_member()
except IndexError:
return
for mlun in first.mapped_luns:
yield MappedLUNGroup(self, mlun.mapped_lun) |
Generates all MappedLUNGroup objects in this NodeACLGroup.
| Generates all MappedLUNGroup objects in this NodeACLGroup. | [
"Generates",
"all",
"MappedLUNGroup",
"objects",
"in",
"this",
"NodeACLGroup",
"."
] | def mapped_lun_groups(self):
try:
first = self._get_first_member()
except IndexError:
return
for mlun in first.mapped_luns:
yield MappedLUNGroup(self, mlun.mapped_lun) | [
"def",
"mapped_lun_groups",
"(",
"self",
")",
":",
"try",
":",
"first",
"=",
"self",
".",
"_get_first_member",
"(",
")",
"except",
"IndexError",
":",
"return",
"for",
"mlun",
"in",
"first",
".",
"mapped_luns",
":",
"yield",
"MappedLUNGroup",
"(",
"self",
"... | Generates all MappedLUNGroup objects in this NodeACLGroup. | [
"Generates",
"all",
"MappedLUNGroup",
"objects",
"in",
"this",
"NodeACLGroup",
"."
] | [
"'''\n Generates all MappedLUNGroup objects in this NodeACLGroup.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1477197f2018e9254d3a3e0a340127df00742767 | bostroesser/rtslib-fb | rtslib/target.py | [
"Apache-2.0"
] | Python | parent_nodeaclgroup | <not_specific> | def parent_nodeaclgroup(self):
'''
Get the parent NodeACLGroup object.
'''
return self._nag |
Get the parent NodeACLGroup object.
| Get the parent NodeACLGroup object. | [
"Get",
"the",
"parent",
"NodeACLGroup",
"object",
"."
] | def parent_nodeaclgroup(self):
return self._nag | [
"def",
"parent_nodeaclgroup",
"(",
"self",
")",
":",
"return",
"self",
".",
"_nag"
] | Get the parent NodeACLGroup object. | [
"Get",
"the",
"parent",
"NodeACLGroup",
"object",
"."
] | [
"'''\n Get the parent NodeACLGroup object.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | fwrite | null | def fwrite(path, string):
'''
This function writes a string to a file, and takes care of
opening it and closing it. If the file does not exist, it
will be created.
>>> from rtslib.utils import *
>>> fwrite("/tmp/test", "hello")
>>> fread("/tmp/test")
'hello'
@param path: The file t... |
This function writes a string to a file, and takes care of
opening it and closing it. If the file does not exist, it
will be created.
>>> from rtslib.utils import *
>>> fwrite("/tmp/test", "hello")
>>> fread("/tmp/test")
'hello'
@param path: The file to write to.
@type path: strin... | This function writes a string to a file, and takes care of
opening it and closing it. If the file does not exist, it
will be created.
| [
"This",
"function",
"writes",
"a",
"string",
"to",
"a",
"file",
"and",
"takes",
"care",
"of",
"opening",
"it",
"and",
"closing",
"it",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"."
] | def fwrite(path, string):
with open(path, 'w') as file_fd:
file_fd.write(str(string)) | [
"def",
"fwrite",
"(",
"path",
",",
"string",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"file_fd",
":",
"file_fd",
".",
"write",
"(",
"str",
"(",
"string",
")",
")"
] | This function writes a string to a file, and takes care of
opening it and closing it. | [
"This",
"function",
"writes",
"a",
"string",
"to",
"a",
"file",
"and",
"takes",
"care",
"of",
"opening",
"it",
"and",
"closing",
"it",
"."
] | [
"'''\n This function writes a string to a file, and takes care of\n opening it and closing it. If the file does not exist, it\n will be created.\n\n >>> from rtslib.utils import *\n >>> fwrite(\"/tmp/test\", \"hello\")\n >>> fread(\"/tmp/test\")\n 'hello'\n\n @param path: The file to write t... | [
{
"param": "path",
"type": null
},
{
"param": "string",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "The file to write to.",
"docstring_tokens": [
"The",
"file",
"to",
"write",
"to",
"."
],
"default": null,
"is_optional": fals... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | fread | <not_specific> | def fread(path):
'''
This function reads the contents of a file.
It takes care of opening and closing it.
>>> from rtslib.utils import *
>>> fwrite("/tmp/test", "hello")
>>> fread("/tmp/test")
'hello'
>>> fread("/tmp/notexistingfile") # doctest: +ELLIPSIS
Traceback (most recent call... |
This function reads the contents of a file.
It takes care of opening and closing it.
>>> from rtslib.utils import *
>>> fwrite("/tmp/test", "hello")
>>> fread("/tmp/test")
'hello'
>>> fread("/tmp/notexistingfile") # doctest: +ELLIPSIS
Traceback (most recent call last):
...
... | This function reads the contents of a file.
It takes care of opening and closing it.
| [
"This",
"function",
"reads",
"the",
"contents",
"of",
"a",
"file",
".",
"It",
"takes",
"care",
"of",
"opening",
"and",
"closing",
"it",
"."
] | def fread(path):
with open(path, 'r') as file_fd:
return file_fd.read().strip() | [
"def",
"fread",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"file_fd",
":",
"return",
"file_fd",
".",
"read",
"(",
")",
".",
"strip",
"(",
")"
] | This function reads the contents of a file. | [
"This",
"function",
"reads",
"the",
"contents",
"of",
"a",
"file",
"."
] | [
"'''\n This function reads the contents of a file.\n It takes care of opening and closing it.\n\n >>> from rtslib.utils import *\n >>> fwrite(\"/tmp/test\", \"hello\")\n >>> fread(\"/tmp/test\")\n 'hello'\n >>> fread(\"/tmp/notexistingfile\") # doctest: +ELLIPSIS\n Traceback (most recent cal... | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "A string containing the file's contents.",
"docstring_tokens": [
"A",
"string",
"containing",
"the",
"file",
"'",
"s",
"contents",
"."
],
"type": null
}
],
"raises": [],
"params... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | is_dev_in_use | <not_specific> | def is_dev_in_use(path):
'''
This function will check if the device or file referenced by path is
already mounted or used as a storage object backend. It works by trying to
open the path with O_EXCL flag, which will fail if someone else already
did. Note that the file is closed before the function... |
This function will check if the device or file referenced by path is
already mounted or used as a storage object backend. It works by trying to
open the path with O_EXCL flag, which will fail if someone else already
did. Note that the file is closed before the function returns, so this
does not g... | This function will check if the device or file referenced by path is
already mounted or used as a storage object backend. It works by trying to
open the path with O_EXCL flag, which will fail if someone else already
did. Note that the file is closed before the function returns, so this
does not guaranteed the device ... | [
"This",
"function",
"will",
"check",
"if",
"the",
"device",
"or",
"file",
"referenced",
"by",
"path",
"is",
"already",
"mounted",
"or",
"used",
"as",
"a",
"storage",
"object",
"backend",
".",
"It",
"works",
"by",
"trying",
"to",
"open",
"the",
"path",
"w... | def is_dev_in_use(path):
path = os.path.realpath(str(path))
try:
device = pyudev.Device.from_device_file(_CONTEXT, path)
if device.subsystem == u'scsi_generic':
file_fd = os.open(path, os.O_EXCL|os.O_NDELAY|os.O_RDWR)
else:
file_fd = os.open(path, os.O_EXCL|os.O_N... | [
"def",
"is_dev_in_use",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"str",
"(",
"path",
")",
")",
"try",
":",
"device",
"=",
"pyudev",
".",
"Device",
".",
"from_device_file",
"(",
"_CONTEXT",
",",
"path",
")",
"if",
... | This function will check if the device or file referenced by path is
already mounted or used as a storage object backend. | [
"This",
"function",
"will",
"check",
"if",
"the",
"device",
"or",
"file",
"referenced",
"by",
"path",
"is",
"already",
"mounted",
"or",
"used",
"as",
"a",
"storage",
"object",
"backend",
"."
] | [
"'''\n This function will check if the device or file referenced by path is\n already mounted or used as a storage object backend. It works by trying to\n open the path with O_EXCL flag, which will fail if someone else already\n did. Note that the file is closed before the function returns, so this\n ... | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "A boolean, True is we cannot get exclusive descriptor on the path,\nFalse if we can.",
"docstring_tokens": [
"A",
"boolean",
"True",
"is",
"we",
"cannot",
"get",
"exclusive",
"descriptor",
"o... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | convert_scsi_path_to_hctl | <not_specific> | def convert_scsi_path_to_hctl(path):
'''
This function returns the SCSI ID in H:C:T:L form for the block
device being mapped to the udev path specified.
If no match is found, None is returned.
>>> import rtslib.utils as utils
>>> utils.convert_scsi_path_to_hctl('/dev/scd0')
(2, 0, 0, 0)
... |
This function returns the SCSI ID in H:C:T:L form for the block
device being mapped to the udev path specified.
If no match is found, None is returned.
>>> import rtslib.utils as utils
>>> utils.convert_scsi_path_to_hctl('/dev/scd0')
(2, 0, 0, 0)
>>> utils.convert_scsi_path_to_hctl('/dev/s... | This function returns the SCSI ID in H:C:T:L form for the block
device being mapped to the udev path specified.
If no match is found, None is returned.
| [
"This",
"function",
"returns",
"the",
"SCSI",
"ID",
"in",
"H",
":",
"C",
":",
"T",
":",
"L",
"form",
"for",
"the",
"block",
"device",
"being",
"mapped",
"to",
"the",
"udev",
"path",
"specified",
".",
"If",
"no",
"match",
"is",
"found",
"None",
"is",
... | def convert_scsi_path_to_hctl(path):
try:
path = os.path.realpath(path)
device = pyudev.Device.from_device_file(_CONTEXT, path)
parent = device.find_parent(subsystem='scsi')
return [int(data) for data in parent.sys_name.split(':')]
except:
raise RTSLibError("Could not con... | [
"def",
"convert_scsi_path_to_hctl",
"(",
"path",
")",
":",
"try",
":",
"path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"path",
")",
"device",
"=",
"pyudev",
".",
"Device",
".",
"from_device_file",
"(",
"_CONTEXT",
",",
"path",
")",
"parent",
"=",
... | This function returns the SCSI ID in H:C:T:L form for the block
device being mapped to the udev path specified. | [
"This",
"function",
"returns",
"the",
"SCSI",
"ID",
"in",
"H",
":",
"C",
":",
"T",
":",
"L",
"form",
"for",
"the",
"block",
"device",
"being",
"mapped",
"to",
"the",
"udev",
"path",
"specified",
"."
] | [
"'''\n This function returns the SCSI ID in H:C:T:L form for the block\n device being mapped to the udev path specified.\n If no match is found, None is returned.\n\n >>> import rtslib.utils as utils\n >>> utils.convert_scsi_path_to_hctl('/dev/scd0')\n (2, 0, 0, 0)\n >>> utils.convert_scsi_path... | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "An (host, controller, target, lun) tuple of integer\nvalues representing the SCSI ID of the device, or raise RTSLibError.",
"docstring_tokens": [
"An",
"(",
"host",
"controller",
"target",
"lun",
")",
"tuple... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | convert_scsi_hctl_to_path | <not_specific> | def convert_scsi_hctl_to_path(host, controller, target, lun):
'''
This function returns a udev path pointing to the block device being
mapped to the SCSI device that has the provided H:C:T:L.
>>> import rtslib.utils as utils
>>> utils.convert_scsi_hctl_to_path(0,0,0,0)
''
>>> utils.convert_... |
This function returns a udev path pointing to the block device being
mapped to the SCSI device that has the provided H:C:T:L.
>>> import rtslib.utils as utils
>>> utils.convert_scsi_hctl_to_path(0,0,0,0)
''
>>> utils.convert_scsi_hctl_to_path(2,0,0,0) # doctest: +ELLIPSIS
'/dev/s...0'
... | This function returns a udev path pointing to the block device being
mapped to the SCSI device that has the provided H:C:T:L.
| [
"This",
"function",
"returns",
"a",
"udev",
"path",
"pointing",
"to",
"the",
"block",
"device",
"being",
"mapped",
"to",
"the",
"SCSI",
"device",
"that",
"has",
"the",
"provided",
"H",
":",
"C",
":",
"T",
":",
"L",
"."
] | def convert_scsi_hctl_to_path(host, controller, target, lun):
try:
host = int(host)
controller = int(controller)
target = int(target)
lun = int(lun)
except ValueError:
raise RTSLibError(
"The host, controller, target and lun parameter must be integers")
hc... | [
"def",
"convert_scsi_hctl_to_path",
"(",
"host",
",",
"controller",
",",
"target",
",",
"lun",
")",
":",
"try",
":",
"host",
"=",
"int",
"(",
"host",
")",
"controller",
"=",
"int",
"(",
"controller",
")",
"target",
"=",
"int",
"(",
"target",
")",
"lun"... | This function returns a udev path pointing to the block device being
mapped to the SCSI device that has the provided H:C:T:L. | [
"This",
"function",
"returns",
"a",
"udev",
"path",
"pointing",
"to",
"the",
"block",
"device",
"being",
"mapped",
"to",
"the",
"SCSI",
"device",
"that",
"has",
"the",
"provided",
"H",
":",
"C",
":",
"T",
":",
"L",
"."
] | [
"'''\n This function returns a udev path pointing to the block device being\n mapped to the SCSI device that has the provided H:C:T:L.\n\n >>> import rtslib.utils as utils\n >>> utils.convert_scsi_hctl_to_path(0,0,0,0)\n ''\n >>> utils.convert_scsi_hctl_to_path(2,0,0,0) # doctest: +ELLIPSIS\n '... | [
{
"param": "host",
"type": null
},
{
"param": "controller",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "lun",
"type": null
}
] | {
"returns": [
{
"docstring": "A string for the canonical path to the device, or raise RTSLibError.",
"docstring_tokens": [
"A",
"string",
"for",
"the",
"canonical",
"path",
"to",
"the",
"device",
"or",
"raise",
... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | generate_wwn | <not_specific> | def generate_wwn(wwn_type):
'''
Generates a random WWN of the specified type:
- unit_serial: T10 WWN Unit Serial.
- iqn: iSCSI IQN
- naa: SAS NAA address
@param wwn_type: The WWN address type.
@type wwn_type: str
@returns: A string containing the WWN.
'''
wwn_type = w... |
Generates a random WWN of the specified type:
- unit_serial: T10 WWN Unit Serial.
- iqn: iSCSI IQN
- naa: SAS NAA address
@param wwn_type: The WWN address type.
@type wwn_type: str
@returns: A string containing the WWN.
| Generates a random WWN of the specified type:
unit_serial: T10 WWN Unit Serial.
iqn: iSCSI IQN
naa: SAS NAA address | [
"Generates",
"a",
"random",
"WWN",
"of",
"the",
"specified",
"type",
":",
"unit_serial",
":",
"T10",
"WWN",
"Unit",
"Serial",
".",
"iqn",
":",
"iSCSI",
"IQN",
"naa",
":",
"SAS",
"NAA",
"address"
] | def generate_wwn(wwn_type):
wwn_type = wwn_type.lower()
if wwn_type == 'free':
return str(uuid.uuid4())
if wwn_type == 'unit_serial':
return str(uuid.uuid4())
elif wwn_type == 'iqn':
localname = socket.gethostname().split(".")[0].replace("_", "")
localarch = os.uname()[4]... | [
"def",
"generate_wwn",
"(",
"wwn_type",
")",
":",
"wwn_type",
"=",
"wwn_type",
".",
"lower",
"(",
")",
"if",
"wwn_type",
"==",
"'free'",
":",
"return",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"if",
"wwn_type",
"==",
"'unit_serial'",
":",
"retu... | Generates a random WWN of the specified type:
unit_serial: T10 WWN Unit Serial. | [
"Generates",
"a",
"random",
"WWN",
"of",
"the",
"specified",
"type",
":",
"unit_serial",
":",
"T10",
"WWN",
"Unit",
"Serial",
"."
] | [
"'''\n Generates a random WWN of the specified type:\n - unit_serial: T10 WWN Unit Serial.\n - iqn: iSCSI IQN\n - naa: SAS NAA address\n @param wwn_type: The WWN address type.\n @type wwn_type: str\n @returns: A string containing the WWN.\n '''",
"# see http://standards.ieee.or... | [
{
"param": "wwn_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wwn_type",
"type": null,
"docstring": "The WWN address type.",
"docstring_tokens": [
"The",
"WWN",
"address",
"type",
"."
],
"default": null,
"is_optional": false
}... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | colonize | <not_specific> | def colonize(str):
'''
helper function to add colons every 2 chars
'''
return ":".join(str[i:i+2] for i in range(0, len(str), 2)) |
helper function to add colons every 2 chars
| helper function to add colons every 2 chars | [
"helper",
"function",
"to",
"add",
"colons",
"every",
"2",
"chars"
] | def colonize(str):
return ":".join(str[i:i+2] for i in range(0, len(str), 2)) | [
"def",
"colonize",
"(",
"str",
")",
":",
"return",
"\":\"",
".",
"join",
"(",
"str",
"[",
"i",
":",
"i",
"+",
"2",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"str",
")",
",",
"2",
")",
")"
] | helper function to add colons every 2 chars | [
"helper",
"function",
"to",
"add",
"colons",
"every",
"2",
"chars"
] | [
"'''\n helper function to add colons every 2 chars\n '''"
] | [
{
"param": "str",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "str",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | _cleanse_wwn | <not_specific> | def _cleanse_wwn(wwn_type, wwn):
'''
Some wwns may have alternate text representations. Adjust to our
preferred representation.
'''
wwn = str(wwn.strip()).lower()
if wwn_type in ('naa', 'eui', 'ib'):
if wwn.startswith("0x"):
wwn = wwn[2:]
wwn = wwn.replace("-", "")
... |
Some wwns may have alternate text representations. Adjust to our
preferred representation.
| Some wwns may have alternate text representations. Adjust to our
preferred representation. | [
"Some",
"wwns",
"may",
"have",
"alternate",
"text",
"representations",
".",
"Adjust",
"to",
"our",
"preferred",
"representation",
"."
] | def _cleanse_wwn(wwn_type, wwn):
wwn = str(wwn.strip()).lower()
if wwn_type in ('naa', 'eui', 'ib'):
if wwn.startswith("0x"):
wwn = wwn[2:]
wwn = wwn.replace("-", "")
wwn = wwn.replace(":", "")
if not (wwn.startswith("naa.") or wwn.startswith("eui.") or \
... | [
"def",
"_cleanse_wwn",
"(",
"wwn_type",
",",
"wwn",
")",
":",
"wwn",
"=",
"str",
"(",
"wwn",
".",
"strip",
"(",
")",
")",
".",
"lower",
"(",
")",
"if",
"wwn_type",
"in",
"(",
"'naa'",
",",
"'eui'",
",",
"'ib'",
")",
":",
"if",
"wwn",
".",
"star... | Some wwns may have alternate text representations. | [
"Some",
"wwns",
"may",
"have",
"alternate",
"text",
"representations",
"."
] | [
"'''\n Some wwns may have alternate text representations. Adjust to our\n preferred representation.\n '''"
] | [
{
"param": "wwn_type",
"type": null
},
{
"param": "wwn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wwn_type",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "wwn",
"type": null,
"docstring": null,
"docstring_tokens"... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | normalize_wwn | <not_specific> | def normalize_wwn(wwn_types, wwn):
'''
Take a WWN as given by the user and convert it to a standard text
representation.
Returns (normalized_wwn, wwn_type), or exception if invalid wwn.
'''
wwn_test = {
'free': lambda wwn: True,
'iqn': lambda wwn: \
re.match(r"iqn\.[0-9]{4}-[0-1... |
Take a WWN as given by the user and convert it to a standard text
representation.
Returns (normalized_wwn, wwn_type), or exception if invalid wwn.
| Take a WWN as given by the user and convert it to a standard text
representation.
Returns (normalized_wwn, wwn_type), or exception if invalid wwn. | [
"Take",
"a",
"WWN",
"as",
"given",
"by",
"the",
"user",
"and",
"convert",
"it",
"to",
"a",
"standard",
"text",
"representation",
".",
"Returns",
"(",
"normalized_wwn",
"wwn_type",
")",
"or",
"exception",
"if",
"invalid",
"wwn",
"."
] | def normalize_wwn(wwn_types, wwn):
wwn_test = {
'free': lambda wwn: True,
'iqn': lambda wwn: \
re.match(r"iqn\.[0-9]{4}-[0-1][0-9]\..*\..*", wwn) \
and not re.search(' ', wwn) \
and not re.search('_', wwn),
'naa': lambda wwn: re.match(r"naa\.[125][0-9a-fA-F]{15}$", wwn),
'eui... | [
"def",
"normalize_wwn",
"(",
"wwn_types",
",",
"wwn",
")",
":",
"wwn_test",
"=",
"{",
"'free'",
":",
"lambda",
"wwn",
":",
"True",
",",
"'iqn'",
":",
"lambda",
"wwn",
":",
"re",
".",
"match",
"(",
"r\"iqn\\.[0-9]{4}-[0-1][0-9]\\..*\\..*\"",
",",
"wwn",
")"... | Take a WWN as given by the user and convert it to a standard text
representation. | [
"Take",
"a",
"WWN",
"as",
"given",
"by",
"the",
"user",
"and",
"convert",
"it",
"to",
"a",
"standard",
"text",
"representation",
"."
] | [
"'''\n Take a WWN as given by the user and convert it to a standard text\n representation.\n\n Returns (normalized_wwn, wwn_type), or exception if invalid wwn.\n '''"
] | [
{
"param": "wwn_types",
"type": null
},
{
"param": "wwn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wwn_types",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "wwn",
"type": null,
"docstring": null,
"docstring_tokens... |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | list_loaded_kernel_modules | <not_specific> | def list_loaded_kernel_modules():
'''
List all currently loaded kernel modules
'''
return [line.split(" ")[0] for line in
fread("/proc/modules").split('\n') if line] |
List all currently loaded kernel modules
| List all currently loaded kernel modules | [
"List",
"all",
"currently",
"loaded",
"kernel",
"modules"
] | def list_loaded_kernel_modules():
return [line.split(" ")[0] for line in
fread("/proc/modules").split('\n') if line] | [
"def",
"list_loaded_kernel_modules",
"(",
")",
":",
"return",
"[",
"line",
".",
"split",
"(",
"\" \"",
")",
"[",
"0",
"]",
"for",
"line",
"in",
"fread",
"(",
"\"/proc/modules\"",
")",
".",
"split",
"(",
"'\\n'",
")",
"if",
"line",
"]"
] | List all currently loaded kernel modules | [
"List",
"all",
"currently",
"loaded",
"kernel",
"modules"
] | [
"'''\n List all currently loaded kernel modules\n '''"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b460e4ab9ed9e8a04e4d29d360ef9b383c55f241 | bostroesser/rtslib-fb | rtslib/utils.py | [
"Apache-2.0"
] | Python | modprobe | <not_specific> | def modprobe(module):
'''
Load the specified kernel module if needed.
@param module: The name of the kernel module to be loaded.
@type module: str
'''
if module in list_loaded_kernel_modules():
return
try:
import kmod
except ImportError:
process = subprocess.Pope... |
Load the specified kernel module if needed.
@param module: The name of the kernel module to be loaded.
@type module: str
| Load the specified kernel module if needed. | [
"Load",
"the",
"specified",
"kernel",
"module",
"if",
"needed",
"."
] | def modprobe(module):
if module in list_loaded_kernel_modules():
return
try:
import kmod
except ImportError:
process = subprocess.Popen(("modprobe", module),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
... | [
"def",
"modprobe",
"(",
"module",
")",
":",
"if",
"module",
"in",
"list_loaded_kernel_modules",
"(",
")",
":",
"return",
"try",
":",
"import",
"kmod",
"except",
"ImportError",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"(",
"\"modprobe\"",
",",
... | Load the specified kernel module if needed. | [
"Load",
"the",
"specified",
"kernel",
"module",
"if",
"needed",
"."
] | [
"'''\n Load the specified kernel module if needed.\n @param module: The name of the kernel module to be loaded.\n @type module: str\n '''"
] | [
{
"param": "module",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "module",
"type": null,
"docstring": "The name of the kernel module to be loaded.",
"docstring_tokens": [
"The",
"name",
"of",
"the",
"kernel",
"module",
"to",
"be... |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _read_raw | <not_specific> | def _read_raw(raw_path, electrode=None, hsp=None, hpi=None,
allow_maxshield=False, config_path=None, **kwargs):
"""Read a raw file into MNE, making inferences based on extension."""
_, ext = _parse_ext(raw_path)
# KIT systems
if ext in ['.con', '.sqd']:
raw = io.read_raw_kit(raw_p... | Read a raw file into MNE, making inferences based on extension. | Read a raw file into MNE, making inferences based on extension. | [
"Read",
"a",
"raw",
"file",
"into",
"MNE",
"making",
"inferences",
"based",
"on",
"extension",
"."
] | def _read_raw(raw_path, electrode=None, hsp=None, hpi=None,
allow_maxshield=False, config_path=None, **kwargs):
_, ext = _parse_ext(raw_path)
if ext in ['.con', '.sqd']:
raw = io.read_raw_kit(raw_path, elp=electrode, hsp=hsp,
mrk=hpi, preload=False, **kwargs)
... | [
"def",
"_read_raw",
"(",
"raw_path",
",",
"electrode",
"=",
"None",
",",
"hsp",
"=",
"None",
",",
"hpi",
"=",
"None",
",",
"allow_maxshield",
"=",
"False",
",",
"config_path",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"_",
",",
"ext",
"=",
"_parse_... | Read a raw file into MNE, making inferences based on extension. | [
"Read",
"a",
"raw",
"file",
"into",
"MNE",
"making",
"inferences",
"based",
"on",
"extension",
"."
] | [
"\"\"\"Read a raw file into MNE, making inferences based on extension.\"\"\"",
"# KIT systems",
"# BTi systems",
"# FIXME MNE should accept Path!",
"# FIXME MNE should accept Path!",
"# MEF and NWB are allowed, but not yet implemented",
"# No supported data found ...",
"# ---------------------------"
... | [
{
"param": "raw_path",
"type": null
},
{
"param": "electrode",
"type": null
},
{
"param": "hsp",
"type": null
},
{
"param": "hpi",
"type": null
},
{
"param": "allow_maxshield",
"type": null
},
{
"param": "config_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "electrode",
"type": null,
"docstring": null,
"docstring_t... |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _handle_scans_reading | <not_specific> | def _handle_scans_reading(scans_fname, raw, bids_path):
"""Read associated scans.tsv and set meas_date."""
scans_tsv = _from_tsv(scans_fname)
fname = bids_path.fpath.name
if fname.endswith('.pdf'):
# for BTI files, the scan is an entire directory
fname = fname.split('.')[0]
# get t... | Read associated scans.tsv and set meas_date. | Read associated scans.tsv and set meas_date. | [
"Read",
"associated",
"scans",
".",
"tsv",
"and",
"set",
"meas_date",
"."
] | def _handle_scans_reading(scans_fname, raw, bids_path):
scans_tsv = _from_tsv(scans_fname)
fname = bids_path.fpath.name
if fname.endswith('.pdf'):
fname = fname.split('.')[0]
data_fname = bids_path.datatype + '/' + fname
fnames = scans_tsv['filename']
if 'acq_time' in scans_tsv:
... | [
"def",
"_handle_scans_reading",
"(",
"scans_fname",
",",
"raw",
",",
"bids_path",
")",
":",
"scans_tsv",
"=",
"_from_tsv",
"(",
"scans_fname",
")",
"fname",
"=",
"bids_path",
".",
"fpath",
".",
"name",
"if",
"fname",
".",
"endswith",
"(",
"'.pdf'",
")",
":... | Read associated scans.tsv and set meas_date. | [
"Read",
"associated",
"scans",
".",
"tsv",
"and",
"set",
"meas_date",
"."
] | [
"\"\"\"Read associated scans.tsv and set meas_date.\"\"\"",
"# for BTI files, the scan is an entire directory",
"# get the row corresponding to the file",
"# use string concatenation instead of os.path",
"# to work nicely with windows",
"# check whether all split files have the same acq_time",
"# and th... | [
{
"param": "scans_fname",
"type": null
},
{
"param": "raw",
"type": null
},
{
"param": "bids_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scans_fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_toke... |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _handle_info_reading | <not_specific> | def _handle_info_reading(sidecar_fname, raw):
"""Read associated sidecar JSON and populate raw.
Handle PowerLineFrequency of recording.
"""
with open(sidecar_fname, 'r', encoding='utf-8-sig') as fin:
sidecar_json = json.load(fin)
# read in the sidecar JSON's and raw object's line frequency... | Read associated sidecar JSON and populate raw.
Handle PowerLineFrequency of recording.
| Read associated sidecar JSON and populate raw.
Handle PowerLineFrequency of recording. | [
"Read",
"associated",
"sidecar",
"JSON",
"and",
"populate",
"raw",
".",
"Handle",
"PowerLineFrequency",
"of",
"recording",
"."
] | def _handle_info_reading(sidecar_fname, raw):
with open(sidecar_fname, 'r', encoding='utf-8-sig') as fin:
sidecar_json = json.load(fin)
json_linefreq = sidecar_json.get("PowerLineFrequency")
raw_linefreq = raw.info["line_freq"]
if (json_linefreq is not None) and (raw_linefreq is not None):
... | [
"def",
"_handle_info_reading",
"(",
"sidecar_fname",
",",
"raw",
")",
":",
"with",
"open",
"(",
"sidecar_fname",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8-sig'",
")",
"as",
"fin",
":",
"sidecar_json",
"=",
"json",
".",
"load",
"(",
"fin",
")",
"json_linefr... | Read associated sidecar JSON and populate raw. | [
"Read",
"associated",
"sidecar",
"JSON",
"and",
"populate",
"raw",
"."
] | [
"\"\"\"Read associated sidecar JSON and populate raw.\n\n Handle PowerLineFrequency of recording.\n \"\"\"",
"# read in the sidecar JSON's and raw object's line frequency",
"# If both are defined, warn if there is a conflict, else all is fine",
"# Else, try to use JSON, fall back on mne.Raw",
"# line ... | [
{
"param": "sidecar_fname",
"type": null
},
{
"param": "raw",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sidecar_fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_to... |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _handle_events_reading | <not_specific> | def _handle_events_reading(events_fname, raw):
"""Read associated events.tsv and populate raw.
Handle onset, duration, and description of each event.
"""
logger.info('Reading events from {}.'.format(events_fname))
events_dict = _from_tsv(events_fname)
# Get the descriptions of the events
i... | Read associated events.tsv and populate raw.
Handle onset, duration, and description of each event.
| Read associated events.tsv and populate raw.
Handle onset, duration, and description of each event. | [
"Read",
"associated",
"events",
".",
"tsv",
"and",
"populate",
"raw",
".",
"Handle",
"onset",
"duration",
"and",
"description",
"of",
"each",
"event",
"."
] | def _handle_events_reading(events_fname, raw):
logger.info('Reading events from {}.'.format(events_fname))
events_dict = _from_tsv(events_fname)
if 'trial_type' in events_dict:
trial_type_col_name = 'trial_type'
elif 'stim_type' in events_dict:
trial_type_col_name = 'stim_type'
... | [
"def",
"_handle_events_reading",
"(",
"events_fname",
",",
"raw",
")",
":",
"logger",
".",
"info",
"(",
"'Reading events from {}.'",
".",
"format",
"(",
"events_fname",
")",
")",
"events_dict",
"=",
"_from_tsv",
"(",
"events_fname",
")",
"if",
"'trial_type'",
"i... | Read associated events.tsv and populate raw. | [
"Read",
"associated",
"events",
".",
"tsv",
"and",
"populate",
"raw",
"."
] | [
"\"\"\"Read associated events.tsv and populate raw.\n\n Handle onset, duration, and description of each event.\n \"\"\"",
"# Get the descriptions of the events",
"# Backward-compat with old datasets.",
"# Drop events unrelated to a trial type",
"# Check whether the `trial_type` <> `value` mapping is u... | [
{
"param": "events_fname",
"type": null
},
{
"param": "raw",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "events_fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_tok... |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _get_bads_from_tsv_data | <not_specific> | def _get_bads_from_tsv_data(tsv_data):
"""Extract names of bads from data read from channels.tsv."""
idx = []
for ch_idx, status in enumerate(tsv_data['status']):
if status.lower() == 'bad':
idx.append(ch_idx)
bads = [tsv_data['name'][i] for i in idx]
return bads | Extract names of bads from data read from channels.tsv. | Extract names of bads from data read from channels.tsv. | [
"Extract",
"names",
"of",
"bads",
"from",
"data",
"read",
"from",
"channels",
".",
"tsv",
"."
] | def _get_bads_from_tsv_data(tsv_data):
idx = []
for ch_idx, status in enumerate(tsv_data['status']):
if status.lower() == 'bad':
idx.append(ch_idx)
bads = [tsv_data['name'][i] for i in idx]
return bads | [
"def",
"_get_bads_from_tsv_data",
"(",
"tsv_data",
")",
":",
"idx",
"=",
"[",
"]",
"for",
"ch_idx",
",",
"status",
"in",
"enumerate",
"(",
"tsv_data",
"[",
"'status'",
"]",
")",
":",
"if",
"status",
".",
"lower",
"(",
")",
"==",
"'bad'",
":",
"idx",
... | Extract names of bads from data read from channels.tsv. | [
"Extract",
"names",
"of",
"bads",
"from",
"data",
"read",
"from",
"channels",
".",
"tsv",
"."
] | [
"\"\"\"Extract names of bads from data read from channels.tsv.\"\"\""
] | [
{
"param": "tsv_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tsv_data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
604b425dd4faca4648748549a92dc92da89a8a09 | paul30402/mne-bids | mne_bids/read.py | [
"BSD-3-Clause"
] | Python | _handle_channels_reading | <not_specific> | def _handle_channels_reading(channels_fname, raw):
"""Read associated channels.tsv and populate raw.
Updates status (bad) and types of channels.
"""
logger.info('Reading channel info from {}.'.format(channels_fname))
channels_dict = _from_tsv(channels_fname)
ch_names_tsv = channels_dict['name']... | Read associated channels.tsv and populate raw.
Updates status (bad) and types of channels.
| Read associated channels.tsv and populate raw.
Updates status (bad) and types of channels. | [
"Read",
"associated",
"channels",
".",
"tsv",
"and",
"populate",
"raw",
".",
"Updates",
"status",
"(",
"bad",
")",
"and",
"types",
"of",
"channels",
"."
] | def _handle_channels_reading(channels_fname, raw):
logger.info('Reading channel info from {}.'.format(channels_fname))
channels_dict = _from_tsv(channels_fname)
ch_names_tsv = channels_dict['name']
channel_type_dict = dict()
bids_to_mne_ch_types = _get_ch_type_mapping(fro='bids', to='mne')
ch_ty... | [
"def",
"_handle_channels_reading",
"(",
"channels_fname",
",",
"raw",
")",
":",
"logger",
".",
"info",
"(",
"'Reading channel info from {}.'",
".",
"format",
"(",
"channels_fname",
")",
")",
"channels_dict",
"=",
"_from_tsv",
"(",
"channels_fname",
")",
"ch_names_ts... | Read associated channels.tsv and populate raw. | [
"Read",
"associated",
"channels",
".",
"tsv",
"and",
"populate",
"raw",
"."
] | [
"\"\"\"Read associated channels.tsv and populate raw.\n\n Updates status (bad) and types of channels.\n \"\"\"",
"# Now we can do some work.",
"# The \"type\" column is mandatory in BIDS. We can use it to set channel",
"# types in the raw data using a mapping between channel types",
"# Get the best ma... | [
{
"param": "channels_fname",
"type": null
},
{
"param": "raw",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "channels_fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_t... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _events_tsv | null | def _events_tsv(events, durations, raw, fname, trial_type, overwrite=False):
"""Create an events.tsv file and save it.
This function will write the mandatory 'onset', and 'duration' columns as
well as the optional 'value' and 'sample'. The 'value'
corresponds to the marker value as found in the TRIG ch... | Create an events.tsv file and save it.
This function will write the mandatory 'onset', and 'duration' columns as
well as the optional 'value' and 'sample'. The 'value'
corresponds to the marker value as found in the TRIG channel of the
recording. In addition, the 'trial_type' field can be written.
... | Create an events.tsv file and save it.
Parameters
events : np.ndarray, shape = (n_events, 3)
The first column contains the event time in samples and the third
column contains the event id. The second column is ignored for now but
typically contains the value of the trigger channel either immediately
before the event ... | [
"Create",
"an",
"events",
".",
"tsv",
"file",
"and",
"save",
"it",
".",
"Parameters",
"events",
":",
"np",
".",
"ndarray",
"shape",
"=",
"(",
"n_events",
"3",
")",
"The",
"first",
"column",
"contains",
"the",
"event",
"time",
"in",
"samples",
"and",
"t... | def _events_tsv(events, durations, raw, fname, trial_type, overwrite=False):
first_samp = raw.first_samp
sfreq = raw.info['sfreq']
events = events.copy()
events[:, 0] -= first_samp
data = OrderedDict([('onset', events[:, 0] / sfreq),
('duration', durations),
... | [
"def",
"_events_tsv",
"(",
"events",
",",
"durations",
",",
"raw",
",",
"fname",
",",
"trial_type",
",",
"overwrite",
"=",
"False",
")",
":",
"first_samp",
"=",
"raw",
".",
"first_samp",
"sfreq",
"=",
"raw",
".",
"info",
"[",
"'sfreq'",
"]",
"events",
... | Create an events.tsv file and save it. | [
"Create",
"an",
"events",
".",
"tsv",
"file",
"and",
"save",
"it",
"."
] | [
"\"\"\"Create an events.tsv file and save it.\n\n This function will write the mandatory 'onset', and 'duration' columns as\n well as the optional 'value' and 'sample'. The 'value'\n corresponds to the marker value as found in the TRIG channel of the\n recording. In addition, the 'trial_type' field can ... | [
{
"param": "events",
"type": null
},
{
"param": "durations",
"type": null
},
{
"param": "raw",
"type": null
},
{
"param": "fname",
"type": null
},
{
"param": "trial_type",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "events",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "durations",
"type": null,
"docstring": null,
"docstring_tok... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _readme | <not_specific> | def _readme(datatype, fname, overwrite=False):
"""Create a README file and save it.
This will write a README file containing an MNE-BIDS citation.
If a README already exists, the behavior depends on the
`overwrite` parameter, as described below.
Parameters
----------
datatype : string
... | Create a README file and save it.
This will write a README file containing an MNE-BIDS citation.
If a README already exists, the behavior depends on the
`overwrite` parameter, as described below.
Parameters
----------
datatype : string
The type of data contained in the raw file ('meg',... | Create a README file and save it.
This will write a README file containing an MNE-BIDS citation.
If a README already exists, the behavior depends on the
`overwrite` parameter, as described below.
Parameters
| [
"Create",
"a",
"README",
"file",
"and",
"save",
"it",
".",
"This",
"will",
"write",
"a",
"README",
"file",
"containing",
"an",
"MNE",
"-",
"BIDS",
"citation",
".",
"If",
"a",
"README",
"already",
"exists",
"the",
"behavior",
"depends",
"on",
"the",
"`",
... | def _readme(datatype, fname, overwrite=False):
if os.path.isfile(fname) and not overwrite:
with open(fname, 'r', encoding='utf-8-sig') as fid:
orig_data = fid.read()
mne_bids_ref = REFERENCES['mne-bids'] in orig_data
datatype_ref = REFERENCES[datatype] in orig_data
if mne... | [
"def",
"_readme",
"(",
"datatype",
",",
"fname",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"fname",
")",
"and",
"not",
"overwrite",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
",",
"encoding",
"=",
"'... | Create a README file and save it. | [
"Create",
"a",
"README",
"file",
"and",
"save",
"it",
"."
] | [
"\"\"\"Create a README file and save it.\n\n This will write a README file containing an MNE-BIDS citation.\n If a README already exists, the behavior depends on the\n `overwrite` parameter, as described below.\n\n Parameters\n ----------\n datatype : string\n The type of data contained in ... | [
{
"param": "datatype",
"type": null
},
{
"param": "fname",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "datatype",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fname",
"type": null,
"docstring": null,
"docstring_token... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _participants_tsv | null | def _participants_tsv(raw, subject_id, fname, overwrite=False):
"""Create a participants.tsv file and save it.
This will append any new participant data to the current list if it
exists. Otherwise a new file will be created with the provided information.
Parameters
----------
raw : mne.io.Raw
... | Create a participants.tsv file and save it.
This will append any new participant data to the current list if it
exists. Otherwise a new file will be created with the provided information.
Parameters
----------
raw : mne.io.Raw
The data as MNE-Python Raw object.
subject_id : str
... | Create a participants.tsv file and save it.
This will append any new participant data to the current list if it
exists. Otherwise a new file will be created with the provided information.
Parameters
raw : mne.io.Raw
The data as MNE-Python Raw object.
subject_id : str
The subject name in BIDS compatible format ('01', ... | [
"Create",
"a",
"participants",
".",
"tsv",
"file",
"and",
"save",
"it",
".",
"This",
"will",
"append",
"any",
"new",
"participant",
"data",
"to",
"the",
"current",
"list",
"if",
"it",
"exists",
".",
"Otherwise",
"a",
"new",
"file",
"will",
"be",
"created... | def _participants_tsv(raw, subject_id, fname, overwrite=False):
subject_id = 'sub-' + subject_id
data = OrderedDict(participant_id=[subject_id])
subject_age = "n/a"
sex = "n/a"
hand = 'n/a'
subject_info = raw.info.get('subject_info', None)
if subject_info is not None:
sex = _map_opti... | [
"def",
"_participants_tsv",
"(",
"raw",
",",
"subject_id",
",",
"fname",
",",
"overwrite",
"=",
"False",
")",
":",
"subject_id",
"=",
"'sub-'",
"+",
"subject_id",
"data",
"=",
"OrderedDict",
"(",
"participant_id",
"=",
"[",
"subject_id",
"]",
")",
"subject_a... | Create a participants.tsv file and save it. | [
"Create",
"a",
"participants",
".",
"tsv",
"file",
"and",
"save",
"it",
"."
] | [
"\"\"\"Create a participants.tsv file and save it.\n\n This will append any new participant data to the current list if it\n exists. Otherwise a new file will be created with the provided information.\n\n Parameters\n ----------\n raw : mne.io.Raw\n The data as MNE-Python Raw object.\n subj... | [
{
"param": "raw",
"type": null
},
{
"param": "subject_id",
"type": null
},
{
"param": "fname",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "subject_id",
"type": null,
"docstring": null,
"docstring_token... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _participants_json | null | def _participants_json(fname, overwrite=False):
"""Create participants.json for non-default columns in accompanying TSV.
Parameters
----------
fname : str | mne_bids.BIDSPath
Filename to save the scans.tsv to.
overwrite : bool
Defaults to False.
Whether to overwrite the exis... | Create participants.json for non-default columns in accompanying TSV.
Parameters
----------
fname : str | mne_bids.BIDSPath
Filename to save the scans.tsv to.
overwrite : bool
Defaults to False.
Whether to overwrite the existing data in the file.
If there is already data... | Create participants.json for non-default columns in accompanying TSV.
Parameters
fname : str | mne_bids.BIDSPath
Filename to save the scans.tsv to.
overwrite : bool
Defaults to False.
Whether to overwrite the existing data in the file.
If there is already data for the given `fname` and overwrite is False,
an error wil... | [
"Create",
"participants",
".",
"json",
"for",
"non",
"-",
"default",
"columns",
"in",
"accompanying",
"TSV",
".",
"Parameters",
"fname",
":",
"str",
"|",
"mne_bids",
".",
"BIDSPath",
"Filename",
"to",
"save",
"the",
"scans",
".",
"tsv",
"to",
".",
"overwri... | def _participants_json(fname, overwrite=False):
cols = OrderedDict()
cols['participant_id'] = {'Description': 'Unique participant identifier'}
cols['age'] = {'Description': 'Age of the participant at time of testing',
'Units': 'years'}
cols['sex'] = {'Description': 'Biological sex of ... | [
"def",
"_participants_json",
"(",
"fname",
",",
"overwrite",
"=",
"False",
")",
":",
"cols",
"=",
"OrderedDict",
"(",
")",
"cols",
"[",
"'participant_id'",
"]",
"=",
"{",
"'Description'",
":",
"'Unique participant identifier'",
"}",
"cols",
"[",
"'age'",
"]",
... | Create participants.json for non-default columns in accompanying TSV. | [
"Create",
"participants",
".",
"json",
"for",
"non",
"-",
"default",
"columns",
"in",
"accompanying",
"TSV",
"."
] | [
"\"\"\"Create participants.json for non-default columns in accompanying TSV.\n\n Parameters\n ----------\n fname : str | mne_bids.BIDSPath\n Filename to save the scans.tsv to.\n overwrite : bool\n Defaults to False.\n Whether to overwrite the existing data in the file.\n If t... | [
{
"param": "fname",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overwrite",
"type": null,
"docstring": null,
"docstring_toke... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _sidecar_json | <not_specific> | def _sidecar_json(raw, task, manufacturer, fname, datatype,
emptyroom_fname=None, overwrite=False):
"""Create a sidecar json file depending on the suffix and save it.
The sidecar json file provides meta data about the data
of a certain datatype.
Parameters
----------
raw : mn... | Create a sidecar json file depending on the suffix and save it.
The sidecar json file provides meta data about the data
of a certain datatype.
Parameters
----------
raw : mne.io.Raw
The data as MNE-Python Raw object.
task : str
Name of the task the data is based on.
manufac... | Create a sidecar json file depending on the suffix and save it.
The sidecar json file provides meta data about the data
of a certain datatype.
Parameters
raw : mne.io.Raw
The data as MNE-Python Raw object.
task : str
Name of the task the data is based on.
manufacturer : str
Manufacturer of the acquisition system. For... | [
"Create",
"a",
"sidecar",
"json",
"file",
"depending",
"on",
"the",
"suffix",
"and",
"save",
"it",
".",
"The",
"sidecar",
"json",
"file",
"provides",
"meta",
"data",
"about",
"the",
"data",
"of",
"a",
"certain",
"datatype",
".",
"Parameters",
"raw",
":",
... | def _sidecar_json(raw, task, manufacturer, fname, datatype,
emptyroom_fname=None, overwrite=False):
sfreq = raw.info['sfreq']
try:
powerlinefrequency = raw.info['line_freq']
powerlinefrequency = ('n/a' if powerlinefrequency is None else
powerlinefr... | [
"def",
"_sidecar_json",
"(",
"raw",
",",
"task",
",",
"manufacturer",
",",
"fname",
",",
"datatype",
",",
"emptyroom_fname",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"sfreq",
"=",
"raw",
".",
"info",
"[",
"'sfreq'",
"]",
"try",
":",
"powe... | Create a sidecar json file depending on the suffix and save it. | [
"Create",
"a",
"sidecar",
"json",
"file",
"depending",
"on",
"the",
"suffix",
"and",
"save",
"it",
"."
] | [
"\"\"\"Create a sidecar json file depending on the suffix and save it.\n\n The sidecar json file provides meta data about the data\n of a certain datatype.\n\n Parameters\n ----------\n raw : mne.io.Raw\n The data as MNE-Python Raw object.\n task : str\n Name of the task the data is ... | [
{
"param": "raw",
"type": null
},
{
"param": "task",
"type": null
},
{
"param": "manufacturer",
"type": null
},
{
"param": "fname",
"type": null
},
{
"param": "datatype",
"type": null
},
{
"param": "emptyroom_fname",
"type": null
},
{
"para... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "task",
"type": null,
"docstring": null,
"docstring_tokens": []... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | _write_raw_brainvision | null | def _write_raw_brainvision(raw, bids_fname, events, overwrite):
"""Save out the raw file in BrainVision format.
Parameters
----------
raw : mne.io.Raw
Raw file to save out.
bids_fname : str
The name of the BIDS-specified file where the raw object
should be saved.
events ... | Save out the raw file in BrainVision format.
Parameters
----------
raw : mne.io.Raw
Raw file to save out.
bids_fname : str
The name of the BIDS-specified file where the raw object
should be saved.
events : ndarray
The events as MNE-Python format ndaray.
overwrite... | Save out the raw file in BrainVision format.
Parameters
raw : mne.io.Raw
Raw file to save out.
bids_fname : str
The name of the BIDS-specified file where the raw object
should be saved.
events : ndarray
The events as MNE-Python format ndaray.
overwrite : bool
Whether or not to overwrite existing files. | [
"Save",
"out",
"the",
"raw",
"file",
"in",
"BrainVision",
"format",
".",
"Parameters",
"raw",
":",
"mne",
".",
"io",
".",
"Raw",
"Raw",
"file",
"to",
"save",
"out",
".",
"bids_fname",
":",
"str",
"The",
"name",
"of",
"the",
"BIDS",
"-",
"specified",
... | def _write_raw_brainvision(raw, bids_fname, events, overwrite):
if not check_version('pybv', '0.6'):
raise ImportError('pybv >=0.6 is required for converting '
'file to BrainVision format')
from pybv import write_brainvision
if events is not None:
events[:, 0] -= ... | [
"def",
"_write_raw_brainvision",
"(",
"raw",
",",
"bids_fname",
",",
"events",
",",
"overwrite",
")",
":",
"if",
"not",
"check_version",
"(",
"'pybv'",
",",
"'0.6'",
")",
":",
"raise",
"ImportError",
"(",
"'pybv >=0.6 is required for converting '",
"'file to BrainVi... | Save out the raw file in BrainVision format. | [
"Save",
"out",
"the",
"raw",
"file",
"in",
"BrainVision",
"format",
"."
] | [
"\"\"\"Save out the raw file in BrainVision format.\n\n Parameters\n ----------\n raw : mne.io.Raw\n Raw file to save out.\n bids_fname : str\n The name of the BIDS-specified file where the raw object\n should be saved.\n events : ndarray\n The events as MNE-Python format ... | [
{
"param": "raw",
"type": null
},
{
"param": "bids_fname",
"type": null
},
{
"param": "events",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bids_fname",
"type": null,
"docstring": null,
"docstring_token... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | make_dataset_description | null | def make_dataset_description(path, name, data_license=None,
authors=None, acknowledgements=None,
how_to_acknowledge=None, funding=None,
references_and_links=None, doi=None,
dataset_type='raw',
... | Create json for a dataset description.
BIDS datasets may have one or more fields, this function allows you to
specify which you wish to include in the description. See the BIDS
documentation for information about what each field means.
Parameters
----------
path : str
A path to a folde... | Create json for a dataset description.
BIDS datasets may have one or more fields, this function allows you to
specify which you wish to include in the description. See the BIDS
documentation for information about what each field means.
Parameters
path : str
A path to a folder where the description will be created.
na... | [
"Create",
"json",
"for",
"a",
"dataset",
"description",
".",
"BIDS",
"datasets",
"may",
"have",
"one",
"or",
"more",
"fields",
"this",
"function",
"allows",
"you",
"to",
"specify",
"which",
"you",
"wish",
"to",
"include",
"in",
"the",
"description",
".",
"... | def make_dataset_description(path, name, data_license=None,
authors=None, acknowledgements=None,
how_to_acknowledge=None, funding=None,
references_and_links=None, doi=None,
dataset_type='raw',
... | [
"def",
"make_dataset_description",
"(",
"path",
",",
"name",
",",
"data_license",
"=",
"None",
",",
"authors",
"=",
"None",
",",
"acknowledgements",
"=",
"None",
",",
"how_to_acknowledge",
"=",
"None",
",",
"funding",
"=",
"None",
",",
"references_and_links",
... | Create json for a dataset description. | [
"Create",
"json",
"for",
"a",
"dataset",
"description",
"."
] | [
"\"\"\"Create json for a dataset description.\n\n BIDS datasets may have one or more fields, this function allows you to\n specify which you wish to include in the description. See the BIDS\n documentation for information about what each field means.\n\n Parameters\n ----------\n path : str\n ... | [
{
"param": "path",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "data_license",
"type": null
},
{
"param": "authors",
"type": null
},
{
"param": "acknowledgements",
"type": null
},
{
"param": "how_to_acknowledge",
"type": null
},... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
42653a342e697bb8a6cd6a4b59bde0648c7e7f1e | paul30402/mne-bids | mne_bids/write.py | [
"BSD-3-Clause"
] | Python | write_anat | <not_specific> | def write_anat(image, bids_path, landmarks=None, deface=False, overwrite=False,
verbose=None):
"""Put anatomical MRI data into a BIDS format.
Given an MRI scan, format and store the MR data according to BIDS in the
correct location inside the specified :class:`mne_bids.BIDSPath`. If a
tr... | Put anatomical MRI data into a BIDS format.
Given an MRI scan, format and store the MR data according to BIDS in the
correct location inside the specified :class:`mne_bids.BIDSPath`. If a
transformation matrix is supplied, this information will be stored in a
sidecar JSON file.
.. note:: To genera... | Put anatomical MRI data into a BIDS format.
Given an MRI scan, format and store the MR data according to BIDS in the
correct location inside the specified :class:`mne_bids.BIDSPath`. If a
transformation matrix is supplied, this information will be stored in a
sidecar JSON file.
: To generate the JSON sidecar with anat... | [
"Put",
"anatomical",
"MRI",
"data",
"into",
"a",
"BIDS",
"format",
".",
"Given",
"an",
"MRI",
"scan",
"format",
"and",
"store",
"the",
"MR",
"data",
"according",
"to",
"BIDS",
"in",
"the",
"correct",
"location",
"inside",
"the",
"specified",
":",
"class",
... | def write_anat(image, bids_path, landmarks=None, deface=False, overwrite=False,
verbose=None):
if not has_nibabel():
raise ImportError('This function requires nibabel.')
import nibabel as nib
write_sidecar = landmarks is not None
if deface and landmarks is None:
raise Va... | [
"def",
"write_anat",
"(",
"image",
",",
"bids_path",
",",
"landmarks",
"=",
"None",
",",
"deface",
"=",
"False",
",",
"overwrite",
"=",
"False",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"not",
"has_nibabel",
"(",
")",
":",
"raise",
"ImportError",
"... | Put anatomical MRI data into a BIDS format. | [
"Put",
"anatomical",
"MRI",
"data",
"into",
"a",
"BIDS",
"format",
"."
] | [
"\"\"\"Put anatomical MRI data into a BIDS format.\n\n Given an MRI scan, format and store the MR data according to BIDS in the\n correct location inside the specified :class:`mne_bids.BIDSPath`. If a\n transformation matrix is supplied, this information will be stored in a\n sidecar JSON file.\n\n .... | [
{
"param": "image",
"type": null
},
{
"param": "bids_path",
"type": null
},
{
"param": "landmarks",
"type": null
},
{
"param": "deface",
"type": null
},
{
"param": "overwrite",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bids_path",
"type": null,
"docstring": null,
"docstring_toke... |
d8a44786a76e2d95bce362676373ba58a269e0db | geishm-ansto/python-streaming-data-types | streaming_data_types/utils.py | [
"BSD-2-Clause"
] | Python | check_schema_identifier | null | def check_schema_identifier(buffer, expected_identifer: bytes):
"""
Check the schema code embedded in the buffer matches an expected identifier
:param buffer: The raw buffer of the FlatBuffers message
:param expected_identifer: The expected flatbuffer identifier
"""
if get_schema(buffer) != exp... |
Check the schema code embedded in the buffer matches an expected identifier
:param buffer: The raw buffer of the FlatBuffers message
:param expected_identifer: The expected flatbuffer identifier
| Check the schema code embedded in the buffer matches an expected identifier | [
"Check",
"the",
"schema",
"code",
"embedded",
"in",
"the",
"buffer",
"matches",
"an",
"expected",
"identifier"
] | def check_schema_identifier(buffer, expected_identifer: bytes):
if get_schema(buffer) != expected_identifer.decode():
raise WrongSchemaException(
f"Incorrect schema: expected {expected_identifer} but got {get_schema(buffer)}"
) | [
"def",
"check_schema_identifier",
"(",
"buffer",
",",
"expected_identifer",
":",
"bytes",
")",
":",
"if",
"get_schema",
"(",
"buffer",
")",
"!=",
"expected_identifer",
".",
"decode",
"(",
")",
":",
"raise",
"WrongSchemaException",
"(",
"f\"Incorrect schema: expected... | Check the schema code embedded in the buffer matches an expected identifier | [
"Check",
"the",
"schema",
"code",
"embedded",
"in",
"the",
"buffer",
"matches",
"an",
"expected",
"identifier"
] | [
"\"\"\"\n Check the schema code embedded in the buffer matches an expected identifier\n\n :param buffer: The raw buffer of the FlatBuffers message\n :param expected_identifer: The expected flatbuffer identifier\n \"\"\""
] | [
{
"param": "buffer",
"type": null
},
{
"param": "expected_identifer",
"type": "bytes"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffer",
"type": null,
"docstring": "The raw buffer of the FlatBuffers message",
"docstring_tokens": [
"The",
"raw",
"buffer",
"of",
"the",
"FlatBuffers",
"message"
... |
94a3774a918f8022a544bd5aedd32cdc2e2e0eb2 | geishm-ansto/python-streaming-data-types | streaming_data_types/logdata_f142.py | [
"BSD-2-Clause"
] | Python | serialise_f142 | bytes | def serialise_f142(
value: Any,
source_name: str,
timestamp_unix_ns: int = 0,
alarm_status: Union[int, None] = None,
alarm_severity: Union[int, None] = None,
) -> bytes:
"""
Serialise value and corresponding timestamp as an f142 Flatbuffer message.
Should automagically use a sensible typ... |
Serialise value and corresponding timestamp as an f142 Flatbuffer message.
Should automagically use a sensible type for value in the message, but if
in doubt pass value in as a numpy ndarray of a carefully chosen dtype.
:param value: only scalar value currently supported; if ndarray then ndim must be ... | Serialise value and corresponding timestamp as an f142 Flatbuffer message.
Should automagically use a sensible type for value in the message, but if
in doubt pass value in as a numpy ndarray of a carefully chosen dtype. | [
"Serialise",
"value",
"and",
"corresponding",
"timestamp",
"as",
"an",
"f142",
"Flatbuffer",
"message",
".",
"Should",
"automagically",
"use",
"a",
"sensible",
"type",
"for",
"value",
"in",
"the",
"message",
"but",
"if",
"in",
"doubt",
"pass",
"value",
"in",
... | def serialise_f142(
value: Any,
source_name: str,
timestamp_unix_ns: int = 0,
alarm_status: Union[int, None] = None,
alarm_severity: Union[int, None] = None,
) -> bytes:
builder, source = _setup_builder(source_name)
value = np.array(value)
if value.ndim == 0:
_serialise_value(
... | [
"def",
"serialise_f142",
"(",
"value",
":",
"Any",
",",
"source_name",
":",
"str",
",",
"timestamp_unix_ns",
":",
"int",
"=",
"0",
",",
"alarm_status",
":",
"Union",
"[",
"int",
",",
"None",
"]",
"=",
"None",
",",
"alarm_severity",
":",
"Union",
"[",
"... | Serialise value and corresponding timestamp as an f142 Flatbuffer message. | [
"Serialise",
"value",
"and",
"corresponding",
"timestamp",
"as",
"an",
"f142",
"Flatbuffer",
"message",
"."
] | [
"\"\"\"\n Serialise value and corresponding timestamp as an f142 Flatbuffer message.\n Should automagically use a sensible type for value in the message, but if\n in doubt pass value in as a numpy ndarray of a carefully chosen dtype.\n\n :param value: only scalar value currently supported; if ndarray th... | [
{
"param": "value",
"type": "Any"
},
{
"param": "source_name",
"type": "str"
},
{
"param": "timestamp_unix_ns",
"type": "int"
},
{
"param": "alarm_status",
"type": "Union[int, None]"
},
{
"param": "alarm_severity",
"type": "Union[int, None]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": "Any",
"docstring": "only scalar value currently supported; if ndarray then ndim must be 0",
"docstring_tokens": [
"only",
"scalar",
"value",
"currently",
"supported",
... |
08b5e3b2c4d2d1fc6f03a9716e9ac0940988b129 | geishm-ansto/python-streaming-data-types | streaming_data_types/eventdata_ev43.py | [
"BSD-2-Clause"
] | Python | serialise_ev43 | <not_specific> | def serialise_ev43(
source_name, message_id, pulse_time, pulse_index, time_of_flight, detector_id
):
"""
Serialise event data as an ev43 FlatBuffers message.
:param source_name:
:param message_id:
:param pulse_time:
:param pulse_index:
:param time_of_flight:
:param detector_id:
... |
Serialise event data as an ev43 FlatBuffers message.
:param source_name:
:param message_id:
:param pulse_time:
:param pulse_index:
:param time_of_flight:
:param detector_id:
:return:
| Serialise event data as an ev43 FlatBuffers message. | [
"Serialise",
"event",
"data",
"as",
"an",
"ev43",
"FlatBuffers",
"message",
"."
] | def serialise_ev43(
source_name, message_id, pulse_time, pulse_index, time_of_flight, detector_id
):
builder = flatbuffers.Builder(1024)
builder.ForceDefaults(True)
source = builder.CreateString(source_name)
pulse_ts_data = builder.CreateNumpyVector(np.asarray(pulse_time).astype(np.uint64))
puls... | [
"def",
"serialise_ev43",
"(",
"source_name",
",",
"message_id",
",",
"pulse_time",
",",
"pulse_index",
",",
"time_of_flight",
",",
"detector_id",
")",
":",
"builder",
"=",
"flatbuffers",
".",
"Builder",
"(",
"1024",
")",
"builder",
".",
"ForceDefaults",
"(",
"... | Serialise event data as an ev43 FlatBuffers message. | [
"Serialise",
"event",
"data",
"as",
"an",
"ev43",
"FlatBuffers",
"message",
"."
] | [
"\"\"\"\n Serialise event data as an ev43 FlatBuffers message.\n\n :param source_name:\n :param message_id:\n :param pulse_time:\n :param pulse_index:\n :param time_of_flight:\n :param detector_id:\n :return:\n \"\"\"",
"# Build the actual buffer"
] | [
{
"param": "source_name",
"type": null
},
{
"param": "message_id",
"type": null
},
{
"param": "pulse_time",
"type": null
},
{
"param": "pulse_index",
"type": null
},
{
"param": "time_of_flight",
"type": null
},
{
"param": "detector_id",
"type": nul... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "source_name",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,... |
890f04f57d658bd6587b1c76d053ed8ad8c8feeb | kb1lqc/pytun | pytun.py | [
"MIT"
] | Python | mode_name | <not_specific> | def mode_name(self):
""" Returns the tunnel mode's name, for printing purpose. """
for name, id in self.MODES.iteritems():
if id == self.mode:
return name | Returns the tunnel mode's name, for printing purpose. | Returns the tunnel mode's name, for printing purpose. | [
"Returns",
"the",
"tunnel",
"mode",
"'",
"s",
"name",
"for",
"printing",
"purpose",
"."
] | def mode_name(self):
for name, id in self.MODES.iteritems():
if id == self.mode:
return name | [
"def",
"mode_name",
"(",
"self",
")",
":",
"for",
"name",
",",
"id",
"in",
"self",
".",
"MODES",
".",
"iteritems",
"(",
")",
":",
"if",
"id",
"==",
"self",
".",
"mode",
":",
"return",
"name"
] | Returns the tunnel mode's name, for printing purpose. | [
"Returns",
"the",
"tunnel",
"mode",
"'",
"s",
"name",
"for",
"printing",
"purpose",
"."
] | [
"\"\"\" Returns the tunnel mode's name, for printing purpose. \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
890f04f57d658bd6587b1c76d053ed8ad8c8feeb | kb1lqc/pytun | pytun.py | [
"MIT"
] | Python | open | null | def open(self):
""" Create the tunnel.
If the tunnel is already opened, the function will
raised an AlreadyOpened exception.
"""
if self.fd is not None:
raise self.AlreadyOpened()
logger.debug("Opening %s..." % (TUN_KO_PATH, ))
self.fd = os.o... | Create the tunnel.
If the tunnel is already opened, the function will
raised an AlreadyOpened exception.
| Create the tunnel.
If the tunnel is already opened, the function will
raised an AlreadyOpened exception. | [
"Create",
"the",
"tunnel",
".",
"If",
"the",
"tunnel",
"is",
"already",
"opened",
"the",
"function",
"will",
"raised",
"an",
"AlreadyOpened",
"exception",
"."
] | def open(self):
if self.fd is not None:
raise self.AlreadyOpened()
logger.debug("Opening %s..." % (TUN_KO_PATH, ))
self.fd = os.open(TUN_KO_PATH, os.O_RDWR)
logger.debug("Opening %s tunnel '%s'..." % (self.mode_name.upper(), self.pattern, ))
try:
ret = fcn... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"fd",
"is",
"not",
"None",
":",
"raise",
"self",
".",
"AlreadyOpened",
"(",
")",
"logger",
".",
"debug",
"(",
"\"Opening %s...\"",
"%",
"(",
"TUN_KO_PATH",
",",
")",
")",
"self",
".",
"fd",
"... | Create the tunnel. | [
"Create",
"the",
"tunnel",
"."
] | [
"\"\"\" Create the tunnel.\n If the tunnel is already opened, the function will\n raised an AlreadyOpened exception.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
890f04f57d658bd6587b1c76d053ed8ad8c8feeb | kb1lqc/pytun | pytun.py | [
"MIT"
] | Python | close | <not_specific> | def close(self):
""" Close the tunnel.
If the tunnel is already closed or never opened,
do nothing.
"""
if self.fd is None:
return
logger.debug("Closing tunnel '%s'..." % (self.name or "", ))
# Close tun.ko file
os.close(... | Close the tunnel.
If the tunnel is already closed or never opened,
do nothing.
| Close the tunnel.
If the tunnel is already closed or never opened,
do nothing. | [
"Close",
"the",
"tunnel",
".",
"If",
"the",
"tunnel",
"is",
"already",
"closed",
"or",
"never",
"opened",
"do",
"nothing",
"."
] | def close(self):
if self.fd is None:
return
logger.debug("Closing tunnel '%s'..." % (self.name or "", ))
os.close(self.fd)
self.fd = None
logger.info("Tunnel '%s' closed." % (self.name or "", )) | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"fd",
"is",
"None",
":",
"return",
"logger",
".",
"debug",
"(",
"\"Closing tunnel '%s'...\"",
"%",
"(",
"self",
".",
"name",
"or",
"\"\"",
",",
")",
")",
"os",
".",
"close",
"(",
"self",
"."... | Close the tunnel. | [
"Close",
"the",
"tunnel",
"."
] | [
"\"\"\" Close the tunnel.\n If the tunnel is already closed or never opened,\n do nothing.\n \"\"\"",
"# Close tun.ko file"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
890f04f57d658bd6587b1c76d053ed8ad8c8feeb | kb1lqc/pytun | pytun.py | [
"MIT"
] | Python | recv | <not_specific> | def recv(self, size = None):
""" Receive a buffer. The default size is 1500, the
classical MTU.
"""
size = size if size is not None else 1500
return os.read(self.fd, size) | Receive a buffer. The default size is 1500, the
classical MTU.
| Receive a buffer. The default size is 1500, the
classical MTU. | [
"Receive",
"a",
"buffer",
".",
"The",
"default",
"size",
"is",
"1500",
"the",
"classical",
"MTU",
"."
] | def recv(self, size = None):
size = size if size is not None else 1500
return os.read(self.fd, size) | [
"def",
"recv",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"size",
"=",
"size",
"if",
"size",
"is",
"not",
"None",
"else",
"1500",
"return",
"os",
".",
"read",
"(",
"self",
".",
"fd",
",",
"size",
")"
] | Receive a buffer. | [
"Receive",
"a",
"buffer",
"."
] | [
"\"\"\" Receive a buffer. The default size is 1500, the\n classical MTU.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": null,
"docstring": null,
"docstring_tokens": [... |
a5dd99acebda99627c287e7bd503fb215318ade8 | kb1lqc/pytun | tests.py | [
"MIT"
] | Python | pprint_buf | <not_specific> | def pprint_buf(buf):
""" Dirty & convenient function to display the hexademical
repr. of a buffer.
"""
DEFAULT_SIZE = 4
def hex2(i, l = None):
l = l if l is not None else DEFAULT_SIZE
h = hex(i).upper()[2:]
if len(h) != l:
h = "0" * (l - len(h)) + ... | Dirty & convenient function to display the hexademical
repr. of a buffer.
| Dirty & convenient function to display the hexademical
repr. of a buffer. | [
"Dirty",
"&",
"convenient",
"function",
"to",
"display",
"the",
"hexademical",
"repr",
".",
"of",
"a",
"buffer",
"."
] | def pprint_buf(buf):
DEFAULT_SIZE = 4
def hex2(i, l = None):
l = l if l is not None else DEFAULT_SIZE
h = hex(i).upper()[2:]
if len(h) != l:
h = "0" * (l - len(h)) + h
return h
def displayable_char(c):
if ord(c) < 0x20 or ord(c) >= 0x7f:
c = ".... | [
"def",
"pprint_buf",
"(",
"buf",
")",
":",
"DEFAULT_SIZE",
"=",
"4",
"def",
"hex2",
"(",
"i",
",",
"l",
"=",
"None",
")",
":",
"l",
"=",
"l",
"if",
"l",
"is",
"not",
"None",
"else",
"DEFAULT_SIZE",
"h",
"=",
"hex",
"(",
"i",
")",
".",
"upper",
... | Dirty & convenient function to display the hexademical
repr. | [
"Dirty",
"&",
"convenient",
"function",
"to",
"display",
"the",
"hexademical",
"repr",
"."
] | [
"\"\"\" Dirty & convenient function to display the hexademical\n repr. of a buffer.\n \"\"\""
] | [
{
"param": "buf",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buf",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b87512f16d9aec9a813fc36cd1f9d296cf5ebbf7 | CoinbaseInc/gevent | src/gevent/_sslgte279.py | [
"MIT"
] | Python | read | <not_specific> | def read(self, len=0, buffer=None):
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
self._checkClosed()
while 1:
if not self._sslobj:
raise ValueError("Read on closed or unwrapped SSL socket.")
try:
i... | Read up to LEN bytes and return them.
Return zero-length string on EOF. | Read up to LEN bytes and return them.
Return zero-length string on EOF. | [
"Read",
"up",
"to",
"LEN",
"bytes",
"and",
"return",
"them",
".",
"Return",
"zero",
"-",
"length",
"string",
"on",
"EOF",
"."
] | def read(self, len=0, buffer=None):
self._checkClosed()
while 1:
if not self._sslobj:
raise ValueError("Read on closed or unwrapped SSL socket.")
try:
if buffer is not None:
return self._sslobj.read(len, buffer)
... | [
"def",
"read",
"(",
"self",
",",
"len",
"=",
"0",
",",
"buffer",
"=",
"None",
")",
":",
"self",
".",
"_checkClosed",
"(",
")",
"while",
"1",
":",
"if",
"not",
"self",
".",
"_sslobj",
":",
"raise",
"ValueError",
"(",
"\"Read on closed or unwrapped SSL soc... | Read up to LEN bytes and return them. | [
"Read",
"up",
"to",
"LEN",
"bytes",
"and",
"return",
"them",
"."
] | [
"\"\"\"Read up to LEN bytes and return them.\n Return zero-length string on EOF.\"\"\"",
"# note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional"
] | [
{
"param": "self",
"type": null
},
{
"param": "len",
"type": null
},
{
"param": "buffer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "len",
"type": null,
"docstring": null,
"docstring_tokens": []... |
d74ebf03c5415a3f9f4d9add534cee9190ac13d9 | lym/allura-git | Allura/allura/tests/functional/test_auth.py | [
"Apache-2.0"
] | Python | _create_password_reset_hash | <not_specific> | def _create_password_reset_hash():
""" Generates a password reset token for a given user.
:return: User object
:rtype: User
"""
# test-user claimed email address
user = M.User.by_username('test-admin')
user.set_tool_data('AuthPasswordReset',
... | Generates a password reset token for a given user.
:return: User object
:rtype: User
| Generates a password reset token for a given user. | [
"Generates",
"a",
"password",
"reset",
"token",
"for",
"a",
"given",
"user",
"."
] | def _create_password_reset_hash():
user = M.User.by_username('test-admin')
user.set_tool_data('AuthPasswordReset',
hash="generated_hash_value",
hash_expiry="04-08-2020")
hash = user.get_tool_data('AuthPasswordReset', 'hash')
session(u... | [
"def",
"_create_password_reset_hash",
"(",
")",
":",
"user",
"=",
"M",
".",
"User",
".",
"by_username",
"(",
"'test-admin'",
")",
"user",
".",
"set_tool_data",
"(",
"'AuthPasswordReset'",
",",
"hash",
"=",
"\"generated_hash_value\"",
",",
"hash_expiry",
"=",
"\"... | Generates a password reset token for a given user. | [
"Generates",
"a",
"password",
"reset",
"token",
"for",
"a",
"given",
"user",
"."
] | [
"\"\"\" Generates a password reset token for a given user.\n\n :return: User object\n :rtype: User\n \"\"\"",
"# test-user claimed email address"
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "User"
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
97691dfc686923fe95983df0199bea899ded05ec | lym/allura-git | AlluraTest/alluratest/validation.py | [
"Apache-2.0"
] | Python | validate_html5_chunk | <not_specific> | def validate_html5_chunk(html):
""" When you don't have a html & body tags - this adds it"""
# WebTest doesn't like HTML fragments without doctype,
# so we output them sometimes for fragments, which is hack.
# Unhack it here.
doctype = '<!DOCTYPE html>'
if html.startswith(doctype):
html ... | When you don't have a html & body tags - this adds it | When you don't have a html & body tags - this adds it | [
"When",
"you",
"don",
"'",
"t",
"have",
"a",
"html",
"&",
"body",
"tags",
"-",
"this",
"adds",
"it"
] | def validate_html5_chunk(html):
doctype = '<!DOCTYPE html>'
if html.startswith(doctype):
html = html[len(doctype):]
html = '''<!DOCTYPE html>
<html>
<head><title>Not empty</title></head>
<body>
%s
</body></html>''' % html
return validate_html5(html) | [
"def",
"validate_html5_chunk",
"(",
"html",
")",
":",
"doctype",
"=",
"'<!DOCTYPE html>'",
"if",
"html",
".",
"startswith",
"(",
"doctype",
")",
":",
"html",
"=",
"html",
"[",
"len",
"(",
"doctype",
")",
":",
"]",
"html",
"=",
"'''<!DOCTYPE html>\n <html>... | When you don't have a html & body tags - this adds it | [
"When",
"you",
"don",
"'",
"t",
"have",
"a",
"html",
"&",
"body",
"tags",
"-",
"this",
"adds",
"it"
] | [
"\"\"\" When you don't have a html & body tags - this adds it\"\"\"",
"# WebTest doesn't like HTML fragments without doctype,",
"# so we output them sometimes for fragments, which is hack.",
"# Unhack it here."
] | [
{
"param": "html",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "html",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
97691dfc686923fe95983df0199bea899ded05ec | lym/allura-git | AlluraTest/alluratest/validation.py | [
"Apache-2.0"
] | Python | _validate | <not_specific> | def _validate(self, resp, method, val_params):
"""Perform validation on webapp response. This handles responses of
various types and forms."""
if resp.status_int != 200:
return
content = resp.body
content_type = resp.headers['Content-Type']
if content_type.st... | Perform validation on webapp response. This handles responses of
various types and forms. | Perform validation on webapp response. This handles responses of
various types and forms. | [
"Perform",
"validation",
"on",
"webapp",
"response",
".",
"This",
"handles",
"responses",
"of",
"various",
"types",
"and",
"forms",
"."
] | def _validate(self, resp, method, val_params):
if resp.status_int != 200:
return
content = resp.body
content_type = resp.headers['Content-Type']
if content_type.startswith('text/html'):
if val_params['validate_chunk']:
if Config.instance().validati... | [
"def",
"_validate",
"(",
"self",
",",
"resp",
",",
"method",
",",
"val_params",
")",
":",
"if",
"resp",
".",
"status_int",
"!=",
"200",
":",
"return",
"content",
"=",
"resp",
".",
"body",
"content_type",
"=",
"resp",
".",
"headers",
"[",
"'Content-Type'"... | Perform validation on webapp response. | [
"Perform",
"validation",
"on",
"webapp",
"response",
"."
] | [
"\"\"\"Perform validation on webapp response. This handles responses of\n various types and forms.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "resp",
"type": null
},
{
"param": "method",
"type": null
},
{
"param": "val_params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resp",
"type": null,
"docstring": null,
"docstring_tokens": [... |
97691dfc686923fe95983df0199bea899ded05ec | lym/allura-git | AlluraTest/alluratest/validation.py | [
"Apache-2.0"
] | Python | _get_validation_params | <not_specific> | def _get_validation_params(self, kw):
"Separate validation params from normal TestApp methods params."
params = {}
for k in ('validate_skip', 'validate_chunk'):
params[k] = kw.pop(k, False)
return params, kw | Separate validation params from normal TestApp methods params. | Separate validation params from normal TestApp methods params. | [
"Separate",
"validation",
"params",
"from",
"normal",
"TestApp",
"methods",
"params",
"."
] | def _get_validation_params(self, kw):
params = {}
for k in ('validate_skip', 'validate_chunk'):
params[k] = kw.pop(k, False)
return params, kw | [
"def",
"_get_validation_params",
"(",
"self",
",",
"kw",
")",
":",
"params",
"=",
"{",
"}",
"for",
"k",
"in",
"(",
"'validate_skip'",
",",
"'validate_chunk'",
")",
":",
"params",
"[",
"k",
"]",
"=",
"kw",
".",
"pop",
"(",
"k",
",",
"False",
")",
"r... | Separate validation params from normal TestApp methods params. | [
"Separate",
"validation",
"params",
"from",
"normal",
"TestApp",
"methods",
"params",
"."
] | [
"\"Separate validation params from normal TestApp methods params.\""
] | [
{
"param": "self",
"type": null
},
{
"param": "kw",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kw",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
f2043af641f22aaf893e909caa7555c6a5a625ba | lym/allura-git | Allura/allura/controllers/auth.py | [
"Apache-2.0"
] | Python | index | <not_specific> | def index(self, **kw):
""" The subscription selection page in user preferences.
Builds up a list of dictionaries, each containing subscription
information about a tool.
"""
c.form = F.subscription_form
c.revoke_access = F.oauth_revocation_form
subscriptions = []... | The subscription selection page in user preferences.
Builds up a list of dictionaries, each containing subscription
information about a tool.
| The subscription selection page in user preferences.
Builds up a list of dictionaries, each containing subscription
information about a tool. | [
"The",
"subscription",
"selection",
"page",
"in",
"user",
"preferences",
".",
"Builds",
"up",
"a",
"list",
"of",
"dictionaries",
"each",
"containing",
"subscription",
"information",
"about",
"a",
"tool",
"."
] | def index(self, **kw):
c.form = F.subscription_form
c.revoke_access = F.oauth_revocation_form
subscriptions = []
mailboxes = list(M.Mailbox.query.find(
dict(user_id=c.user._id, is_flash=False)))
projects = dict(
(p._id, p) for p in M.Project.query.find(dic... | [
"def",
"index",
"(",
"self",
",",
"**",
"kw",
")",
":",
"c",
".",
"form",
"=",
"F",
".",
"subscription_form",
"c",
".",
"revoke_access",
"=",
"F",
".",
"oauth_revocation_form",
"subscriptions",
"=",
"[",
"]",
"mailboxes",
"=",
"list",
"(",
"M",
".",
... | The subscription selection page in user preferences. | [
"The",
"subscription",
"selection",
"page",
"in",
"user",
"preferences",
"."
] | [
"\"\"\" The subscription selection page in user preferences.\n\n Builds up a list of dictionaries, each containing subscription\n information about a tool.\n \"\"\"",
"# Add the tools that are already subscribed to by the user.",
"# Dictionary of all projects projects accessible based on a ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f2043af641f22aaf893e909caa7555c6a5a625ba | lym/allura-git | Allura/allura/controllers/auth.py | [
"Apache-2.0"
] | Python | generate_access_token | null | def generate_access_token(self, _id):
"""
Manually generate an OAuth access token for the given consumer.
NB: Manually generated access tokens are bearer tokens, which are
less secure (since they rely only on the token, which is transmitted
with each request, unlike the access t... |
Manually generate an OAuth access token for the given consumer.
NB: Manually generated access tokens are bearer tokens, which are
less secure (since they rely only on the token, which is transmitted
with each request, unlike the access token secret).
| Manually generate an OAuth access token for the given consumer.
NB: Manually generated access tokens are bearer tokens, which are
less secure (since they rely only on the token, which is transmitted
with each request, unlike the access token secret). | [
"Manually",
"generate",
"an",
"OAuth",
"access",
"token",
"for",
"the",
"given",
"consumer",
".",
"NB",
":",
"Manually",
"generated",
"access",
"tokens",
"are",
"bearer",
"tokens",
"which",
"are",
"less",
"secure",
"(",
"since",
"they",
"rely",
"only",
"on",... | def generate_access_token(self, _id):
consumer_token = M.OAuthConsumerToken.query.get(_id=bson.ObjectId(_id))
if consumer_token is None:
flash('Invalid app ID', 'error')
redirect('.')
if consumer_token.user_id != c.user._id:
flash('Invalid app ID', 'error')
... | [
"def",
"generate_access_token",
"(",
"self",
",",
"_id",
")",
":",
"consumer_token",
"=",
"M",
".",
"OAuthConsumerToken",
".",
"query",
".",
"get",
"(",
"_id",
"=",
"bson",
".",
"ObjectId",
"(",
"_id",
")",
")",
"if",
"consumer_token",
"is",
"None",
":",... | Manually generate an OAuth access token for the given consumer. | [
"Manually",
"generate",
"an",
"OAuth",
"access",
"token",
"for",
"the",
"given",
"consumer",
"."
] | [
"\"\"\"\n Manually generate an OAuth access token for the given consumer.\n\n NB: Manually generated access tokens are bearer tokens, which are\n less secure (since they rely only on the token, which is transmitted\n with each request, unlike the access token secret).\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "_id",
"type": null,
"docstring": null,
"docstring_tokens": []... |
2c363eaf89a1893f5a13eb803a37244fc1bf11f3 | lym/allura-git | Allura/allura/lib/patches.py | [
"Apache-2.0"
] | Python | lookup_template_engine | <not_specific> | def lookup_template_engine(self, request):
'''Wrapper to handle totally borked-up HTTP-ACCEPT headers'''
try:
return old_lookup_template_engine(self, request)
except:
pass
environ = dict(request.environ, HTTP_ACCEPT='*/*')
request = webob.Request(environ)
... | Wrapper to handle totally borked-up HTTP-ACCEPT headers | Wrapper to handle totally borked-up HTTP-ACCEPT headers | [
"Wrapper",
"to",
"handle",
"totally",
"borked",
"-",
"up",
"HTTP",
"-",
"ACCEPT",
"headers"
] | def lookup_template_engine(self, request):
try:
return old_lookup_template_engine(self, request)
except:
pass
environ = dict(request.environ, HTTP_ACCEPT='*/*')
request = webob.Request(environ)
return old_lookup_template_engine(self, request) | [
"def",
"lookup_template_engine",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"return",
"old_lookup_template_engine",
"(",
"self",
",",
"request",
")",
"except",
":",
"pass",
"environ",
"=",
"dict",
"(",
"request",
".",
"environ",
",",
"HTTP_ACCEPT",
"... | Wrapper to handle totally borked-up HTTP-ACCEPT headers | [
"Wrapper",
"to",
"handle",
"totally",
"borked",
"-",
"up",
"HTTP",
"-",
"ACCEPT",
"headers"
] | [
"'''Wrapper to handle totally borked-up HTTP-ACCEPT headers'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
2c363eaf89a1893f5a13eb803a37244fc1bf11f3 | lym/allura-git | Allura/allura/lib/patches.py | [
"Apache-2.0"
] | Python | override_template | <not_specific> | def override_template(controller, template):
'''Copy-pasted patch to allow multiple colons in a template spec'''
if hasattr(controller, 'decoration'):
decoration = controller.decoration
else:
return
if hasattr(decoration, 'engines'):
engines = decorati... | Copy-pasted patch to allow multiple colons in a template spec | Copy-pasted patch to allow multiple colons in a template spec | [
"Copy",
"-",
"pasted",
"patch",
"to",
"allow",
"multiple",
"colons",
"in",
"a",
"template",
"spec"
] | def override_template(controller, template):
if hasattr(controller, 'decoration'):
decoration = controller.decoration
else:
return
if hasattr(decoration, 'engines'):
engines = decoration.engines
else:
return
for content_type, conten... | [
"def",
"override_template",
"(",
"controller",
",",
"template",
")",
":",
"if",
"hasattr",
"(",
"controller",
",",
"'decoration'",
")",
":",
"decoration",
"=",
"controller",
".",
"decoration",
"else",
":",
"return",
"if",
"hasattr",
"(",
"decoration",
",",
"... | Copy-pasted patch to allow multiple colons in a template spec | [
"Copy",
"-",
"pasted",
"patch",
"to",
"allow",
"multiple",
"colons",
"in",
"a",
"template",
"spec"
] | [
"'''Copy-pasted patch to allow multiple colons in a template spec'''"
] | [
{
"param": "controller",
"type": null
},
{
"param": "template",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "controller",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "template",
"type": null,
"docstring": null,
"docstring_... |
2c363eaf89a1893f5a13eb803a37244fc1bf11f3 | lym/allura-git | Allura/allura/lib/patches.py | [
"Apache-2.0"
] | Python | without_trailing_slash | <not_specific> | def without_trailing_slash(func, *args, **kwargs):
'''Monkey-patched to use 301 redirects for SEO'''
response_type = getattr(request, 'response_type', None)
if (request.method == 'GET' and request.path.endswith('/')
and not response_type and len(request.params) == 0):
... | Monkey-patched to use 301 redirects for SEO | Monkey-patched to use 301 redirects for SEO | [
"Monkey",
"-",
"patched",
"to",
"use",
"301",
"redirects",
"for",
"SEO"
] | def without_trailing_slash(func, *args, **kwargs):
response_type = getattr(request, 'response_type', None)
if (request.method == 'GET' and request.path.endswith('/')
and not response_type and len(request.params) == 0):
raise webob.exc.HTTPMovedPermanently(location=request.url... | [
"def",
"without_trailing_slash",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"response_type",
"=",
"getattr",
"(",
"request",
",",
"'response_type'",
",",
"None",
")",
"if",
"(",
"request",
".",
"method",
"==",
"'GET'",
"and",
"request",
... | Monkey-patched to use 301 redirects for SEO | [
"Monkey",
"-",
"patched",
"to",
"use",
"301",
"redirects",
"for",
"SEO"
] | [
"'''Monkey-patched to use 301 redirects for SEO'''"
] | [
{
"param": "func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c363eaf89a1893f5a13eb803a37244fc1bf11f3 | lym/allura-git | Allura/allura/lib/patches.py | [
"Apache-2.0"
] | Python | with_trailing_slash | <not_specific> | def with_trailing_slash(func, *args, **kwargs):
'''Monkey-patched to use 301 redirects for SEO'''
response_type = getattr(request, 'response_type', None)
if (request.method == 'GET' and not(request.path.endswith('/'))
and not response_type and len(request.params) == 0):
... | Monkey-patched to use 301 redirects for SEO | Monkey-patched to use 301 redirects for SEO | [
"Monkey",
"-",
"patched",
"to",
"use",
"301",
"redirects",
"for",
"SEO"
] | def with_trailing_slash(func, *args, **kwargs):
response_type = getattr(request, 'response_type', None)
if (request.method == 'GET' and not(request.path.endswith('/'))
and not response_type and len(request.params) == 0):
raise webob.exc.HTTPMovedPermanently(location=request.u... | [
"def",
"with_trailing_slash",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"response_type",
"=",
"getattr",
"(",
"request",
",",
"'response_type'",
",",
"None",
")",
"if",
"(",
"request",
".",
"method",
"==",
"'GET'",
"and",
"not",
"(",
... | Monkey-patched to use 301 redirects for SEO | [
"Monkey",
"-",
"patched",
"to",
"use",
"301",
"redirects",
"for",
"SEO"
] | [
"'''Monkey-patched to use 301 redirects for SEO'''"
] | [
{
"param": "func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c363eaf89a1893f5a13eb803a37244fc1bf11f3 | lym/allura-git | Allura/allura/lib/patches.py | [
"Apache-2.0"
] | Python | _call | <not_specific> | def _call(self, controller, *args, **kwargs):
'''Set NewRelic transaction name to actual controller name'''
import newrelic.agent
newrelic.agent.set_transaction_name(
newrelic.agent.callable_name(controller))
return old_controller_call(self, controller, *args, **kwargs) | Set NewRelic transaction name to actual controller name | Set NewRelic transaction name to actual controller name | [
"Set",
"NewRelic",
"transaction",
"name",
"to",
"actual",
"controller",
"name"
] | def _call(self, controller, *args, **kwargs):
import newrelic.agent
newrelic.agent.set_transaction_name(
newrelic.agent.callable_name(controller))
return old_controller_call(self, controller, *args, **kwargs) | [
"def",
"_call",
"(",
"self",
",",
"controller",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"import",
"newrelic",
".",
"agent",
"newrelic",
".",
"agent",
".",
"set_transaction_name",
"(",
"newrelic",
".",
"agent",
".",
"callable_name",
"(",
"controlle... | Set NewRelic transaction name to actual controller name | [
"Set",
"NewRelic",
"transaction",
"name",
"to",
"actual",
"controller",
"name"
] | [
"'''Set NewRelic transaction name to actual controller name'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "controller",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "controller",
"type": null,
"docstring": null,
"docstring_toke... |
babf2622b52badf535910bf3a795b33220364287 | lym/allura-git | AlluraTest/alluratest/controller.py | [
"Apache-2.0"
] | Python | subscription_options | <not_specific> | def subscription_options(self, response):
"""
Extract subscription options to be passed to React SubscriptionForm
component from the <script> tag
"""
script = None
for s in response.html.findAll('script'):
if s.getText().strip().startswith('document.SUBSCRIPTI... |
Extract subscription options to be passed to React SubscriptionForm
component from the <script> tag
| Extract subscription options to be passed to React SubscriptionForm
component from the | [
"Extract",
"subscription",
"options",
"to",
"be",
"passed",
"to",
"React",
"SubscriptionForm",
"component",
"from",
"the"
] | def subscription_options(self, response):
script = None
for s in response.html.findAll('script'):
if s.getText().strip().startswith('document.SUBSCRIPTION_OPTIONS'):
script = s
break
assert script is not None, 'subscription options not found'
_... | [
"def",
"subscription_options",
"(",
"self",
",",
"response",
")",
":",
"script",
"=",
"None",
"for",
"s",
"in",
"response",
".",
"html",
".",
"findAll",
"(",
"'script'",
")",
":",
"if",
"s",
".",
"getText",
"(",
")",
".",
"strip",
"(",
")",
".",
"s... | Extract subscription options to be passed to React SubscriptionForm
component from the <script> tag | [
"Extract",
"subscription",
"options",
"to",
"be",
"passed",
"to",
"React",
"SubscriptionForm",
"component",
"from",
"the",
"<script",
">",
"tag"
] | [
"\"\"\"\n Extract subscription options to be passed to React SubscriptionForm\n component from the <script> tag\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "response",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens... |
babf2622b52badf535910bf3a795b33220364287 | lym/allura-git | AlluraTest/alluratest/controller.py | [
"Apache-2.0"
] | Python | find_form | <not_specific> | def find_form(self, resp, cond):
"""Find form on the page that meets given condition"""
for f in resp.forms.itervalues():
if cond(f):
return f | Find form on the page that meets given condition | Find form on the page that meets given condition | [
"Find",
"form",
"on",
"the",
"page",
"that",
"meets",
"given",
"condition"
] | def find_form(self, resp, cond):
for f in resp.forms.itervalues():
if cond(f):
return f | [
"def",
"find_form",
"(",
"self",
",",
"resp",
",",
"cond",
")",
":",
"for",
"f",
"in",
"resp",
".",
"forms",
".",
"itervalues",
"(",
")",
":",
"if",
"cond",
"(",
"f",
")",
":",
"return",
"f"
] | Find form on the page that meets given condition | [
"Find",
"form",
"on",
"the",
"page",
"that",
"meets",
"given",
"condition"
] | [
"\"\"\"Find form on the page that meets given condition\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "resp",
"type": null
},
{
"param": "cond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resp",
"type": null,
"docstring": null,
"docstring_tokens": [... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | encode_keys | <not_specific> | def encode_keys(d):
'''Encodes the unicode keys of d, making the result
a valid kwargs argument'''
return dict(
(k.encode('utf-8'), v)
for k, v in d.iteritems()) | Encodes the unicode keys of d, making the result
a valid kwargs argument | Encodes the unicode keys of d, making the result
a valid kwargs argument | [
"Encodes",
"the",
"unicode",
"keys",
"of",
"d",
"making",
"the",
"result",
"a",
"valid",
"kwargs",
"argument"
] | def encode_keys(d):
return dict(
(k.encode('utf-8'), v)
for k, v in d.iteritems()) | [
"def",
"encode_keys",
"(",
"d",
")",
":",
"return",
"dict",
"(",
"(",
"k",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"iteritems",
"(",
")",
")"
] | Encodes the unicode keys of d, making the result
a valid kwargs argument | [
"Encodes",
"the",
"unicode",
"keys",
"of",
"d",
"making",
"the",
"result",
"a",
"valid",
"kwargs",
"argument"
] | [
"'''Encodes the unicode keys of d, making the result\n a valid kwargs argument'''"
] | [
{
"param": "d",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | convert_bools | <not_specific> | def convert_bools(conf, prefix=''):
'''
For a given dict, automatically convert any true/false string values into bools.
Only applies to keys starting with the prefix.
:param dict conf:
:param str prefix:
:return: dict
'''
def convert_value(val):
if isinstance(val, basestring):
... |
For a given dict, automatically convert any true/false string values into bools.
Only applies to keys starting with the prefix.
:param dict conf:
:param str prefix:
:return: dict
| For a given dict, automatically convert any true/false string values into bools.
Only applies to keys starting with the prefix. | [
"For",
"a",
"given",
"dict",
"automatically",
"convert",
"any",
"true",
"/",
"false",
"string",
"values",
"into",
"bools",
".",
"Only",
"applies",
"to",
"keys",
"starting",
"with",
"the",
"prefix",
"."
] | def convert_bools(conf, prefix=''):
def convert_value(val):
if isinstance(val, basestring):
if val.strip().lower() == 'true':
return True
elif val.strip().lower() == 'false':
return False
return val
return {
k: (convert_value(v) if ... | [
"def",
"convert_bools",
"(",
"conf",
",",
"prefix",
"=",
"''",
")",
":",
"def",
"convert_value",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"basestring",
")",
":",
"if",
"val",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"==",
... | For a given dict, automatically convert any true/false string values into bools. | [
"For",
"a",
"given",
"dict",
"automatically",
"convert",
"any",
"true",
"/",
"false",
"string",
"values",
"into",
"bools",
"."
] | [
"'''\n For a given dict, automatically convert any true/false string values into bools.\n Only applies to keys starting with the prefix.\n\n :param dict conf:\n :param str prefix:\n :return: dict\n '''"
] | [
{
"param": "conf",
"type": null
},
{
"param": "prefix",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "conf",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | ago | <not_specific> | def ago(start_time, show_date_after=7):
"""
Return time since starting time as a rounded, human readable string.
E.g., "3 hours ago"
"""
if start_time is None:
return 'unknown'
granularities = ['century', 'decade', 'year', 'month', 'day', 'hour',
'minute']
end_t... |
Return time since starting time as a rounded, human readable string.
E.g., "3 hours ago"
| Return time since starting time as a rounded, human readable string. | [
"Return",
"time",
"since",
"starting",
"time",
"as",
"a",
"rounded",
"human",
"readable",
"string",
"."
] | def ago(start_time, show_date_after=7):
if start_time is None:
return 'unknown'
granularities = ['century', 'decade', 'year', 'month', 'day', 'hour',
'minute']
end_time = datetime.utcnow()
if show_date_after is not None and end_time - start_time > timedelta(days=show_date_af... | [
"def",
"ago",
"(",
"start_time",
",",
"show_date_after",
"=",
"7",
")",
":",
"if",
"start_time",
"is",
"None",
":",
"return",
"'unknown'",
"granularities",
"=",
"[",
"'century'",
",",
"'decade'",
",",
"'year'",
",",
"'month'",
",",
"'day'",
",",
"'hour'",
... | Return time since starting time as a rounded, human readable string. | [
"Return",
"time",
"since",
"starting",
"time",
"as",
"a",
"rounded",
"human",
"readable",
"string",
"."
] | [
"\"\"\"\n Return time since starting time as a rounded, human readable string.\n E.g., \"3 hours ago\"\n \"\"\""
] | [
{
"param": "start_time",
"type": null
},
{
"param": "show_date_after",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "start_time",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "show_date_after",
"type": null,
"docstring": null,
"doc... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | absurl | <not_specific> | def absurl(url):
"""
Given a root-relative URL, return a full URL including protocol and host
"""
if url is None:
return None
if '://' in url:
return url
try:
# try request first, so we can get proper http/https value
host = request.host_url
except TypeError:
... |
Given a root-relative URL, return a full URL including protocol and host
| Given a root-relative URL, return a full URL including protocol and host | [
"Given",
"a",
"root",
"-",
"relative",
"URL",
"return",
"a",
"full",
"URL",
"including",
"protocol",
"and",
"host"
] | def absurl(url):
if url is None:
return None
if '://' in url:
return url
try:
host = request.host_url
except TypeError:
host = tg.config['base_url'].rstrip('/')
return host + url | [
"def",
"absurl",
"(",
"url",
")",
":",
"if",
"url",
"is",
"None",
":",
"return",
"None",
"if",
"'://'",
"in",
"url",
":",
"return",
"url",
"try",
":",
"host",
"=",
"request",
".",
"host_url",
"except",
"TypeError",
":",
"host",
"=",
"tg",
".",
"con... | Given a root-relative URL, return a full URL including protocol and host | [
"Given",
"a",
"root",
"-",
"relative",
"URL",
"return",
"a",
"full",
"URL",
"including",
"protocol",
"and",
"host"
] | [
"\"\"\"\n Given a root-relative URL, return a full URL including protocol and host\n \"\"\"",
"# try request first, so we can get proper http/https value",
"# for tests, etc"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | config_with_prefix | <not_specific> | def config_with_prefix(d, prefix):
'''Return a subdictionary keys with a given prefix,
with the prefix stripped
'''
plen = len(prefix)
return dict((k[plen:], v) for k, v in d.iteritems()
if k.startswith(prefix)) | Return a subdictionary keys with a given prefix,
with the prefix stripped
| Return a subdictionary keys with a given prefix,
with the prefix stripped | [
"Return",
"a",
"subdictionary",
"keys",
"with",
"a",
"given",
"prefix",
"with",
"the",
"prefix",
"stripped"
] | def config_with_prefix(d, prefix):
plen = len(prefix)
return dict((k[plen:], v) for k, v in d.iteritems()
if k.startswith(prefix)) | [
"def",
"config_with_prefix",
"(",
"d",
",",
"prefix",
")",
":",
"plen",
"=",
"len",
"(",
"prefix",
")",
"return",
"dict",
"(",
"(",
"k",
"[",
"plen",
":",
"]",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"iteritems",
"(",
")",
"if",
... | Return a subdictionary keys with a given prefix,
with the prefix stripped | [
"Return",
"a",
"subdictionary",
"keys",
"with",
"a",
"given",
"prefix",
"with",
"the",
"prefix",
"stripped"
] | [
"'''Return a subdictionary keys with a given prefix,\n with the prefix stripped\n '''"
] | [
{
"param": "d",
"type": null
},
{
"param": "prefix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prefix",
"type": null,
"docstring": null,
"docstring_tokens": []... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | paging_sanitizer | <not_specific> | def paging_sanitizer(limit, page, total_count=sys.maxint, zero_based_pages=True):
"""Return limit, page - both converted to int and constrained to
valid ranges based on total_count.
Useful for sanitizing limit and page query params.
"""
limit = max(int(limit), 1)
limit = min(limit, asint(tg.con... | Return limit, page - both converted to int and constrained to
valid ranges based on total_count.
Useful for sanitizing limit and page query params.
| Return limit, page - both converted to int and constrained to
valid ranges based on total_count.
Useful for sanitizing limit and page query params. | [
"Return",
"limit",
"page",
"-",
"both",
"converted",
"to",
"int",
"and",
"constrained",
"to",
"valid",
"ranges",
"based",
"on",
"total_count",
".",
"Useful",
"for",
"sanitizing",
"limit",
"and",
"page",
"query",
"params",
"."
] | def paging_sanitizer(limit, page, total_count=sys.maxint, zero_based_pages=True):
limit = max(int(limit), 1)
limit = min(limit, asint(tg.config.get('limit_param_max', 500)))
max_page = (total_count / limit) + (1 if total_count % limit else 0)
max_page = max(0, max_page - (1 if zero_based_pages else 0))
... | [
"def",
"paging_sanitizer",
"(",
"limit",
",",
"page",
",",
"total_count",
"=",
"sys",
".",
"maxint",
",",
"zero_based_pages",
"=",
"True",
")",
":",
"limit",
"=",
"max",
"(",
"int",
"(",
"limit",
")",
",",
"1",
")",
"limit",
"=",
"min",
"(",
"limit",... | Return limit, page - both converted to int and constrained to
valid ranges based on total_count. | [
"Return",
"limit",
"page",
"-",
"both",
"converted",
"to",
"int",
"and",
"constrained",
"to",
"valid",
"ranges",
"based",
"on",
"total_count",
"."
] | [
"\"\"\"Return limit, page - both converted to int and constrained to\n valid ranges based on total_count.\n\n Useful for sanitizing limit and page query params.\n \"\"\""
] | [
{
"param": "limit",
"type": null
},
{
"param": "page",
"type": null
},
{
"param": "total_count",
"type": null
},
{
"param": "zero_based_pages",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "limit",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "page",
"type": null,
"docstring": null,
"docstring_tokens": ... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | render_any_markup | <not_specific> | def render_any_markup(name, txt, code_mode=False, linenumbers_style=TABLE):
"""
renders markdown using allura enhacements if file is in markdown format
renders any other markup format using the pypeline
Returns jinja-safe text
"""
if txt == '':
txt = '<p><em>Empty File</em></p>'
else... |
renders markdown using allura enhacements if file is in markdown format
renders any other markup format using the pypeline
Returns jinja-safe text
| renders markdown using allura enhacements if file is in markdown format
renders any other markup format using the pypeline
Returns jinja-safe text | [
"renders",
"markdown",
"using",
"allura",
"enhacements",
"if",
"file",
"is",
"in",
"markdown",
"format",
"renders",
"any",
"other",
"markup",
"format",
"using",
"the",
"pypeline",
"Returns",
"jinja",
"-",
"safe",
"text"
] | def render_any_markup(name, txt, code_mode=False, linenumbers_style=TABLE):
if txt == '':
txt = '<p><em>Empty File</em></p>'
else:
fmt = g.pypeline_markup.can_render(name)
if fmt == 'markdown':
txt = g.markdown.convert(txt)
else:
txt = g.pypeline_markup.re... | [
"def",
"render_any_markup",
"(",
"name",
",",
"txt",
",",
"code_mode",
"=",
"False",
",",
"linenumbers_style",
"=",
"TABLE",
")",
":",
"if",
"txt",
"==",
"''",
":",
"txt",
"=",
"'<p><em>Empty File</em></p>'",
"else",
":",
"fmt",
"=",
"g",
".",
"pypeline_ma... | renders markdown using allura enhacements if file is in markdown format
renders any other markup format using the pypeline
Returns jinja-safe text | [
"renders",
"markdown",
"using",
"allura",
"enhacements",
"if",
"file",
"is",
"in",
"markdown",
"format",
"renders",
"any",
"other",
"markup",
"format",
"using",
"the",
"pypeline",
"Returns",
"jinja",
"-",
"safe",
"text"
] | [
"\"\"\"\n renders markdown using allura enhacements if file is in markdown format\n renders any other markup format using the pypeline\n Returns jinja-safe text\n \"\"\""
] | [
{
"param": "name",
"type": null
},
{
"param": "txt",
"type": null
},
{
"param": "code_mode",
"type": null
},
{
"param": "linenumbers_style",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "txt",
"type": null,
"docstring": null,
"docstring_tokens": []... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | topological_sort | <not_specific> | def topological_sort(items, partial_order):
"""Perform topological sort.
items is a list of items to be sorted.
partial_order is a list of pairs. If pair (a,b) is in it, it means
that item a should appear before item b.
Returns a list of the items in one of the possible orders, or None
... | Perform topological sort.
items is a list of items to be sorted.
partial_order is a list of pairs. If pair (a,b) is in it, it means
that item a should appear before item b.
Returns a list of the items in one of the possible orders, or None
if partial_order contains a loop.
Mod... | Perform topological sort.
items is a list of items to be sorted.
partial_order is a list of pairs. If pair (a,b) is in it, it means
that item a should appear before item b.
Returns a list of the items in one of the possible orders, or None
if partial_order contains a loop.
| [
"Perform",
"topological",
"sort",
".",
"items",
"is",
"a",
"list",
"of",
"items",
"to",
"be",
"sorted",
".",
"partial_order",
"is",
"a",
"list",
"of",
"pairs",
".",
"If",
"pair",
"(",
"a",
"b",
")",
"is",
"in",
"it",
"it",
"means",
"that",
"item",
... | def topological_sort(items, partial_order):
def add_arc(graph, fromnode, tonode):
graph[fromnode].append(tonode)
graph[tonode][0] = graph[tonode][0] + 1
graph = defaultdict(lambda: [0])
for a, b in partial_order:
add_arc(graph, a, b)
roots = [n for n in items if graph[n][0] == 0]... | [
"def",
"topological_sort",
"(",
"items",
",",
"partial_order",
")",
":",
"def",
"add_arc",
"(",
"graph",
",",
"fromnode",
",",
"tonode",
")",
":",
"\"\"\"Add an arc to a graph. Can create multiple arcs.\n The end nodes must already exist.\"\"\"",
"graph",
"[",
"fr... | Perform topological sort. | [
"Perform",
"topological",
"sort",
"."
] | [
"\"\"\"Perform topological sort.\n items is a list of items to be sorted.\n partial_order is a list of pairs. If pair (a,b) is in it, it means\n that item a should appear before item b.\n Returns a list of the items in one of the possible orders, or None\n if partial_order contains a l... | [
{
"param": "items",
"type": null
},
{
"param": "partial_order",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "items",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "partial_order",
"type": null,
"docstring": null,
"docstring_... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | ming_config | null | def ming_config(**conf):
"""Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits.
:param \*\*conf: keyword arguments defining the new ming configuration
"""
import ming
from ming.session import Session
datastores = Session._datastores
t... | Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits.
:param \*\*conf: keyword arguments defining the new ming configuration
| Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits. | [
"Temporarily",
"swap",
"in",
"a",
"new",
"ming",
"configuration",
"restoring",
"the",
"previous",
"one",
"when",
"the",
"contextmanager",
"exits",
"."
] | def ming_config(**conf):
import ming
from ming.session import Session
datastores = Session._datastores
try:
ming.configure(**conf)
yield
finally:
Session._datastores = datastores
for name, session in Session._registry.iteritems():
session.bind = datastores... | [
"def",
"ming_config",
"(",
"**",
"conf",
")",
":",
"import",
"ming",
"from",
"ming",
".",
"session",
"import",
"Session",
"datastores",
"=",
"Session",
".",
"_datastores",
"try",
":",
"ming",
".",
"configure",
"(",
"**",
"conf",
")",
"yield",
"finally",
... | Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits. | [
"Temporarily",
"swap",
"in",
"a",
"new",
"ming",
"configuration",
"restoring",
"the",
"previous",
"one",
"when",
"the",
"contextmanager",
"exits",
"."
] | [
"\"\"\"Temporarily swap in a new ming configuration, restoring the previous\n one when the contextmanager exits.\n\n :param \\*\\*conf: keyword arguments defining the new ming configuration\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [
{
"identifier": "\\*\\*conf",
"type": null,
"docstring": "keyword arguments defining the new ming configuration",
"docstring_tokens": [
"keyword",
"arguments",
"defining",
"the",
... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | ming_config_from_ini | null | def ming_config_from_ini(ini_path):
"""Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits.
:param ini_path: Path to ini file containing the ming configuration
"""
root = pkg_resources.get_distribution('allura').location
conf = appconfig('conf... | Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits.
:param ini_path: Path to ini file containing the ming configuration
| Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits. | [
"Temporarily",
"swap",
"in",
"a",
"new",
"ming",
"configuration",
"restoring",
"the",
"previous",
"one",
"when",
"the",
"contextmanager",
"exits",
"."
] | def ming_config_from_ini(ini_path):
root = pkg_resources.get_distribution('allura').location
conf = appconfig('config:%s' % os.path.join(root, ini_path))
with ming_config(**conf):
yield | [
"def",
"ming_config_from_ini",
"(",
"ini_path",
")",
":",
"root",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"'allura'",
")",
".",
"location",
"conf",
"=",
"appconfig",
"(",
"'config:%s'",
"%",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"in... | Temporarily swap in a new ming configuration, restoring the previous
one when the contextmanager exits. | [
"Temporarily",
"swap",
"in",
"a",
"new",
"ming",
"configuration",
"restoring",
"the",
"previous",
"one",
"when",
"the",
"contextmanager",
"exits",
"."
] | [
"\"\"\"Temporarily swap in a new ming configuration, restoring the previous\n one when the contextmanager exits.\n\n :param ini_path: Path to ini file containing the ming configuration\n\n \"\"\""
] | [
{
"param": "ini_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ini_path",
"type": null,
"docstring": "Path to ini file containing the ming configuration",
"docstring_tokens": [
"Path",
"to",
"ini",
"file",
"containing",
"the",
"ming"... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | notifications_disabled | null | def notifications_disabled(project, disabled=True):
"""Temporarily disable email notifications on a project.
"""
orig = project.notifications_disabled
try:
project.notifications_disabled = disabled
yield
finally:
project.notifications_disabled = orig | Temporarily disable email notifications on a project.
| Temporarily disable email notifications on a project. | [
"Temporarily",
"disable",
"email",
"notifications",
"on",
"a",
"project",
"."
] | def notifications_disabled(project, disabled=True):
orig = project.notifications_disabled
try:
project.notifications_disabled = disabled
yield
finally:
project.notifications_disabled = orig | [
"def",
"notifications_disabled",
"(",
"project",
",",
"disabled",
"=",
"True",
")",
":",
"orig",
"=",
"project",
".",
"notifications_disabled",
"try",
":",
"project",
".",
"notifications_disabled",
"=",
"disabled",
"yield",
"finally",
":",
"project",
".",
"notif... | Temporarily disable email notifications on a project. | [
"Temporarily",
"disable",
"email",
"notifications",
"on",
"a",
"project",
"."
] | [
"\"\"\"Temporarily disable email notifications on a project.\n\n \"\"\""
] | [
{
"param": "project",
"type": null
},
{
"param": "disabled",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "disabled",
"type": null,
"docstring": null,
"docstring_tok... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | null_contextmanager | null | def null_contextmanager(returning=None, *args, **kw):
"""A no-op contextmanager.
"""
yield returning | A no-op contextmanager.
| A no-op contextmanager. | [
"A",
"no",
"-",
"op",
"contextmanager",
"."
] | def null_contextmanager(returning=None, *args, **kw):
yield returning | [
"def",
"null_contextmanager",
"(",
"returning",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kw",
")",
":",
"yield",
"returning"
] | A no-op contextmanager. | [
"A",
"no",
"-",
"op",
"contextmanager",
"."
] | [
"\"\"\"A no-op contextmanager.\n\n \"\"\""
] | [
{
"param": "returning",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "returning",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | urlopen | <not_specific> | def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
"""Open url, optionally retrying if an error is encountered.
Socket and other IO errors will always be retried if retries > 0.
HTTP errors are retried if the error code is passed in ``codes``.
:param retries: Number of time to... | Open url, optionally retrying if an error is encountered.
Socket and other IO errors will always be retried if retries > 0.
HTTP errors are retried if the error code is passed in ``codes``.
:param retries: Number of time to retry.
:param codes: HTTP error codes that should be retried.
| Open url, optionally retrying if an error is encountered.
Socket and other IO errors will always be retried if retries > 0.
HTTP errors are retried if the error code is passed in ``codes``. | [
"Open",
"url",
"optionally",
"retrying",
"if",
"an",
"error",
"is",
"encountered",
".",
"Socket",
"and",
"other",
"IO",
"errors",
"will",
"always",
"be",
"retried",
"if",
"retries",
">",
"0",
".",
"HTTP",
"errors",
"are",
"retried",
"if",
"the",
"error",
... | def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
attempts = 0
while True:
try:
return urllib2.urlopen(url, timeout=timeout)
except IOError as e:
no_retry = isinstance(e, urllib2.HTTPError) and e.code not in codes
if attempts < retrie... | [
"def",
"urlopen",
"(",
"url",
",",
"retries",
"=",
"3",
",",
"codes",
"=",
"(",
"408",
",",
"500",
",",
"502",
",",
"503",
",",
"504",
")",
",",
"timeout",
"=",
"None",
")",
":",
"attempts",
"=",
"0",
"while",
"True",
":",
"try",
":",
"return",... | Open url, optionally retrying if an error is encountered. | [
"Open",
"url",
"optionally",
"retrying",
"if",
"an",
"error",
"is",
"encountered",
"."
] | [
"\"\"\"Open url, optionally retrying if an error is encountered.\n\n Socket and other IO errors will always be retried if retries > 0.\n HTTP errors are retried if the error code is passed in ``codes``.\n\n :param retries: Number of time to retry.\n :param codes: HTTP error codes that should be retried.... | [
{
"param": "url",
"type": null
},
{
"param": "retries",
"type": null
},
{
"param": "codes",
"type": null
},
{
"param": "timeout",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "retries",
"type": null,
"docstring": "Number of time to retry.",
... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | iter_entry_points | <not_specific> | def iter_entry_points(group, *a, **kw):
"""Yields entry points that have not been disabled in the config.
If ``group`` is "allura" (Allura tool entry points) or one of subgroups
(e.g. "allura.phone"), this function also checks for multiple entry points
with the same name. If there are multiple entry po... | Yields entry points that have not been disabled in the config.
If ``group`` is "allura" (Allura tool entry points) or one of subgroups
(e.g. "allura.phone"), this function also checks for multiple entry points
with the same name. If there are multiple entry points with the same name,
and one of them is... | Yields entry points that have not been disabled in the config.
If ``group`` is "allura" (Allura tool entry points) or one of subgroups
, this function also checks for multiple entry points
with the same name. If there are multiple entry points with the same name,
and one of them is a subclass of the other(s), it will b... | [
"Yields",
"entry",
"points",
"that",
"have",
"not",
"been",
"disabled",
"in",
"the",
"config",
".",
"If",
"`",
"`",
"group",
"`",
"`",
"is",
"\"",
"allura",
"\"",
"(",
"Allura",
"tool",
"entry",
"points",
")",
"or",
"one",
"of",
"subgroups",
"this",
... | def iter_entry_points(group, *a, **kw):
def active_eps():
disabled = aslist(
tg.config.get('disable_entry_points.' + group), sep=',')
return [ep for ep in pkg_resources.iter_entry_points(group, *a, **kw)
if ep.name not in disabled]
def unique_eps(entry_points):
... | [
"def",
"iter_entry_points",
"(",
"group",
",",
"*",
"a",
",",
"**",
"kw",
")",
":",
"def",
"active_eps",
"(",
")",
":",
"disabled",
"=",
"aslist",
"(",
"tg",
".",
"config",
".",
"get",
"(",
"'disable_entry_points.'",
"+",
"group",
")",
",",
"sep",
"=... | Yields entry points that have not been disabled in the config. | [
"Yields",
"entry",
"points",
"that",
"have",
"not",
"been",
"disabled",
"in",
"the",
"config",
"."
] | [
"\"\"\"Yields entry points that have not been disabled in the config.\n\n If ``group`` is \"allura\" (Allura tool entry points) or one of subgroups\n (e.g. \"allura.phone\"), this function also checks for multiple entry points\n with the same name. If there are multiple entry points with the same name,\n ... | [
{
"param": "group",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "group",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | map_jinja_filter | <not_specific> | def map_jinja_filter(ctx, seq, filter_name, *a, **kw):
"""
A Jinja2 filter that applies the named filter with the
given args to the sequence this filter is applied to.
"""
filter_ = get_filter(ctx, filter_name)
return [filter_(value, *a, **kw) for value in seq] |
A Jinja2 filter that applies the named filter with the
given args to the sequence this filter is applied to.
| A Jinja2 filter that applies the named filter with the
given args to the sequence this filter is applied to. | [
"A",
"Jinja2",
"filter",
"that",
"applies",
"the",
"named",
"filter",
"with",
"the",
"given",
"args",
"to",
"the",
"sequence",
"this",
"filter",
"is",
"applied",
"to",
"."
] | def map_jinja_filter(ctx, seq, filter_name, *a, **kw):
filter_ = get_filter(ctx, filter_name)
return [filter_(value, *a, **kw) for value in seq] | [
"def",
"map_jinja_filter",
"(",
"ctx",
",",
"seq",
",",
"filter_name",
",",
"*",
"a",
",",
"**",
"kw",
")",
":",
"filter_",
"=",
"get_filter",
"(",
"ctx",
",",
"filter_name",
")",
"return",
"[",
"filter_",
"(",
"value",
",",
"*",
"a",
",",
"**",
"k... | A Jinja2 filter that applies the named filter with the
given args to the sequence this filter is applied to. | [
"A",
"Jinja2",
"filter",
"that",
"applies",
"the",
"named",
"filter",
"with",
"the",
"given",
"args",
"to",
"the",
"sequence",
"this",
"filter",
"is",
"applied",
"to",
"."
] | [
"\"\"\"\n A Jinja2 filter that applies the named filter with the\n given args to the sequence this filter is applied to.\n \"\"\""
] | [
{
"param": "ctx",
"type": null
},
{
"param": "seq",
"type": null
},
{
"param": "filter_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | auditlog_user | <not_specific> | def auditlog_user(message, *args, **kwargs):
"""
Create an audit log entry for a user, including the IP address
:param str message:
:param user: a :class:`allura.model.auth.User`
"""
from allura import model as M
ip_address = utils.ip_address(request)
message = 'IP Address: {}\n'.format... |
Create an audit log entry for a user, including the IP address
:param str message:
:param user: a :class:`allura.model.auth.User`
| Create an audit log entry for a user, including the IP address | [
"Create",
"an",
"audit",
"log",
"entry",
"for",
"a",
"user",
"including",
"the",
"IP",
"address"
] | def auditlog_user(message, *args, **kwargs):
from allura import model as M
ip_address = utils.ip_address(request)
message = 'IP Address: {}\n'.format(ip_address) + message
if kwargs.get('user') and kwargs['user'] != c.user:
message = 'Done by user: {}\n'.format(c.user.username) + message
ret... | [
"def",
"auditlog_user",
"(",
"message",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"from",
"allura",
"import",
"model",
"as",
"M",
"ip_address",
"=",
"utils",
".",
"ip_address",
"(",
"request",
")",
"message",
"=",
"'IP Address: {}\\n'",
".",
"format... | Create an audit log entry for a user, including the IP address | [
"Create",
"an",
"audit",
"log",
"entry",
"for",
"a",
"user",
"including",
"the",
"IP",
"address"
] | [
"\"\"\"\n Create an audit log entry for a user, including the IP address\n\n :param str message:\n :param user: a :class:`allura.model.auth.User`\n \"\"\""
] | [
{
"param": "message",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": false
}
],
"outlier_params": [
{
"identifier": "user",
"type": null,
... |
93c0d6f4ea03a2cba7b55b7259575deb9aa109d6 | lym/allura-git | Allura/allura/lib/helpers.py | [
"Apache-2.0"
] | Python | rate_limit | null | def rate_limit(cfg_opt, artifact_count, start_date, exception=None):
"""
Check the various config-defined artifact creation rate limits, and if any
are exceeded, raise exception.
"""
if exception is None:
exception = exc.RatelimitError
rate_limits = json.loads(tg.config.get(cfg_opt, '{}'... |
Check the various config-defined artifact creation rate limits, and if any
are exceeded, raise exception.
| Check the various config-defined artifact creation rate limits, and if any
are exceeded, raise exception. | [
"Check",
"the",
"various",
"config",
"-",
"defined",
"artifact",
"creation",
"rate",
"limits",
"and",
"if",
"any",
"are",
"exceeded",
"raise",
"exception",
"."
] | def rate_limit(cfg_opt, artifact_count, start_date, exception=None):
if exception is None:
exception = exc.RatelimitError
rate_limits = json.loads(tg.config.get(cfg_opt, '{}'))
now = datetime.utcnow()
for rate, count in rate_limits.items():
age = now - start_date
age = (age.micro... | [
"def",
"rate_limit",
"(",
"cfg_opt",
",",
"artifact_count",
",",
"start_date",
",",
"exception",
"=",
"None",
")",
":",
"if",
"exception",
"is",
"None",
":",
"exception",
"=",
"exc",
".",
"RatelimitError",
"rate_limits",
"=",
"json",
".",
"loads",
"(",
"tg... | Check the various config-defined artifact creation rate limits, and if any
are exceeded, raise exception. | [
"Check",
"the",
"various",
"config",
"-",
"defined",
"artifact",
"creation",
"rate",
"limits",
"and",
"if",
"any",
"are",
"exceeded",
"raise",
"exception",
"."
] | [
"\"\"\"\n Check the various config-defined artifact creation rate limits, and if any\n are exceeded, raise exception.\n \"\"\""
] | [
{
"param": "cfg_opt",
"type": null
},
{
"param": "artifact_count",
"type": null
},
{
"param": "start_date",
"type": null
},
{
"param": "exception",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfg_opt",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "artifact_count",
"type": null,
"docstring": null,
"docstri... |
dde7a028601e5ba4c2f754e08a96309aa0d2c8a2 | lym/allura-git | ForgeLink/forgelink/link_main.py | [
"Apache-2.0"
] | Python | install | null | def install(self, project):
'Set up any default permissions and roles here'
self.config.options['project_name'] = project.name
super(ForgeLinkApp, self).install(project)
# Setup permissions
role_admin = M.ProjectRole.by_name('Admin')._id
role_anon = M.ProjectRole.anonymou... | Set up any default permissions and roles here | Set up any default permissions and roles here | [
"Set",
"up",
"any",
"default",
"permissions",
"and",
"roles",
"here"
] | def install(self, project):
self.config.options['project_name'] = project.name
super(ForgeLinkApp, self).install(project)
role_admin = M.ProjectRole.by_name('Admin')._id
role_anon = M.ProjectRole.anonymous()._id
self.config.acl = [
M.ACE.allow(role_anon, 'read'),
... | [
"def",
"install",
"(",
"self",
",",
"project",
")",
":",
"self",
".",
"config",
".",
"options",
"[",
"'project_name'",
"]",
"=",
"project",
".",
"name",
"super",
"(",
"ForgeLinkApp",
",",
"self",
")",
".",
"install",
"(",
"project",
")",
"role_admin",
... | Set up any default permissions and roles here | [
"Set",
"up",
"any",
"default",
"permissions",
"and",
"roles",
"here"
] | [
"'Set up any default permissions and roles here'",
"# Setup permissions"
] | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens"... |
2ee9b826df226052a9993253370eab8eba6607ad | lym/allura-git | Allura/allura/lib/search.py | [
"Apache-2.0"
] | Python | search_artifact | <not_specific> | def search_artifact(atype, q, history=False, rows=10, short_timeout=False, filter=None, **kw):
"""Performs SOLR search.
Raises SearchError if SOLR returns an error.
"""
# first, grab an artifact and get the fields that it indexes
a = atype.query.find().first()
if a is None:
return # if... | Performs SOLR search.
Raises SearchError if SOLR returns an error.
| Performs SOLR search.
Raises SearchError if SOLR returns an error. | [
"Performs",
"SOLR",
"search",
".",
"Raises",
"SearchError",
"if",
"SOLR",
"returns",
"an",
"error",
"."
] | def search_artifact(atype, q, history=False, rows=10, short_timeout=False, filter=None, **kw):
a = atype.query.find().first()
if a is None:
return
fields = a.index()
q = atype.translate_query(q, fields)
fq = [
'type_s:%s' % fields['type_s'],
'project_id_s:%s' % c.project._i... | [
"def",
"search_artifact",
"(",
"atype",
",",
"q",
",",
"history",
"=",
"False",
",",
"rows",
"=",
"10",
",",
"short_timeout",
"=",
"False",
",",
"filter",
"=",
"None",
",",
"**",
"kw",
")",
":",
"a",
"=",
"atype",
".",
"query",
".",
"find",
"(",
... | Performs SOLR search. | [
"Performs",
"SOLR",
"search",
"."
] | [
"\"\"\"Performs SOLR search.\n\n Raises SearchError if SOLR returns an error.\n \"\"\"",
"# first, grab an artifact and get the fields that it indexes",
"# if there are no instance of atype, we won't find anything",
"# Now, we'll translate all the fld:",
"# Specific solr syntax for empty fields"
] | [
{
"param": "atype",
"type": null
},
{
"param": "q",
"type": null
},
{
"param": "history",
"type": null
},
{
"param": "rows",
"type": null
},
{
"param": "short_timeout",
"type": null
},
{
"param": "filter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "atype",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
2ee9b826df226052a9993253370eab8eba6607ad | lym/allura-git | Allura/allura/lib/search.py | [
"Apache-2.0"
] | Python | site_admin_search | <not_specific> | def site_admin_search(model, q, field, **kw):
"""Performs SOLR search for a given model.
Raises SearchError if SOLR returns an error.
"""
# first, grab an object and get the fields that it indexes
obj = model.query.find().first()
if obj is None:
return # if there are no objects, we won... | Performs SOLR search for a given model.
Raises SearchError if SOLR returns an error.
| Performs SOLR search for a given model.
Raises SearchError if SOLR returns an error. | [
"Performs",
"SOLR",
"search",
"for",
"a",
"given",
"model",
".",
"Raises",
"SearchError",
"if",
"SOLR",
"returns",
"an",
"error",
"."
] | def site_admin_search(model, q, field, **kw):
obj = model.query.find().first()
if obj is None:
return
fields = obj.index()
if field == '__custom__':
q = obj.translate_query(q, fields)
else:
q = obj.translate_query(u'%s:%s' % (field, q), fields)
fq = [u'type_s:%s' % mode... | [
"def",
"site_admin_search",
"(",
"model",
",",
"q",
",",
"field",
",",
"**",
"kw",
")",
":",
"obj",
"=",
"model",
".",
"query",
".",
"find",
"(",
")",
".",
"first",
"(",
")",
"if",
"obj",
"is",
"None",
":",
"return",
"fields",
"=",
"obj",
".",
... | Performs SOLR search for a given model. | [
"Performs",
"SOLR",
"search",
"for",
"a",
"given",
"model",
"."
] | [
"\"\"\"Performs SOLR search for a given model.\n\n Raises SearchError if SOLR returns an error.\n \"\"\"",
"# first, grab an object and get the fields that it indexes",
"# if there are no objects, we won't find anything",
"# custom query -> query as is",
"# construct query for a specific selected fiel... | [
{
"param": "model",
"type": null
},
{
"param": "q",
"type": null
},
{
"param": "field",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | should_update_index | <not_specific> | def should_update_index(self, old_doc, new_doc):
"""Skip index update if only `num_views` has changed.
Value of `num_views` is updated whenever user loads thread page.
This generates a lot of unnecessary `add_artifacts` tasks.
"""
old_doc.pop('num_views', None)
new_doc.p... | Skip index update if only `num_views` has changed.
Value of `num_views` is updated whenever user loads thread page.
This generates a lot of unnecessary `add_artifacts` tasks.
| Skip index update if only `num_views` has changed.
Value of `num_views` is updated whenever user loads thread page.
This generates a lot of unnecessary `add_artifacts` tasks. | [
"Skip",
"index",
"update",
"if",
"only",
"`",
"num_views",
"`",
"has",
"changed",
".",
"Value",
"of",
"`",
"num_views",
"`",
"is",
"updated",
"whenever",
"user",
"loads",
"thread",
"page",
".",
"This",
"generates",
"a",
"lot",
"of",
"unnecessary",
"`",
"... | def should_update_index(self, old_doc, new_doc):
old_doc.pop('num_views', None)
new_doc.pop('num_views', None)
return old_doc != new_doc | [
"def",
"should_update_index",
"(",
"self",
",",
"old_doc",
",",
"new_doc",
")",
":",
"old_doc",
".",
"pop",
"(",
"'num_views'",
",",
"None",
")",
"new_doc",
".",
"pop",
"(",
"'num_views'",
",",
"None",
")",
"return",
"old_doc",
"!=",
"new_doc"
] | Skip index update if only `num_views` has changed. | [
"Skip",
"index",
"update",
"if",
"only",
"`",
"num_views",
"`",
"has",
"changed",
"."
] | [
"\"\"\"Skip index update if only `num_views` has changed.\n\n Value of `num_views` is updated whenever user loads thread page.\n This generates a lot of unnecessary `add_artifacts` tasks.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "old_doc",
"type": null
},
{
"param": "new_doc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "old_doc",
"type": null,
"docstring": null,
"docstring_tokens"... |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | new | <not_specific> | def new(cls, **props):
'''Creates a new Thread instance, ensuring a unique _id.'''
for i in range(5):
try:
thread = cls(**props)
session(thread).flush(thread)
return thread
except DuplicateKeyError as err:
log.warnin... | Creates a new Thread instance, ensuring a unique _id. | Creates a new Thread instance, ensuring a unique _id. | [
"Creates",
"a",
"new",
"Thread",
"instance",
"ensuring",
"a",
"unique",
"_id",
"."
] | def new(cls, **props):
for i in range(5):
try:
thread = cls(**props)
session(thread).flush(thread)
return thread
except DuplicateKeyError as err:
log.warning(
'Got DuplicateKeyError: attempt #%s, trying a... | [
"def",
"new",
"(",
"cls",
",",
"**",
"props",
")",
":",
"for",
"i",
"in",
"range",
"(",
"5",
")",
":",
"try",
":",
"thread",
"=",
"cls",
"(",
"**",
"props",
")",
"session",
"(",
"thread",
")",
".",
"flush",
"(",
"thread",
")",
"return",
"thread... | Creates a new Thread instance, ensuring a unique _id. | [
"Creates",
"a",
"new",
"Thread",
"instance",
"ensuring",
"a",
"unique",
"_id",
"."
] | [
"'''Creates a new Thread instance, ensuring a unique _id.'''"
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | notify_moderators | null | def notify_moderators(self, post):
''' Notify moderators that a post needs approval [#2963] '''
artifact = self.artifact or self
subject = '[%s:%s] Moderation action required' % (
c.project.shortname, c.app.config.options.mount_point)
author = post.author()
url = self... | Notify moderators that a post needs approval [#2963] | Notify moderators that a post needs approval [#2963] | [
"Notify",
"moderators",
"that",
"a",
"post",
"needs",
"approval",
"[",
"#2963",
"]"
] | def notify_moderators(self, post):
artifact = self.artifact or self
subject = '[%s:%s] Moderation action required' % (
c.project.shortname, c.app.config.options.mount_point)
author = post.author()
url = self.discussion_class().query.get(_id=self.discussion_id).url()
t... | [
"def",
"notify_moderators",
"(",
"self",
",",
"post",
")",
":",
"artifact",
"=",
"self",
".",
"artifact",
"or",
"self",
"subject",
"=",
"'[%s:%s] Moderation action required'",
"%",
"(",
"c",
".",
"project",
".",
"shortname",
",",
"c",
".",
"app",
".",
"con... | Notify moderators that a post needs approval [#2963] | [
"Notify",
"moderators",
"that",
"a",
"post",
"needs",
"approval",
"[",
"#2963",
"]"
] | [
"''' Notify moderators that a post needs approval [#2963] '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "post",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "post",
"type": null,
"docstring": null,
"docstring_tokens": [... |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | has_activity_access | <not_specific> | def has_activity_access(self, perm, user, activity):
"""Return True if user has perm access to this object, otherwise
return False.
For the purposes of activitystreams, we're saying that the user does
not have access to a 'comment' activity unless he also has access to
the artif... | Return True if user has perm access to this object, otherwise
return False.
For the purposes of activitystreams, we're saying that the user does
not have access to a 'comment' activity unless he also has access to
the artifact on which it was posted (if there is one).
| Return True if user has perm access to this object, otherwise
return False.
For the purposes of activitystreams, we're saying that the user does
not have access to a 'comment' activity unless he also has access to
the artifact on which it was posted (if there is one). | [
"Return",
"True",
"if",
"user",
"has",
"perm",
"access",
"to",
"this",
"object",
"otherwise",
"return",
"False",
".",
"For",
"the",
"purposes",
"of",
"activitystreams",
"we",
"'",
"re",
"saying",
"that",
"the",
"user",
"does",
"not",
"have",
"access",
"to"... | def has_activity_access(self, perm, user, activity):
if self.project is None or self.deleted or self.status != 'ok':
return False
artifact_access = True
if self.thread.artifact:
if self.thread.artifact.project is None:
return False
if self.thre... | [
"def",
"has_activity_access",
"(",
"self",
",",
"perm",
",",
"user",
",",
"activity",
")",
":",
"if",
"self",
".",
"project",
"is",
"None",
"or",
"self",
".",
"deleted",
"or",
"self",
".",
"status",
"!=",
"'ok'",
":",
"return",
"False",
"artifact_access"... | Return True if user has perm access to this object, otherwise
return False. | [
"Return",
"True",
"if",
"user",
"has",
"perm",
"access",
"to",
"this",
"object",
"otherwise",
"return",
"False",
"."
] | [
"\"\"\"Return True if user has perm access to this object, otherwise\n return False.\n\n For the purposes of activitystreams, we're saying that the user does\n not have access to a 'comment' activity unless he also has access to\n the artifact on which it was posted (if there is one).\n ... | [
{
"param": "self",
"type": null
},
{
"param": "perm",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "activity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "perm",
"type": null,
"docstring": null,
"docstring_tokens": [... |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | url_paginated | <not_specific> | def url_paginated(self):
'''Return link to the thread with a #target that poins to this comment.
Also handle pagination properly.
'''
if not self.thread: # pragma no cover
return None
limit, p, s = g.handle_paging(None, 0) # get paging limit
if self.query.f... | Return link to the thread with a #target that poins to this comment.
Also handle pagination properly.
| Return link to the thread with a #target that poins to this comment.
Also handle pagination properly. | [
"Return",
"link",
"to",
"the",
"thread",
"with",
"a",
"#target",
"that",
"poins",
"to",
"this",
"comment",
".",
"Also",
"handle",
"pagination",
"properly",
"."
] | def url_paginated(self):
if not self.thread:
return None
limit, p, s = g.handle_paging(None, 0)
if self.query.find(dict(thread_id=self.thread._id)).count() <= limit:
page = 0
else:
posts = self.thread.find_posts()
posts = self.thread.cr... | [
"def",
"url_paginated",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"thread",
":",
"return",
"None",
"limit",
",",
"p",
",",
"s",
"=",
"g",
".",
"handle_paging",
"(",
"None",
",",
"0",
")",
"if",
"self",
".",
"query",
".",
"find",
"(",
"dict... | Return link to the thread with a #target that poins to this comment. | [
"Return",
"link",
"to",
"the",
"thread",
"with",
"a",
"#target",
"that",
"poins",
"to",
"this",
"comment",
"."
] | [
"'''Return link to the thread with a #target that poins to this comment.\n\n Also handle pagination properly.\n '''",
"# pragma no cover",
"# get paging limit",
"# all posts in a single page",
"'''Find the index number of this post in the display order'''",
"# found"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a7642a70dbffacd0f30ca5819906a4ab594a3892 | lym/allura-git | Allura/allura/model/discuss.py | [
"Apache-2.0"
] | Python | find_i | <not_specific> | def find_i(posts):
'''Find the index number of this post in the display order'''
q = []
def traverse(posts):
for p in posts:
if p['post']._id == self._id:
return True # found
... | Find the index number of this post in the display order | Find the index number of this post in the display order | [
"Find",
"the",
"index",
"number",
"of",
"this",
"post",
"in",
"the",
"display",
"order"
] | def find_i(posts):
q = []
def traverse(posts):
for p in posts:
if p['post']._id == self._id:
return True
q.append(p)
if traverse(p['children']):
... | [
"def",
"find_i",
"(",
"posts",
")",
":",
"q",
"=",
"[",
"]",
"def",
"traverse",
"(",
"posts",
")",
":",
"for",
"p",
"in",
"posts",
":",
"if",
"p",
"[",
"'post'",
"]",
".",
"_id",
"==",
"self",
".",
"_id",
":",
"return",
"True",
"q",
".",
"app... | Find the index number of this post in the display order | [
"Find",
"the",
"index",
"number",
"of",
"this",
"post",
"in",
"the",
"display",
"order"
] | [
"'''Find the index number of this post in the display order'''",
"# found"
] | [
{
"param": "posts",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "posts",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6a3f43c7d7d8417615ae94b2f7faf290ab99f09d | lym/allura-git | ForgeImporters/forgeimporters/google/code.py | [
"Apache-2.0"
] | Python | import_tool | <not_specific> | def import_tool(self, project, user, project_name=None, mount_point=None,
mount_label=None, **kw):
""" Import a Google Code repo into a new SVN, Git, or Hg Allura tool.
"""
extractor = GoogleCodeProjectExtractor(project_name, 'source_browse')
repo_type = extractor.ge... | Import a Google Code repo into a new SVN, Git, or Hg Allura tool.
| Import a Google Code repo into a new SVN, Git, or Hg Allura tool. | [
"Import",
"a",
"Google",
"Code",
"repo",
"into",
"a",
"new",
"SVN",
"Git",
"or",
"Hg",
"Allura",
"tool",
"."
] | def import_tool(self, project, user, project_name=None, mount_point=None,
mount_label=None, **kw):
extractor = GoogleCodeProjectExtractor(project_name, 'source_browse')
repo_type = extractor.get_repo_type()
repo_url = get_repo_url(project_name, repo_type)
app = projec... | [
"def",
"import_tool",
"(",
"self",
",",
"project",
",",
"user",
",",
"project_name",
"=",
"None",
",",
"mount_point",
"=",
"None",
",",
"mount_label",
"=",
"None",
",",
"**",
"kw",
")",
":",
"extractor",
"=",
"GoogleCodeProjectExtractor",
"(",
"project_name"... | Import a Google Code repo into a new SVN, Git, or Hg Allura tool. | [
"Import",
"a",
"Google",
"Code",
"repo",
"into",
"a",
"new",
"SVN",
"Git",
"or",
"Hg",
"Allura",
"tool",
"."
] | [
"\"\"\" Import a Google Code repo into a new SVN, Git, or Hg Allura tool.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "project_name",
"type": null
},
{
"param": "mount_point",
"type": null
},
{
"param": "mount_label",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project",
"type": null,
"docstring": null,
"docstring_tokens"... |
955c952b3dece6dcdb059bb4543619c253effae6 | lym/allura-git | Allura/allura/model/auth.py | [
"Apache-2.0"
] | Python | urlencode | <not_specific> | def urlencode(params):
"""
A version of Python's urllib.urlencode() function that can operate on
unicode strings. The parameters are first case to UTF-8 encoded strings and
then encoded as per normal.
"""
return urllib.urlencode([i for i in generate_smart_str(params)]) |
A version of Python's urllib.urlencode() function that can operate on
unicode strings. The parameters are first case to UTF-8 encoded strings and
then encoded as per normal.
| A version of Python's urllib.urlencode() function that can operate on
unicode strings. The parameters are first case to UTF-8 encoded strings and
then encoded as per normal. | [
"A",
"version",
"of",
"Python",
"'",
"s",
"urllib",
".",
"urlencode",
"()",
"function",
"that",
"can",
"operate",
"on",
"unicode",
"strings",
".",
"The",
"parameters",
"are",
"first",
"case",
"to",
"UTF",
"-",
"8",
"encoded",
"strings",
"and",
"then",
"e... | def urlencode(params):
return urllib.urlencode([i for i in generate_smart_str(params)]) | [
"def",
"urlencode",
"(",
"params",
")",
":",
"return",
"urllib",
".",
"urlencode",
"(",
"[",
"i",
"for",
"i",
"in",
"generate_smart_str",
"(",
"params",
")",
"]",
")"
] | A version of Python's urllib.urlencode() function that can operate on
unicode strings. | [
"A",
"version",
"of",
"Python",
"'",
"s",
"urllib",
".",
"urlencode",
"()",
"function",
"that",
"can",
"operate",
"on",
"unicode",
"strings",
"."
] | [
"\"\"\"\n A version of Python's urllib.urlencode() function that can operate on\n unicode strings. The parameters are first case to UTF-8 encoded strings and\n then encoded as per normal.\n \"\"\""
] | [
{
"param": "params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "params",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
955c952b3dece6dcdb059bb4543619c253effae6 | lym/allura-git | Allura/allura/model/auth.py | [
"Apache-2.0"
] | Python | time_to_next_user_message | <not_specific> | def time_to_next_user_message(self):
"""Return a timedelta of the time remaining before this user can send
another user message.
Returns zero if user message can be sent immediately.
"""
if self.can_send_user_message():
return 0
return self.sent_user_message... | Return a timedelta of the time remaining before this user can send
another user message.
Returns zero if user message can be sent immediately.
| Return a timedelta of the time remaining before this user can send
another user message.
Returns zero if user message can be sent immediately. | [
"Return",
"a",
"timedelta",
"of",
"the",
"time",
"remaining",
"before",
"this",
"user",
"can",
"send",
"another",
"user",
"message",
".",
"Returns",
"zero",
"if",
"user",
"message",
"can",
"be",
"sent",
"immediately",
"."
] | def time_to_next_user_message(self):
if self.can_send_user_message():
return 0
return self.sent_user_message_times[0] + \
timedelta(seconds=g.user_message_time_interval) - \
datetime.utcnow() | [
"def",
"time_to_next_user_message",
"(",
"self",
")",
":",
"if",
"self",
".",
"can_send_user_message",
"(",
")",
":",
"return",
"0",
"return",
"self",
".",
"sent_user_message_times",
"[",
"0",
"]",
"+",
"timedelta",
"(",
"seconds",
"=",
"g",
".",
"user_messa... | Return a timedelta of the time remaining before this user can send
another user message. | [
"Return",
"a",
"timedelta",
"of",
"the",
"time",
"remaining",
"before",
"this",
"user",
"can",
"send",
"another",
"user",
"message",
"."
] | [
"\"\"\"Return a timedelta of the time remaining before this user can send\n another user message.\n\n Returns zero if user message can be sent immediately.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
955c952b3dece6dcdb059bb4543619c253effae6 | lym/allura-git | Allura/allura/model/auth.py | [
"Apache-2.0"
] | Python | url | <not_specific> | def url(self):
'''
Return the URL (relative to root domain) for this user's user-project.
This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine the proper user-project name
'''
return '/%s/' % plugin.AuthenticationProvider.get(... |
Return the URL (relative to root domain) for this user's user-project.
This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine the proper user-project name
| Return the URL (relative to root domain) for this user's user-project.
This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine the proper user-project name | [
"Return",
"the",
"URL",
"(",
"relative",
"to",
"root",
"domain",
")",
"for",
"this",
"user",
"'",
"s",
"user",
"-",
"project",
".",
"This",
"includes",
"any",
"special",
"handling",
"via",
"the",
":",
"class",
":",
"`",
"~allura",
".",
"lib",
".",
"p... | def url(self):
return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self) | [
"def",
"url",
"(",
"self",
")",
":",
"return",
"'/%s/'",
"%",
"plugin",
".",
"AuthenticationProvider",
".",
"get",
"(",
"request",
")",
".",
"user_project_shortname",
"(",
"self",
")"
] | Return the URL (relative to root domain) for this user's user-project. | [
"Return",
"the",
"URL",
"(",
"relative",
"to",
"root",
"domain",
")",
"for",
"this",
"user",
"'",
"s",
"user",
"-",
"project",
"."
] | [
"'''\n Return the URL (relative to root domain) for this user's user-project.\n This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine the proper user-project name\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
955c952b3dece6dcdb059bb4543619c253effae6 | lym/allura-git | Allura/allura/model/auth.py | [
"Apache-2.0"
] | Python | my_projects_by_role_name | <not_specific> | def my_projects_by_role_name(self, role_name):
"""
Return only projects for which user has
that role.
"""
if self.is_anonymous():
return
reaching_role_ids = list(
g.credentials.user_roles(user_id=self._id).reaching_ids_set)
reaching_roles ... |
Return only projects for which user has
that role.
| Return only projects for which user has
that role. | [
"Return",
"only",
"projects",
"for",
"which",
"user",
"has",
"that",
"role",
"."
] | def my_projects_by_role_name(self, role_name):
if self.is_anonymous():
return
reaching_role_ids = list(
g.credentials.user_roles(user_id=self._id).reaching_ids_set)
reaching_roles = ProjectRole.query.find(
{'_id': {'$in': reaching_role_ids}, 'name': role_name}... | [
"def",
"my_projects_by_role_name",
"(",
"self",
",",
"role_name",
")",
":",
"if",
"self",
".",
"is_anonymous",
"(",
")",
":",
"return",
"reaching_role_ids",
"=",
"list",
"(",
"g",
".",
"credentials",
".",
"user_roles",
"(",
"user_id",
"=",
"self",
".",
"_i... | Return only projects for which user has
that role. | [
"Return",
"only",
"projects",
"for",
"which",
"user",
"has",
"that",
"role",
"."
] | [
"\"\"\"\n Return only projects for which user has\n that role.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "role_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "role_name",
"type": null,
"docstring": null,
"docstring_token... |
43cdf55aa94b0abb5dc52db4aa4e0e8c65178d9a | lym/allura-git | Allura/allura/ext/admin/admin_main.py | [
"Apache-2.0"
] | Python | options_on_install | <not_specific> | def options_on_install(self, tool_name):
"""Renders form fields for options configuration on install"""
tool = [t['app'] for t in AdminApp.installable_tools_for(c.project)
if t['name'].lower() == tool_name.lower()]
if len(tool) == 1:
return {'options': tool[0].options... | Renders form fields for options configuration on install | Renders form fields for options configuration on install | [
"Renders",
"form",
"fields",
"for",
"options",
"configuration",
"on",
"install"
] | def options_on_install(self, tool_name):
tool = [t['app'] for t in AdminApp.installable_tools_for(c.project)
if t['name'].lower() == tool_name.lower()]
if len(tool) == 1:
return {'options': tool[0].options_on_install()}
raise exc.HTTPNotFound | [
"def",
"options_on_install",
"(",
"self",
",",
"tool_name",
")",
":",
"tool",
"=",
"[",
"t",
"[",
"'app'",
"]",
"for",
"t",
"in",
"AdminApp",
".",
"installable_tools_for",
"(",
"c",
".",
"project",
")",
"if",
"t",
"[",
"'name'",
"]",
".",
"lower",
"(... | Renders form fields for options configuration on install | [
"Renders",
"form",
"fields",
"for",
"options",
"configuration",
"on",
"install"
] | [
"\"\"\"Renders form fields for options configuration on install\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tool_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tool_name",
"type": null,
"docstring": null,
"docstring_token... |
43cdf55aa94b0abb5dc52db4aa4e0e8c65178d9a | lym/allura-git | Allura/allura/ext/admin/admin_main.py | [
"Apache-2.0"
] | Python | export | <not_specific> | def export(self, tools=None, send_email=False, **kw):
"""
Initiate a bulk export of the project data.
Must be given a list of tool mount points to include in the export.
The list can either be comma-separated or a repeated param, e.g.,
`export?tools=tickets&tools=discussion`.
... |
Initiate a bulk export of the project data.
Must be given a list of tool mount points to include in the export.
The list can either be comma-separated or a repeated param, e.g.,
`export?tools=tickets&tools=discussion`.
If the tools are not provided, an invalid mount point is l... | Initiate a bulk export of the project data.
Must be given a list of tool mount points to include in the export.
The list can either be comma-separated or a repeated param, e.g.,
`export?tools=tickets&tools=discussion`.
If the tools are not provided, an invalid mount point is listed, or
there is some other problems wit... | [
"Initiate",
"a",
"bulk",
"export",
"of",
"the",
"project",
"data",
".",
"Must",
"be",
"given",
"a",
"list",
"of",
"tool",
"mount",
"points",
"to",
"include",
"in",
"the",
"export",
".",
"The",
"list",
"can",
"either",
"be",
"comma",
"-",
"separated",
"... | def export(self, tools=None, send_email=False, **kw):
if not asbool(config.get('bulk_export_enabled', True)):
raise exc.HTTPNotFound()
if not tools:
raise exc.HTTPBadRequest(
'Must give at least one tool mount point to export')
tools = aslist(tools, ',')
... | [
"def",
"export",
"(",
"self",
",",
"tools",
"=",
"None",
",",
"send_email",
"=",
"False",
",",
"**",
"kw",
")",
":",
"if",
"not",
"asbool",
"(",
"config",
".",
"get",
"(",
"'bulk_export_enabled'",
",",
"True",
")",
")",
":",
"raise",
"exc",
".",
"H... | Initiate a bulk export of the project data. | [
"Initiate",
"a",
"bulk",
"export",
"of",
"the",
"project",
"data",
"."
] | [
"\"\"\"\n Initiate a bulk export of the project data.\n\n Must be given a list of tool mount points to include in the export.\n The list can either be comma-separated or a repeated param, e.g.,\n `export?tools=tickets&tools=discussion`.\n\n If the tools are not provided, an invali... | [
{
"param": "self",
"type": null
},
{
"param": "tools",
"type": null
},
{
"param": "send_email",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tools",
"type": null,
"docstring": null,
"docstring_tokens": ... |
b26a23cc6059532ce802585d6026da14dcfd6e49 | lym/allura-git | Allura/allura/lib/security.py | [
"Apache-2.0"
] | Python | load_user_roles | <not_specific> | def load_user_roles(self, user_id, *project_ids):
'''Load the credentials with all user roles for a set of projects'''
# Don't reload roles
project_ids = [
pid for pid in project_ids if self.users.get((user_id, pid)) is None]
if not project_ids:
return
if ... | Load the credentials with all user roles for a set of projects | Load the credentials with all user roles for a set of projects | [
"Load",
"the",
"credentials",
"with",
"all",
"user",
"roles",
"for",
"a",
"set",
"of",
"projects"
] | def load_user_roles(self, user_id, *project_ids):
project_ids = [
pid for pid in project_ids if self.users.get((user_id, pid)) is None]
if not project_ids:
return
if user_id is None:
q = self.project_role.find({
'user_id': None,
... | [
"def",
"load_user_roles",
"(",
"self",
",",
"user_id",
",",
"*",
"project_ids",
")",
":",
"project_ids",
"=",
"[",
"pid",
"for",
"pid",
"in",
"project_ids",
"if",
"self",
".",
"users",
".",
"get",
"(",
"(",
"user_id",
",",
"pid",
")",
")",
"is",
"Non... | Load the credentials with all user roles for a set of projects | [
"Load",
"the",
"credentials",
"with",
"all",
"user",
"roles",
"for",
"a",
"set",
"of",
"projects"
] | [
"'''Load the credentials with all user roles for a set of projects'''",
"# Don't reload roles"
] | [
{
"param": "self",
"type": null
},
{
"param": "user_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user_id",
"type": null,
"docstring": null,
"docstring_tokens"... |
b26a23cc6059532ce802585d6026da14dcfd6e49 | lym/allura-git | Allura/allura/lib/security.py | [
"Apache-2.0"
] | Python | load_project_roles | <not_specific> | def load_project_roles(self, *project_ids):
'''Load the credentials with all user roles for a set of projects'''
# Don't reload roles
project_ids = [
pid for pid in project_ids if self.projects.get(pid) is None]
if not project_ids:
return
q = self.project_... | Load the credentials with all user roles for a set of projects | Load the credentials with all user roles for a set of projects | [
"Load",
"the",
"credentials",
"with",
"all",
"user",
"roles",
"for",
"a",
"set",
"of",
"projects"
] | def load_project_roles(self, *project_ids):
project_ids = [
pid for pid in project_ids if self.projects.get(pid) is None]
if not project_ids:
return
q = self.project_role.find({
'project_id': {'$in': project_ids}})
roles_by_project = dict((pid, []) for... | [
"def",
"load_project_roles",
"(",
"self",
",",
"*",
"project_ids",
")",
":",
"project_ids",
"=",
"[",
"pid",
"for",
"pid",
"in",
"project_ids",
"if",
"self",
".",
"projects",
".",
"get",
"(",
"pid",
")",
"is",
"None",
"]",
"if",
"not",
"project_ids",
"... | Load the credentials with all user roles for a set of projects | [
"Load",
"the",
"credentials",
"with",
"all",
"user",
"roles",
"for",
"a",
"set",
"of",
"projects"
] | [
"'''Load the credentials with all user roles for a set of projects'''",
"# Don't reload roles"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb5cfc589587da9146611c5fe16b95d2d5070b53 | lym/allura-git | Allura/allura/lib/decorators.py | [
"Apache-2.0"
] | Python | _make_extra | <not_specific> | def _make_extra(self, result=None):
'''Create a dict of extra items to be added to a log record
'''
extra = self._extra_proto.copy()
# Save the client IP address
extra.update(client_ip=utils.ip_address(request))
# Save the user info
user = getattr(request, 'user',... | Create a dict of extra items to be added to a log record
| Create a dict of extra items to be added to a log record | [
"Create",
"a",
"dict",
"of",
"extra",
"items",
"to",
"be",
"added",
"to",
"a",
"log",
"record"
] | def _make_extra(self, result=None):
extra = self._extra_proto.copy()
extra.update(client_ip=utils.ip_address(request))
user = getattr(request, 'user', None)
if user:
extra.update(user=user.username,
user_id=user.id)
if (result
... | [
"def",
"_make_extra",
"(",
"self",
",",
"result",
"=",
"None",
")",
":",
"extra",
"=",
"self",
".",
"_extra_proto",
".",
"copy",
"(",
")",
"extra",
".",
"update",
"(",
"client_ip",
"=",
"utils",
".",
"ip_address",
"(",
"request",
")",
")",
"user",
"=... | Create a dict of extra items to be added to a log record | [
"Create",
"a",
"dict",
"of",
"extra",
"items",
"to",
"be",
"added",
"to",
"a",
"log",
"record"
] | [
"'''Create a dict of extra items to be added to a log record\n '''",
"# Save the client IP address",
"# Save the user info",
"# Save the project info",
"# Log the referer cookie if it exists"
] | [
{
"param": "self",
"type": null
},
{
"param": "result",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "result",
"type": null,
"docstring": null,
"docstring_tokens":... |
cb5cfc589587da9146611c5fe16b95d2d5070b53 | lym/allura-git | Allura/allura/lib/decorators.py | [
"Apache-2.0"
] | Python | memoize | <not_specific> | def memoize(func, *args):
"""
Cache the method's result, for the given args
"""
dic = getattr_(func, "memoize_dic", dict)
# memoize_dic is created at the first call
if args in dic:
return dic[args]
else:
result = func(*args)
dic[args] = result
return result |
Cache the method's result, for the given args
| Cache the method's result, for the given args | [
"Cache",
"the",
"method",
"'",
"s",
"result",
"for",
"the",
"given",
"args"
] | def memoize(func, *args):
dic = getattr_(func, "memoize_dic", dict)
if args in dic:
return dic[args]
else:
result = func(*args)
dic[args] = result
return result | [
"def",
"memoize",
"(",
"func",
",",
"*",
"args",
")",
":",
"dic",
"=",
"getattr_",
"(",
"func",
",",
"\"memoize_dic\"",
",",
"dict",
")",
"if",
"args",
"in",
"dic",
":",
"return",
"dic",
"[",
"args",
"]",
"else",
":",
"result",
"=",
"func",
"(",
... | Cache the method's result, for the given args | [
"Cache",
"the",
"method",
"'",
"s",
"result",
"for",
"the",
"given",
"args"
] | [
"\"\"\"\n Cache the method's result, for the given args\n \"\"\"",
"# memoize_dic is created at the first call"
] | [
{
"param": "func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af1dea10826479d3dacbf770116224319a149220 | lym/allura-git | Allura/allura/model/filesystem.py | [
"Apache-2.0"
] | Python | serve | <not_specific> | def serve(self, embed=True):
'''Sets the response headers and serves as a wsgi iter'''
gridfs_file = self.rfile()
return utils.serve_file(gridfs_file, self.filename, self.content_type,
last_modified=self._id.generation_time,
size=gr... | Sets the response headers and serves as a wsgi iter | Sets the response headers and serves as a wsgi iter | [
"Sets",
"the",
"response",
"headers",
"and",
"serves",
"as",
"a",
"wsgi",
"iter"
] | def serve(self, embed=True):
gridfs_file = self.rfile()
return utils.serve_file(gridfs_file, self.filename, self.content_type,
last_modified=self._id.generation_time,
size=gridfs_file.length,
embed=embed) | [
"def",
"serve",
"(",
"self",
",",
"embed",
"=",
"True",
")",
":",
"gridfs_file",
"=",
"self",
".",
"rfile",
"(",
")",
"return",
"utils",
".",
"serve_file",
"(",
"gridfs_file",
",",
"self",
".",
"filename",
",",
"self",
".",
"content_type",
",",
"last_m... | Sets the response headers and serves as a wsgi iter | [
"Sets",
"the",
"response",
"headers",
"and",
"serves",
"as",
"a",
"wsgi",
"iter"
] | [
"'''Sets the response headers and serves as a wsgi iter'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "embed",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "embed",
"type": null,
"docstring": null,
"docstring_tokens": ... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | url_for_commit | <not_specific> | def url_for_commit(self, commit, url_type='ci'):
'return an URL, given either a commit or object id'
if isinstance(commit, basestring):
object_id = commit
else:
object_id = commit._id
if '/' in object_id:
object_id = os.path.join(
obje... | return an URL, given either a commit or object id | return an URL, given either a commit or object id | [
"return",
"an",
"URL",
"given",
"either",
"a",
"commit",
"or",
"object",
"id"
] | def url_for_commit(self, commit, url_type='ci'):
if isinstance(commit, basestring):
object_id = commit
else:
object_id = commit._id
if '/' in object_id:
object_id = os.path.join(
object_id, self._repo.app.END_OF_REF_ESCAPE)
return os.pa... | [
"def",
"url_for_commit",
"(",
"self",
",",
"commit",
",",
"url_type",
"=",
"'ci'",
")",
":",
"if",
"isinstance",
"(",
"commit",
",",
"basestring",
")",
":",
"object_id",
"=",
"commit",
"else",
":",
"object_id",
"=",
"commit",
".",
"_id",
"if",
"'/'",
"... | return an URL, given either a commit or object id | [
"return",
"an",
"URL",
"given",
"either",
"a",
"commit",
"or",
"object",
"id"
] | [
"'return an URL, given either a commit or object id'"
] | [
{
"param": "self",
"type": null
},
{
"param": "commit",
"type": null
},
{
"param": "url_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commit",
"type": null,
"docstring": null,
"docstring_tokens":... |
75ed2dc409a81cf508323ad109a64e23c4c4fead | lym/allura-git | Allura/allura/model/repository.py | [
"Apache-2.0"
] | Python | paged_diffs | null | def paged_diffs(self, commit_id, start=0, end=None):
"""
Returns files touched by the commit, grouped by status (added, removed,
and changed) and the total number of such files. Paginates according
to :param start: and :param end:.
"""
raise NotImplementedError('paged_di... |
Returns files touched by the commit, grouped by status (added, removed,
and changed) and the total number of such files. Paginates according
to :param start: and :param end:.
| Returns files touched by the commit, grouped by status (added, removed,
and changed) and the total number of such files. Paginates according
to :param start: and :param end:. | [
"Returns",
"files",
"touched",
"by",
"the",
"commit",
"grouped",
"by",
"status",
"(",
"added",
"removed",
"and",
"changed",
")",
"and",
"the",
"total",
"number",
"of",
"such",
"files",
".",
"Paginates",
"according",
"to",
":",
"param",
"start",
":",
"and",... | def paged_diffs(self, commit_id, start=0, end=None):
raise NotImplementedError('paged_diffs') | [
"def",
"paged_diffs",
"(",
"self",
",",
"commit_id",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'paged_diffs'",
")"
] | Returns files touched by the commit, grouped by status (added, removed,
and changed) and the total number of such files. | [
"Returns",
"files",
"touched",
"by",
"the",
"commit",
"grouped",
"by",
"status",
"(",
"added",
"removed",
"and",
"changed",
")",
"and",
"the",
"total",
"number",
"of",
"such",
"files",
"."
] | [
"\"\"\"\n Returns files touched by the commit, grouped by status (added, removed,\n and changed) and the total number of such files. Paginates according\n to :param start: and :param end:.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "commit_id",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commit_id",
"type": null,
"docstring": null,
"docstring_token... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.