partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | scrape_links | function to scrape file links from html response | ctdl/ctdl.py | def scrape_links(html, engine):
"""
function to scrape file links from html response
"""
soup = BeautifulSoup(html, 'lxml')
links = []
if engine == 'd':
results = soup.findAll('a', {'class': 'result__a'})
for result in results:
link = result.get('href')[15:]
link = link.replace('/blob/', '/raw/')
li... | def scrape_links(html, engine):
"""
function to scrape file links from html response
"""
soup = BeautifulSoup(html, 'lxml')
links = []
if engine == 'd':
results = soup.findAll('a', {'class': 'result__a'})
for result in results:
link = result.get('href')[15:]
link = link.replace('/blob/', '/raw/')
li... | [
"function",
"to",
"scrape",
"file",
"links",
"from",
"html",
"response"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L55-L76 | [
"def",
"scrape_links",
"(",
"html",
",",
"engine",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"html",
",",
"'lxml'",
")",
"links",
"=",
"[",
"]",
"if",
"engine",
"==",
"'d'",
":",
"results",
"=",
"soup",
".",
"findAll",
"(",
"'a'",
",",
"{",
"'cl... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | get_url_nofollow | function to get return code of a url
Credits: http://blog.jasonantman.com/2013/06/python-script-to-check-a-list-of-urls-for-return-code-and-final-return-code-if-redirected/ | ctdl/ctdl.py | def get_url_nofollow(url):
"""
function to get return code of a url
Credits: http://blog.jasonantman.com/2013/06/python-script-to-check-a-list-of-urls-for-return-code-and-final-return-code-if-redirected/
"""
try:
response = urlopen(url)
code = response.getcode()
return code
except HTTPError as e:
return... | def get_url_nofollow(url):
"""
function to get return code of a url
Credits: http://blog.jasonantman.com/2013/06/python-script-to-check-a-list-of-urls-for-return-code-and-final-return-code-if-redirected/
"""
try:
response = urlopen(url)
code = response.getcode()
return code
except HTTPError as e:
return... | [
"function",
"to",
"get",
"return",
"code",
"of",
"a",
"url"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L81-L94 | [
"def",
"get_url_nofollow",
"(",
"url",
")",
":",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
")",
"code",
"=",
"response",
".",
"getcode",
"(",
")",
"return",
"code",
"except",
"HTTPError",
"as",
"e",
":",
"return",
"e",
".",
"code",
"except",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | validate_links | function to validate urls based on http(s) prefix and return code | ctdl/ctdl.py | def validate_links(links):
"""
function to validate urls based on http(s) prefix and return code
"""
valid_links = []
for link in links:
if link[:7] in "http://" or link[:8] in "https://":
valid_links.append(link)
if not valid_links:
print("No files found.")
sys.exit(0)
# checking valid urls for retu... | def validate_links(links):
"""
function to validate urls based on http(s) prefix and return code
"""
valid_links = []
for link in links:
if link[:7] in "http://" or link[:8] in "https://":
valid_links.append(link)
if not valid_links:
print("No files found.")
sys.exit(0)
# checking valid urls for retu... | [
"function",
"to",
"validate",
"urls",
"based",
"on",
"http",
"(",
"s",
")",
"prefix",
"and",
"return",
"code"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L97-L125 | [
"def",
"validate_links",
"(",
"links",
")",
":",
"valid_links",
"=",
"[",
"]",
"for",
"link",
"in",
"links",
":",
"if",
"link",
"[",
":",
"7",
"]",
"in",
"\"http://\"",
"or",
"link",
"[",
":",
"8",
"]",
"in",
"\"https://\"",
":",
"valid_links",
".",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | search | main function to search for links and return valid ones | ctdl/ctdl.py | def search(query, engine='g', site="", file_type = 'pdf', limit = 10):
"""
main function to search for links and return valid ones
"""
if site == "":
search_query = "filetype:{0} {1}".format(file_type, query)
else:
search_query = "site:{0} filetype:{1} {2}".format(site,file_type, query)
headers = {
'User A... | def search(query, engine='g', site="", file_type = 'pdf', limit = 10):
"""
main function to search for links and return valid ones
"""
if site == "":
search_query = "filetype:{0} {1}".format(file_type, query)
else:
search_query = "site:{0} filetype:{1} {2}".format(site,file_type, query)
headers = {
'User A... | [
"main",
"function",
"to",
"search",
"for",
"links",
"and",
"return",
"valid",
"ones"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L128-L158 | [
"def",
"search",
"(",
"query",
",",
"engine",
"=",
"'g'",
",",
"site",
"=",
"\"\"",
",",
"file_type",
"=",
"'pdf'",
",",
"limit",
"=",
"10",
")",
":",
"if",
"site",
"==",
"\"\"",
":",
"search_query",
"=",
"\"filetype:{0} {1}\"",
".",
"format",
"(",
"... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | check_threats | function to check input filetype against threat extensions list | ctdl/ctdl.py | def check_threats(**args):
"""
function to check input filetype against threat extensions list
"""
is_high_threat = False
for val in THREAT_EXTENSIONS.values():
if type(val) == list:
for el in val:
if args['file_type'] == el:
is_high_threat = True
break
else:
if args['file_type'] == val:
... | def check_threats(**args):
"""
function to check input filetype against threat extensions list
"""
is_high_threat = False
for val in THREAT_EXTENSIONS.values():
if type(val) == list:
for el in val:
if args['file_type'] == el:
is_high_threat = True
break
else:
if args['file_type'] == val:
... | [
"function",
"to",
"check",
"input",
"filetype",
"against",
"threat",
"extensions",
"list"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L161-L176 | [
"def",
"check_threats",
"(",
"*",
"*",
"args",
")",
":",
"is_high_threat",
"=",
"False",
"for",
"val",
"in",
"THREAT_EXTENSIONS",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"val",
")",
"==",
"list",
":",
"for",
"el",
"in",
"val",
":",
"if",
"... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | validate_args | function to check if input query is not None
and set missing arguments to default value | ctdl/ctdl.py | def validate_args(**args):
"""
function to check if input query is not None
and set missing arguments to default value
"""
if not args['query']:
print("\nMissing required query argument.")
sys.exit()
for key in DEFAULTS:
if key not in args:
args[key] = DEFAULTS[key]
return args | def validate_args(**args):
"""
function to check if input query is not None
and set missing arguments to default value
"""
if not args['query']:
print("\nMissing required query argument.")
sys.exit()
for key in DEFAULTS:
if key not in args:
args[key] = DEFAULTS[key]
return args | [
"function",
"to",
"check",
"if",
"input",
"query",
"is",
"not",
"None",
"and",
"set",
"missing",
"arguments",
"to",
"default",
"value"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L179-L192 | [
"def",
"validate_args",
"(",
"*",
"*",
"args",
")",
":",
"if",
"not",
"args",
"[",
"'query'",
"]",
":",
"print",
"(",
"\"\\nMissing required query argument.\"",
")",
"sys",
".",
"exit",
"(",
")",
"for",
"key",
"in",
"DEFAULTS",
":",
"if",
"key",
"not",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | download_content | main function to fetch links and download them | ctdl/ctdl.py | def download_content(**args):
"""
main function to fetch links and download them
"""
args = validate_args(**args)
if not args['directory']:
args['directory'] = args['query'].replace(' ', '-')
print("Downloading {0} {1} files on topic {2} from {3} and saving to directory: {4}"
.format(args['limit'], args['fi... | def download_content(**args):
"""
main function to fetch links and download them
"""
args = validate_args(**args)
if not args['directory']:
args['directory'] = args['query'].replace(' ', '-')
print("Downloading {0} {1} files on topic {2} from {3} and saving to directory: {4}"
.format(args['limit'], args['fi... | [
"main",
"function",
"to",
"fetch",
"links",
"and",
"download",
"them"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L195-L213 | [
"def",
"download_content",
"(",
"*",
"*",
"args",
")",
":",
"args",
"=",
"validate_args",
"(",
"*",
"*",
"args",
")",
"if",
"not",
"args",
"[",
"'directory'",
"]",
":",
"args",
"[",
"'directory'",
"]",
"=",
"args",
"[",
"'query'",
"]",
".",
"replace"... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | show_filetypes | function to show valid file extensions | ctdl/ctdl.py | def show_filetypes(extensions):
"""
function to show valid file extensions
"""
for item in extensions.items():
val = item[1]
if type(item[1]) == list:
val = ", ".join(str(x) for x in item[1])
print("{0:4}: {1}".format(val, item[0])) | def show_filetypes(extensions):
"""
function to show valid file extensions
"""
for item in extensions.items():
val = item[1]
if type(item[1]) == list:
val = ", ".join(str(x) for x in item[1])
print("{0:4}: {1}".format(val, item[0])) | [
"function",
"to",
"show",
"valid",
"file",
"extensions"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L216-L224 | [
"def",
"show_filetypes",
"(",
"extensions",
")",
":",
"for",
"item",
"in",
"extensions",
".",
"items",
"(",
")",
":",
"val",
"=",
"item",
"[",
"1",
"]",
"if",
"type",
"(",
"item",
"[",
"1",
"]",
")",
"==",
"list",
":",
"val",
"=",
"\", \"",
".",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | validate_ex | Determine if a python datum is an instance of a schema. | schema_salad/validate.py | def validate_ex(expected_schema, # type: Schema
datum, # type: Any
identifiers=None, # type: List[Text]
strict=False, # type: bool
foreign_properties=None, # type: Set... | def validate_ex(expected_schema, # type: Schema
datum, # type: Any
identifiers=None, # type: List[Text]
strict=False, # type: bool
foreign_properties=None, # type: Set... | [
"Determine",
"if",
"a",
"python",
"datum",
"is",
"an",
"instance",
"of",
"a",
"schema",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/validate.py#L70-L347 | [
"def",
"validate_ex",
"(",
"expected_schema",
",",
"# type: Schema",
"datum",
",",
"# type: Any",
"identifiers",
"=",
"None",
",",
"# type: List[Text]",
"strict",
"=",
"False",
",",
"# type: bool",
"foreign_properties",
"=",
"None",
",",
"# type: Set[Text]",
"raise_ex... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | json_dump | Force use of unicode. | schema_salad/utils.py | def json_dump(obj, # type: Any
fp, # type: IO[str]
**kwargs # type: Any
): # type: (...) -> None
""" Force use of unicode. """
if six.PY2:
kwargs['encoding'] = 'utf-8'
json.dump(convert_to_dict(obj), fp, **kwargs) | def json_dump(obj, # type: Any
fp, # type: IO[str]
**kwargs # type: Any
): # type: (...) -> None
""" Force use of unicode. """
if six.PY2:
kwargs['encoding'] = 'utf-8'
json.dump(convert_to_dict(obj), fp, **kwargs) | [
"Force",
"use",
"of",
"unicode",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L62-L69 | [
"def",
"json_dump",
"(",
"obj",
",",
"# type: Any",
"fp",
",",
"# type: IO[str]",
"*",
"*",
"kwargs",
"# type: Any",
")",
":",
"# type: (...) -> None",
"if",
"six",
".",
"PY2",
":",
"kwargs",
"[",
"'encoding'",
"]",
"=",
"'utf-8'",
"json",
".",
"dump",
"("... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | json_dumps | Force use of unicode. | schema_salad/utils.py | def json_dumps(obj, # type: Any
**kwargs # type: Any
): # type: (...) -> str
""" Force use of unicode. """
if six.PY2:
kwargs['encoding'] = 'utf-8'
return json.dumps(convert_to_dict(obj), **kwargs) | def json_dumps(obj, # type: Any
**kwargs # type: Any
): # type: (...) -> str
""" Force use of unicode. """
if six.PY2:
kwargs['encoding'] = 'utf-8'
return json.dumps(convert_to_dict(obj), **kwargs) | [
"Force",
"use",
"of",
"unicode",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L72-L78 | [
"def",
"json_dumps",
"(",
"obj",
",",
"# type: Any",
"*",
"*",
"kwargs",
"# type: Any",
")",
":",
"# type: (...) -> str",
"if",
"six",
".",
"PY2",
":",
"kwargs",
"[",
"'encoding'",
"]",
"=",
"'utf-8'",
"return",
"json",
".",
"dumps",
"(",
"convert_to_dict",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | codegen | Generate classes with loaders for the given Schema Salad description. | schema_salad/codegen.py | def codegen(lang, # type: str
i, # type: List[Dict[Text, Any]]
schema_metadata, # type: Dict[Text, Any]
loader # type: Loader
): # type: (...) -> None
"""Generate classes with loaders for the given Schema Salad description."""
... | def codegen(lang, # type: str
i, # type: List[Dict[Text, Any]]
schema_metadata, # type: Dict[Text, Any]
loader # type: Loader
): # type: (...) -> None
"""Generate classes with loaders for the given Schema Salad description."""
... | [
"Generate",
"classes",
"with",
"loaders",
"for",
"the",
"given",
"Schema",
"Salad",
"description",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/codegen.py#L17-L111 | [
"def",
"codegen",
"(",
"lang",
",",
"# type: str",
"i",
",",
"# type: List[Dict[Text, Any]]",
"schema_metadata",
",",
"# type: Dict[Text, Any]",
"loader",
"# type: Loader",
")",
":",
"# type: (...) -> None",
"j",
"=",
"schema",
".",
"extend_and_specialize",
"(",
"i",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | VMList.find | Return a list of subset of VM that match the pattern name
@param name (str): the vm name of the virtual machine
@param name (Obj): the vm object that represent the virtual
machine (can be Pro or Smart)
@return (list): the subset containing the serach result. | ArubaCloud/base/vm.py | def find(self, name):
"""
Return a list of subset of VM that match the pattern name
@param name (str): the vm name of the virtual machine
@param name (Obj): the vm object that represent the virtual
machine (can be Pro or Smart)
@return (list): the subse... | def find(self, name):
"""
Return a list of subset of VM that match the pattern name
@param name (str): the vm name of the virtual machine
@param name (Obj): the vm object that represent the virtual
machine (can be Pro or Smart)
@return (list): the subse... | [
"Return",
"a",
"list",
"of",
"subset",
"of",
"VM",
"that",
"match",
"the",
"pattern",
"name"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L6-L24 | [
"def",
"find",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
".",
"__class__",
"is",
"'base.Server.Pro'",
"or",
"name",
".",
"__class__",
"is",
"'base.Server.Smart'",
":",
"# print('DEBUG: matched VM object %s' % name.__class__)",
"pattern",
"=",
"name",
".",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | VM.reinitialize | Reinitialize a VM.
:param admin_password: Administrator password.
:param debug: Flag to enable debug output.
:param ConfigureIPv6: Flag to enable IPv6 on the VM.
:param OSTemplateID: TemplateID to reinitialize the VM with.
:return: True in case of success, otherwise False
... | ArubaCloud/base/vm.py | def reinitialize(self, admin_password=None, debug=False, ConfigureIPv6=False, OSTemplateID=None):
"""
Reinitialize a VM.
:param admin_password: Administrator password.
:param debug: Flag to enable debug output.
:param ConfigureIPv6: Flag to enable IPv6 on the VM.
:param O... | def reinitialize(self, admin_password=None, debug=False, ConfigureIPv6=False, OSTemplateID=None):
"""
Reinitialize a VM.
:param admin_password: Administrator password.
:param debug: Flag to enable debug output.
:param ConfigureIPv6: Flag to enable IPv6 on the VM.
:param O... | [
"Reinitialize",
"a",
"VM",
".",
":",
"param",
"admin_password",
":",
"Administrator",
"password",
".",
":",
"param",
"debug",
":",
"Flag",
"to",
"enable",
"debug",
"output",
".",
":",
"param",
"ConfigureIPv6",
":",
"Flag",
"to",
"enable",
"IPv6",
"on",
"th... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L82-L106 | [
"def",
"reinitialize",
"(",
"self",
",",
"admin_password",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"ConfigureIPv6",
"=",
"False",
",",
"OSTemplateID",
"=",
"None",
")",
":",
"data",
"=",
"dict",
"(",
"AdministratorPassword",
"=",
"admin_password",
",",... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.login | Set the authentication data in the object, and if load is True
(default is True) it also retrieve the ip list and the vm list
in order to build the internal objects list.
@param (str) username: username of the cloud
@param (str) password: password of the cloud
@param (bool) load:... | ArubaCloud/PyArubaAPI.py | def login(self, username, password, load=True):
"""
Set the authentication data in the object, and if load is True
(default is True) it also retrieve the ip list and the vm list
in order to build the internal objects list.
@param (str) username: username of the cloud
@par... | def login(self, username, password, load=True):
"""
Set the authentication data in the object, and if load is True
(default is True) it also retrieve the ip list and the vm list
in order to build the internal objects list.
@param (str) username: username of the cloud
@par... | [
"Set",
"the",
"authentication",
"data",
"in",
"the",
"object",
"and",
"if",
"load",
"is",
"True",
"(",
"default",
"is",
"True",
")",
"it",
"also",
"retrieve",
"the",
"ip",
"list",
"and",
"the",
"vm",
"list",
"in",
"order",
"to",
"build",
"the",
"intern... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L54-L67 | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
",",
"load",
"=",
"True",
")",
":",
"self",
".",
"auth",
"=",
"Auth",
"(",
"username",
",",
"password",
")",
"if",
"load",
"is",
"True",
":",
"self",
".",
"get_ip",
"(",
")",
"self",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.poweroff_server | Poweroff a VM. If possible to pass the VM object or simply the ID
of the VM that we want to turn on.
Args:
server: VM Object that represent the VM to power off,
server_id: Int or Str representing the ID of the VM to power off.
Returns:
return True if json_obj[... | ArubaCloud/PyArubaAPI.py | def poweroff_server(self, server=None, server_id=None):
"""
Poweroff a VM. If possible to pass the VM object or simply the ID
of the VM that we want to turn on.
Args:
server: VM Object that represent the VM to power off,
server_id: Int or Str representing the ID o... | def poweroff_server(self, server=None, server_id=None):
"""
Poweroff a VM. If possible to pass the VM object or simply the ID
of the VM that we want to turn on.
Args:
server: VM Object that represent the VM to power off,
server_id: Int or Str representing the ID o... | [
"Poweroff",
"a",
"VM",
".",
"If",
"possible",
"to",
"pass",
"the",
"VM",
"object",
"or",
"simply",
"the",
"ID",
"of",
"the",
"VM",
"that",
"we",
"want",
"to",
"turn",
"on",
".",
"Args",
":",
"server",
":",
"VM",
"Object",
"that",
"represent",
"the",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L69-L84 | [
"def",
"poweroff_server",
"(",
"self",
",",
"server",
"=",
"None",
",",
"server_id",
"=",
"None",
")",
":",
"sid",
"=",
"server_id",
"if",
"server_id",
"is",
"not",
"None",
"else",
"server",
".",
"sid",
"if",
"sid",
"is",
"None",
":",
"raise",
"Excepti... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.get_hypervisors | Initialize the internal list containing each template available for each
hypervisor.
:return: [bool] True in case of success, otherwise False | ArubaCloud/PyArubaAPI.py | def get_hypervisors(self):
"""
Initialize the internal list containing each template available for each
hypervisor.
:return: [bool] True in case of success, otherwise False
"""
json_scheme = self.gen_def_json_scheme('GetHypervisors')
json_obj = self.call_method_p... | def get_hypervisors(self):
"""
Initialize the internal list containing each template available for each
hypervisor.
:return: [bool] True in case of success, otherwise False
"""
json_scheme = self.gen_def_json_scheme('GetHypervisors')
json_obj = self.call_method_p... | [
"Initialize",
"the",
"internal",
"list",
"containing",
"each",
"template",
"available",
"for",
"each",
"hypervisor",
"."
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L103-L139 | [
"def",
"get_hypervisors",
"(",
"self",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetHypervisors'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetHypervisors'",
",",
"json_scheme",
"=",
"json_scheme",... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.get_servers | Create the list of Server object inside the Datacenter objects.
Build an internal list of VM Objects (pro or smart) as iterator.
:return: bool | ArubaCloud/PyArubaAPI.py | def get_servers(self):
"""
Create the list of Server object inside the Datacenter objects.
Build an internal list of VM Objects (pro or smart) as iterator.
:return: bool
"""
json_scheme = self.gen_def_json_scheme('GetServers')
json_obj = self.call_method_post(meth... | def get_servers(self):
"""
Create the list of Server object inside the Datacenter objects.
Build an internal list of VM Objects (pro or smart) as iterator.
:return: bool
"""
json_scheme = self.gen_def_json_scheme('GetServers')
json_obj = self.call_method_post(meth... | [
"Create",
"the",
"list",
"of",
"Server",
"object",
"inside",
"the",
"Datacenter",
"objects",
".",
"Build",
"an",
"internal",
"list",
"of",
"VM",
"Objects",
"(",
"pro",
"or",
"smart",
")",
"as",
"iterator",
".",
":",
"return",
":",
"bool"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L141-L182 | [
"def",
"get_servers",
"(",
"self",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetServers'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetServers'",
",",
"json_scheme",
"=",
"json_scheme",
")",
"s... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.find_template | Return a list of templates that could have one or more elements.
Args:
name: name of the template to find.
hv: the ID of the hypervisor to search the template in
Returns:
A list of templates object. If hv is None will return all the
templates matching the ... | ArubaCloud/PyArubaAPI.py | def find_template(self, name=None, hv=None):
"""
Return a list of templates that could have one or more elements.
Args:
name: name of the template to find.
hv: the ID of the hypervisor to search the template in
Returns:
A list of templates object. If h... | def find_template(self, name=None, hv=None):
"""
Return a list of templates that could have one or more elements.
Args:
name: name of the template to find.
hv: the ID of the hypervisor to search the template in
Returns:
A list of templates object. If h... | [
"Return",
"a",
"list",
"of",
"templates",
"that",
"could",
"have",
"one",
"or",
"more",
"elements",
".",
"Args",
":",
"name",
":",
"name",
"of",
"the",
"template",
"to",
"find",
".",
"hv",
":",
"the",
"ID",
"of",
"the",
"hypervisor",
"to",
"search",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L184-L216 | [
"def",
"find_template",
"(",
"self",
",",
"name",
"=",
"None",
",",
"hv",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"templates",
")",
"<=",
"0",
":",
"self",
".",
"get_hypervisors",
"(",
")",
"if",
"name",
"is",
"not",
"None",
"and",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.purchase_ip | Return an ip object representing a new bought IP
@param debug [Boolean] if true, request and response will be printed
@return (Ip): Ip object | ArubaCloud/PyArubaAPI.py | def purchase_ip(self, debug=False):
"""
Return an ip object representing a new bought IP
@param debug [Boolean] if true, request and response will be printed
@return (Ip): Ip object
"""
json_scheme = self.gen_def_json_scheme('SetPurchaseIpAddress')
json_obj = self... | def purchase_ip(self, debug=False):
"""
Return an ip object representing a new bought IP
@param debug [Boolean] if true, request and response will be printed
@return (Ip): Ip object
"""
json_scheme = self.gen_def_json_scheme('SetPurchaseIpAddress')
json_obj = self... | [
"Return",
"an",
"ip",
"object",
"representing",
"a",
"new",
"bought",
"IP"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L234-L248 | [
"def",
"purchase_ip",
"(",
"self",
",",
"debug",
"=",
"False",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetPurchaseIpAddress'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'SetPurchaseIpAddress'",
"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.purchase_vlan | Purchase a new VLAN.
:param debug: Log the json response if True
:param vlan_name: String representing the name of the vlan (virtual switch)
:return: a Vlan Object representing the vlan created | ArubaCloud/PyArubaAPI.py | def purchase_vlan(self, vlan_name, debug=False):
"""
Purchase a new VLAN.
:param debug: Log the json response if True
:param vlan_name: String representing the name of the vlan (virtual switch)
:return: a Vlan Object representing the vlan created
"""
vlan_name = {... | def purchase_vlan(self, vlan_name, debug=False):
"""
Purchase a new VLAN.
:param debug: Log the json response if True
:param vlan_name: String representing the name of the vlan (virtual switch)
:return: a Vlan Object representing the vlan created
"""
vlan_name = {... | [
"Purchase",
"a",
"new",
"VLAN",
".",
":",
"param",
"debug",
":",
"Log",
"the",
"json",
"response",
"if",
"True",
":",
"param",
"vlan_name",
":",
"String",
"representing",
"the",
"name",
"of",
"the",
"vlan",
"(",
"virtual",
"switch",
")",
":",
"return",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L250-L268 | [
"def",
"purchase_vlan",
"(",
"self",
",",
"vlan_name",
",",
"debug",
"=",
"False",
")",
":",
"vlan_name",
"=",
"{",
"'VLanName'",
":",
"vlan_name",
"}",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetPurchaseVLan'",
",",
"vlan_name",
")",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.remove_vlan | Remove a VLAN
:param vlan_resource_id:
:return: | ArubaCloud/PyArubaAPI.py | def remove_vlan(self, vlan_resource_id):
"""
Remove a VLAN
:param vlan_resource_id:
:return:
"""
vlan_id = {'VLanResourceId': vlan_resource_id}
json_scheme = self.gen_def_json_scheme('SetRemoveVLan', vlan_id)
json_obj = self.call_method_post(method='SetRem... | def remove_vlan(self, vlan_resource_id):
"""
Remove a VLAN
:param vlan_resource_id:
:return:
"""
vlan_id = {'VLanResourceId': vlan_resource_id}
json_scheme = self.gen_def_json_scheme('SetRemoveVLan', vlan_id)
json_obj = self.call_method_post(method='SetRem... | [
"Remove",
"a",
"VLAN",
":",
"param",
"vlan_resource_id",
":",
":",
"return",
":"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L270-L279 | [
"def",
"remove_vlan",
"(",
"self",
",",
"vlan_resource_id",
")",
":",
"vlan_id",
"=",
"{",
"'VLanResourceId'",
":",
"vlan_resource_id",
"}",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetRemoveVLan'",
",",
"vlan_id",
")",
"json_obj",
"=",
"se... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.remove_ip | Delete an Ip from the boughs ip list
@param (str) ip_id: a string representing the resource id of the IP
@return: True if json method had success else False | ArubaCloud/PyArubaAPI.py | def remove_ip(self, ip_id):
"""
Delete an Ip from the boughs ip list
@param (str) ip_id: a string representing the resource id of the IP
@return: True if json method had success else False
"""
ip_id = ' "IpAddressResourceId": %s' % ip_id
json_scheme = self.gen_... | def remove_ip(self, ip_id):
"""
Delete an Ip from the boughs ip list
@param (str) ip_id: a string representing the resource id of the IP
@return: True if json method had success else False
"""
ip_id = ' "IpAddressResourceId": %s' % ip_id
json_scheme = self.gen_... | [
"Delete",
"an",
"Ip",
"from",
"the",
"boughs",
"ip",
"list"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L297-L307 | [
"def",
"remove_ip",
"(",
"self",
",",
"ip_id",
")",
":",
"ip_id",
"=",
"' \"IpAddressResourceId\": %s'",
"%",
"ip_id",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetRemoveIpAddress'",
",",
"ip_id",
")",
"json_obj",
"=",
"self",
".",
"call_... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.get_package_id | Retrieve the smart package id given is English name
@param (str) name: the Aruba Smart package size name, ie: "small", "medium", "large", "extra large".
@return: The package id that depends on the Data center and the size choosen. | ArubaCloud/PyArubaAPI.py | def get_package_id(self, name):
"""
Retrieve the smart package id given is English name
@param (str) name: the Aruba Smart package size name, ie: "small", "medium", "large", "extra large".
@return: The package id that depends on the Data center and the size choosen.
"""
j... | def get_package_id(self, name):
"""
Retrieve the smart package id given is English name
@param (str) name: the Aruba Smart package size name, ie: "small", "medium", "large", "extra large".
@return: The package id that depends on the Data center and the size choosen.
"""
j... | [
"Retrieve",
"the",
"smart",
"package",
"id",
"given",
"is",
"English",
"name"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L309-L323 | [
"def",
"get_package_id",
"(",
"self",
",",
"name",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetPreConfiguredPackages'",
",",
"dict",
"(",
"HypervisorType",
"=",
"4",
")",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CloudInterface.get_ip | Retrieve a complete list of bought ip address related only to PRO Servers.
It create an internal object (Iplist) representing all of the ips object
iterated form the WS.
@param: None
@return: None | ArubaCloud/PyArubaAPI.py | def get_ip(self):
"""
Retrieve a complete list of bought ip address related only to PRO Servers.
It create an internal object (Iplist) representing all of the ips object
iterated form the WS.
@param: None
@return: None
"""
json_scheme = self.gen_def_json_s... | def get_ip(self):
"""
Retrieve a complete list of bought ip address related only to PRO Servers.
It create an internal object (Iplist) representing all of the ips object
iterated form the WS.
@param: None
@return: None
"""
json_scheme = self.gen_def_json_s... | [
"Retrieve",
"a",
"complete",
"list",
"of",
"bought",
"ip",
"address",
"related",
"only",
"to",
"PRO",
"Servers",
".",
"It",
"create",
"an",
"internal",
"object",
"(",
"Iplist",
")",
"representing",
"all",
"of",
"the",
"ips",
"object",
"iterated",
"form",
"... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L325-L341 | [
"def",
"get_ip",
"(",
"self",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetPurchasedIpAddresses'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetPurchasedIpAddresses '",
",",
"json_scheme",
"=",
"jso... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | JsonInterfaceBase.gen_def_json_scheme | Generate the scheme for the json request.
:param req: String representing the name of the method to call
:param method_fields: A dictionary containing the method-specified fields
:rtype : json object representing the method call | ArubaCloud/base/__init__.py | def gen_def_json_scheme(self, req, method_fields=None):
"""
Generate the scheme for the json request.
:param req: String representing the name of the method to call
:param method_fields: A dictionary containing the method-specified fields
:rtype : json object representing the met... | def gen_def_json_scheme(self, req, method_fields=None):
"""
Generate the scheme for the json request.
:param req: String representing the name of the method to call
:param method_fields: A dictionary containing the method-specified fields
:rtype : json object representing the met... | [
"Generate",
"the",
"scheme",
"for",
"the",
"json",
"request",
".",
":",
"param",
"req",
":",
"String",
"representing",
"the",
"name",
"of",
"the",
"method",
"to",
"call",
":",
"param",
"method_fields",
":",
"A",
"dictionary",
"containing",
"the",
"method",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L14-L31 | [
"def",
"gen_def_json_scheme",
"(",
"self",
",",
"req",
",",
"method_fields",
"=",
"None",
")",
":",
"json_dict",
"=",
"dict",
"(",
"ApplicationId",
"=",
"req",
",",
"RequestId",
"=",
"req",
",",
"SessionId",
"=",
"req",
",",
"Password",
"=",
"self",
".",... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | Request._commit | :return: (dict) Response object content | ArubaCloud/base/__init__.py | def _commit(self):
"""
:return: (dict) Response object content
"""
assert self.uri is not None, Exception("BadArgument: uri property cannot be None")
url = '{}/{}'.format(self.uri, self.__class__.__name__)
serialized_json = jsonpickle.encode(self, unpicklable=False, )
... | def _commit(self):
"""
:return: (dict) Response object content
"""
assert self.uri is not None, Exception("BadArgument: uri property cannot be None")
url = '{}/{}'.format(self.uri, self.__class__.__name__)
serialized_json = jsonpickle.encode(self, unpicklable=False, )
... | [
":",
"return",
":",
"(",
"dict",
")",
"Response",
"object",
"content"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L95-L114 | [
"def",
"_commit",
"(",
"self",
")",
":",
"assert",
"self",
".",
"uri",
"is",
"not",
"None",
",",
"Exception",
"(",
"\"BadArgument: uri property cannot be None\"",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"uri",
",",
"self",
".",
"__clas... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | SharedStorage.get | Retrieve the current configured SharedStorages entries
:return: [list] List containing the current SharedStorages entries | ArubaCloud/SharedStorage/SharedStorage.py | def get(self):
"""
Retrieve the current configured SharedStorages entries
:return: [list] List containing the current SharedStorages entries
"""
request = self._call(GetSharedStorages)
response = request.commit()
return response['Value'] | def get(self):
"""
Retrieve the current configured SharedStorages entries
:return: [list] List containing the current SharedStorages entries
"""
request = self._call(GetSharedStorages)
response = request.commit()
return response['Value'] | [
"Retrieve",
"the",
"current",
"configured",
"SharedStorages",
"entries",
":",
"return",
":",
"[",
"list",
"]",
"List",
"containing",
"the",
"current",
"SharedStorages",
"entries"
] | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L13-L20 | [
"def",
"get",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"GetSharedStorages",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return",
"response",
"[",
"'Value'",
"]"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | SharedStorage.purchase_iscsi | :type quantity: int
:type iqn: list[str]
:type name: str
:type protocol: SharedStorageProtocols
:param quantity: Amount of GB
:param iqn: List of IQN represented in string format
:param name: Name of the resource
:param protocol: Protocol to use
:return: | ArubaCloud/SharedStorage/SharedStorage.py | def purchase_iscsi(self, quantity, iqn, name, protocol=SharedStorageProtocolType.ISCSI):
"""
:type quantity: int
:type iqn: list[str]
:type name: str
:type protocol: SharedStorageProtocols
:param quantity: Amount of GB
:param iqn: List of IQN represented in string... | def purchase_iscsi(self, quantity, iqn, name, protocol=SharedStorageProtocolType.ISCSI):
"""
:type quantity: int
:type iqn: list[str]
:type name: str
:type protocol: SharedStorageProtocols
:param quantity: Amount of GB
:param iqn: List of IQN represented in string... | [
":",
"type",
"quantity",
":",
"int",
":",
"type",
"iqn",
":",
"list",
"[",
"str",
"]",
":",
"type",
"name",
":",
"str",
":",
"type",
"protocol",
":",
"SharedStorageProtocols",
":",
"param",
"quantity",
":",
"Amount",
"of",
"GB",
":",
"param",
"iqn",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L22-L40 | [
"def",
"purchase_iscsi",
"(",
"self",
",",
"quantity",
",",
"iqn",
",",
"name",
",",
"protocol",
"=",
"SharedStorageProtocolType",
".",
"ISCSI",
")",
":",
"iqns",
"=",
"[",
"]",
"for",
"_iqn",
"in",
"iqn",
":",
"iqns",
".",
"append",
"(",
"SharedStorageI... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | CrowdServer._get | Wrapper around Requests for GET requests
Returns:
Response:
A Requests Response object | crowd.py | def _get(self, *args, **kwargs):
"""Wrapper around Requests for GET requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.get(*args, **kwargs)
r... | def _get(self, *args, **kwargs):
"""Wrapper around Requests for GET requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.get(*args, **kwargs)
r... | [
"Wrapper",
"around",
"Requests",
"for",
"GET",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L70-L82 | [
"def",
"_get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"get",
"(",
"*"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer._get_xml | Wrapper around Requests for GET XML requests
Returns:
Response:
A Requests Response object | crowd.py | def _get_xml(self, *args, **kwargs):
"""Wrapper around Requests for GET XML requests
Returns:
Response:
A Requests Response object
"""
req = self.session_xml.get(*args, **kwargs)
return req | def _get_xml(self, *args, **kwargs):
"""Wrapper around Requests for GET XML requests
Returns:
Response:
A Requests Response object
"""
req = self.session_xml.get(*args, **kwargs)
return req | [
"Wrapper",
"around",
"Requests",
"for",
"GET",
"XML",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L84-L92 | [
"def",
"_get_xml",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"req",
"=",
"self",
".",
"session_xml",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"req"
] | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer._post | Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object | crowd.py | def _post(self, *args, **kwargs):
"""Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.post(*args, **kwargs)
... | def _post(self, *args, **kwargs):
"""Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.post(*args, **kwargs)
... | [
"Wrapper",
"around",
"Requests",
"for",
"POST",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L94-L106 | [
"def",
"_post",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"post",
"(",
"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer._post_xml | Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object | crowd.py | def _post_xml(self, *args, **kwargs):
"""Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session_xml.post(*args, **kwargs... | def _post_xml(self, *args, **kwargs):
"""Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session_xml.post(*args, **kwargs... | [
"Wrapper",
"around",
"Requests",
"for",
"POST",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L108-L120 | [
"def",
"_post_xml",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session_xml",
".",
"post",
... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer._put | Wrapper around Requests for PUT requests
Returns:
Response:
A Requests Response object | crowd.py | def _put(self, *args, **kwargs):
"""Wrapper around Requests for PUT requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.put(*args, **kwargs)
r... | def _put(self, *args, **kwargs):
"""Wrapper around Requests for PUT requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.put(*args, **kwargs)
r... | [
"Wrapper",
"around",
"Requests",
"for",
"PUT",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L122-L134 | [
"def",
"_put",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"put",
"(",
"*"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer._delete | Wrapper around Requests for DELETE requests
Returns:
Response:
A Requests Response object | crowd.py | def _delete(self, *args, **kwargs):
"""Wrapper around Requests for DELETE requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.delete(*args, **kwargs)
... | def _delete(self, *args, **kwargs):
"""Wrapper around Requests for DELETE requests
Returns:
Response:
A Requests Response object
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
req = self.session.delete(*args, **kwargs)
... | [
"Wrapper",
"around",
"Requests",
"for",
"DELETE",
"requests"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L136-L148 | [
"def",
"_delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"delete",
"(",... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.auth_ping | Test that application can authenticate to Crowd.
Attempts to authenticate the application user against
the Crowd server. In order for user authentication to
work, an application must be able to authenticate.
Returns:
bool:
True if the application authenticat... | crowd.py | def auth_ping(self):
"""Test that application can authenticate to Crowd.
Attempts to authenticate the application user against
the Crowd server. In order for user authentication to
work, an application must be able to authenticate.
Returns:
bool:
Tru... | def auth_ping(self):
"""Test that application can authenticate to Crowd.
Attempts to authenticate the application user against
the Crowd server. In order for user authentication to
work, an application must be able to authenticate.
Returns:
bool:
Tru... | [
"Test",
"that",
"application",
"can",
"authenticate",
"to",
"Crowd",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L150-L171 | [
"def",
"auth_ping",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"rest_url",
"+",
"\"/non-existent/location\"",
"response",
"=",
"self",
".",
"_get",
"(",
"url",
")",
"if",
"response",
".",
"status_code",
"==",
"401",
":",
"return",
"False",
"elif",
"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.auth_user | Authenticate a user account against the Crowd server.
Attempts to authenticate the user against the Crowd server.
Args:
username: The account username.
password: The account password.
Returns:
dict:
A dict mapping of user attributes if the ... | crowd.py | def auth_user(self, username, password):
"""Authenticate a user account against the Crowd server.
Attempts to authenticate the user against the Crowd server.
Args:
username: The account username.
password: The account password.
Returns:
dict:
... | def auth_user(self, username, password):
"""Authenticate a user account against the Crowd server.
Attempts to authenticate the user against the Crowd server.
Args:
username: The account username.
password: The account password.
Returns:
dict:
... | [
"Authenticate",
"a",
"user",
"account",
"against",
"the",
"Crowd",
"server",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L173-L201 | [
"def",
"auth_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
"\"/authentication\"",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"value\"",
":",
"password",
... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.get_session | Create a session for a user.
Attempts to create a user session on the Crowd server.
Args:
username: The account username.
password: The account password.
remote:
The remote address of the user. This can be used
to create multiple co... | crowd.py | def get_session(self, username, password, remote="127.0.0.1", proxy=None):
"""Create a session for a user.
Attempts to create a user session on the Crowd server.
Args:
username: The account username.
password: The account password.
remote:
... | def get_session(self, username, password, remote="127.0.0.1", proxy=None):
"""Create a session for a user.
Attempts to create a user session on the Crowd server.
Args:
username: The account username.
password: The account password.
remote:
... | [
"Create",
"a",
"session",
"for",
"a",
"user",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L203-L252 | [
"def",
"get_session",
"(",
"self",
",",
"username",
",",
"password",
",",
"remote",
"=",
"\"127.0.0.1\"",
",",
"proxy",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"username\"",
":",
"username",
",",
"\"password\"",
":",
"password",
",",
"\"validation-facto... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.validate_session | Validate a session token.
Validate a previously acquired session token against the
Crowd server. This may be a token provided by a user from
a http cookie or by some other means.
Args:
token: The session token.
remote: The remote address of the user.
... | crowd.py | def validate_session(self, token, remote="127.0.0.1", proxy=None):
"""Validate a session token.
Validate a previously acquired session token against the
Crowd server. This may be a token provided by a user from
a http cookie or by some other means.
Args:
token: The ... | def validate_session(self, token, remote="127.0.0.1", proxy=None):
"""Validate a session token.
Validate a previously acquired session token against the
Crowd server. This may be a token provided by a user from
a http cookie or by some other means.
Args:
token: The ... | [
"Validate",
"a",
"session",
"token",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L254-L295 | [
"def",
"validate_session",
"(",
"self",
",",
"token",
",",
"remote",
"=",
"\"127.0.0.1\"",
",",
"proxy",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"validationFactors\"",
":",
"[",
"{",
"\"name\"",
":",
"\"remote_address\"",
",",
"\"value\"",
":",
"remote"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.terminate_session | Terminates the session token, effectively logging out the user
from all crowd-enabled services.
Args:
token: The session token.
Returns:
True: If session terminated
None: If session termination failed | crowd.py | def terminate_session(self, token):
"""Terminates the session token, effectively logging out the user
from all crowd-enabled services.
Args:
token: The session token.
Returns:
True: If session terminated
None: If session termination failed
"... | def terminate_session(self, token):
"""Terminates the session token, effectively logging out the user
from all crowd-enabled services.
Args:
token: The session token.
Returns:
True: If session terminated
None: If session termination failed
"... | [
"Terminates",
"the",
"session",
"token",
"effectively",
"logging",
"out",
"the",
"user",
"from",
"all",
"crowd",
"-",
"enabled",
"services",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L297-L319 | [
"def",
"terminate_session",
"(",
"self",
",",
"token",
")",
":",
"url",
"=",
"self",
".",
"rest_url",
"+",
"\"/session/%s\"",
"%",
"token",
"response",
"=",
"self",
".",
"_delete",
"(",
"url",
")",
"# For consistency between methods use None rather than False",
"#... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.add_user | Add a user to the directory
Args:
username: The account username
raise_on_error: optional (default: False)
**kwargs: key-value pairs:
password: mandatory
email: mandatory
first_name: optional
... | crowd.py | def add_user(self, username, raise_on_error=False, **kwargs):
"""Add a user to the directory
Args:
username: The account username
raise_on_error: optional (default: False)
**kwargs: key-value pairs:
password: mandatory
... | def add_user(self, username, raise_on_error=False, **kwargs):
"""Add a user to the directory
Args:
username: The account username
raise_on_error: optional (default: False)
**kwargs: key-value pairs:
password: mandatory
... | [
"Add",
"a",
"user",
"to",
"the",
"directory"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L321-L380 | [
"def",
"add_user",
"(",
"self",
",",
"username",
",",
"raise_on_error",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check that mandatory elements have been provided",
"if",
"'password'",
"not",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"missing pa... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.get_user | Retrieve information about a user
Returns:
dict: User information
None: If no user or failure occurred | crowd.py | def get_user(self, username):
"""Retrieve information about a user
Returns:
dict: User information
None: If no user or failure occurred
"""
response = self._get(self.rest_url + "/user",
params={"username": username,
... | def get_user(self, username):
"""Retrieve information about a user
Returns:
dict: User information
None: If no user or failure occurred
"""
response = self._get(self.rest_url + "/user",
params={"username": username,
... | [
"Retrieve",
"information",
"about",
"a",
"user"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L382-L398 | [
"def",
"get_user",
"(",
"self",
",",
"username",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
",",
"\"expand\"",
":",
"\"attributes\"",
"}",
")",... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.set_active | Set the active state of a user
Args:
username: The account username
active_state: True or False
Returns:
True: If successful
None: If no user or failure occurred | crowd.py | def set_active(self, username, active_state):
"""Set the active state of a user
Args:
username: The account username
active_state: True or False
Returns:
True: If successful
None: If no user or failure occurred
"""
if active_stat... | def set_active(self, username, active_state):
"""Set the active state of a user
Args:
username: The account username
active_state: True or False
Returns:
True: If successful
None: If no user or failure occurred
"""
if active_stat... | [
"Set",
"the",
"active",
"state",
"of",
"a",
"user"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L400-L431 | [
"def",
"set_active",
"(",
"self",
",",
"username",
",",
"active_state",
")",
":",
"if",
"active_state",
"not",
"in",
"(",
"True",
",",
"False",
")",
":",
"raise",
"ValueError",
"(",
"\"active_state must be True or False\"",
")",
"user",
"=",
"self",
".",
"ge... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.set_user_attribute | Set an attribute on a user
:param username: The username on which to set the attribute
:param attribute: The name of the attribute to set
:param value: The value of the attribute to set
:return: True on success, False on failure. | crowd.py | def set_user_attribute(self, username, attribute, value, raise_on_error=False):
"""Set an attribute on a user
:param username: The username on which to set the attribute
:param attribute: The name of the attribute to set
:param value: The value of the attribute to set
:return: T... | def set_user_attribute(self, username, attribute, value, raise_on_error=False):
"""Set an attribute on a user
:param username: The username on which to set the attribute
:param attribute: The name of the attribute to set
:param value: The value of the attribute to set
:return: T... | [
"Set",
"an",
"attribute",
"on",
"a",
"user",
":",
"param",
"username",
":",
"The",
"username",
"on",
"which",
"to",
"set",
"the",
"attribute",
":",
"param",
"attribute",
":",
"The",
"name",
"of",
"the",
"attribute",
"to",
"set",
":",
"param",
"value",
... | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L433-L460 | [
"def",
"set_user_attribute",
"(",
"self",
",",
"username",
",",
"attribute",
",",
"value",
",",
"raise_on_error",
"=",
"False",
")",
":",
"data",
"=",
"{",
"'attributes'",
":",
"[",
"{",
"'name'",
":",
"attribute",
",",
"'values'",
":",
"[",
"value",
"]"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.add_user_to_group | Add a user to a group
:param username: The username to assign to the group
:param groupname: The group name into which to assign the user
:return: True on success, False on failure. | crowd.py | def add_user_to_group(self, username, groupname, raise_on_error=False):
"""Add a user to a group
:param username: The username to assign to the group
:param groupname: The group name into which to assign the user
:return: True on success, False on failure.
"""
data = {
... | def add_user_to_group(self, username, groupname, raise_on_error=False):
"""Add a user to a group
:param username: The username to assign to the group
:param groupname: The group name into which to assign the user
:return: True on success, False on failure.
"""
data = {
... | [
"Add",
"a",
"user",
"to",
"a",
"group",
":",
"param",
"username",
":",
"The",
"username",
"to",
"assign",
"to",
"the",
"group",
":",
"param",
"groupname",
":",
"The",
"group",
"name",
"into",
"which",
"to",
"assign",
"the",
"user",
":",
"return",
":",
... | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L462-L481 | [
"def",
"add_user_to_group",
"(",
"self",
",",
"username",
",",
"groupname",
",",
"raise_on_error",
"=",
"False",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"groupname",
",",
"}",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.remove_user_from_group | Remove a user from a group
Attempts to remove a user from a group
Args
username: The username to remove from the group.
groupname: The group name to be removed from the user.
Returns:
True: Succeeded
False: If unsuccessful | crowd.py | def remove_user_from_group(self, username, groupname, raise_on_error=False):
"""Remove a user from a group
Attempts to remove a user from a group
Args
username: The username to remove from the group.
groupname: The group name to be removed from the user.
Returns:
... | def remove_user_from_group(self, username, groupname, raise_on_error=False):
"""Remove a user from a group
Attempts to remove a user from a group
Args
username: The username to remove from the group.
groupname: The group name to be removed from the user.
Returns:
... | [
"Remove",
"a",
"user",
"from",
"a",
"group"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L483-L505 | [
"def",
"remove_user_from_group",
"(",
"self",
",",
"username",
",",
"groupname",
",",
"raise_on_error",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_delete",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/user/direct\"",
",",
"params",
"=",
"{",
"\"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.change_password | Change new password for a user
Args:
username: The account username.
newpassword: The account new password.
raise_on_error: optional (default: False)
Returns:
True: Succeeded
False: If unsuccessful | crowd.py | def change_password(self, username, newpassword, raise_on_error=False):
"""Change new password for a user
Args:
username: The account username.
newpassword: The account new password.
raise_on_error: optional (default: False)
Returns:
True: Succ... | def change_password(self, username, newpassword, raise_on_error=False):
"""Change new password for a user
Args:
username: The account username.
newpassword: The account new password.
raise_on_error: optional (default: False)
Returns:
True: Succ... | [
"Change",
"new",
"password",
"for",
"a",
"user"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L507-L532 | [
"def",
"change_password",
"(",
"self",
",",
"username",
",",
"newpassword",
",",
"raise_on_error",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_put",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/password\"",
",",
"data",
"=",
"json",
".",
"dumps"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.send_password_reset_link | Sends the user a password reset link (by email)
Args:
username: The account username.
Returns:
True: Succeeded
False: If unsuccessful | crowd.py | def send_password_reset_link(self, username):
"""Sends the user a password reset link (by email)
Args:
username: The account username.
Returns:
True: Succeeded
False: If unsuccessful
"""
response = self._post(self.rest_url + "/user/mail/pass... | def send_password_reset_link(self, username):
"""Sends the user a password reset link (by email)
Args:
username: The account username.
Returns:
True: Succeeded
False: If unsuccessful
"""
response = self._post(self.rest_url + "/user/mail/pass... | [
"Sends",
"the",
"user",
"a",
"password",
"reset",
"link",
"(",
"by",
"email",
")"
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L534-L551 | [
"def",
"send_password_reset_link",
"(",
"self",
",",
"username",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/mail/password\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"respons... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.get_nested_groups | Retrieve a list of all group names that have <username> as a direct or indirect member.
Args:
username: The account username.
Returns:
list:
A list of strings of group names. | crowd.py | def get_nested_groups(self, username):
"""Retrieve a list of all group names that have <username> as a direct or indirect member.
Args:
username: The account username.
Returns:
list:
A list of strings of group names.
"""
response = self... | def get_nested_groups(self, username):
"""Retrieve a list of all group names that have <username> as a direct or indirect member.
Args:
username: The account username.
Returns:
list:
A list of strings of group names.
"""
response = self... | [
"Retrieve",
"a",
"list",
"of",
"all",
"group",
"names",
"that",
"have",
"<username",
">",
"as",
"a",
"direct",
"or",
"indirect",
"member",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L569-L587 | [
"def",
"get_nested_groups",
"(",
"self",
",",
"username",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/group/nested\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"not",
"respons... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.get_nested_group_users | Retrieves a list of all users that directly or indirectly belong to the given groupname.
Args:
groupname: The group name.
Returns:
list:
A list of strings of user names. | crowd.py | def get_nested_group_users(self, groupname):
"""Retrieves a list of all users that directly or indirectly belong to the given groupname.
Args:
groupname: The group name.
Returns:
list:
A list of strings of user names.
"""
response = sel... | def get_nested_group_users(self, groupname):
"""Retrieves a list of all users that directly or indirectly belong to the given groupname.
Args:
groupname: The group name.
Returns:
list:
A list of strings of user names.
"""
response = sel... | [
"Retrieves",
"a",
"list",
"of",
"all",
"users",
"that",
"directly",
"or",
"indirectly",
"belong",
"to",
"the",
"given",
"groupname",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L589-L609 | [
"def",
"get_nested_group_users",
"(",
"self",
",",
"groupname",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/user/nested\"",
",",
"params",
"=",
"{",
"\"groupname\"",
":",
"groupname",
",",
"\"start-index\"",
":"... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.user_exists | Determines if the user exists.
Args:
username: The user name.
Returns:
bool:
True if the user exists in the Crowd application. | crowd.py | def user_exists(self, username):
"""Determines if the user exists.
Args:
username: The user name.
Returns:
bool:
True if the user exists in the Crowd application.
"""
response = self._get(self.rest_url + "/user",
... | def user_exists(self, username):
"""Determines if the user exists.
Args:
username: The user name.
Returns:
bool:
True if the user exists in the Crowd application.
"""
response = self._get(self.rest_url + "/user",
... | [
"Determines",
"if",
"the",
"user",
"exists",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L611-L629 | [
"def",
"user_exists",
"(",
"self",
",",
"username",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"not",
"response",
".",
"ok",
... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.get_memberships | Fetches all group memberships.
Returns:
dict:
key: group name
value: (array of users, array of groups) | crowd.py | def get_memberships(self):
"""Fetches all group memberships.
Returns:
dict:
key: group name
value: (array of users, array of groups)
"""
response = self._get_xml(self.rest_url + "/group/membership")
if not response.ok:
return None
... | def get_memberships(self):
"""Fetches all group memberships.
Returns:
dict:
key: group name
value: (array of users, array of groups)
"""
response = self._get_xml(self.rest_url + "/group/membership")
if not response.ok:
return None
... | [
"Fetches",
"all",
"group",
"memberships",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L631-L653 | [
"def",
"get_memberships",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_get_xml",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/membership\"",
")",
"if",
"not",
"response",
".",
"ok",
":",
"return",
"None",
"xmltree",
"=",
"etree",
".",
"fromstring... | a075e45774dd5baecf0217843cda747084268e32 |
train | CrowdServer.search | Performs a user search using the Crowd search API.
https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-SearchResource
Args:
entity_type: 'user' or 'group'
property_name: eg. 'email', 'name'
search_string: the string to search for... | crowd.py | def search(self, entity_type, property_name, search_string, start_index=0, max_results=99999):
"""Performs a user search using the Crowd search API.
https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-SearchResource
Args:
entity_type: 'user' or ... | def search(self, entity_type, property_name, search_string, start_index=0, max_results=99999):
"""Performs a user search using the Crowd search API.
https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-SearchResource
Args:
entity_type: 'user' or ... | [
"Performs",
"a",
"user",
"search",
"using",
"the",
"Crowd",
"search",
"API",
"."
] | pycontribs/python-crowd | python | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L655-L728 | [
"def",
"search",
"(",
"self",
",",
"entity_type",
",",
"property_name",
",",
"search_string",
",",
"start_index",
"=",
"0",
",",
"max_results",
"=",
"99999",
")",
":",
"params",
"=",
"{",
"\"entity-type\"",
":",
"entity_type",
",",
"\"expand\"",
":",
"entity... | a075e45774dd5baecf0217843cda747084268e32 |
train | Blender.versions | The versions associated with Blender | setup.py | def versions(self) -> List(BlenderVersion):
"""
The versions associated with Blender
"""
return [BlenderVersion(tag) for tag in self.git_repo.tags] + [BlenderVersion(BLENDER_VERSION_MASTER)] | def versions(self) -> List(BlenderVersion):
"""
The versions associated with Blender
"""
return [BlenderVersion(tag) for tag in self.git_repo.tags] + [BlenderVersion(BLENDER_VERSION_MASTER)] | [
"The",
"versions",
"associated",
"with",
"Blender"
] | TylerGubala/bpy-build | python | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L120-L125 | [
"def",
"versions",
"(",
"self",
")",
"->",
"List",
"(",
"BlenderVersion",
")",
":",
"return",
"[",
"BlenderVersion",
"(",
"tag",
")",
"for",
"tag",
"in",
"self",
".",
"git_repo",
".",
"tags",
"]",
"+",
"[",
"BlenderVersion",
"(",
"BLENDER_VERSION_MASTER",
... | 667d41526a346cfa271e26c5d675689c7ab1a254 |
train | InstallCMakeLibs.run | Copy libraries from the bin directory and place them as appropriate | setup.py | def run(self):
"""
Copy libraries from the bin directory and place them as appropriate
"""
self.announce("Moving library files", level=3)
# We have already built the libraries in the previous build_ext step
self.skip_build = True
bin_dir = self.distribution.bi... | def run(self):
"""
Copy libraries from the bin directory and place them as appropriate
"""
self.announce("Moving library files", level=3)
# We have already built the libraries in the previous build_ext step
self.skip_build = True
bin_dir = self.distribution.bi... | [
"Copy",
"libraries",
"from",
"the",
"bin",
"directory",
"and",
"place",
"them",
"as",
"appropriate"
] | TylerGubala/bpy-build | python | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L181-L225 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"announce",
"(",
"\"Moving library files\"",
",",
"level",
"=",
"3",
")",
"# We have already built the libraries in the previous build_ext step",
"self",
".",
"skip_build",
"=",
"True",
"bin_dir",
"=",
"self",
".",
... | 667d41526a346cfa271e26c5d675689c7ab1a254 |
train | InstallBlenderScripts.run | Copy the required directory to the build directory and super().run() | setup.py | def run(self):
"""
Copy the required directory to the build directory and super().run()
"""
self.announce("Moving scripts files", level=3)
self.skip_build = True
bin_dir = self.distribution.bin_dir
scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in
... | def run(self):
"""
Copy the required directory to the build directory and super().run()
"""
self.announce("Moving scripts files", level=3)
self.skip_build = True
bin_dir = self.distribution.bin_dir
scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in
... | [
"Copy",
"the",
"required",
"directory",
"to",
"the",
"build",
"directory",
"and",
"super",
"()",
".",
"run",
"()"
] | TylerGubala/bpy-build | python | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L232-L273 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"announce",
"(",
"\"Moving scripts files\"",
",",
"level",
"=",
"3",
")",
"self",
".",
"skip_build",
"=",
"True",
"bin_dir",
"=",
"self",
".",
"distribution",
".",
"bin_dir",
"scripts_dirs",
"=",
"[",
"os... | 667d41526a346cfa271e26c5d675689c7ab1a254 |
train | BuildCMakeExt.run | Perform build_cmake before doing the 'normal' stuff | setup.py | def run(self):
"""
Perform build_cmake before doing the 'normal' stuff
"""
for extension in self.extensions:
if extension.name == "bpy":
self.build_cmake(extension)
super().run() | def run(self):
"""
Perform build_cmake before doing the 'normal' stuff
"""
for extension in self.extensions:
if extension.name == "bpy":
self.build_cmake(extension)
super().run() | [
"Perform",
"build_cmake",
"before",
"doing",
"the",
"normal",
"stuff"
] | TylerGubala/bpy-build | python | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L280-L291 | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"extension",
"in",
"self",
".",
"extensions",
":",
"if",
"extension",
".",
"name",
"==",
"\"bpy\"",
":",
"self",
".",
"build_cmake",
"(",
"extension",
")",
"super",
"(",
")",
".",
"run",
"(",
")"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 |
train | BuildCMakeExt.build_cmake | The steps required to build the extension | setup.py | def build_cmake(self, extension: Extension):
"""
The steps required to build the extension
"""
# We import the setup_requires modules here because if we import them
# at the top this script will always fail as they won't be present
from git import Repo as GitRepo
... | def build_cmake(self, extension: Extension):
"""
The steps required to build the extension
"""
# We import the setup_requires modules here because if we import them
# at the top this script will always fail as they won't be present
from git import Repo as GitRepo
... | [
"The",
"steps",
"required",
"to",
"build",
"the",
"extension"
] | TylerGubala/bpy-build | python | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L293-L536 | [
"def",
"build_cmake",
"(",
"self",
",",
"extension",
":",
"Extension",
")",
":",
"# We import the setup_requires modules here because if we import them",
"# at the top this script will always fail as they won't be present",
"from",
"git",
"import",
"Repo",
"as",
"GitRepo",
"from"... | 667d41526a346cfa271e26c5d675689c7ab1a254 |
train | ReverseDns.get | :type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses | ArubaCloud/ReverseDns/ReverseDns.py | def get(self, addresses):
"""
:type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses
"""
request =... | def get(self, addresses):
"""
:type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses
"""
request =... | [
":",
"type",
"addresses",
":",
"list",
"[",
"str",
"]",
":",
"param",
"addresses",
":",
"(",
"list",
"[",
"str",
"]",
")",
"List",
"of",
"addresses",
"to",
"retrieve",
"their",
"reverse",
"dns",
"Retrieve",
"the",
"current",
"configured",
"ReverseDns",
"... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L12-L21 | [
"def",
"get",
"(",
"self",
",",
"addresses",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"GetReverseDns",
".",
"GetReverseDns",
",",
"IPs",
"=",
"addresses",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return",
"response",
"[",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | ReverseDns.set | Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:return: (bool) True in case of success, False in case o... | ArubaCloud/ReverseDns/ReverseDns.py | def set(self, address, host_name):
"""
Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:... | def set(self, address, host_name):
"""
Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:... | [
"Assign",
"one",
"or",
"more",
"PTR",
"record",
"to",
"a",
"single",
"IP",
"Address",
":",
"type",
"address",
":",
"str",
":",
"type",
"host_name",
":",
"list",
"[",
"str",
"]",
":",
"param",
"address",
":",
"(",
"str",
")",
"The",
"IP",
"address",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L23-L34 | [
"def",
"set",
"(",
"self",
",",
"address",
",",
"host_name",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"SetEnqueueSetReverseDns",
".",
"SetEnqueueSetReverseDns",
",",
"IP",
"=",
"address",
",",
"Hosts",
"=",
"host_name",
")",
"response",
"=",
"r... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | ReverseDns.reset | Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure | ArubaCloud/ReverseDns/ReverseDns.py | def reset(self, addresses):
"""
Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure
"""
request = self._call(SetEnqueueRese... | def reset(self, addresses):
"""
Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure
"""
request = self._call(SetEnqueueRese... | [
"Remove",
"all",
"PTR",
"records",
"from",
"the",
"given",
"address",
":",
"type",
"addresses",
":",
"List",
"[",
"str",
"]",
":",
"param",
"addresses",
":",
"(",
"List",
"[",
"str",
"]",
")",
"The",
"IP",
"Address",
"to",
"reset",
":",
"return",
":"... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L36-L45 | [
"def",
"reset",
"(",
"self",
",",
"addresses",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"SetEnqueueResetReverseDns",
".",
"SetEnqueueResetReverseDns",
",",
"IPs",
"=",
"addresses",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | LoadBalancer.create | :type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
:type loadBalancerClassOfServiceID: int
:type name: str
:type notificationContacts: NotificationContacts or list[NotificationContact]
:type rules: Rules
:param ... | ArubaCloud/Compute/LoadBalancer/LoadBalancer.py | def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules,
loadBalancerClassOfServiceID=1, *args, **kwargs):
"""
:type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
... | def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules,
loadBalancerClassOfServiceID=1, *args, **kwargs):
"""
:type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
... | [
":",
"type",
"healthCheckNotification",
":",
"bool",
":",
"type",
"instance",
":",
"list",
"[",
"Instance",
"]",
":",
"type",
"ipAddressResourceId",
":",
"list",
"[",
"int",
"]",
":",
"type",
"loadBalancerClassOfServiceID",
":",
"int",
":",
"type",
"name",
"... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L15-L41 | [
"def",
"create",
"(",
"self",
",",
"healthCheckNotification",
",",
"instance",
",",
"ipAddressResourceId",
",",
"name",
",",
"notificationContacts",
",",
"rules",
",",
"loadBalancerClassOfServiceID",
"=",
"1",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | LoadBalancer.get_notifications | Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBalancerRuleID: int
:param startDate: From Date
:param endDate: To Date
:param loadB... | ArubaCloud/Compute/LoadBalancer/LoadBalancer.py | def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID):
"""
Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBal... | def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID):
"""
Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBal... | [
"Get",
"the",
"load",
"balancer",
"notifications",
"for",
"a",
"specific",
"rule",
"within",
"a",
"specifying",
"window",
"time",
"frame",
":",
"type",
"startDate",
":",
"datetime",
":",
"type",
"endDate",
":",
"datetime",
":",
"type",
"loadBalancerID",
":",
... | Arubacloud/pyArubaCloud | python | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L50-L63 | [
"def",
"get_notifications",
"(",
"self",
",",
"startDate",
",",
"endDate",
",",
"loadBalancerID",
",",
"loadBalancerRuleID",
")",
":",
"return",
"self",
".",
"_call",
"(",
"GetLoadBalancerNotifications",
",",
"startDate",
"=",
"startDate",
",",
"endDate",
"=",
"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 |
train | get_oauth_authcfg | Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None | qgiscommons2/network/oauth2.py | def get_oauth_authcfg(authcfg_id=AUTHCFG_ID):
"""Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None"""
# Handle empty strings
if not authcfg_id:
authcfg_id = AUTHCFG_ID
configs = auth_manager().availableAuthMethodConfigs()
if... | def get_oauth_authcfg(authcfg_id=AUTHCFG_ID):
"""Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None"""
# Handle empty strings
if not authcfg_id:
authcfg_id = AUTHCFG_ID
configs = auth_manager().availableAuthMethodConfigs()
if... | [
"Check",
"if",
"the",
"given",
"authcfg_id",
"(",
"or",
"the",
"default",
")",
"exists",
"and",
"if",
"it",
"s",
"valid",
"OAuth2",
"return",
"the",
"configuration",
"or",
"None"
] | boundlessgeo/lib-qgis-commons | python | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L47-L58 | [
"def",
"get_oauth_authcfg",
"(",
"authcfg_id",
"=",
"AUTHCFG_ID",
")",
":",
"# Handle empty strings",
"if",
"not",
"authcfg_id",
":",
"authcfg_id",
"=",
"AUTHCFG_ID",
"configs",
"=",
"auth_manager",
"(",
")",
".",
"availableAuthMethodConfigs",
"(",
")",
"if",
"aut... | d25d13803db08c18632b55d12036e332f006d9ac |
train | setup_oauth | Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure | qgiscommons2/network/oauth2.py | def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME):
"""Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure
"""
cfgjson = {
"accessMethod" : 0,
"apiKey" : "",
"clientId" : "",
"clientSecr... | def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME):
"""Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure
"""
cfgjson = {
"accessMethod" : 0,
"apiKey" : "",
"clientId" : "",
"clientSecr... | [
"Setup",
"oauth",
"configuration",
"to",
"access",
"the",
"BCS",
"API",
"return",
"authcfg_id",
"on",
"success",
"None",
"on",
"failure"
] | boundlessgeo/lib-qgis-commons | python | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L60-L99 | [
"def",
"setup_oauth",
"(",
"username",
",",
"password",
",",
"basemaps_token_uri",
",",
"authcfg_id",
"=",
"AUTHCFG_ID",
",",
"authcfg_name",
"=",
"AUTHCFG_NAME",
")",
":",
"cfgjson",
"=",
"{",
"\"accessMethod\"",
":",
"0",
",",
"\"apiKey\"",
":",
"\"\"",
",",... | d25d13803db08c18632b55d12036e332f006d9ac |
train | execute_search | Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
the connection and query; this is the query that is executed. All
we are doing is logging the input and parsing the output.
search_te... | elasticsearch_django/models.py | def execute_search(
search,
search_terms="",
user=None,
reference="",
save=True,
query_type=SearchQuery.QUERY_TYPE_SEARCH,
):
"""
Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
... | def execute_search(
search,
search_terms="",
user=None,
reference="",
save=True,
query_type=SearchQuery.QUERY_TYPE_SEARCH,
):
"""
Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
... | [
"Create",
"a",
"new",
"SearchQuery",
"instance",
"and",
"execute",
"a",
"search",
"against",
"ES",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L565-L617 | [
"def",
"execute_search",
"(",
"search",
",",
"search_terms",
"=",
"\"\"",
",",
"user",
"=",
"None",
",",
"reference",
"=",
"\"\"",
",",
"save",
"=",
"True",
",",
"query_type",
"=",
"SearchQuery",
".",
"QUERY_TYPE_SEARCH",
",",
")",
":",
"start",
"=",
"ti... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentManagerMixin.in_search_queryset | Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? The simplest (albeit not most efficient) way
is to check if it appear... | elasticsearch_django/models.py | def in_search_queryset(self, instance_id, index="_all"):
"""
Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? ... | def in_search_queryset(self, instance_id, index="_all"):
"""
Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? ... | [
"Return",
"True",
"if",
"an",
"object",
"is",
"part",
"of",
"the",
"search",
"index",
"queryset",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L59-L80 | [
"def",
"in_search_queryset",
"(",
"self",
",",
"instance_id",
",",
"index",
"=",
"\"_all\"",
")",
":",
"return",
"self",
".",
"get_search_queryset",
"(",
"index",
"=",
"index",
")",
".",
"filter",
"(",
"pk",
"=",
"instance_id",
")",
".",
"exists",
"(",
"... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentManagerMixin.from_search_query | Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON and converts that into a queryset
of all the relevant o... | elasticsearch_django/models.py | def from_search_query(self, search_query):
"""
Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON ... | def from_search_query(self, search_query):
"""
Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON ... | [
"Return",
"queryset",
"of",
"objects",
"from",
"SearchQuery",
".",
"results",
"**",
"in",
"order",
"**",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L82-L133 | [
"def",
"from_search_query",
"(",
"self",
",",
"search_query",
")",
":",
"hits",
"=",
"search_query",
".",
"hits",
"score_sql",
"=",
"self",
".",
"_raw_sql",
"(",
"[",
"(",
"h",
"[",
"\"id\"",
"]",
",",
"h",
"[",
"\"score\"",
"]",
"or",
"0",
")",
"for... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentManagerMixin._raw_sql | Prepare SQL statement consisting of a sequence of WHEN .. THEN statements. | elasticsearch_django/models.py | def _raw_sql(self, values):
"""Prepare SQL statement consisting of a sequence of WHEN .. THEN statements."""
if isinstance(self.model._meta.pk, CharField):
when_clauses = " ".join(
[self._when("'{}'".format(x), y) for (x, y) in values]
)
else:
... | def _raw_sql(self, values):
"""Prepare SQL statement consisting of a sequence of WHEN .. THEN statements."""
if isinstance(self.model._meta.pk, CharField):
when_clauses = " ".join(
[self._when("'{}'".format(x), y) for (x, y) in values]
)
else:
... | [
"Prepare",
"SQL",
"statement",
"consisting",
"of",
"a",
"sequence",
"of",
"WHEN",
"..",
"THEN",
"statements",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L138-L150 | [
"def",
"_raw_sql",
"(",
"self",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"model",
".",
"_meta",
".",
"pk",
",",
"CharField",
")",
":",
"when_clauses",
"=",
"\" \"",
".",
"join",
"(",
"[",
"self",
".",
"_when",
"(",
"\"'{}'\"",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.search_document_cache_key | Key used for storing search docs in local cache. | elasticsearch_django/models.py | def search_document_cache_key(self):
"""Key used for storing search docs in local cache."""
return "elasticsearch_django:{}.{}.{}".format(
self._meta.app_label, self._meta.model_name, self.pk
) | def search_document_cache_key(self):
"""Key used for storing search docs in local cache."""
return "elasticsearch_django:{}.{}.{}".format(
self._meta.app_label, self._meta.model_name, self.pk
) | [
"Key",
"used",
"for",
"storing",
"search",
"docs",
"in",
"local",
"cache",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L188-L192 | [
"def",
"search_document_cache_key",
"(",
"self",
")",
":",
"return",
"\"elasticsearch_django:{}.{}.{}\"",
".",
"format",
"(",
"self",
".",
"_meta",
".",
"app_label",
",",
"self",
".",
"_meta",
".",
"model_name",
",",
"self",
".",
"pk",
")"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin._is_field_serializable | Return True if the field can be serialized into a JSON doc. | elasticsearch_django/models.py | def _is_field_serializable(self, field_name):
"""Return True if the field can be serialized into a JSON doc."""
return (
self._meta.get_field(field_name).get_internal_type()
in self.SIMPLE_UPDATE_FIELD_TYPES
) | def _is_field_serializable(self, field_name):
"""Return True if the field can be serialized into a JSON doc."""
return (
self._meta.get_field(field_name).get_internal_type()
in self.SIMPLE_UPDATE_FIELD_TYPES
) | [
"Return",
"True",
"if",
"the",
"field",
"can",
"be",
"serialized",
"into",
"a",
"JSON",
"doc",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L223-L228 | [
"def",
"_is_field_serializable",
"(",
"self",
",",
"field_name",
")",
":",
"return",
"(",
"self",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
".",
"get_internal_type",
"(",
")",
"in",
"self",
".",
"SIMPLE_UPDATE_FIELD_TYPES",
")"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.clean_update_fields | Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in the mapping, but the underlying model field is a
related object, a... | elasticsearch_django/models.py | def clean_update_fields(self, index, update_fields):
"""
Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in t... | def clean_update_fields(self, index, update_fields):
"""
Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in t... | [
"Clean",
"the",
"list",
"of",
"update_fields",
"based",
"on",
"the",
"index",
"being",
"updated",
".",
"\\"
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L230-L255 | [
"def",
"clean_update_fields",
"(",
"self",
",",
"index",
",",
"update_fields",
")",
":",
"search_fields",
"=",
"get_model_index_properties",
"(",
"self",
",",
"index",
")",
"clean_fields",
"=",
"[",
"f",
"for",
"f",
"in",
"update_fields",
"if",
"f",
"in",
"s... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.as_search_document_update | Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenario we need a {property: value} dictionary containing
just the fields we wan... | elasticsearch_django/models.py | def as_search_document_update(self, *, index, update_fields):
"""
Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenari... | def as_search_document_update(self, *, index, update_fields):
"""
Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenari... | [
"Return",
"a",
"partial",
"update",
"document",
"based",
"on",
"which",
"fields",
"have",
"been",
"updated",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L257-L306 | [
"def",
"as_search_document_update",
"(",
"self",
",",
"*",
",",
"index",
",",
"update_fields",
")",
":",
"if",
"UPDATE_STRATEGY",
"==",
"UPDATE_STRATEGY_FULL",
":",
"return",
"self",
".",
"as_search_document",
"(",
"index",
"=",
"index",
")",
"if",
"UPDATE_STRAT... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.as_search_action | Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format for the action specified.
https://www.elastic.co/guide/en... | elasticsearch_django/models.py | def as_search_action(self, *, index, action):
"""
Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format ... | def as_search_action(self, *, index, action):
"""
Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format ... | [
"Return",
"an",
"object",
"as",
"represented",
"in",
"a",
"bulk",
"api",
"operation",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L308-L342 | [
"def",
"as_search_action",
"(",
"self",
",",
"*",
",",
"index",
",",
"action",
")",
":",
"if",
"action",
"not",
"in",
"(",
"\"index\"",
",",
"\"update\"",
",",
"\"delete\"",
")",
":",
"raise",
"ValueError",
"(",
"\"Action must be 'index', 'update' or 'delete'.\"... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.fetch_search_document | Fetch the object's document from a search index by id. | elasticsearch_django/models.py | def fetch_search_document(self, *, index):
"""Fetch the object's document from a search index by id."""
assert self.pk, "Object must have a primary key before being indexed."
client = get_client()
return client.get(index=index, doc_type=self.search_doc_type, id=self.pk) | def fetch_search_document(self, *, index):
"""Fetch the object's document from a search index by id."""
assert self.pk, "Object must have a primary key before being indexed."
client = get_client()
return client.get(index=index, doc_type=self.search_doc_type, id=self.pk) | [
"Fetch",
"the",
"object",
"s",
"document",
"from",
"a",
"search",
"index",
"by",
"id",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L344-L348 | [
"def",
"fetch_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"assert",
"self",
".",
"pk",
",",
"\"Object must have a primary key before being indexed.\"",
"client",
"=",
"get_client",
"(",
")",
"return",
"client",
".",
"get",
"(",
"index",
"=",... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.index_search_document | Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
in the settings, and defaults to 60s. | elasticsearch_django/models.py | def index_search_document(self, *, index):
"""
Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
... | def index_search_document(self, *, index):
"""
Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
... | [
"Create",
"or",
"replace",
"search",
"document",
"in",
"named",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L350-L369 | [
"def",
"index_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"cache_key",
"=",
"self",
".",
"search_document_cache_key",
"new_doc",
"=",
"self",
".",
"as_search_document",
"(",
"index",
"=",
"index",
")",
"cached_doc",
"=",
"cache",
".",
"g... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.update_search_document | Partial update of a document in named index.
Partial updates are invoked via a call to save the document
with 'update_fields'. These fields are passed to the
as_search_document method so that it can build a partial
document. NB we don't just call as_search_document and then
stri... | elasticsearch_django/models.py | def update_search_document(self, *, index, update_fields):
"""
Partial update of a document in named index.
Partial updates are invoked via a call to save the document
with 'update_fields'. These fields are passed to the
as_search_document method so that it can build a partial
... | def update_search_document(self, *, index, update_fields):
"""
Partial update of a document in named index.
Partial updates are invoked via a call to save the document
with 'update_fields'. These fields are passed to the
as_search_document method so that it can build a partial
... | [
"Partial",
"update",
"of",
"a",
"document",
"in",
"named",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L371-L398 | [
"def",
"update_search_document",
"(",
"self",
",",
"*",
",",
"index",
",",
"update_fields",
")",
":",
"doc",
"=",
"self",
".",
"as_search_document_update",
"(",
"index",
"=",
"index",
",",
"update_fields",
"=",
"update_fields",
")",
"if",
"not",
"doc",
":",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchDocumentMixin.delete_search_document | Delete document from named index. | elasticsearch_django/models.py | def delete_search_document(self, *, index):
"""Delete document from named index."""
cache.delete(self.search_document_cache_key)
get_client().delete(index=index, doc_type=self.search_doc_type, id=self.pk) | def delete_search_document(self, *, index):
"""Delete document from named index."""
cache.delete(self.search_document_cache_key)
get_client().delete(index=index, doc_type=self.search_doc_type, id=self.pk) | [
"Delete",
"document",
"from",
"named",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L400-L403 | [
"def",
"delete_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"cache",
".",
"delete",
"(",
"self",
".",
"search_document_cache_key",
")",
"get_client",
"(",
")",
".",
"delete",
"(",
"index",
"=",
"index",
",",
"doc_type",
"=",
"self",
"... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchQuery.execute | Create a new SearchQuery instance and execute a search against ES. | elasticsearch_django/models.py | def execute(cls, search, search_terms="", user=None, reference=None, save=True):
"""Create a new SearchQuery instance and execute a search against ES."""
warnings.warn(
"Pending deprecation - please use `execute_search` function instead.",
PendingDeprecationWarning,
)
... | def execute(cls, search, search_terms="", user=None, reference=None, save=True):
"""Create a new SearchQuery instance and execute a search against ES."""
warnings.warn(
"Pending deprecation - please use `execute_search` function instead.",
PendingDeprecationWarning,
)
... | [
"Create",
"a",
"new",
"SearchQuery",
"instance",
"and",
"execute",
"a",
"search",
"against",
"ES",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L498-L506 | [
"def",
"execute",
"(",
"cls",
",",
"search",
",",
"search_terms",
"=",
"\"\"",
",",
"user",
"=",
"None",
",",
"reference",
"=",
"None",
",",
"save",
"=",
"True",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Pending deprecation - please use `execute_search` funct... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchQuery.save | Save and return the object (for chaining). | elasticsearch_django/models.py | def save(self, **kwargs):
"""Save and return the object (for chaining)."""
if self.search_terms is None:
self.search_terms = ""
super().save(**kwargs)
return self | def save(self, **kwargs):
"""Save and return the object (for chaining)."""
if self.search_terms is None:
self.search_terms = ""
super().save(**kwargs)
return self | [
"Save",
"and",
"return",
"the",
"object",
"(",
"for",
"chaining",
")",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L508-L513 | [
"def",
"save",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"search_terms",
"is",
"None",
":",
"self",
".",
"search_terms",
"=",
"\"\"",
"super",
"(",
")",
".",
"save",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | SearchQuery.page_slice | Return the query from:size tuple (0-based). | elasticsearch_django/models.py | def page_slice(self):
"""Return the query from:size tuple (0-based)."""
return (
None
if self.query is None
else (self.query.get("from", 0), self.query.get("size", 10))
) | def page_slice(self):
"""Return the query from:size tuple (0-based)."""
return (
None
if self.query is None
else (self.query.get("from", 0), self.query.get("size", 10))
) | [
"Return",
"the",
"query",
"from",
":",
"size",
"tuple",
"(",
"0",
"-",
"based",
")",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L541-L547 | [
"def",
"page_slice",
"(",
"self",
")",
":",
"return",
"(",
"None",
"if",
"self",
".",
"query",
"is",
"None",
"else",
"(",
"self",
".",
"query",
".",
"get",
"(",
"\"from\"",
",",
"0",
")",
",",
"self",
".",
"query",
".",
"get",
"(",
"\"size\"",
",... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | setPluginSetting | Sets the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param value: the value to set for the plugin setting
:param namespace: The namespace. If not passed or None, the namespace will be inferred from
the caller method. Normally, ... | qgiscommons2/settings.py | def setPluginSetting(name, value, namespace = None):
'''
Sets the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param value: the value to set for the plugin setting
:param namespace: The namespace. If not passed or None, the ... | def setPluginSetting(name, value, namespace = None):
'''
Sets the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param value: the value to set for the plugin setting
:param namespace: The namespace. If not passed or None, the ... | [
"Sets",
"the",
"value",
"of",
"a",
"plugin",
"setting",
"."
] | boundlessgeo/lib-qgis-commons | python | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L35-L47 | [
"def",
"setPluginSetting",
"(",
"name",
",",
"value",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"namespace",
"or",
"_callerName",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
"]",
"settings",
".",
"setValue",
"(",
"namespace",
... | d25d13803db08c18632b55d12036e332f006d9ac |
train | pluginSetting | Returns the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param namespace: The namespace. If not passed or None, the namespace will be inferred from
the caller method. Normally, this should not be passed, since it suffices to let thi... | qgiscommons2/settings.py | def pluginSetting(name, namespace=None, typ=None):
'''
Returns the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param namespace: The namespace. If not passed or None, the namespace will be inferred from
the caller method. No... | def pluginSetting(name, namespace=None, typ=None):
'''
Returns the value of a plugin setting.
:param name: the name of the setting. It is not the full path, but just the last name of it
:param namespace: The namespace. If not passed or None, the namespace will be inferred from
the caller method. No... | [
"Returns",
"the",
"value",
"of",
"a",
"plugin",
"setting",
"."
] | boundlessgeo/lib-qgis-commons | python | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L50-L88 | [
"def",
"pluginSetting",
"(",
"name",
",",
"namespace",
"=",
"None",
",",
"typ",
"=",
"None",
")",
":",
"def",
"_find_in_cache",
"(",
"name",
",",
"key",
")",
":",
"for",
"setting",
"in",
"_settings",
"[",
"namespace",
"]",
":",
"if",
"setting",
"[",
... | d25d13803db08c18632b55d12036e332f006d9ac |
train | readSettings | Reads the settings corresponding to the plugin from where the method is called.
This function has to be called in the __init__ method of the plugin class.
Settings are stored in a settings.json file in the plugin folder.
Here is an eample of such a file:
[
{"name":"mysetting",
"label": "My set... | qgiscommons2/settings.py | def readSettings(settings_path=None):
global _settings
'''
Reads the settings corresponding to the plugin from where the method is called.
This function has to be called in the __init__ method of the plugin class.
Settings are stored in a settings.json file in the plugin folder.
Here is an eampl... | def readSettings(settings_path=None):
global _settings
'''
Reads the settings corresponding to the plugin from where the method is called.
This function has to be called in the __init__ method of the plugin class.
Settings are stored in a settings.json file in the plugin folder.
Here is an eampl... | [
"Reads",
"the",
"settings",
"corresponding",
"to",
"the",
"plugin",
"from",
"where",
"the",
"method",
"is",
"called",
".",
"This",
"function",
"has",
"to",
"be",
"called",
"in",
"the",
"__init__",
"method",
"of",
"the",
"plugin",
"class",
".",
"Settings",
... | boundlessgeo/lib-qgis-commons | python | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L95-L146 | [
"def",
"readSettings",
"(",
"settings_path",
"=",
"None",
")",
":",
"global",
"_settings",
"namespace",
"=",
"_callerName",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
"]",
"settings_path",
"=",
"settings_path",
"or",
"os",
".",
"path",
".",
"jo... | d25d13803db08c18632b55d12036e332f006d9ac |
train | Command.do_index_command | Delete search index. | elasticsearch_django/management/commands/delete_search_index.py | def do_index_command(self, index, **options):
"""Delete search index."""
if options["interactive"]:
logger.warning("This will permanently delete the index '%s'.", index)
if not self._confirm_action():
logger.warning(
"Aborting deletion of index... | def do_index_command(self, index, **options):
"""Delete search index."""
if options["interactive"]:
logger.warning("This will permanently delete the index '%s'.", index)
if not self._confirm_action():
logger.warning(
"Aborting deletion of index... | [
"Delete",
"search",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/management/commands/delete_search_index.py#L17-L26 | [
"def",
"do_index_command",
"(",
"self",
",",
"index",
",",
"*",
"*",
"options",
")",
":",
"if",
"options",
"[",
"\"interactive\"",
"]",
":",
"logger",
".",
"warning",
"(",
"\"This will permanently delete the index '%s'.\"",
",",
"index",
")",
"if",
"not",
"sel... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | create_index | Create an index and apply mapping if appropriate. | elasticsearch_django/index.py | def create_index(index):
"""Create an index and apply mapping if appropriate."""
logger.info("Creating search index: '%s'", index)
client = get_client()
return client.indices.create(index=index, body=get_index_mapping(index)) | def create_index(index):
"""Create an index and apply mapping if appropriate."""
logger.info("Creating search index: '%s'", index)
client = get_client()
return client.indices.create(index=index, body=get_index_mapping(index)) | [
"Create",
"an",
"index",
"and",
"apply",
"mapping",
"if",
"appropriate",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L10-L14 | [
"def",
"create_index",
"(",
"index",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating search index: '%s'\"",
",",
"index",
")",
"client",
"=",
"get_client",
"(",
")",
"return",
"client",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"index",
",",
"bod... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | update_index | Re-index every document in a named index. | elasticsearch_django/index.py | def update_index(index):
"""Re-index every document in a named index."""
logger.info("Updating search index: '%s'", index)
client = get_client()
responses = []
for model in get_index_models(index):
logger.info("Updating search index model: '%s'", model.search_doc_type)
objects = mode... | def update_index(index):
"""Re-index every document in a named index."""
logger.info("Updating search index: '%s'", index)
client = get_client()
responses = []
for model in get_index_models(index):
logger.info("Updating search index model: '%s'", model.search_doc_type)
objects = mode... | [
"Re",
"-",
"index",
"every",
"document",
"in",
"a",
"named",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L17-L28 | [
"def",
"update_index",
"(",
"index",
")",
":",
"logger",
".",
"info",
"(",
"\"Updating search index: '%s'\"",
",",
"index",
")",
"client",
"=",
"get_client",
"(",
")",
"responses",
"=",
"[",
"]",
"for",
"model",
"in",
"get_index_models",
"(",
"index",
")",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | delete_index | Delete index entirely (removes all documents and mapping). | elasticsearch_django/index.py | def delete_index(index):
"""Delete index entirely (removes all documents and mapping)."""
logger.info("Deleting search index: '%s'", index)
client = get_client()
return client.indices.delete(index=index) | def delete_index(index):
"""Delete index entirely (removes all documents and mapping)."""
logger.info("Deleting search index: '%s'", index)
client = get_client()
return client.indices.delete(index=index) | [
"Delete",
"index",
"entirely",
"(",
"removes",
"all",
"documents",
"and",
"mapping",
")",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L31-L35 | [
"def",
"delete_index",
"(",
"index",
")",
":",
"logger",
".",
"info",
"(",
"\"Deleting search index: '%s'\"",
",",
"index",
")",
"client",
"=",
"get_client",
"(",
")",
"return",
"client",
".",
"indices",
".",
"delete",
"(",
"index",
"=",
"index",
")"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | prune_index | Remove all orphaned documents from an index.
This function works by scanning the remote index, and in each returned
batch of documents looking up whether they appear in the default index
queryset. If they don't (they've been deleted, or no longer fit the qs
filters) then they are deleted from the index... | elasticsearch_django/index.py | def prune_index(index):
"""Remove all orphaned documents from an index.
This function works by scanning the remote index, and in each returned
batch of documents looking up whether they appear in the default index
queryset. If they don't (they've been deleted, or no longer fit the qs
filters) then ... | def prune_index(index):
"""Remove all orphaned documents from an index.
This function works by scanning the remote index, and in each returned
batch of documents looking up whether they appear in the default index
queryset. If they don't (they've been deleted, or no longer fit the qs
filters) then ... | [
"Remove",
"all",
"orphaned",
"documents",
"from",
"an",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L38-L76 | [
"def",
"prune_index",
"(",
"index",
")",
":",
"logger",
".",
"info",
"(",
"\"Pruning missing objects from index '%s'\"",
",",
"index",
")",
"prunes",
"=",
"[",
"]",
"responses",
"=",
"[",
"]",
"client",
"=",
"get_client",
"(",
")",
"for",
"model",
"in",
"g... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _prune_hit | Check whether a document should be pruned.
This method uses the SearchDocumentManagerMixin.in_search_queryset method
to determine whether a 'hit' (search document) should be pruned from an index,
and if so it returns the hit as a Django object(id=hit_id).
Args:
hit: dict object the represents ... | elasticsearch_django/index.py | def _prune_hit(hit, model):
"""
Check whether a document should be pruned.
This method uses the SearchDocumentManagerMixin.in_search_queryset method
to determine whether a 'hit' (search document) should be pruned from an index,
and if so it returns the hit as a Django object(id=hit_id).
Args:
... | def _prune_hit(hit, model):
"""
Check whether a document should be pruned.
This method uses the SearchDocumentManagerMixin.in_search_queryset method
to determine whether a 'hit' (search document) should be pruned from an index,
and if so it returns the hit as a Django object(id=hit_id).
Args:
... | [
"Check",
"whether",
"a",
"document",
"should",
"be",
"pruned",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L79-L116 | [
"def",
"_prune_hit",
"(",
"hit",
",",
"model",
")",
":",
"hit_id",
"=",
"hit",
"[",
"\"_id\"",
"]",
"hit_index",
"=",
"hit",
"[",
"\"_index\"",
"]",
"if",
"model",
".",
"objects",
".",
"in_search_queryset",
"(",
"hit_id",
",",
"index",
"=",
"hit_index",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | scan_index | Yield all documents of model type in an index.
This function calls the elasticsearch.helpers.scan function,
and yields all the documents in the index that match the doc_type
produced by a specific Django model.
Args:
index: string, the name of the index to scan, must be a configured
... | elasticsearch_django/index.py | def scan_index(index, model):
"""
Yield all documents of model type in an index.
This function calls the elasticsearch.helpers.scan function,
and yields all the documents in the index that match the doc_type
produced by a specific Django model.
Args:
index: string, the name of the inde... | def scan_index(index, model):
"""
Yield all documents of model type in an index.
This function calls the elasticsearch.helpers.scan function,
and yields all the documents in the index that match the doc_type
produced by a specific Django model.
Args:
index: string, the name of the inde... | [
"Yield",
"all",
"documents",
"of",
"model",
"type",
"in",
"an",
"index",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L119-L140 | [
"def",
"scan_index",
"(",
"index",
",",
"model",
")",
":",
"# see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html",
"query",
"=",
"{",
"\"query\"",
":",
"{",
"\"type\"",
":",
"{",
"\"value\"",
":",
"model",
".",
"_meta",
".",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | bulk_actions | Yield bulk api 'actions' from a collection of objects.
The output from this method can be fed in to the bulk
api helpers - each document returned by get_documents
is decorated with the appropriate bulk api op_type.
Args:
objects: iterable (queryset, list, ...) of SearchDocumentMixin
... | elasticsearch_django/index.py | def bulk_actions(objects, index, action):
"""
Yield bulk api 'actions' from a collection of objects.
The output from this method can be fed in to the bulk
api helpers - each document returned by get_documents
is decorated with the appropriate bulk api op_type.
Args:
objects: iterable (... | def bulk_actions(objects, index, action):
"""
Yield bulk api 'actions' from a collection of objects.
The output from this method can be fed in to the bulk
api helpers - each document returned by get_documents
is decorated with the appropriate bulk api op_type.
Args:
objects: iterable (... | [
"Yield",
"bulk",
"api",
"actions",
"from",
"a",
"collection",
"of",
"objects",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L143-L170 | [
"def",
"bulk_actions",
"(",
"objects",
",",
"index",
",",
"action",
")",
":",
"assert",
"(",
"index",
"!=",
"\"_all\"",
")",
",",
"\"index arg must be a valid index name. '_all' is a reserved term.\"",
"logger",
".",
"info",
"(",
"\"Creating bulk '%s' actions for '%s'\"",... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _validate_config | Validate settings.SEARCH_SETTINGS. | elasticsearch_django/apps.py | def _validate_config(strict=False):
"""Validate settings.SEARCH_SETTINGS."""
for index in settings.get_index_names():
_validate_mapping(index, strict=strict)
for model in settings.get_index_models(index):
_validate_model(model)
if settings.get_setting("update_strategy", "full") n... | def _validate_config(strict=False):
"""Validate settings.SEARCH_SETTINGS."""
for index in settings.get_index_names():
_validate_mapping(index, strict=strict)
for model in settings.get_index_models(index):
_validate_model(model)
if settings.get_setting("update_strategy", "full") n... | [
"Validate",
"settings",
".",
"SEARCH_SETTINGS",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L28-L37 | [
"def",
"_validate_config",
"(",
"strict",
"=",
"False",
")",
":",
"for",
"index",
"in",
"settings",
".",
"get_index_names",
"(",
")",
":",
"_validate_mapping",
"(",
"index",
",",
"strict",
"=",
"strict",
")",
"for",
"model",
"in",
"settings",
".",
"get_ind... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _validate_mapping | Check that an index mapping JSON file exists. | elasticsearch_django/apps.py | def _validate_mapping(index, strict=False):
"""Check that an index mapping JSON file exists."""
try:
settings.get_index_mapping(index)
except IOError:
if strict:
raise ImproperlyConfigured("Index '%s' has no mapping file." % index)
else:
logger.warning("Index ... | def _validate_mapping(index, strict=False):
"""Check that an index mapping JSON file exists."""
try:
settings.get_index_mapping(index)
except IOError:
if strict:
raise ImproperlyConfigured("Index '%s' has no mapping file." % index)
else:
logger.warning("Index ... | [
"Check",
"that",
"an",
"index",
"mapping",
"JSON",
"file",
"exists",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L40-L48 | [
"def",
"_validate_mapping",
"(",
"index",
",",
"strict",
"=",
"False",
")",
":",
"try",
":",
"settings",
".",
"get_index_mapping",
"(",
"index",
")",
"except",
"IOError",
":",
"if",
"strict",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"Index '%s' has no mappin... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _validate_model | Check that a model configured for an index subclasses the required classes. | elasticsearch_django/apps.py | def _validate_model(model):
"""Check that a model configured for an index subclasses the required classes."""
if not hasattr(model, "as_search_document"):
raise ImproperlyConfigured("'%s' must implement `as_search_document`." % model)
if not hasattr(model.objects, "get_search_queryset"):
rai... | def _validate_model(model):
"""Check that a model configured for an index subclasses the required classes."""
if not hasattr(model, "as_search_document"):
raise ImproperlyConfigured("'%s' must implement `as_search_document`." % model)
if not hasattr(model.objects, "get_search_queryset"):
rai... | [
"Check",
"that",
"a",
"model",
"configured",
"for",
"an",
"index",
"subclasses",
"the",
"required",
"classes",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L51-L58 | [
"def",
"_validate_model",
"(",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"model",
",",
"\"as_search_document\"",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"'%s' must implement `as_search_document`.\"",
"%",
"model",
")",
"if",
"not",
"hasattr",
"(",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _connect_signals | Connect up post_save, post_delete signals for models. | elasticsearch_django/apps.py | def _connect_signals():
"""Connect up post_save, post_delete signals for models."""
for index in settings.get_index_names():
for model in settings.get_index_models(index):
_connect_model_signals(model) | def _connect_signals():
"""Connect up post_save, post_delete signals for models."""
for index in settings.get_index_names():
for model in settings.get_index_models(index):
_connect_model_signals(model) | [
"Connect",
"up",
"post_save",
"post_delete",
"signals",
"for",
"models",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L61-L65 | [
"def",
"_connect_signals",
"(",
")",
":",
"for",
"index",
"in",
"settings",
".",
"get_index_names",
"(",
")",
":",
"for",
"model",
"in",
"settings",
".",
"get_index_models",
"(",
"index",
")",
":",
"_connect_model_signals",
"(",
"model",
")"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _connect_model_signals | Connect signals for a single model. | elasticsearch_django/apps.py | def _connect_model_signals(model):
"""Connect signals for a single model."""
dispatch_uid = "%s.post_save" % model._meta.model_name
logger.debug("Connecting search index model post_save signal: %s", dispatch_uid)
signals.post_save.connect(_on_model_save, sender=model, dispatch_uid=dispatch_uid)
disp... | def _connect_model_signals(model):
"""Connect signals for a single model."""
dispatch_uid = "%s.post_save" % model._meta.model_name
logger.debug("Connecting search index model post_save signal: %s", dispatch_uid)
signals.post_save.connect(_on_model_save, sender=model, dispatch_uid=dispatch_uid)
disp... | [
"Connect",
"signals",
"for",
"a",
"single",
"model",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L68-L77 | [
"def",
"_connect_model_signals",
"(",
"model",
")",
":",
"dispatch_uid",
"=",
"\"%s.post_save\"",
"%",
"model",
".",
"_meta",
".",
"model_name",
"logger",
".",
"debug",
"(",
"\"Connecting search index model post_save signal: %s\"",
",",
"dispatch_uid",
")",
"signals",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _on_model_save | Update document in search index post_save. | elasticsearch_django/apps.py | def _on_model_save(sender, **kwargs):
"""Update document in search index post_save."""
instance = kwargs.pop("instance")
update_fields = kwargs.pop("update_fields")
for index in instance.search_indexes:
try:
_update_search_index(
instance=instance, index=index, update... | def _on_model_save(sender, **kwargs):
"""Update document in search index post_save."""
instance = kwargs.pop("instance")
update_fields = kwargs.pop("update_fields")
for index in instance.search_indexes:
try:
_update_search_index(
instance=instance, index=index, update... | [
"Update",
"document",
"in",
"search",
"index",
"post_save",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L80-L90 | [
"def",
"_on_model_save",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
".",
"pop",
"(",
"\"instance\"",
")",
"update_fields",
"=",
"kwargs",
".",
"pop",
"(",
"\"update_fields\"",
")",
"for",
"index",
"in",
"instance",
".",
... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _on_model_delete | Remove documents from search indexes post_delete. | elasticsearch_django/apps.py | def _on_model_delete(sender, **kwargs):
"""Remove documents from search indexes post_delete."""
instance = kwargs.pop("instance")
for index in instance.search_indexes:
try:
_delete_from_search_index(instance=instance, index=index)
except Exception:
logger.exception("E... | def _on_model_delete(sender, **kwargs):
"""Remove documents from search indexes post_delete."""
instance = kwargs.pop("instance")
for index in instance.search_indexes:
try:
_delete_from_search_index(instance=instance, index=index)
except Exception:
logger.exception("E... | [
"Remove",
"documents",
"from",
"search",
"indexes",
"post_delete",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L93-L100 | [
"def",
"_on_model_delete",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
".",
"pop",
"(",
"\"instance\"",
")",
"for",
"index",
"in",
"instance",
".",
"search_indexes",
":",
"try",
":",
"_delete_from_search_index",
"(",
"instanc... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
train | _in_search_queryset | Wrapper around the instance manager method. | elasticsearch_django/apps.py | def _in_search_queryset(*, instance, index) -> bool:
"""Wrapper around the instance manager method."""
try:
return instance.__class__.objects.in_search_queryset(instance.id, index=index)
except Exception:
logger.exception("Error checking object in_search_queryset.")
return False | def _in_search_queryset(*, instance, index) -> bool:
"""Wrapper around the instance manager method."""
try:
return instance.__class__.objects.in_search_queryset(instance.id, index=index)
except Exception:
logger.exception("Error checking object in_search_queryset.")
return False | [
"Wrapper",
"around",
"the",
"instance",
"manager",
"method",
"."
] | yunojuno/elasticsearch-django | python | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L103-L109 | [
"def",
"_in_search_queryset",
"(",
"*",
",",
"instance",
",",
"index",
")",
"->",
"bool",
":",
"try",
":",
"return",
"instance",
".",
"__class__",
".",
"objects",
".",
"in_search_queryset",
"(",
"instance",
".",
"id",
",",
"index",
"=",
"index",
")",
"ex... | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.