repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L429-L443 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L449-L488 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L491-L503 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L506-L591 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L609-L621 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L631-L636 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L639-L658 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L661-L691 | train |
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"
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L515-L524 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L527-L573 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L184-L193 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L215-L235 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L446-L476 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L53-L60 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L63-L71 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L74-L98 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L330-L337 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L258-L273 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L276-L283 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L286-L292 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L295-L315 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L317-L322 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L26-L39 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L43-L52 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L55-L76 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L81-L94 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L97-L125 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L128-L158 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L161-L176 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L179-L192 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L195-L213 | train |
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"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L216-L224 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/validate.py#L70-L347 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L62-L69 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/utils.py#L72-L78 | train |
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",
"."
] | 608ba207b9058fe0a9c3db161058ab3782eef015 | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/codegen.py#L17-L111 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L6-L24 | train |
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... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L82-L106 | train |
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... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L54-L67 | train |
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",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L69-L84 | train |
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",
"."
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L103-L139 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L141-L182 | train |
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",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L184-L216 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L234-L248 | train |
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",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L250-L268 | train |
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",
":"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L270-L279 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L297-L307 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L309-L323 | train |
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",
"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L325-L341 | train |
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",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L14-L31 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/__init__.py#L95-L114 | train |
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"
] | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L13-L20 | train |
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",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/SharedStorage/SharedStorage.py#L22-L40 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L70-L82 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L84-L92 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L94-L106 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L108-L120 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L122-L134 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L136-L148 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L150-L171 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L173-L201 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L203-L252 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L254-L295 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L297-L319 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L321-L380 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L382-L398 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L400-L431 | train |
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",
... | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L433-L460 | train |
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",
":",
... | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L462-L481 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L483-L505 | train |
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"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L507-L532 | train |
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",
")"
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L534-L551 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L569-L587 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L589-L609 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L611-L629 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L631-L653 | train |
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",
"."
] | a075e45774dd5baecf0217843cda747084268e32 | https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L655-L728 | train |
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"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L120-L125 | train |
TylerGubala/bpy-build | setup.py | InstallCMakeLibs.run | def run(self):
"""
Copy libraries from the bin directory and place them as appropriate
"""
self.announce("Moving library files", level=3)
# We have already built the libraries in the previous build_ext step
self.skip_build = True
bin_dir = self.distribution.bi... | python | def run(self):
"""
Copy libraries from the bin directory and place them as appropriate
"""
self.announce("Moving library files", level=3)
# We have already built the libraries in the previous build_ext step
self.skip_build = True
bin_dir = self.distribution.bi... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"announce",
"(",
"\"Moving library files\"",
",",
"level",
"=",
"3",
")",
"# We have already built the libraries in the previous build_ext step",
"self",
".",
"skip_build",
"=",
"True",
"bin_dir",
"=",
"self",
".",
... | Copy libraries from the bin directory and place them as appropriate | [
"Copy",
"libraries",
"from",
"the",
"bin",
"directory",
"and",
"place",
"them",
"as",
"appropriate"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L181-L225 | train |
TylerGubala/bpy-build | setup.py | InstallBlenderScripts.run | def run(self):
"""
Copy the required directory to the build directory and super().run()
"""
self.announce("Moving scripts files", level=3)
self.skip_build = True
bin_dir = self.distribution.bin_dir
scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in
... | python | def run(self):
"""
Copy the required directory to the build directory and super().run()
"""
self.announce("Moving scripts files", level=3)
self.skip_build = True
bin_dir = self.distribution.bin_dir
scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"announce",
"(",
"\"Moving scripts files\"",
",",
"level",
"=",
"3",
")",
"self",
".",
"skip_build",
"=",
"True",
"bin_dir",
"=",
"self",
".",
"distribution",
".",
"bin_dir",
"scripts_dirs",
"=",
"[",
"os... | Copy the required directory to the build directory and super().run() | [
"Copy",
"the",
"required",
"directory",
"to",
"the",
"build",
"directory",
"and",
"super",
"()",
".",
"run",
"()"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L232-L273 | train |
TylerGubala/bpy-build | setup.py | BuildCMakeExt.run | def run(self):
"""
Perform build_cmake before doing the 'normal' stuff
"""
for extension in self.extensions:
if extension.name == "bpy":
self.build_cmake(extension)
super().run() | python | def run(self):
"""
Perform build_cmake before doing the 'normal' stuff
"""
for extension in self.extensions:
if extension.name == "bpy":
self.build_cmake(extension)
super().run() | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"extension",
"in",
"self",
".",
"extensions",
":",
"if",
"extension",
".",
"name",
"==",
"\"bpy\"",
":",
"self",
".",
"build_cmake",
"(",
"extension",
")",
"super",
"(",
")",
".",
"run",
"(",
")"
] | Perform build_cmake before doing the 'normal' stuff | [
"Perform",
"build_cmake",
"before",
"doing",
"the",
"normal",
"stuff"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L280-L291 | train |
TylerGubala/bpy-build | setup.py | BuildCMakeExt.build_cmake | def build_cmake(self, extension: Extension):
"""
The steps required to build the extension
"""
# We import the setup_requires modules here because if we import them
# at the top this script will always fail as they won't be present
from git import Repo as GitRepo
... | python | def build_cmake(self, extension: Extension):
"""
The steps required to build the extension
"""
# We import the setup_requires modules here because if we import them
# at the top this script will always fail as they won't be present
from git import Repo as GitRepo
... | [
"def",
"build_cmake",
"(",
"self",
",",
"extension",
":",
"Extension",
")",
":",
"# We import the setup_requires modules here because if we import them",
"# at the top this script will always fail as they won't be present",
"from",
"git",
"import",
"Repo",
"as",
"GitRepo",
"from"... | The steps required to build the extension | [
"The",
"steps",
"required",
"to",
"build",
"the",
"extension"
] | 667d41526a346cfa271e26c5d675689c7ab1a254 | https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L293-L536 | train |
Arubacloud/pyArubaCloud | ArubaCloud/ReverseDns/ReverseDns.py | ReverseDns.get | def get(self, addresses):
"""
:type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses
"""
request =... | python | def get(self, addresses):
"""
:type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses
"""
request =... | [
"def",
"get",
"(",
"self",
",",
"addresses",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"GetReverseDns",
".",
"GetReverseDns",
",",
"IPs",
"=",
"addresses",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return",
"response",
"[",
... | :type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses | [
":",
"type",
"addresses",
":",
"list",
"[",
"str",
"]",
":",
"param",
"addresses",
":",
"(",
"list",
"[",
"str",
"]",
")",
"List",
"of",
"addresses",
"to",
"retrieve",
"their",
"reverse",
"dns",
"Retrieve",
"the",
"current",
"configured",
"ReverseDns",
"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L12-L21 | train |
Arubacloud/pyArubaCloud | ArubaCloud/ReverseDns/ReverseDns.py | ReverseDns.set | def set(self, address, host_name):
"""
Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:... | python | def set(self, address, host_name):
"""
Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:... | [
"def",
"set",
"(",
"self",
",",
"address",
",",
"host_name",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"SetEnqueueSetReverseDns",
".",
"SetEnqueueSetReverseDns",
",",
"IP",
"=",
"address",
",",
"Hosts",
"=",
"host_name",
")",
"response",
"=",
"r... | Assign one or more PTR record to a single IP Address
:type address: str
:type host_name: list[str]
:param address: (str) The IP address to configure
:param host_name: (list[str]) The list of strings representing PTR records
:return: (bool) True in case of success, False in case o... | [
"Assign",
"one",
"or",
"more",
"PTR",
"record",
"to",
"a",
"single",
"IP",
"Address",
":",
"type",
"address",
":",
"str",
":",
"type",
"host_name",
":",
"list",
"[",
"str",
"]",
":",
"param",
"address",
":",
"(",
"str",
")",
"The",
"IP",
"address",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L23-L34 | train |
Arubacloud/pyArubaCloud | ArubaCloud/ReverseDns/ReverseDns.py | ReverseDns.reset | def reset(self, addresses):
"""
Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure
"""
request = self._call(SetEnqueueRese... | python | def reset(self, addresses):
"""
Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure
"""
request = self._call(SetEnqueueRese... | [
"def",
"reset",
"(",
"self",
",",
"addresses",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"SetEnqueueResetReverseDns",
".",
"SetEnqueueResetReverseDns",
",",
"IPs",
"=",
"addresses",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return... | Remove all PTR records from the given address
:type addresses: List[str]
:param addresses: (List[str]) The IP Address to reset
:return: (bool) True in case of success, False in case of failure | [
"Remove",
"all",
"PTR",
"records",
"from",
"the",
"given",
"address",
":",
"type",
"addresses",
":",
"List",
"[",
"str",
"]",
":",
"param",
"addresses",
":",
"(",
"List",
"[",
"str",
"]",
")",
"The",
"IP",
"Address",
"to",
"reset",
":",
"return",
":"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L36-L45 | train |
Arubacloud/pyArubaCloud | ArubaCloud/Compute/LoadBalancer/LoadBalancer.py | LoadBalancer.create | def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules,
loadBalancerClassOfServiceID=1, *args, **kwargs):
"""
:type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
... | python | def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules,
loadBalancerClassOfServiceID=1, *args, **kwargs):
"""
:type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
... | [
"def",
"create",
"(",
"self",
",",
"healthCheckNotification",
",",
"instance",
",",
"ipAddressResourceId",
",",
"name",
",",
"notificationContacts",
",",
"rules",
",",
"loadBalancerClassOfServiceID",
"=",
"1",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":... | :type healthCheckNotification: bool
:type instance: list[Instance]
:type ipAddressResourceId: list[int]
:type loadBalancerClassOfServiceID: int
:type name: str
:type notificationContacts: NotificationContacts or list[NotificationContact]
:type rules: Rules
:param ... | [
":",
"type",
"healthCheckNotification",
":",
"bool",
":",
"type",
"instance",
":",
"list",
"[",
"Instance",
"]",
":",
"type",
"ipAddressResourceId",
":",
"list",
"[",
"int",
"]",
":",
"type",
"loadBalancerClassOfServiceID",
":",
"int",
":",
"type",
"name",
"... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L15-L41 | train |
Arubacloud/pyArubaCloud | ArubaCloud/Compute/LoadBalancer/LoadBalancer.py | LoadBalancer.get_notifications | def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID):
"""
Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBal... | python | def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID):
"""
Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBal... | [
"def",
"get_notifications",
"(",
"self",
",",
"startDate",
",",
"endDate",
",",
"loadBalancerID",
",",
"loadBalancerRuleID",
")",
":",
"return",
"self",
".",
"_call",
"(",
"GetLoadBalancerNotifications",
",",
"startDate",
"=",
"startDate",
",",
"endDate",
"=",
"... | Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBalancerRuleID: int
:param startDate: From Date
:param endDate: To Date
:param loadB... | [
"Get",
"the",
"load",
"balancer",
"notifications",
"for",
"a",
"specific",
"rule",
"within",
"a",
"specifying",
"window",
"time",
"frame",
":",
"type",
"startDate",
":",
"datetime",
":",
"type",
"endDate",
":",
"datetime",
":",
"type",
"loadBalancerID",
":",
... | ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4 | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L50-L63 | train |
boundlessgeo/lib-qgis-commons | qgiscommons2/network/oauth2.py | get_oauth_authcfg | def get_oauth_authcfg(authcfg_id=AUTHCFG_ID):
"""Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None"""
# Handle empty strings
if not authcfg_id:
authcfg_id = AUTHCFG_ID
configs = auth_manager().availableAuthMethodConfigs()
if... | python | def get_oauth_authcfg(authcfg_id=AUTHCFG_ID):
"""Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None"""
# Handle empty strings
if not authcfg_id:
authcfg_id = AUTHCFG_ID
configs = auth_manager().availableAuthMethodConfigs()
if... | [
"def",
"get_oauth_authcfg",
"(",
"authcfg_id",
"=",
"AUTHCFG_ID",
")",
":",
"# Handle empty strings",
"if",
"not",
"authcfg_id",
":",
"authcfg_id",
"=",
"AUTHCFG_ID",
"configs",
"=",
"auth_manager",
"(",
")",
".",
"availableAuthMethodConfigs",
"(",
")",
"if",
"aut... | Check if the given authcfg_id (or the default) exists, and if it's valid
OAuth2, return the configuration or None | [
"Check",
"if",
"the",
"given",
"authcfg_id",
"(",
"or",
"the",
"default",
")",
"exists",
"and",
"if",
"it",
"s",
"valid",
"OAuth2",
"return",
"the",
"configuration",
"or",
"None"
] | d25d13803db08c18632b55d12036e332f006d9ac | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L47-L58 | train |
boundlessgeo/lib-qgis-commons | qgiscommons2/network/oauth2.py | setup_oauth | def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME):
"""Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure
"""
cfgjson = {
"accessMethod" : 0,
"apiKey" : "",
"clientId" : "",
"clientSecr... | python | def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME):
"""Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure
"""
cfgjson = {
"accessMethod" : 0,
"apiKey" : "",
"clientId" : "",
"clientSecr... | [
"def",
"setup_oauth",
"(",
"username",
",",
"password",
",",
"basemaps_token_uri",
",",
"authcfg_id",
"=",
"AUTHCFG_ID",
",",
"authcfg_name",
"=",
"AUTHCFG_NAME",
")",
":",
"cfgjson",
"=",
"{",
"\"accessMethod\"",
":",
"0",
",",
"\"apiKey\"",
":",
"\"\"",
",",... | Setup oauth configuration to access the BCS API,
return authcfg_id on success, None on failure | [
"Setup",
"oauth",
"configuration",
"to",
"access",
"the",
"BCS",
"API",
"return",
"authcfg_id",
"on",
"success",
"None",
"on",
"failure"
] | d25d13803db08c18632b55d12036e332f006d9ac | https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L60-L99 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | execute_search | def execute_search(
search,
search_terms="",
user=None,
reference="",
save=True,
query_type=SearchQuery.QUERY_TYPE_SEARCH,
):
"""
Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
... | python | def execute_search(
search,
search_terms="",
user=None,
reference="",
save=True,
query_type=SearchQuery.QUERY_TYPE_SEARCH,
):
"""
Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
... | [
"def",
"execute_search",
"(",
"search",
",",
"search_terms",
"=",
"\"\"",
",",
"user",
"=",
"None",
",",
"reference",
"=",
"\"\"",
",",
"save",
"=",
"True",
",",
"query_type",
"=",
"SearchQuery",
".",
"QUERY_TYPE_SEARCH",
",",
")",
":",
"start",
"=",
"ti... | Create a new SearchQuery instance and execute a search against ES.
Args:
search: elasticsearch.search.Search object, that internally contains
the connection and query; this is the query that is executed. All
we are doing is logging the input and parsing the output.
search_te... | [
"Create",
"a",
"new",
"SearchQuery",
"instance",
"and",
"execute",
"a",
"search",
"against",
"ES",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L565-L617 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentManagerMixin.in_search_queryset | def in_search_queryset(self, instance_id, index="_all"):
"""
Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? ... | python | def in_search_queryset(self, instance_id, index="_all"):
"""
Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? ... | [
"def",
"in_search_queryset",
"(",
"self",
",",
"instance_id",
",",
"index",
"=",
"\"_all\"",
")",
":",
"return",
"self",
".",
"get_search_queryset",
"(",
"index",
"=",
"index",
")",
".",
"filter",
"(",
"pk",
"=",
"instance_id",
")",
".",
"exists",
"(",
"... | Return True if an object is part of the search index queryset.
Sometimes it's useful to know if an object _should_ be indexed. If
an object is saved, how do you know if you should push that change
to the search index? The simplest (albeit not most efficient) way
is to check if it appear... | [
"Return",
"True",
"if",
"an",
"object",
"is",
"part",
"of",
"the",
"search",
"index",
"queryset",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L59-L80 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentManagerMixin.from_search_query | def from_search_query(self, search_query):
"""
Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON ... | python | def from_search_query(self, search_query):
"""
Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON ... | [
"def",
"from_search_query",
"(",
"self",
",",
"search_query",
")",
":",
"hits",
"=",
"search_query",
".",
"hits",
"score_sql",
"=",
"self",
".",
"_raw_sql",
"(",
"[",
"(",
"h",
"[",
"\"id\"",
"]",
",",
"h",
"[",
"\"score\"",
"]",
"or",
"0",
")",
"for... | Return queryset of objects from SearchQuery.results, **in order**.
EXPERIMENTAL: this will only work with results from a single index,
with a single doc_type - as we are returning a single QuerySet.
This method takes the hits JSON and converts that into a queryset
of all the relevant o... | [
"Return",
"queryset",
"of",
"objects",
"from",
"SearchQuery",
".",
"results",
"**",
"in",
"order",
"**",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L82-L133 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentManagerMixin._raw_sql | def _raw_sql(self, values):
"""Prepare SQL statement consisting of a sequence of WHEN .. THEN statements."""
if isinstance(self.model._meta.pk, CharField):
when_clauses = " ".join(
[self._when("'{}'".format(x), y) for (x, y) in values]
)
else:
... | python | def _raw_sql(self, values):
"""Prepare SQL statement consisting of a sequence of WHEN .. THEN statements."""
if isinstance(self.model._meta.pk, CharField):
when_clauses = " ".join(
[self._when("'{}'".format(x), y) for (x, y) in values]
)
else:
... | [
"def",
"_raw_sql",
"(",
"self",
",",
"values",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"model",
".",
"_meta",
".",
"pk",
",",
"CharField",
")",
":",
"when_clauses",
"=",
"\" \"",
".",
"join",
"(",
"[",
"self",
".",
"_when",
"(",
"\"'{}'\"",
... | Prepare SQL statement consisting of a sequence of WHEN .. THEN statements. | [
"Prepare",
"SQL",
"statement",
"consisting",
"of",
"a",
"sequence",
"of",
"WHEN",
"..",
"THEN",
"statements",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L138-L150 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.search_document_cache_key | def search_document_cache_key(self):
"""Key used for storing search docs in local cache."""
return "elasticsearch_django:{}.{}.{}".format(
self._meta.app_label, self._meta.model_name, self.pk
) | python | def search_document_cache_key(self):
"""Key used for storing search docs in local cache."""
return "elasticsearch_django:{}.{}.{}".format(
self._meta.app_label, self._meta.model_name, self.pk
) | [
"def",
"search_document_cache_key",
"(",
"self",
")",
":",
"return",
"\"elasticsearch_django:{}.{}.{}\"",
".",
"format",
"(",
"self",
".",
"_meta",
".",
"app_label",
",",
"self",
".",
"_meta",
".",
"model_name",
",",
"self",
".",
"pk",
")"
] | Key used for storing search docs in local cache. | [
"Key",
"used",
"for",
"storing",
"search",
"docs",
"in",
"local",
"cache",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L188-L192 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin._is_field_serializable | def _is_field_serializable(self, field_name):
"""Return True if the field can be serialized into a JSON doc."""
return (
self._meta.get_field(field_name).get_internal_type()
in self.SIMPLE_UPDATE_FIELD_TYPES
) | python | def _is_field_serializable(self, field_name):
"""Return True if the field can be serialized into a JSON doc."""
return (
self._meta.get_field(field_name).get_internal_type()
in self.SIMPLE_UPDATE_FIELD_TYPES
) | [
"def",
"_is_field_serializable",
"(",
"self",
",",
"field_name",
")",
":",
"return",
"(",
"self",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
".",
"get_internal_type",
"(",
")",
"in",
"self",
".",
"SIMPLE_UPDATE_FIELD_TYPES",
")"
] | Return True if the field can be serialized into a JSON doc. | [
"Return",
"True",
"if",
"the",
"field",
"can",
"be",
"serialized",
"into",
"a",
"JSON",
"doc",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L223-L228 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.clean_update_fields | def clean_update_fields(self, index, update_fields):
"""
Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in t... | python | def clean_update_fields(self, index, update_fields):
"""
Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in t... | [
"def",
"clean_update_fields",
"(",
"self",
",",
"index",
",",
"update_fields",
")",
":",
"search_fields",
"=",
"get_model_index_properties",
"(",
"self",
",",
"index",
")",
"clean_fields",
"=",
"[",
"f",
"for",
"f",
"in",
"update_fields",
"if",
"f",
"in",
"s... | Clean the list of update_fields based on the index being updated.\
If any field in the update_fields list is not in the set of properties
defined by the index mapping for this model, then we ignore it. If
a field _is_ in the mapping, but the underlying model field is a
related object, a... | [
"Clean",
"the",
"list",
"of",
"update_fields",
"based",
"on",
"the",
"index",
"being",
"updated",
".",
"\\"
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L230-L255 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.as_search_document_update | def as_search_document_update(self, *, index, update_fields):
"""
Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenari... | python | def as_search_document_update(self, *, index, update_fields):
"""
Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenari... | [
"def",
"as_search_document_update",
"(",
"self",
",",
"*",
",",
"index",
",",
"update_fields",
")",
":",
"if",
"UPDATE_STRATEGY",
"==",
"UPDATE_STRATEGY_FULL",
":",
"return",
"self",
".",
"as_search_document",
"(",
"index",
"=",
"index",
")",
"if",
"UPDATE_STRAT... | Return a partial update document based on which fields have been updated.
If an object is saved with the `update_fields` argument passed
through, then it is assumed that this is a 'partial update'. In
this scenario we need a {property: value} dictionary containing
just the fields we wan... | [
"Return",
"a",
"partial",
"update",
"document",
"based",
"on",
"which",
"fields",
"have",
"been",
"updated",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L257-L306 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.as_search_action | def as_search_action(self, *, index, action):
"""
Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format ... | python | def as_search_action(self, *, index, action):
"""
Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format ... | [
"def",
"as_search_action",
"(",
"self",
",",
"*",
",",
"index",
",",
"action",
")",
":",
"if",
"action",
"not",
"in",
"(",
"\"index\"",
",",
"\"update\"",
",",
"\"delete\"",
")",
":",
"raise",
"ValueError",
"(",
"\"Action must be 'index', 'update' or 'delete'.\"... | Return an object as represented in a bulk api operation.
Bulk API operations have a very specific format. This function will
call the standard `as_search_document` method on the object and then
wrap that up in the correct format for the action specified.
https://www.elastic.co/guide/en... | [
"Return",
"an",
"object",
"as",
"represented",
"in",
"a",
"bulk",
"api",
"operation",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L308-L342 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.fetch_search_document | def fetch_search_document(self, *, index):
"""Fetch the object's document from a search index by id."""
assert self.pk, "Object must have a primary key before being indexed."
client = get_client()
return client.get(index=index, doc_type=self.search_doc_type, id=self.pk) | python | def fetch_search_document(self, *, index):
"""Fetch the object's document from a search index by id."""
assert self.pk, "Object must have a primary key before being indexed."
client = get_client()
return client.get(index=index, doc_type=self.search_doc_type, id=self.pk) | [
"def",
"fetch_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"assert",
"self",
".",
"pk",
",",
"\"Object must have a primary key before being indexed.\"",
"client",
"=",
"get_client",
"(",
")",
"return",
"client",
".",
"get",
"(",
"index",
"=",... | Fetch the object's document from a search index by id. | [
"Fetch",
"the",
"object",
"s",
"document",
"from",
"a",
"search",
"index",
"by",
"id",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L344-L348 | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | SearchDocumentMixin.index_search_document | def index_search_document(self, *, index):
"""
Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
... | python | def index_search_document(self, *, index):
"""
Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
... | [
"def",
"index_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"cache_key",
"=",
"self",
".",
"search_document_cache_key",
"new_doc",
"=",
"self",
".",
"as_search_document",
"(",
"index",
"=",
"index",
")",
"cached_doc",
"=",
"cache",
".",
"g... | Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
in the settings, and defaults to 60s. | [
"Create",
"or",
"replace",
"search",
"document",
"in",
"named",
"index",
"."
] | e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489 | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L350-L369 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.