repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.get_age | def get_age(dt):
"""Calculate delta between current time and datetime and return a human readable form of the delta object"""
delta = datetime.now() - dt
days = delta.days
hours, rem = divmod(delta.seconds, 3600)
minutes, seconds = divmod(rem, 60)
if days:
re... | python | def get_age(dt):
"""Calculate delta between current time and datetime and return a human readable form of the delta object"""
delta = datetime.now() - dt
days = delta.days
hours, rem = divmod(delta.seconds, 3600)
minutes, seconds = divmod(rem, 60)
if days:
re... | [
"def",
"get_age",
"(",
"dt",
")",
":",
"delta",
"=",
"datetime",
".",
"now",
"(",
")",
"-",
"dt",
"days",
"=",
"delta",
".",
"days",
"hours",
",",
"rem",
"=",
"divmod",
"(",
"delta",
".",
"seconds",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=... | Calculate delta between current time and datetime and return a human readable form of the delta object | [
"Calculate",
"delta",
"between",
"current",
"time",
"and",
"datetime",
"and",
"return",
"a",
"human",
"readable",
"form",
"of",
"the",
"delta",
"object"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L227-L237 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.json_obj | def json_obj(self, method, params=None, auth=True):
"""Return JSON object expected by the Zabbix API"""
if params is None:
params = {}
obj = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'auth': self.__auth if auth else None,... | python | def json_obj(self, method, params=None, auth=True):
"""Return JSON object expected by the Zabbix API"""
if params is None:
params = {}
obj = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'auth': self.__auth if auth else None,... | [
"def",
"json_obj",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
",",
"auth",
"=",
"True",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"obj",
"=",
"{",
"'jsonrpc'",
":",
"'2.0'",
",",
"'method'",
":",
"method",
... | Return JSON object expected by the Zabbix API | [
"Return",
"JSON",
"object",
"expected",
"by",
"the",
"Zabbix",
"API"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L253-L266 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.do_request | def do_request(self, json_obj):
"""Perform one HTTP request to Zabbix API"""
self.debug('Request: url="%s" headers=%s', self._api_url, self._http_headers)
self.debug('Request: body=%s', json_obj)
self.r_query.append(json_obj)
request = urllib2.Request(url=self._api_url, data=jso... | python | def do_request(self, json_obj):
"""Perform one HTTP request to Zabbix API"""
self.debug('Request: url="%s" headers=%s', self._api_url, self._http_headers)
self.debug('Request: body=%s', json_obj)
self.r_query.append(json_obj)
request = urllib2.Request(url=self._api_url, data=jso... | [
"def",
"do_request",
"(",
"self",
",",
"json_obj",
")",
":",
"self",
".",
"debug",
"(",
"'Request: url=\"%s\" headers=%s'",
",",
"self",
".",
"_api_url",
",",
"self",
".",
"_http_headers",
")",
"self",
".",
"debug",
"(",
"'Request: body=%s'",
",",
"json_obj",
... | Perform one HTTP request to Zabbix API | [
"Perform",
"one",
"HTTP",
"request",
"to",
"Zabbix",
"API"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L268-L312 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.login | def login(self, user=None, password=None, save=True):
"""Perform a user.login API request"""
if user and password:
if save:
self.__username = user
self.__password = password
elif self.__username and self.__password:
user = self.__username
... | python | def login(self, user=None, password=None, save=True):
"""Perform a user.login API request"""
if user and password:
if save:
self.__username = user
self.__password = password
elif self.__username and self.__password:
user = self.__username
... | [
"def",
"login",
"(",
"self",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"save",
"=",
"True",
")",
":",
"if",
"user",
"and",
"password",
":",
"if",
"save",
":",
"self",
".",
"__username",
"=",
"user",
"self",
".",
"__password",
"="... | Perform a user.login API request | [
"Perform",
"a",
"user",
".",
"login",
"API",
"request"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L314-L331 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.relogin | def relogin(self):
"""Perform a re-login"""
try:
self.__auth = None # reset auth before relogin
self.login()
except ZabbixAPIException as e:
self.log(ERROR, 'Zabbix API relogin error (%s)', e)
self.__auth = None # logged_in() will always return F... | python | def relogin(self):
"""Perform a re-login"""
try:
self.__auth = None # reset auth before relogin
self.login()
except ZabbixAPIException as e:
self.log(ERROR, 'Zabbix API relogin error (%s)', e)
self.__auth = None # logged_in() will always return F... | [
"def",
"relogin",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__auth",
"=",
"None",
"# reset auth before relogin",
"self",
".",
"login",
"(",
")",
"except",
"ZabbixAPIException",
"as",
"e",
":",
"self",
".",
"log",
"(",
"ERROR",
",",
"'Zabbix API relo... | Perform a re-login | [
"Perform",
"a",
"re",
"-",
"login"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L333-L341 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.check_auth | def check_auth(self):
"""Perform a re-login if not signed in or raise an exception"""
if not self.logged_in:
if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API... | python | def check_auth(self):
"""Perform a re-login if not signed in or raise an exception"""
if not self.logged_in:
if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API... | [
"def",
"check_auth",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"logged_in",
":",
"if",
"self",
".",
"relogin_interval",
"and",
"self",
".",
"last_login",
"and",
"(",
"time",
"(",
")",
"-",
"self",
".",
"last_login",
")",
">",
"self",
".",
"rel... | Perform a re-login if not signed in or raise an exception | [
"Perform",
"a",
"re",
"-",
"login",
"if",
"not",
"signed",
"in",
"or",
"raise",
"an",
"exception"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L347-L355 |
erigones/zabbix-api | zabbix_api.py | ZabbixAPI.call | def call(self, method, params=None):
"""Check authentication and perform actual API request and relogin if needed"""
start_time = time()
self.check_auth()
self.log(INFO, '[%s-%05d] Calling Zabbix API method "%s"', start_time, self.id, method)
self.log(DEBUG, '\twith parameters: %... | python | def call(self, method, params=None):
"""Check authentication and perform actual API request and relogin if needed"""
start_time = time()
self.check_auth()
self.log(INFO, '[%s-%05d] Calling Zabbix API method "%s"', start_time, self.id, method)
self.log(DEBUG, '\twith parameters: %... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
"(",
")",
"self",
".",
"check_auth",
"(",
")",
"self",
".",
"log",
"(",
"INFO",
",",
"'[%s-%05d] Calling Zabbix API method \"%s\"'",
",",
"start_tim... | Check authentication and perform actual API request and relogin if needed | [
"Check",
"authentication",
"and",
"perform",
"actual",
"API",
"request",
"and",
"relogin",
"if",
"needed"
] | train | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L361-L378 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | download_parallel | def download_parallel(url, directory, idx, min_file_size = 0, max_file_size = -1,
no_redirects = False, pos = 0, mode = 's'):
"""
download function to download parallely
"""
global main_it
global exit_flag
global total_chunks
global file_name
global i_max
file_name[idx]= url.split('/')[-1]
file_addres... | python | def download_parallel(url, directory, idx, min_file_size = 0, max_file_size = -1,
no_redirects = False, pos = 0, mode = 's'):
"""
download function to download parallely
"""
global main_it
global exit_flag
global total_chunks
global file_name
global i_max
file_name[idx]= url.split('/')[-1]
file_addres... | [
"def",
"download_parallel",
"(",
"url",
",",
"directory",
",",
"idx",
",",
"min_file_size",
"=",
"0",
",",
"max_file_size",
"=",
"-",
"1",
",",
"no_redirects",
"=",
"False",
",",
"pos",
"=",
"0",
",",
"mode",
"=",
"'s'",
")",
":",
"global",
"main_it",
... | download function to download parallely | [
"download",
"function",
"to",
"download",
"parallely"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L75-L116 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | download_parallel_gui | def download_parallel_gui(root, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when paralled downloading is true
"""
global parallel
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
parallel = True
app = progress_class(root, urls, directory, ... | python | def download_parallel_gui(root, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when paralled downloading is true
"""
global parallel
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
parallel = True
app = progress_class(root, urls, directory, ... | [
"def",
"download_parallel_gui",
"(",
"root",
",",
"urls",
",",
"directory",
",",
"min_file_size",
",",
"max_file_size",
",",
"no_redirects",
")",
":",
"global",
"parallel",
"# create directory to save files",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"... | called when paralled downloading is true | [
"called",
"when",
"paralled",
"downloading",
"is",
"true"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L239-L249 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | download_series_gui | def download_series_gui(frame, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when user wants serial downloading
"""
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
app = progress_class(frame, urls, directory, min_file_size, max_file_size, no_... | python | def download_series_gui(frame, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when user wants serial downloading
"""
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
app = progress_class(frame, urls, directory, min_file_size, max_file_size, no_... | [
"def",
"download_series_gui",
"(",
"frame",
",",
"urls",
",",
"directory",
",",
"min_file_size",
",",
"max_file_size",
",",
"no_redirects",
")",
":",
"# create directory to save files",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
... | called when user wants serial downloading | [
"called",
"when",
"user",
"wants",
"serial",
"downloading"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L254-L262 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | myThread.run | def run(self):
"""
function called when thread is started
"""
global parallel
if parallel:
download_parallel(self.url, self.directory, self.idx,
self.min_file_size, self.max_file_size, self.no_redirects)
else:
download(self.url, self.directory, self.idx,
self.min_file_size, self.max... | python | def run(self):
"""
function called when thread is started
"""
global parallel
if parallel:
download_parallel(self.url, self.directory, self.idx,
self.min_file_size, self.max_file_size, self.no_redirects)
else:
download(self.url, self.directory, self.idx,
self.min_file_size, self.max... | [
"def",
"run",
"(",
"self",
")",
":",
"global",
"parallel",
"if",
"parallel",
":",
"download_parallel",
"(",
"self",
".",
"url",
",",
"self",
".",
"directory",
",",
"self",
".",
"idx",
",",
"self",
".",
"min_file_size",
",",
"self",
".",
"max_file_size",
... | function called when thread is started | [
"function",
"called",
"when",
"thread",
"is",
"started"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L134-L145 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | progress_class.start | def start(self):
"""
function to initialize thread for downloading
"""
global parallel
for self.i in range(0, self.length):
if parallel:
self.thread.append(myThread(self.url[ self.i ], self.directory, self.i,
self.min_file_size, self.max_file_size, self.no_redirects))
else:
# if not ... | python | def start(self):
"""
function to initialize thread for downloading
"""
global parallel
for self.i in range(0, self.length):
if parallel:
self.thread.append(myThread(self.url[ self.i ], self.directory, self.i,
self.min_file_size, self.max_file_size, self.no_redirects))
else:
# if not ... | [
"def",
"start",
"(",
"self",
")",
":",
"global",
"parallel",
"for",
"self",
".",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"length",
")",
":",
"if",
"parallel",
":",
"self",
".",
"thread",
".",
"append",
"(",
"myThread",
"(",
"self",
".",
"... | function to initialize thread for downloading | [
"function",
"to",
"initialize",
"thread",
"for",
"downloading"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L198-L215 |
nikhilkumarsingh/content-downloader | ctdl/gui_downloader.py | progress_class.read_bytes | def read_bytes(self):
"""
reading bytes; update progress bar after 1 ms
"""
global exit_flag
for self.i in range(0, self.length) :
self.bytes[self.i] = i_max[self.i]
self.maxbytes[self.i] = total_chunks[self.i]
self.progress[self.i]["maximum"] = total_chunks[self.i]
self.progress[self.i]["value"]... | python | def read_bytes(self):
"""
reading bytes; update progress bar after 1 ms
"""
global exit_flag
for self.i in range(0, self.length) :
self.bytes[self.i] = i_max[self.i]
self.maxbytes[self.i] = total_chunks[self.i]
self.progress[self.i]["maximum"] = total_chunks[self.i]
self.progress[self.i]["value"]... | [
"def",
"read_bytes",
"(",
"self",
")",
":",
"global",
"exit_flag",
"for",
"self",
".",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"length",
")",
":",
"self",
".",
"bytes",
"[",
"self",
".",
"i",
"]",
"=",
"i_max",
"[",
"self",
".",
"i",
"]... | reading bytes; update progress bar after 1 ms | [
"reading",
"bytes",
";",
"update",
"progress",
"bar",
"after",
"1",
"ms"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L218-L236 |
common-workflow-language/schema_salad | schema_salad/codegen_base.py | CodeGenBase.declare_type | def declare_type(self, declared_type): # type: (TypeDef) -> TypeDef
"""Add this type to our collection, if needed."""
if declared_type not in self.collected_types:
self.collected_types[declared_type.name] = declared_type
return declared_type | python | def declare_type(self, declared_type): # type: (TypeDef) -> TypeDef
"""Add this type to our collection, if needed."""
if declared_type not in self.collected_types:
self.collected_types[declared_type.name] = declared_type
return declared_type | [
"def",
"declare_type",
"(",
"self",
",",
"declared_type",
")",
":",
"# type: (TypeDef) -> TypeDef",
"if",
"declared_type",
"not",
"in",
"self",
".",
"collected_types",
":",
"self",
".",
"collected_types",
"[",
"declared_type",
".",
"name",
"]",
"=",
"declared_type... | Add this type to our collection, if needed. | [
"Add",
"this",
"type",
"to",
"our",
"collection",
"if",
"needed",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/codegen_base.py#L33-L37 |
common-workflow-language/schema_salad | schema_salad/schema.py | get_metaschema | def get_metaschema(): # type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]
"""Instantiate the metaschema."""
loader = ref_resolver.Loader({
"Any": "https://w3id.org/cwl/salad#Any",
"ArraySchema": "https://w3id.org/cwl/salad#ArraySchema",
"Array_symbol": "https://w3id.org/cwl/salad#... | python | def get_metaschema(): # type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]
"""Instantiate the metaschema."""
loader = ref_resolver.Loader({
"Any": "https://w3id.org/cwl/salad#Any",
"ArraySchema": "https://w3id.org/cwl/salad#ArraySchema",
"Array_symbol": "https://w3id.org/cwl/salad#... | [
"def",
"get_metaschema",
"(",
")",
":",
"# type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]",
"loader",
"=",
"ref_resolver",
".",
"Loader",
"(",
"{",
"\"Any\"",
":",
"\"https://w3id.org/cwl/salad#Any\"",
",",
"\"ArraySchema\"",
":",
"\"https://w3id.org/cwl/salad#ArraySch... | Instantiate the metaschema. | [
"Instantiate",
"the",
"metaschema",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L56-L194 |
common-workflow-language/schema_salad | schema_salad/schema.py | add_namespaces | def add_namespaces(metadata, namespaces):
# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None
"""Collect the provided namespaces, checking for conflicts."""
for key, value in metadata.items():
if key not in namespaces:
namespaces[key] = value
elif namespaces[key] != ... | python | def add_namespaces(metadata, namespaces):
# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None
"""Collect the provided namespaces, checking for conflicts."""
for key, value in metadata.items():
if key not in namespaces:
namespaces[key] = value
elif namespaces[key] != ... | [
"def",
"add_namespaces",
"(",
"metadata",
",",
"namespaces",
")",
":",
"# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None",
"for",
"key",
",",
"value",
"in",
"metadata",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"namespaces",
":",
"name... | Collect the provided namespaces, checking for conflicts. | [
"Collect",
"the",
"provided",
"namespaces",
"checking",
"for",
"conflicts",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L196-L205 |
common-workflow-language/schema_salad | schema_salad/schema.py | collect_namespaces | def collect_namespaces(metadata):
# type: (Mapping[Text, Any]) -> Dict[Text, Text]
"""Walk through the metadata object, collecting namespace declarations."""
namespaces = {} # type: Dict[Text, Text]
if "$import_metadata" in metadata:
for value in metadata["$import_metadata"].values():
... | python | def collect_namespaces(metadata):
# type: (Mapping[Text, Any]) -> Dict[Text, Text]
"""Walk through the metadata object, collecting namespace declarations."""
namespaces = {} # type: Dict[Text, Text]
if "$import_metadata" in metadata:
for value in metadata["$import_metadata"].values():
... | [
"def",
"collect_namespaces",
"(",
"metadata",
")",
":",
"# type: (Mapping[Text, Any]) -> Dict[Text, Text]",
"namespaces",
"=",
"{",
"}",
"# type: Dict[Text, Text]",
"if",
"\"$import_metadata\"",
"in",
"metadata",
":",
"for",
"value",
"in",
"metadata",
"[",
"\"$import_meta... | Walk through the metadata object, collecting namespace declarations. | [
"Walk",
"through",
"the",
"metadata",
"object",
"collecting",
"namespace",
"declarations",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L208-L217 |
common-workflow-language/schema_salad | schema_salad/schema.py | load_schema | def load_schema(schema_ref, # type: Union[CommentedMap, CommentedSeq, Text]
cache=None # type: Dict
):
# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]
"""
Load a schema that can be used to validate documents using load_and_valida... | python | def load_schema(schema_ref, # type: Union[CommentedMap, CommentedSeq, Text]
cache=None # type: Dict
):
# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]
"""
Load a schema that can be used to validate documents using load_and_valida... | [
"def",
"load_schema",
"(",
"schema_ref",
",",
"# type: Union[CommentedMap, CommentedSeq, Text]",
"cache",
"=",
"None",
"# type: Dict",
")",
":",
"# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]",
"metaschema_names",
",",
"_metaschema_doc",
... | Load a schema that can be used to validate documents using load_and_validate.
return: document_loader, avsc_names, schema_metadata, metaschema_loader | [
"Load",
"a",
"schema",
"that",
"can",
"be",
"used",
"to",
"validate",
"documents",
"using",
"load_and_validate",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L219-L249 |
common-workflow-language/schema_salad | schema_salad/schema.py | load_and_validate | def load_and_validate(document_loader, # type: Loader
avsc_names, # type: Names
document, # type: Union[CommentedMap, Text]
strict, # type: bool
st... | python | def load_and_validate(document_loader, # type: Loader
avsc_names, # type: Names
document, # type: Union[CommentedMap, Text]
strict, # type: bool
st... | [
"def",
"load_and_validate",
"(",
"document_loader",
",",
"# type: Loader",
"avsc_names",
",",
"# type: Names",
"document",
",",
"# type: Union[CommentedMap, Text]",
"strict",
",",
"# type: bool",
"strict_foreign_properties",
"=",
"False",
"# type: bool",
")",
":",
"# type: ... | Load a document and validate it with the provided schema.
return data, metadata | [
"Load",
"a",
"document",
"and",
"validate",
"it",
"with",
"the",
"provided",
"schema",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L252-L278 |
common-workflow-language/schema_salad | schema_salad/schema.py | validate_doc | def validate_doc(schema_names, # type: Names
doc, # type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]
loader, # type: Loader
strict, # type: bool
strict_foreign_properties=False # type: bool
):
... | python | def validate_doc(schema_names, # type: Names
doc, # type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]
loader, # type: Loader
strict, # type: bool
strict_foreign_properties=False # type: bool
):
... | [
"def",
"validate_doc",
"(",
"schema_names",
",",
"# type: Names",
"doc",
",",
"# type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]",
"loader",
",",
"# type: Loader",
"strict",
",",
"# type: bool",
"strict_foreign_properties",
"=",
"False",
"# type: bool",
")",
"... | Validate a document using the provided schema. | [
"Validate",
"a",
"document",
"using",
"the",
"provided",
"schema",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L281-L361 |
common-workflow-language/schema_salad | schema_salad/schema.py | get_anon_name | def get_anon_name(rec):
# type: (MutableMapping[Text, Any]) -> Text
"""Calculate a reproducible name for anonymous types."""
if "name" in rec:
return rec["name"]
anon_name = ""
if rec['type'] in ('enum', 'https://w3id.org/cwl/salad#enum'):
for sym in rec["symbols"]:
anon_... | python | def get_anon_name(rec):
# type: (MutableMapping[Text, Any]) -> Text
"""Calculate a reproducible name for anonymous types."""
if "name" in rec:
return rec["name"]
anon_name = ""
if rec['type'] in ('enum', 'https://w3id.org/cwl/salad#enum'):
for sym in rec["symbols"]:
anon_... | [
"def",
"get_anon_name",
"(",
"rec",
")",
":",
"# type: (MutableMapping[Text, Any]) -> Text",
"if",
"\"name\"",
"in",
"rec",
":",
"return",
"rec",
"[",
"\"name\"",
"]",
"anon_name",
"=",
"\"\"",
"if",
"rec",
"[",
"'type'",
"]",
"in",
"(",
"'enum'",
",",
"'htt... | Calculate a reproducible name for anonymous types. | [
"Calculate",
"a",
"reproducible",
"name",
"for",
"anonymous",
"types",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L363-L379 |
common-workflow-language/schema_salad | schema_salad/schema.py | replace_type | def replace_type(items, spec, loader, found, find_embeds=True, deepen=True):
# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any
""" Go through and replace types in the 'spec' mapping"""
if isinstance(items, MutableMapping):
# recursively check these fields for types to replace
... | python | def replace_type(items, spec, loader, found, find_embeds=True, deepen=True):
# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any
""" Go through and replace types in the 'spec' mapping"""
if isinstance(items, MutableMapping):
# recursively check these fields for types to replace
... | [
"def",
"replace_type",
"(",
"items",
",",
"spec",
",",
"loader",
",",
"found",
",",
"find_embeds",
"=",
"True",
",",
"deepen",
"=",
"True",
")",
":",
"# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any",
"if",
"isinstance",
"(",
"items",
",",
"Mu... | Go through and replace types in the 'spec' mapping | [
"Go",
"through",
"and",
"replace",
"types",
"in",
"the",
"spec",
"mapping"
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L381-L426 |
common-workflow-language/schema_salad | schema_salad/schema.py | avro_name | def avro_name(url): # type: (AnyStr) -> AnyStr
"""
Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment.
"""
frg = urllib.parse.urldefrag(url)[1]
if frg != ''... | python | def avro_name(url): # type: (AnyStr) -> AnyStr
"""
Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment.
"""
frg = urllib.parse.urldefrag(url)[1]
if frg != ''... | [
"def",
"avro_name",
"(",
"url",
")",
":",
"# type: (AnyStr) -> AnyStr",
"frg",
"=",
"urllib",
".",
"parse",
".",
"urldefrag",
"(",
"url",
")",
"[",
"1",
"]",
"if",
"frg",
"!=",
"''",
":",
"if",
"'/'",
"in",
"frg",
":",
"return",
"frg",
"[",
"frg",
... | Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment. | [
"Turn",
"a",
"URL",
"into",
"an",
"Avro",
"-",
"safe",
"name",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L429-L443 |
common-workflow-language/schema_salad | schema_salad/schema.py | make_valid_avro | def make_valid_avro(items, # type: Avro
alltypes, # type: Dict[Text, Dict[Text, Any]]
found, # type: Set[Text]
union=False # type: bool
):
# type: (...) -> Union[Avro, Dict, Text]
"""Convert our schema to... | python | def make_valid_avro(items, # type: Avro
alltypes, # type: Dict[Text, Dict[Text, Any]]
found, # type: Set[Text]
union=False # type: bool
):
# type: (...) -> Union[Avro, Dict, Text]
"""Convert our schema to... | [
"def",
"make_valid_avro",
"(",
"items",
",",
"# type: Avro",
"alltypes",
",",
"# type: Dict[Text, Dict[Text, Any]]",
"found",
",",
"# type: Set[Text]",
"union",
"=",
"False",
"# type: bool",
")",
":",
"# type: (...) -> Union[Avro, Dict, Text]",
"# Possibly could be integrated i... | Convert our schema to be more avro like. | [
"Convert",
"our",
"schema",
"to",
"be",
"more",
"avro",
"like",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L449-L488 |
common-workflow-language/schema_salad | schema_salad/schema.py | deepcopy_strip | def deepcopy_strip(item): # type: (Any) -> Any
"""
Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy.
"""
if isinstance(item, MutableMapping):
r... | python | def deepcopy_strip(item): # type: (Any) -> Any
"""
Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy.
"""
if isinstance(item, MutableMapping):
r... | [
"def",
"deepcopy_strip",
"(",
"item",
")",
":",
"# type: (Any) -> Any",
"if",
"isinstance",
"(",
"item",
",",
"MutableMapping",
")",
":",
"return",
"{",
"k",
":",
"deepcopy_strip",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"item",
")",... | Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy. | [
"Make",
"a",
"deep",
"copy",
"of",
"list",
"and",
"dict",
"objects",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L491-L503 |
common-workflow-language/schema_salad | schema_salad/schema.py | extend_and_specialize | def extend_and_specialize(items, loader):
# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]
"""
Apply 'extend' and 'specialize' to fully materialize derived record types.
"""
items = deepcopy_strip(items)
types = {i["name"]: i for i in items} # type: Dict[Text, Any]
results ... | python | def extend_and_specialize(items, loader):
# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]
"""
Apply 'extend' and 'specialize' to fully materialize derived record types.
"""
items = deepcopy_strip(items)
types = {i["name"]: i for i in items} # type: Dict[Text, Any]
results ... | [
"def",
"extend_and_specialize",
"(",
"items",
",",
"loader",
")",
":",
"# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]",
"items",
"=",
"deepcopy_strip",
"(",
"items",
")",
"types",
"=",
"{",
"i",
"[",
"\"name\"",
"]",
":",
"i",
"for",
"i",
"in",
... | Apply 'extend' and 'specialize' to fully materialize derived record types. | [
"Apply",
"extend",
"and",
"specialize",
"to",
"fully",
"materialize",
"derived",
"record",
"types",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L506-L591 |
common-workflow-language/schema_salad | schema_salad/schema.py | make_avro_schema | def make_avro_schema(i, # type: List[Any]
loader # type: Loader
): # type: (...) -> Names
"""
All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output.
... | python | def make_avro_schema(i, # type: List[Any]
loader # type: Loader
): # type: (...) -> Names
"""
All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output.
... | [
"def",
"make_avro_schema",
"(",
"i",
",",
"# type: List[Any]",
"loader",
"# type: Loader",
")",
":",
"# type: (...) -> Names",
"names",
"=",
"Names",
"(",
")",
"avro",
"=",
"make_avro",
"(",
"i",
",",
"loader",
")",
"make_avsc_object",
"(",
"convert_to_dict",
"(... | All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output. | [
"All",
"in",
"one",
"convenience",
"function",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L609-L621 |
common-workflow-language/schema_salad | schema_salad/schema.py | shortname | def shortname(inputid): # type: (Text) -> Text
"""Returns the last segment of the provided fragment or path."""
parsed_id = urllib.parse.urlparse(inputid)
if parsed_id.fragment:
return parsed_id.fragment.split(u"/")[-1]
return parsed_id.path.split(u"/")[-1] | python | def shortname(inputid): # type: (Text) -> Text
"""Returns the last segment of the provided fragment or path."""
parsed_id = urllib.parse.urlparse(inputid)
if parsed_id.fragment:
return parsed_id.fragment.split(u"/")[-1]
return parsed_id.path.split(u"/")[-1] | [
"def",
"shortname",
"(",
"inputid",
")",
":",
"# type: (Text) -> Text",
"parsed_id",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"inputid",
")",
"if",
"parsed_id",
".",
"fragment",
":",
"return",
"parsed_id",
".",
"fragment",
".",
"split",
"(",
"u\"/\... | Returns the last segment of the provided fragment or path. | [
"Returns",
"the",
"last",
"segment",
"of",
"the",
"provided",
"fragment",
"or",
"path",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L631-L636 |
common-workflow-language/schema_salad | schema_salad/schema.py | print_inheritance | def print_inheritance(doc, stream):
# type: (List[Dict[Text, Any]], IO) -> None
"""Write a Grapviz inheritance graph for the supplied document."""
stream.write("digraph {\n")
for entry in doc:
if entry["type"] == "record":
label = name = shortname(entry["name"])
fields = ... | python | def print_inheritance(doc, stream):
# type: (List[Dict[Text, Any]], IO) -> None
"""Write a Grapviz inheritance graph for the supplied document."""
stream.write("digraph {\n")
for entry in doc:
if entry["type"] == "record":
label = name = shortname(entry["name"])
fields = ... | [
"def",
"print_inheritance",
"(",
"doc",
",",
"stream",
")",
":",
"# type: (List[Dict[Text, Any]], IO) -> None",
"stream",
".",
"write",
"(",
"\"digraph {\\n\"",
")",
"for",
"entry",
"in",
"doc",
":",
"if",
"entry",
"[",
"\"type\"",
"]",
"==",
"\"record\"",
":",
... | Write a Grapviz inheritance graph for the supplied document. | [
"Write",
"a",
"Grapviz",
"inheritance",
"graph",
"for",
"the",
"supplied",
"document",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L639-L658 |
common-workflow-language/schema_salad | schema_salad/schema.py | print_fieldrefs | def print_fieldrefs(doc, loader, stream):
# type: (List[Dict[Text, Any]], Loader, IO) -> None
"""Write a GraphViz graph of the relationships between the fields."""
obj = extend_and_specialize(doc, loader)
primitives = set(("http://www.w3.org/2001/XMLSchema#string",
"http://www.w3.... | python | def print_fieldrefs(doc, loader, stream):
# type: (List[Dict[Text, Any]], Loader, IO) -> None
"""Write a GraphViz graph of the relationships between the fields."""
obj = extend_and_specialize(doc, loader)
primitives = set(("http://www.w3.org/2001/XMLSchema#string",
"http://www.w3.... | [
"def",
"print_fieldrefs",
"(",
"doc",
",",
"loader",
",",
"stream",
")",
":",
"# type: (List[Dict[Text, Any]], Loader, IO) -> None",
"obj",
"=",
"extend_and_specialize",
"(",
"doc",
",",
"loader",
")",
"primitives",
"=",
"set",
"(",
"(",
"\"http://www.w3.org/2001/XMLS... | Write a GraphViz graph of the relationships between the fields. | [
"Write",
"a",
"GraphViz",
"graph",
"of",
"the",
"relationships",
"between",
"the",
"fields",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L661-L691 |
common-workflow-language/schema_salad | schema_salad/avro/schema.py | get_other_props | def get_other_props(all_props, reserved_props):
# type: (Dict, Tuple) -> Optional[Dict]
"""
Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude
"""
if hasattr(all_props, 'items') and callable(all_props.items):
... | python | def get_other_props(all_props, reserved_props):
# type: (Dict, Tuple) -> Optional[Dict]
"""
Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude
"""
if hasattr(all_props, 'items') and callable(all_props.items):
... | [
"def",
"get_other_props",
"(",
"all_props",
",",
"reserved_props",
")",
":",
"# type: (Dict, Tuple) -> Optional[Dict]",
"if",
"hasattr",
"(",
"all_props",
",",
"'items'",
")",
"and",
"callable",
"(",
"all_props",
".",
"items",
")",
":",
"return",
"dict",
"(",
"[... | Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude | [
"Retrieve",
"the",
"non",
"-",
"reserved",
"properties",
"from",
"a",
"dictionary",
"of",
"properties"
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L515-L524 |
common-workflow-language/schema_salad | schema_salad/avro/schema.py | make_avsc_object | def make_avsc_object(json_data, names=None):
# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema
"""
Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space)
"""
if names is None:
names = Names()
... | python | def make_avsc_object(json_data, names=None):
# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema
"""
Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space)
"""
if names is None:
names = Names()
... | [
"def",
"make_avsc_object",
"(",
"json_data",
",",
"names",
"=",
"None",
")",
":",
"# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"Names",
"(",
")",
"assert",
"isinstance",
"(",
"names",
... | Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space) | [
"Build",
"Avro",
"Schema",
"from",
"data",
"parsed",
"out",
"of",
"JSON",
"string",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L527-L573 |
common-workflow-language/schema_salad | schema_salad/avro/schema.py | Name.get_space | def get_space(self):
# type: () -> Optional[Text]
"""Back out a namespace from full name."""
if self._full is None:
return None
if self._full.find('.') > 0:
return self._full.rsplit(".", 1)[0]
else:
return "" | python | def get_space(self):
# type: () -> Optional[Text]
"""Back out a namespace from full name."""
if self._full is None:
return None
if self._full.find('.') > 0:
return self._full.rsplit(".", 1)[0]
else:
return "" | [
"def",
"get_space",
"(",
"self",
")",
":",
"# type: () -> Optional[Text]",
"if",
"self",
".",
"_full",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_full",
".",
"find",
"(",
"'.'",
")",
">",
"0",
":",
"return",
"self",
".",
"_full",
".",
... | Back out a namespace from full name. | [
"Back",
"out",
"a",
"namespace",
"from",
"full",
"name",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L184-L193 |
common-workflow-language/schema_salad | schema_salad/avro/schema.py | Names.add_name | def add_name(self, name_attr, space_attr, new_schema):
# type: (Text, Optional[Text], NamedSchema) -> Name
"""
Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name tha... | python | def add_name(self, name_attr, space_attr, new_schema):
# type: (Text, Optional[Text], NamedSchema) -> Name
"""
Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name tha... | [
"def",
"add_name",
"(",
"self",
",",
"name_attr",
",",
"space_attr",
",",
"new_schema",
")",
":",
"# type: (Text, Optional[Text], NamedSchema) -> Name",
"to_add",
"=",
"Name",
"(",
"name_attr",
",",
"space_attr",
",",
"self",
".",
"default_namespace",
")",
"if",
"... | Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name that was just added. | [
"Add",
"a",
"new",
"schema",
"object",
"to",
"the",
"name",
"set",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L215-L235 |
common-workflow-language/schema_salad | schema_salad/avro/schema.py | RecordSchema.make_field_objects | def make_field_objects(field_data, names):
# type: (List[Dict[Text, Text]], Names) -> List[Field]
"""We're going to need to make message parameters too."""
field_objects = []
field_names = [] # type: List[Text]
for field in field_data:
if hasattr(field, 'get') and ca... | python | def make_field_objects(field_data, names):
# type: (List[Dict[Text, Text]], Names) -> List[Field]
"""We're going to need to make message parameters too."""
field_objects = []
field_names = [] # type: List[Text]
for field in field_data:
if hasattr(field, 'get') and ca... | [
"def",
"make_field_objects",
"(",
"field_data",
",",
"names",
")",
":",
"# type: (List[Dict[Text, Text]], Names) -> List[Field]",
"field_objects",
"=",
"[",
"]",
"field_names",
"=",
"[",
"]",
"# type: List[Text]",
"for",
"field",
"in",
"field_data",
":",
"if",
"hasatt... | We're going to need to make message parameters too. | [
"We",
"re",
"going",
"to",
"need",
"to",
"make",
"message",
"parameters",
"too",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L446-L476 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | search_function | def search_function(root1, q, s, f, l, o='g'):
"""
function to get links
"""
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit() | python | def search_function(root1, q, s, f, l, o='g'):
"""
function to get links
"""
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit() | [
"def",
"search_function",
"(",
"root1",
",",
"q",
",",
"s",
",",
"f",
",",
"l",
",",
"o",
"=",
"'g'",
")",
":",
"global",
"links",
"links",
"=",
"search",
"(",
"q",
",",
"o",
",",
"s",
",",
"f",
",",
"l",
")",
"root1",
".",
"destroy",
"(",
... | function to get links | [
"function",
"to",
"get",
"links"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L53-L60 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | task | def task(ft):
"""
to create loading progress bar
"""
ft.pack(expand = True, fill = BOTH, side = TOP)
pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
pb_hD.pack(expand = True, fill = BOTH, side = TOP)
pb_hD.start(50)
ft.mainloop() | python | def task(ft):
"""
to create loading progress bar
"""
ft.pack(expand = True, fill = BOTH, side = TOP)
pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
pb_hD.pack(expand = True, fill = BOTH, side = TOP)
pb_hD.start(50)
ft.mainloop() | [
"def",
"task",
"(",
"ft",
")",
":",
"ft",
".",
"pack",
"(",
"expand",
"=",
"True",
",",
"fill",
"=",
"BOTH",
",",
"side",
"=",
"TOP",
")",
"pb_hD",
"=",
"ttk",
".",
"Progressbar",
"(",
"ft",
",",
"orient",
"=",
"'horizontal'",
",",
"mode",
"=",
... | to create loading progress bar | [
"to",
"create",
"loading",
"progress",
"bar"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L63-L71 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | download_content_gui | def download_content_gui(**args):
"""
function to fetch links and download them
"""
global row
if not args ['directory']:
args ['directory'] = args ['query'].replace(' ', '-')
root1 = Frame(root)
t1 = threading.Thread(target = search_function, args = (root1,
args['query'], args['website'], args['fil... | python | def download_content_gui(**args):
"""
function to fetch links and download them
"""
global row
if not args ['directory']:
args ['directory'] = args ['query'].replace(' ', '-')
root1 = Frame(root)
t1 = threading.Thread(target = search_function, args = (root1,
args['query'], args['website'], args['fil... | [
"def",
"download_content_gui",
"(",
"*",
"*",
"args",
")",
":",
"global",
"row",
"if",
"not",
"args",
"[",
"'directory'",
"]",
":",
"args",
"[",
"'directory'",
"]",
"=",
"args",
"[",
"'query'",
"]",
".",
"replace",
"(",
"' '",
",",
"'-'",
")",
"root1... | function to fetch links and download them | [
"function",
"to",
"fetch",
"links",
"and",
"download",
"them"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L74-L98 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | main | def main():
"""
main function
"""
s = ttk.Style()
s.theme_use('clam')
ents = makeform(root)
root.mainloop() | python | def main():
"""
main function
"""
s = ttk.Style()
s.theme_use('clam')
ents = makeform(root)
root.mainloop() | [
"def",
"main",
"(",
")",
":",
"s",
"=",
"ttk",
".",
"Style",
"(",
")",
"s",
".",
"theme_use",
"(",
"'clam'",
")",
"ents",
"=",
"makeform",
"(",
"root",
")",
"root",
".",
"mainloop",
"(",
")"
] | main function | [
"main",
"function"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L330-L337 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | makeform.click_download | def click_download(self, event):
"""
event for download button
"""
args ['parallel'] = self.p.get()
args ['file_type'] = self.optionmenu.get()
args ['no_redirects'] = self.t.get()
args ['query'] = self.entry_query.get()
args ['min_file_size'] = int( self.entry_min.get())
args ['max_file_size'] = int( ... | python | def click_download(self, event):
"""
event for download button
"""
args ['parallel'] = self.p.get()
args ['file_type'] = self.optionmenu.get()
args ['no_redirects'] = self.t.get()
args ['query'] = self.entry_query.get()
args ['min_file_size'] = int( self.entry_min.get())
args ['max_file_size'] = int( ... | [
"def",
"click_download",
"(",
"self",
",",
"event",
")",
":",
"args",
"[",
"'parallel'",
"]",
"=",
"self",
".",
"p",
".",
"get",
"(",
")",
"args",
"[",
"'file_type'",
"]",
"=",
"self",
".",
"optionmenu",
".",
"get",
"(",
")",
"args",
"[",
"'no_redi... | event for download button | [
"event",
"for",
"download",
"button"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L258-L273 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | makeform.on_entry_click | def on_entry_click(self, event):
"""
function that gets called whenever entry is clicked
"""
if event.widget.config('fg') [4] == 'grey':
event.widget.delete(0, "end" ) # delete all the text in the entry
event.widget.insert(0, '') #Insert blank for user input
event.widget.config(fg = 'black') | python | def on_entry_click(self, event):
"""
function that gets called whenever entry is clicked
"""
if event.widget.config('fg') [4] == 'grey':
event.widget.delete(0, "end" ) # delete all the text in the entry
event.widget.insert(0, '') #Insert blank for user input
event.widget.config(fg = 'black') | [
"def",
"on_entry_click",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"widget",
".",
"config",
"(",
"'fg'",
")",
"[",
"4",
"]",
"==",
"'grey'",
":",
"event",
".",
"widget",
".",
"delete",
"(",
"0",
",",
"\"end\"",
")",
"# delete all the t... | function that gets called whenever entry is clicked | [
"function",
"that",
"gets",
"called",
"whenever",
"entry",
"is",
"clicked"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L276-L283 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | makeform.on_focusout | def on_focusout(self, event, a):
"""
function that gets called whenever anywhere except entry is clicked
"""
if event.widget.get() == '':
event.widget.insert(0, default_text[a])
event.widget.config(fg = 'grey') | python | def on_focusout(self, event, a):
"""
function that gets called whenever anywhere except entry is clicked
"""
if event.widget.get() == '':
event.widget.insert(0, default_text[a])
event.widget.config(fg = 'grey') | [
"def",
"on_focusout",
"(",
"self",
",",
"event",
",",
"a",
")",
":",
"if",
"event",
".",
"widget",
".",
"get",
"(",
")",
"==",
"''",
":",
"event",
".",
"widget",
".",
"insert",
"(",
"0",
",",
"default_text",
"[",
"a",
"]",
")",
"event",
".",
"w... | function that gets called whenever anywhere except entry is clicked | [
"function",
"that",
"gets",
"called",
"whenever",
"anywhere",
"except",
"entry",
"is",
"clicked"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L286-L292 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | makeform.check_threat | def check_threat(self):
"""
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 self.optionmenu.get() == el:
is_high_threat = True
break
else:
if self.optionmen... | python | def check_threat(self):
"""
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 self.optionmenu.get() == el:
is_high_threat = True
break
else:
if self.optionmen... | [
"def",
"check_threat",
"(",
"self",
")",
":",
"is_high_threat",
"=",
"False",
"for",
"val",
"in",
"THREAT_EXTENSIONS",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"val",
")",
"==",
"list",
":",
"for",
"el",
"in",
"val",
":",
"if",
"self",
".",
... | function to check input filetype against threat extensions list | [
"function",
"to",
"check",
"input",
"filetype",
"against",
"threat",
"extensions",
"list"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L295-L315 |
nikhilkumarsingh/content-downloader | ctdl/gui.py | makeform.ask_dir | def ask_dir(self):
"""
dialogue box for choosing directory
"""
args ['directory'] = askdirectory(**self.dir_opt)
self.dir_text.set(args ['directory']) | python | def ask_dir(self):
"""
dialogue box for choosing directory
"""
args ['directory'] = askdirectory(**self.dir_opt)
self.dir_text.set(args ['directory']) | [
"def",
"ask_dir",
"(",
"self",
")",
":",
"args",
"[",
"'directory'",
"]",
"=",
"askdirectory",
"(",
"*",
"*",
"self",
".",
"dir_opt",
")",
"self",
".",
"dir_text",
".",
"set",
"(",
"args",
"[",
"'directory'",
"]",
")"
] | dialogue box for choosing directory | [
"dialogue",
"box",
"for",
"choosing",
"directory"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L317-L322 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | get_google_links | def get_google_links(limit, params, headers):
"""
function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results.
"""
links = []
for start_index in range(0, limit, 10):
params['start'] = start_index
resp = s.get("https://www.google.com/search"... | python | def get_google_links(limit, params, headers):
"""
function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results.
"""
links = []
for start_index in range(0, limit, 10):
params['start'] = start_index
resp = s.get("https://www.google.com/search"... | [
"def",
"get_google_links",
"(",
"limit",
",",
"params",
",",
"headers",
")",
":",
"links",
"=",
"[",
"]",
"for",
"start_index",
"in",
"range",
"(",
"0",
",",
"limit",
",",
"10",
")",
":",
"params",
"[",
"'start'",
"]",
"=",
"start_index",
"resp",
"="... | function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results. | [
"function",
"to",
"fetch",
"links",
"equal",
"to",
"limit"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L26-L39 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | get_duckduckgo_links | def get_duckduckgo_links(limit, params, headers):
"""
function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped
"""
resp = s.get('https://duckduckgo.com/html', params = params, headers = headers)
links = scrape_links(resp.conte... | python | def get_duckduckgo_links(limit, params, headers):
"""
function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped
"""
resp = s.get('https://duckduckgo.com/html', params = params, headers = headers)
links = scrape_links(resp.conte... | [
"def",
"get_duckduckgo_links",
"(",
"limit",
",",
"params",
",",
"headers",
")",
":",
"resp",
"=",
"s",
".",
"get",
"(",
"'https://duckduckgo.com/html'",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
")",
"links",
"=",
"scrape_links",
"(",
... | function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped | [
"function",
"to",
"fetch",
"links",
"equal",
"to",
"limit"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L43-L52 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | scrape_links | 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... | python | 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",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"html",
",",
"'lxml'",
")",
"links",
"=",
"[",
"]",
"if",
"engine",
"==",
"'d'",
":",
"results",
"=",
"soup",
".",
"findAll",
"(",
"'a'",
",",
"{",
"'cl... | function to scrape file links from html response | [
"function",
"to",
"scrape",
"file",
"links",
"from",
"html",
"response"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L55-L76 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | get_url_nofollow | 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... | python | 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",
")",
":",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
")",
"code",
"=",
"response",
".",
"getcode",
"(",
")",
"return",
"code",
"except",
"HTTPError",
"as",
"e",
":",
"return",
"e",
".",
"code",
"except",
... | 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/ | [
"function",
"to",
"get",
"return",
"code",
"of",
"a",
"url"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L81-L94 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | validate_links | 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... | python | 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",
")",
":",
"valid_links",
"=",
"[",
"]",
"for",
"link",
"in",
"links",
":",
"if",
"link",
"[",
":",
"7",
"]",
"in",
"\"http://\"",
"or",
"link",
"[",
":",
"8",
"]",
"in",
"\"https://\"",
":",
"valid_links",
".",
... | function to validate urls based on http(s) prefix and return code | [
"function",
"to",
"validate",
"urls",
"based",
"on",
"http",
"(",
"s",
")",
"prefix",
"and",
"return",
"code"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L97-L125 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | search | 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... | python | 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",
")",
":",
"if",
"site",
"==",
"\"\"",
":",
"search_query",
"=",
"\"filetype:{0} {1}\"",
".",
"format",
"(",
"... | main function to search for links and return valid ones | [
"main",
"function",
"to",
"search",
"for",
"links",
"and",
"return",
"valid",
"ones"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L128-L158 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | check_threats | 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:
... | python | 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",
")",
":",
"is_high_threat",
"=",
"False",
"for",
"val",
"in",
"THREAT_EXTENSIONS",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"val",
")",
"==",
"list",
":",
"for",
"el",
"in",
"val",
":",
"if",
"... | function to check input filetype against threat extensions list | [
"function",
"to",
"check",
"input",
"filetype",
"against",
"threat",
"extensions",
"list"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L161-L176 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | validate_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 | python | 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",
")",
":",
"if",
"not",
"args",
"[",
"'query'",
"]",
":",
"print",
"(",
"\"\\nMissing required query argument.\"",
")",
"sys",
".",
"exit",
"(",
")",
"for",
"key",
"in",
"DEFAULTS",
":",
"if",
"key",
"not",
... | function to check if input query is not None
and set missing arguments to default value | [
"function",
"to",
"check",
"if",
"input",
"query",
"is",
"not",
"None",
"and",
"set",
"missing",
"arguments",
"to",
"default",
"value"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L179-L192 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | download_content | 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... | python | 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",
")",
":",
"args",
"=",
"validate_args",
"(",
"*",
"*",
"args",
")",
"if",
"not",
"args",
"[",
"'directory'",
"]",
":",
"args",
"[",
"'directory'",
"]",
"=",
"args",
"[",
"'query'",
"]",
".",
"replace"... | main function to fetch links and download them | [
"main",
"function",
"to",
"fetch",
"links",
"and",
"download",
"them"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L195-L213 |
nikhilkumarsingh/content-downloader | ctdl/ctdl.py | show_filetypes | 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])) | python | 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",
")",
":",
"for",
"item",
"in",
"extensions",
".",
"items",
"(",
")",
":",
"val",
"=",
"item",
"[",
"1",
"]",
"if",
"type",
"(",
"item",
"[",
"1",
"]",
")",
"==",
"list",
":",
"val",
"=",
"\", \"",
".",
... | function to show valid file extensions | [
"function",
"to",
"show",
"valid",
"file",
"extensions"
] | train | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L216-L224 |
common-workflow-language/schema_salad | schema_salad/validate.py | validate_ex | def validate_ex(expected_schema, # type: Schema
datum, # type: Any
identifiers=None, # type: List[Text]
strict=False, # type: bool
foreign_properties=None, # type: Set... | python | 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[Text]",
"raise_ex... | Determine if a python datum is an instance of a schema. | [
"Determine",
"if",
"a",
"python",
"datum",
"is",
"an",
"instance",
"of",
"a",
"schema",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/validate.py#L70-L347 |
common-workflow-language/schema_salad | schema_salad/utils.py | json_dump | 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) | python | 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",
"if",
"six",
".",
"PY2",
":",
"kwargs",
"[",
"'encoding'",
"]",
"=",
"'utf-8'",
"json",
".",
"dump",
"("... | Force use of unicode. | [
"Force",
"use",
"of",
"unicode",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L62-L69 |
common-workflow-language/schema_salad | schema_salad/utils.py | json_dumps | 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) | python | 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",
"if",
"six",
".",
"PY2",
":",
"kwargs",
"[",
"'encoding'",
"]",
"=",
"'utf-8'",
"return",
"json",
".",
"dumps",
"(",
"convert_to_dict",
... | Force use of unicode. | [
"Force",
"use",
"of",
"unicode",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L72-L78 |
common-workflow-language/schema_salad | schema_salad/codegen.py | codegen | 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."""
... | python | 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",
"j",
"=",
"schema",
".",
"extend_and_specialize",
"(",
"i",
... | Generate classes with loaders for the given Schema Salad description. | [
"Generate",
"classes",
"with",
"loaders",
"for",
"the",
"given",
"Schema",
"Salad",
"description",
"."
] | train | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/codegen.py#L17-L111 |
Arubacloud/pyArubaCloud | ArubaCloud/base/vm.py | VMList.find | 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... | python | 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",
")",
":",
"if",
"name",
".",
"__class__",
"is",
"'base.Server.Pro'",
"or",
"name",
".",
"__class__",
"is",
"'base.Server.Smart'",
":",
"# print('DEBUG: matched VM object %s' % name.__class__)",
"pattern",
"=",
"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 subset containing the serach result. | [
"Return",
"a",
"list",
"of",
"subset",
"of",
"VM",
"that",
"match",
"the",
"pattern",
"name"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L6-L24 |
Arubacloud/pyArubaCloud | ArubaCloud/base/vm.py | VM.reinitialize | 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... | python | 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",
")",
":",
"data",
"=",
"dict",
"(",
"AdministratorPassword",
"=",
"admin_password",
",",... | 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
... | [
"Reinitialize",
"a",
"VM",
".",
":",
"param",
"admin_password",
":",
"Administrator",
"password",
".",
":",
"param",
"debug",
":",
"Flag",
"to",
"enable",
"debug",
"output",
".",
":",
"param",
"ConfigureIPv6",
":",
"Flag",
"to",
"enable",
"IPv6",
"on",
"th... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L82-L106 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.login | 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... | python | 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",
")",
":",
"self",
".",
"auth",
"=",
"Auth",
"(",
"username",
",",
"password",
")",
"if",
"load",
"is",
"True",
":",
"self",
".",
"get_ip",
"(",
")",
"self",
... | 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:... | [
"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... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L54-L67 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.poweroff_server | 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... | python | 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",
")",
":",
"sid",
"=",
"server_id",
"if",
"server_id",
"is",
"not",
"None",
"else",
"server",
".",
"sid",
"if",
"sid",
"is",
"None",
":",
"raise",
"Excepti... | 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[... | [
"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",
... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L69-L84 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.get_hypervisors | 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... | python | 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",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetHypervisors'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetHypervisors'",
",",
"json_scheme",
"=",
"json_scheme",... | Initialize the internal list containing each template available for each
hypervisor.
:return: [bool] True in case of success, otherwise False | [
"Initialize",
"the",
"internal",
"list",
"containing",
"each",
"template",
"available",
"for",
"each",
"hypervisor",
"."
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L103-L139 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.get_servers | 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... | python | 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",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetServers'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetServers'",
",",
"json_scheme",
"=",
"json_scheme",
")",
"s... | Create the list of Server object inside the Datacenter objects.
Build an internal list of VM Objects (pro or smart) as iterator.
:return: bool | [
"Create",
"the",
"list",
"of",
"Server",
"object",
"inside",
"the",
"Datacenter",
"objects",
".",
"Build",
"an",
"internal",
"list",
"of",
"VM",
"Objects",
"(",
"pro",
"or",
"smart",
")",
"as",
"iterator",
".",
":",
"return",
":",
"bool"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L141-L182 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.find_template | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"self",
".",
"templates",
")",
"<=",
"0",
":",
"self",
".",
"get_hypervisors",
"(",
")",
"if",
"name",
"is",
"not",
"None",
"and",
... | 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 ... | [
"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",
... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L184-L216 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.purchase_ip | 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... | python | 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",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetPurchaseIpAddress'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'SetPurchaseIpAddress'",
"... | Return an ip object representing a new bought IP
@param debug [Boolean] if true, request and response will be printed
@return (Ip): Ip object | [
"Return",
"an",
"ip",
"object",
"representing",
"a",
"new",
"bought",
"IP"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L234-L248 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.purchase_vlan | 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 = {... | python | 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",
")",
":",
"vlan_name",
"=",
"{",
"'VLanName'",
":",
"vlan_name",
"}",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetPurchaseVLan'",
",",
"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: a Vlan Object representing the vlan created | [
"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",
... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L250-L268 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.remove_vlan | 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... | python | 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",
")",
":",
"vlan_id",
"=",
"{",
"'VLanResourceId'",
":",
"vlan_resource_id",
"}",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetRemoveVLan'",
",",
"vlan_id",
")",
"json_obj",
"=",
"se... | Remove a VLAN
:param vlan_resource_id:
:return: | [
"Remove",
"a",
"VLAN",
":",
"param",
"vlan_resource_id",
":",
":",
"return",
":"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L270-L279 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.remove_ip | 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_... | python | 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",
")",
":",
"ip_id",
"=",
"' \"IpAddressResourceId\": %s'",
"%",
"ip_id",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'SetRemoveIpAddress'",
",",
"ip_id",
")",
"json_obj",
"=",
"self",
".",
"call_... | 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 | [
"Delete",
"an",
"Ip",
"from",
"the",
"boughs",
"ip",
"list"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L297-L307 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.get_package_id | 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... | python | 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",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetPreConfiguredPackages'",
",",
"dict",
"(",
"HypervisorType",
"=",
"4",
")",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(... | 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. | [
"Retrieve",
"the",
"smart",
"package",
"id",
"given",
"is",
"English",
"name"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L309-L323 |
Arubacloud/pyArubaCloud | ArubaCloud/PyArubaAPI.py | CloudInterface.get_ip | 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... | python | 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",
")",
":",
"json_scheme",
"=",
"self",
".",
"gen_def_json_scheme",
"(",
"'GetPurchasedIpAddresses'",
")",
"json_obj",
"=",
"self",
".",
"call_method_post",
"(",
"method",
"=",
"'GetPurchasedIpAddresses '",
",",
"json_scheme",
"=",
"jso... | 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 | [
"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",
"... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L325-L341 |
Arubacloud/pyArubaCloud | ArubaCloud/base/__init__.py | JsonInterfaceBase.gen_def_json_scheme | 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... | python | 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",
")",
":",
"json_dict",
"=",
"dict",
"(",
"ApplicationId",
"=",
"req",
",",
"RequestId",
"=",
"req",
",",
"SessionId",
"=",
"req",
",",
"Password",
"=",
"self",
".",... | 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 | [
"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",
... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L14-L31 |
Arubacloud/pyArubaCloud | ArubaCloud/base/__init__.py | Request._commit | 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, )
... | python | 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",
")",
":",
"assert",
"self",
".",
"uri",
"is",
"not",
"None",
",",
"Exception",
"(",
"\"BadArgument: uri property cannot be None\"",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"uri",
",",
"self",
".",
"__clas... | :return: (dict) Response object content | [
":",
"return",
":",
"(",
"dict",
")",
"Response",
"object",
"content"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L95-L114 |
Arubacloud/pyArubaCloud | ArubaCloud/SharedStorage/SharedStorage.py | SharedStorage.get | 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'] | python | 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",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"GetSharedStorages",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return",
"response",
"[",
"'Value'",
"]"
] | Retrieve the current configured SharedStorages entries
:return: [list] List containing the current SharedStorages entries | [
"Retrieve",
"the",
"current",
"configured",
"SharedStorages",
"entries",
":",
"return",
":",
"[",
"list",
"]",
"List",
"containing",
"the",
"current",
"SharedStorages",
"entries"
] | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L13-L20 |
Arubacloud/pyArubaCloud | ArubaCloud/SharedStorage/SharedStorage.py | SharedStorage.purchase_iscsi | 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... | python | 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",
")",
":",
"iqns",
"=",
"[",
"]",
"for",
"_iqn",
"in",
"iqn",
":",
"iqns",
".",
"append",
"(",
"SharedStorageI... | :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: | [
":",
"type",
"quantity",
":",
"int",
":",
"type",
"iqn",
":",
"list",
"[",
"str",
"]",
":",
"type",
"name",
":",
"str",
":",
"type",
"protocol",
":",
"SharedStorageProtocols",
":",
"param",
"quantity",
":",
"Amount",
"of",
"GB",
":",
"param",
"iqn",
... | train | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L22-L40 |
pycontribs/python-crowd | crowd.py | CrowdServer._get | 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... | python | 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",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"get",
"(",
"*"... | Wrapper around Requests for GET requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"GET",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L70-L82 |
pycontribs/python-crowd | crowd.py | CrowdServer._get_xml | 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 | python | 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",
")",
":",
"req",
"=",
"self",
".",
"session_xml",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"req"
] | Wrapper around Requests for GET XML requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"GET",
"XML",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L84-L92 |
pycontribs/python-crowd | crowd.py | CrowdServer._post | 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)
... | python | 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",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"post",
"(",
"... | Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"POST",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L94-L106 |
pycontribs/python-crowd | crowd.py | CrowdServer._post_xml | 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... | python | 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",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session_xml",
".",
"post",
... | Wrapper around Requests for POST requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"POST",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L108-L120 |
pycontribs/python-crowd | crowd.py | CrowdServer._put | 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... | python | 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",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"put",
"(",
"*"... | Wrapper around Requests for PUT requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"PUT",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L122-L134 |
pycontribs/python-crowd | crowd.py | CrowdServer._delete | 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)
... | python | 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",
")",
":",
"if",
"'timeout'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'timeout'",
"]",
"=",
"self",
".",
"timeout",
"req",
"=",
"self",
".",
"session",
".",
"delete",
"(",... | Wrapper around Requests for DELETE requests
Returns:
Response:
A Requests Response object | [
"Wrapper",
"around",
"Requests",
"for",
"DELETE",
"requests"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L136-L148 |
pycontribs/python-crowd | crowd.py | CrowdServer.auth_ping | 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... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"rest_url",
"+",
"\"/non-existent/location\"",
"response",
"=",
"self",
".",
"_get",
"(",
"url",
")",
"if",
"response",
".",
"status_code",
"==",
"401",
":",
"return",
"False",
"elif",
"... | 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... | [
"Test",
"that",
"application",
"can",
"authenticate",
"to",
"Crowd",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L150-L171 |
pycontribs/python-crowd | crowd.py | CrowdServer.auth_user | 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:
... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
"\"/authentication\"",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"value\"",
":",
"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:
A dict mapping of user attributes if the ... | [
"Authenticate",
"a",
"user",
"account",
"against",
"the",
"Crowd",
"server",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L173-L201 |
pycontribs/python-crowd | crowd.py | CrowdServer.get_session | 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:
... | python | 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",
")",
":",
"params",
"=",
"{",
"\"username\"",
":",
"username",
",",
"\"password\"",
":",
"password",
",",
"\"validation-facto... | 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... | [
"Create",
"a",
"session",
"for",
"a",
"user",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L203-L252 |
pycontribs/python-crowd | crowd.py | CrowdServer.validate_session | 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 ... | python | 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",
")",
":",
"params",
"=",
"{",
"\"validationFactors\"",
":",
"[",
"{",
"\"name\"",
":",
"\"remote_address\"",
",",
"\"value\"",
":",
"remote"... | 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.
... | [
"Validate",
"a",
"session",
"token",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L254-L295 |
pycontribs/python-crowd | crowd.py | CrowdServer.terminate_session | 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
"... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"rest_url",
"+",
"\"/session/%s\"",
"%",
"token",
"response",
"=",
"self",
".",
"_delete",
"(",
"url",
")",
"# For consistency between methods use None rather than False",
"#... | 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",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L297-L319 |
pycontribs/python-crowd | crowd.py | CrowdServer.add_user | 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
... | python | 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",
")",
":",
"# Check that mandatory elements have been provided",
"if",
"'password'",
"not",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"missing pa... | 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
... | [
"Add",
"a",
"user",
"to",
"the",
"directory"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L321-L380 |
pycontribs/python-crowd | crowd.py | CrowdServer.get_user | 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,
... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
",",
"\"expand\"",
":",
"\"attributes\"",
"}",
")",... | Retrieve information about a user
Returns:
dict: User information
None: If no user or failure occurred | [
"Retrieve",
"information",
"about",
"a",
"user"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L382-L398 |
pycontribs/python-crowd | crowd.py | CrowdServer.set_active | 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... | python | 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",
")",
":",
"if",
"active_state",
"not",
"in",
"(",
"True",
",",
"False",
")",
":",
"raise",
"ValueError",
"(",
"\"active_state must be True or False\"",
")",
"user",
"=",
"self",
".",
"ge... | 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 | [
"Set",
"the",
"active",
"state",
"of",
"a",
"user"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L400-L431 |
pycontribs/python-crowd | crowd.py | CrowdServer.set_user_attribute | 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... | python | 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",
")",
":",
"data",
"=",
"{",
"'attributes'",
":",
"[",
"{",
"'name'",
":",
"attribute",
",",
"'values'",
":",
"[",
"value",
"]"... | 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. | [
"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",
... | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L433-L460 |
pycontribs/python-crowd | crowd.py | CrowdServer.add_user_to_group | 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 = {
... | python | 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",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"groupname",
",",
"}",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
... | 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. | [
"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",
":",
... | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L462-L481 |
pycontribs/python-crowd | crowd.py | CrowdServer.remove_user_from_group | 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:
... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_delete",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/user/direct\"",
",",
"params",
"=",
"{",
"\"... | 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 | [
"Remove",
"a",
"user",
"from",
"a",
"group"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L483-L505 |
pycontribs/python-crowd | crowd.py | CrowdServer.change_password | 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... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_put",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/password\"",
",",
"data",
"=",
"json",
".",
"dumps"... | 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 | [
"Change",
"new",
"password",
"for",
"a",
"user"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L507-L532 |
pycontribs/python-crowd | crowd.py | CrowdServer.send_password_reset_link | 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... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/mail/password\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"respons... | Sends the user a password reset link (by email)
Args:
username: The account username.
Returns:
True: Succeeded
False: If unsuccessful | [
"Sends",
"the",
"user",
"a",
"password",
"reset",
"link",
"(",
"by",
"email",
")"
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L534-L551 |
pycontribs/python-crowd | crowd.py | CrowdServer.get_nested_groups | 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... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user/group/nested\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"not",
"respons... | 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. | [
"Retrieve",
"a",
"list",
"of",
"all",
"group",
"names",
"that",
"have",
"<username",
">",
"as",
"a",
"direct",
"or",
"indirect",
"member",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L569-L587 |
pycontribs/python-crowd | crowd.py | CrowdServer.get_nested_group_users | 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... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/user/nested\"",
",",
"params",
"=",
"{",
"\"groupname\"",
":",
"groupname",
",",
"\"start-index\"",
":"... | 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. | [
"Retrieves",
"a",
"list",
"of",
"all",
"users",
"that",
"directly",
"or",
"indirectly",
"belong",
"to",
"the",
"given",
"groupname",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L589-L609 |
pycontribs/python-crowd | crowd.py | CrowdServer.user_exists | 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",
... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"rest_url",
"+",
"\"/user\"",
",",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
")",
"if",
"not",
"response",
".",
"ok",
... | Determines if the user exists.
Args:
username: The user name.
Returns:
bool:
True if the user exists in the Crowd application. | [
"Determines",
"if",
"the",
"user",
"exists",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L611-L629 |
pycontribs/python-crowd | crowd.py | CrowdServer.get_memberships | 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
... | python | 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",
")",
":",
"response",
"=",
"self",
".",
"_get_xml",
"(",
"self",
".",
"rest_url",
"+",
"\"/group/membership\"",
")",
"if",
"not",
"response",
".",
"ok",
":",
"return",
"None",
"xmltree",
"=",
"etree",
".",
"fromstring... | Fetches all group memberships.
Returns:
dict:
key: group name
value: (array of users, array of groups) | [
"Fetches",
"all",
"group",
"memberships",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L631-L653 |
pycontribs/python-crowd | crowd.py | CrowdServer.search | 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 ... | python | 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",
")",
":",
"params",
"=",
"{",
"\"entity-type\"",
":",
"entity_type",
",",
"\"expand\"",
":",
"entity... | 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... | [
"Performs",
"a",
"user",
"search",
"using",
"the",
"Crowd",
"search",
"API",
"."
] | train | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L655-L728 |
TylerGubala/bpy-build | setup.py | Blender.versions | def versions(self) -> List(BlenderVersion):
"""
The versions associated with Blender
"""
return [BlenderVersion(tag) for tag in self.git_repo.tags] + [BlenderVersion(BLENDER_VERSION_MASTER)] | python | 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",
")",
":",
"return",
"[",
"BlenderVersion",
"(",
"tag",
")",
"for",
"tag",
"in",
"self",
".",
"git_repo",
".",
"tags",
"]",
"+",
"[",
"BlenderVersion",
"(",
"BLENDER_VERSION_MASTER",
... | The versions associated with Blender | [
"The",
"versions",
"associated",
"with",
"Blender"
] | train | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L120-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.