repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/source.py | AtlasChangeSource.build_api_struct | def build_api_struct(self):
"""
Calls parent's method and just adds the addtional field 'action', that
is required to form the structure that Atlas API is accepting.
"""
data = super(AtlasChangeSource, self).build_api_struct()
data.update({"action": self._action})
... | python | def build_api_struct(self):
"""
Calls parent's method and just adds the addtional field 'action', that
is required to form the structure that Atlas API is accepting.
"""
data = super(AtlasChangeSource, self).build_api_struct()
data.update({"action": self._action})
... | [
"def",
"build_api_struct",
"(",
"self",
")",
":",
"data",
"=",
"super",
"(",
"AtlasChangeSource",
",",
"self",
")",
".",
"build_api_struct",
"(",
")",
"data",
".",
"update",
"(",
"{",
"\"action\"",
":",
"self",
".",
"_action",
"}",
")",
"return",
"data"
... | Calls parent's method and just adds the addtional field 'action', that
is required to form the structure that Atlas API is accepting. | [
"Calls",
"parent",
"s",
"method",
"and",
"just",
"adds",
"the",
"addtional",
"field",
"action",
"that",
"is",
"required",
"to",
"form",
"the",
"structure",
"that",
"Atlas",
"API",
"is",
"accepting",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L226-L233 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | AtlasMeasurement.add_option | def add_option(self, **options):
"""
Adds an option and its value to the class as an attribute and stores it
to the used options set.
"""
for option, value in options.items():
setattr(self, option, value)
self._store_option(option) | python | def add_option(self, **options):
"""
Adds an option and its value to the class as an attribute and stores it
to the used options set.
"""
for option, value in options.items():
setattr(self, option, value)
self._store_option(option) | [
"def",
"add_option",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"for",
"option",
",",
"value",
"in",
"options",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"option",
",",
"value",
")",
"self",
".",
"_store_option",
"(",
"option",
... | Adds an option and its value to the class as an attribute and stores it
to the used options set. | [
"Adds",
"an",
"option",
"and",
"its",
"value",
"to",
"the",
"class",
"as",
"an",
"attribute",
"and",
"stores",
"it",
"to",
"the",
"used",
"options",
"set",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L60-L67 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | AtlasMeasurement._init_required_options | def _init_required_options(self, **kwargs):
"""
Initialize the required option as class members. The value will be
either None or the specified value in the kwargs or __init__. The logic
here is to make the required options accesible to edit after a class
instance has been create... | python | def _init_required_options(self, **kwargs):
"""
Initialize the required option as class members. The value will be
either None or the specified value in the kwargs or __init__. The logic
here is to make the required options accesible to edit after a class
instance has been create... | [
"def",
"_init_required_options",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"field",
"in",
"self",
".",
"required_options",
":",
"setattr",
"(",
"self",
",",
"field",
",",
"kwargs",
".",
"get",
"(",
"field",
")",
")",
"self",
".",
"_store_o... | Initialize the required option as class members. The value will be
either None or the specified value in the kwargs or __init__. The logic
here is to make the required options accesible to edit after a class
instance has been created. | [
"Initialize",
"the",
"required",
"option",
"as",
"class",
"members",
".",
"The",
"value",
"will",
"be",
"either",
"None",
"or",
"the",
"specified",
"value",
"in",
"the",
"kwargs",
"or",
"__init__",
".",
"The",
"logic",
"here",
"is",
"to",
"make",
"the",
... | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L69-L78 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | AtlasMeasurement.clean | def clean(self):
"""
Cleans/checks user entered data making sure required options are at
least present. This might save some queries from being sent if
they are totally wrong.
"""
# make sure the correct measurement type is set.
if not self.measurement_type:
... | python | def clean(self):
"""
Cleans/checks user entered data making sure required options are at
least present. This might save some queries from being sent if
they are totally wrong.
"""
# make sure the correct measurement type is set.
if not self.measurement_type:
... | [
"def",
"clean",
"(",
"self",
")",
":",
"# make sure the correct measurement type is set.",
"if",
"not",
"self",
".",
"measurement_type",
":",
"log",
"=",
"\"Please define a valid measurement type.\"",
"raise",
"MalFormattedMeasurement",
"(",
"log",
")",
"# make sure the req... | Cleans/checks user entered data making sure required options are at
least present. This might save some queries from being sent if
they are totally wrong. | [
"Cleans",
"/",
"checks",
"user",
"entered",
"data",
"making",
"sure",
"required",
"options",
"are",
"at",
"least",
"present",
".",
"This",
"might",
"save",
"some",
"queries",
"from",
"being",
"sent",
"if",
"they",
"are",
"totally",
"wrong",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L80-L98 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | AtlasMeasurement.v2_translator | def v2_translator(self, option):
"""
This is a temporary function that helps move from v1 API to v2 without
breaking already running script and keep backwards compatibility.
Translates option name from API v1 to renamed one of v2 API.
"""
new_option = option
new_v... | python | def v2_translator(self, option):
"""
This is a temporary function that helps move from v1 API to v2 without
breaking already running script and keep backwards compatibility.
Translates option name from API v1 to renamed one of v2 API.
"""
new_option = option
new_v... | [
"def",
"v2_translator",
"(",
"self",
",",
"option",
")",
":",
"new_option",
"=",
"option",
"new_value",
"=",
"getattr",
"(",
"self",
",",
"option",
")",
"renaming_pairs",
"=",
"{",
"\"dontfrag\"",
":",
"\"dont_fragment\"",
",",
"\"maxhops\"",
":",
"\"max_hops\... | This is a temporary function that helps move from v1 API to v2 without
breaking already running script and keep backwards compatibility.
Translates option name from API v1 to renamed one of v2 API. | [
"This",
"is",
"a",
"temporary",
"function",
"that",
"helps",
"move",
"from",
"v1",
"API",
"to",
"v2",
"without",
"breaking",
"already",
"running",
"script",
"and",
"keep",
"backwards",
"compatibility",
".",
"Translates",
"option",
"name",
"from",
"API",
"v1",
... | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L100-L132 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | AtlasMeasurement.build_api_struct | def build_api_struct(self):
"""
Calls the clean method of the class and returns the info in a
structure that Atlas API is accepting.
"""
self.clean()
data = {"type": self.measurement_type}
# add all options
for option in self.used_options:
opt... | python | def build_api_struct(self):
"""
Calls the clean method of the class and returns the info in a
structure that Atlas API is accepting.
"""
self.clean()
data = {"type": self.measurement_type}
# add all options
for option in self.used_options:
opt... | [
"def",
"build_api_struct",
"(",
"self",
")",
":",
"self",
".",
"clean",
"(",
")",
"data",
"=",
"{",
"\"type\"",
":",
"self",
".",
"measurement_type",
"}",
"# add all options",
"for",
"option",
"in",
"self",
".",
"used_options",
":",
"option_key",
",",
"opt... | Calls the clean method of the class and returns the info in a
structure that Atlas API is accepting. | [
"Calls",
"the",
"clean",
"method",
"of",
"the",
"class",
"and",
"returns",
"the",
"info",
"in",
"a",
"structure",
"that",
"Atlas",
"API",
"is",
"accepting",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L134-L147 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/stream.py | AtlasStream.connect | def connect(self):
"""Initiate the channel we want to start streams from."""
self.socketIO = SocketIO(
host=self.iosocket_server,
port=80,
resource=self.iosocket_resource,
proxies=self.proxies,
headers=self.headers,
transports=["web... | python | def connect(self):
"""Initiate the channel we want to start streams from."""
self.socketIO = SocketIO(
host=self.iosocket_server,
port=80,
resource=self.iosocket_resource,
proxies=self.proxies,
headers=self.headers,
transports=["web... | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"socketIO",
"=",
"SocketIO",
"(",
"host",
"=",
"self",
".",
"iosocket_server",
",",
"port",
"=",
"80",
",",
"resource",
"=",
"self",
".",
"iosocket_resource",
",",
"proxies",
"=",
"self",
".",
"prox... | Initiate the channel we want to start streams from. | [
"Initiate",
"the",
"channel",
"we",
"want",
"to",
"start",
"streams",
"from",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L104-L116 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/stream.py | AtlasStream.bind_channel | def bind_channel(self, channel, callback):
"""Bind given channel with the given callback"""
# Remove the following list when deprecation time expires
if channel in self.CHANNELS:
warning = (
"The event name '{}' will soon be deprecated. Use "
"the rea... | python | def bind_channel(self, channel, callback):
"""Bind given channel with the given callback"""
# Remove the following list when deprecation time expires
if channel in self.CHANNELS:
warning = (
"The event name '{}' will soon be deprecated. Use "
"the rea... | [
"def",
"bind_channel",
"(",
"self",
",",
"channel",
",",
"callback",
")",
":",
"# Remove the following list when deprecation time expires",
"if",
"channel",
"in",
"self",
".",
"CHANNELS",
":",
"warning",
"=",
"(",
"\"The event name '{}' will soon be deprecated. Use \"",
"... | Bind given channel with the given callback | [
"Bind",
"given",
"channel",
"with",
"the",
"given",
"callback"
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L130-L149 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/stream.py | AtlasStream.start_stream | def start_stream(self, stream_type, **stream_parameters):
"""Starts new stream for given type with given parameters"""
if stream_type:
self.subscribe(stream_type, **stream_parameters)
else:
self.handle_error("You need to set a stream type") | python | def start_stream(self, stream_type, **stream_parameters):
"""Starts new stream for given type with given parameters"""
if stream_type:
self.subscribe(stream_type, **stream_parameters)
else:
self.handle_error("You need to set a stream type") | [
"def",
"start_stream",
"(",
"self",
",",
"stream_type",
",",
"*",
"*",
"stream_parameters",
")",
":",
"if",
"stream_type",
":",
"self",
".",
"subscribe",
"(",
"stream_type",
",",
"*",
"*",
"stream_parameters",
")",
"else",
":",
"self",
".",
"handle_error",
... | Starts new stream for given type with given parameters | [
"Starts",
"new",
"stream",
"for",
"given",
"type",
"with",
"given",
"parameters"
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L151-L156 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/stream.py | AtlasStream.subscribe | def subscribe(self, stream_type, **parameters):
"""Subscribe to stream with give parameters."""
parameters["stream_type"] = stream_type
if (stream_type == "result") and ("buffering" not in parameters):
parameters["buffering"] = True
self.socketIO.emit(self.EVENT_NAME_SUBSCR... | python | def subscribe(self, stream_type, **parameters):
"""Subscribe to stream with give parameters."""
parameters["stream_type"] = stream_type
if (stream_type == "result") and ("buffering" not in parameters):
parameters["buffering"] = True
self.socketIO.emit(self.EVENT_NAME_SUBSCR... | [
"def",
"subscribe",
"(",
"self",
",",
"stream_type",
",",
"*",
"*",
"parameters",
")",
":",
"parameters",
"[",
"\"stream_type\"",
"]",
"=",
"stream_type",
"if",
"(",
"stream_type",
"==",
"\"result\"",
")",
"and",
"(",
"\"buffering\"",
"not",
"in",
"parameter... | Subscribe to stream with give parameters. | [
"Subscribe",
"to",
"stream",
"with",
"give",
"parameters",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L158-L165 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/stream.py | AtlasStream.timeout | def timeout(self, seconds=None):
"""
Times out all streams after n seconds or wait forever if seconds is
None
"""
if seconds is None:
self.socketIO.wait()
else:
self.socketIO.wait(seconds=seconds) | python | def timeout(self, seconds=None):
"""
Times out all streams after n seconds or wait forever if seconds is
None
"""
if seconds is None:
self.socketIO.wait()
else:
self.socketIO.wait(seconds=seconds) | [
"def",
"timeout",
"(",
"self",
",",
"seconds",
"=",
"None",
")",
":",
"if",
"seconds",
"is",
"None",
":",
"self",
".",
"socketIO",
".",
"wait",
"(",
")",
"else",
":",
"self",
".",
"socketIO",
".",
"wait",
"(",
"seconds",
"=",
"seconds",
")"
] | Times out all streams after n seconds or wait forever if seconds is
None | [
"Times",
"out",
"all",
"streams",
"after",
"n",
"seconds",
"or",
"wait",
"forever",
"if",
"seconds",
"is",
"None"
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L167-L175 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/api_listing.py | RequestGenerator.build_url | def build_url(self):
"""Build the url path based on the filter options."""
if not self.api_filters:
return self.url
# Reduce complex objects to simpler strings
for k, v in self.api_filters.items():
if isinstance(v, datetime): # datetime > UNIX timestamp
... | python | def build_url(self):
"""Build the url path based on the filter options."""
if not self.api_filters:
return self.url
# Reduce complex objects to simpler strings
for k, v in self.api_filters.items():
if isinstance(v, datetime): # datetime > UNIX timestamp
... | [
"def",
"build_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"api_filters",
":",
"return",
"self",
".",
"url",
"# Reduce complex objects to simpler strings",
"for",
"k",
",",
"v",
"in",
"self",
".",
"api_filters",
".",
"items",
"(",
")",
":",
"if",... | Build the url path based on the filter options. | [
"Build",
"the",
"url",
"path",
"based",
"on",
"the",
"filter",
"options",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_listing.py#L55-L77 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/api_listing.py | RequestGenerator.build_url_chunks | def build_url_chunks(self):
"""
If url is too big because of id filter is huge, break id and construct
several urls to call them in order to abstract this complexity from user.
"""
CHUNK_SIZE = 500
id_filter = str(self.api_filters.pop(self.id_filter)).split(',')
... | python | def build_url_chunks(self):
"""
If url is too big because of id filter is huge, break id and construct
several urls to call them in order to abstract this complexity from user.
"""
CHUNK_SIZE = 500
id_filter = str(self.api_filters.pop(self.id_filter)).split(',')
... | [
"def",
"build_url_chunks",
"(",
"self",
")",
":",
"CHUNK_SIZE",
"=",
"500",
"id_filter",
"=",
"str",
"(",
"self",
".",
"api_filters",
".",
"pop",
"(",
"self",
".",
"id_filter",
")",
")",
".",
"split",
"(",
"','",
")",
"chuncks",
"=",
"list",
"(",
"se... | If url is too big because of id filter is huge, break id and construct
several urls to call them in order to abstract this complexity from user. | [
"If",
"url",
"is",
"too",
"big",
"because",
"of",
"id",
"filter",
"is",
"huge",
"break",
"id",
"and",
"construct",
"several",
"urls",
"to",
"call",
"them",
"in",
"order",
"to",
"abstract",
"this",
"complexity",
"from",
"user",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_listing.py#L79-L95 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/api_listing.py | RequestGenerator.next_batch | def next_batch(self):
"""
Querying API for the next batch of objects and store next url and
batch of objects.
"""
is_success, results = AtlasRequest(
url_path=self.atlas_url,
user_agent=self._user_agent,
server=self.server,
verify=s... | python | def next_batch(self):
"""
Querying API for the next batch of objects and store next url and
batch of objects.
"""
is_success, results = AtlasRequest(
url_path=self.atlas_url,
user_agent=self._user_agent,
server=self.server,
verify=s... | [
"def",
"next_batch",
"(",
"self",
")",
":",
"is_success",
",",
"results",
"=",
"AtlasRequest",
"(",
"url_path",
"=",
"self",
".",
"atlas_url",
",",
"user_agent",
"=",
"self",
".",
"_user_agent",
",",
"server",
"=",
"self",
".",
"server",
",",
"verify",
"... | Querying API for the next batch of objects and store next url and
batch of objects. | [
"Querying",
"API",
"for",
"the",
"next",
"batch",
"of",
"objects",
"and",
"store",
"next",
"url",
"and",
"batch",
"of",
"objects",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_listing.py#L123-L140 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/api_listing.py | RequestGenerator.build_next_url | def build_next_url(self, url):
"""Builds next url in a format compatible with cousteau. Path + query"""
if not url:
if self.split_urls: # If we had a long request give the next part
self.total_count_flag = False # Reset flag for count
return self.split_urls.... | python | def build_next_url(self, url):
"""Builds next url in a format compatible with cousteau. Path + query"""
if not url:
if self.split_urls: # If we had a long request give the next part
self.total_count_flag = False # Reset flag for count
return self.split_urls.... | [
"def",
"build_next_url",
"(",
"self",
",",
"url",
")",
":",
"if",
"not",
"url",
":",
"if",
"self",
".",
"split_urls",
":",
"# If we had a long request give the next part",
"self",
".",
"total_count_flag",
"=",
"False",
"# Reset flag for count",
"return",
"self",
"... | Builds next url in a format compatible with cousteau. Path + query | [
"Builds",
"next",
"url",
"in",
"a",
"format",
"compatible",
"with",
"cousteau",
".",
"Path",
"+",
"query"
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_listing.py#L142-L152 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/api_listing.py | RequestGenerator.set_total_count | def set_total_count(self, value):
"""Setter for count attribute. Set should append only one count per splitted url."""
if not self.total_count_flag and value:
self._count.append(int(value))
self.total_count_flag = True | python | def set_total_count(self, value):
"""Setter for count attribute. Set should append only one count per splitted url."""
if not self.total_count_flag and value:
self._count.append(int(value))
self.total_count_flag = True | [
"def",
"set_total_count",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"total_count_flag",
"and",
"value",
":",
"self",
".",
"_count",
".",
"append",
"(",
"int",
"(",
"value",
")",
")",
"self",
".",
"total_count_flag",
"=",
"True"
] | Setter for count attribute. Set should append only one count per splitted url. | [
"Setter",
"for",
"count",
"attribute",
".",
"Set",
"should",
"append",
"only",
"one",
"count",
"per",
"splitted",
"url",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_listing.py#L162-L166 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.get_headers | def get_headers(self):
"""Return header for the HTTP request."""
headers = {
"User-Agent": self.http_agent,
"Content-Type": "application/json",
"Accept": "application/json"
}
if self.headers:
headers.update(self.headers)
return hea... | python | def get_headers(self):
"""Return header for the HTTP request."""
headers = {
"User-Agent": self.http_agent,
"Content-Type": "application/json",
"Accept": "application/json"
}
if self.headers:
headers.update(self.headers)
return hea... | [
"def",
"get_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"\"User-Agent\"",
":",
"self",
".",
"http_agent",
",",
"\"Content-Type\"",
":",
"\"application/json\"",
",",
"\"Accept\"",
":",
"\"application/json\"",
"}",
"if",
"self",
".",
"headers",
":",
"h... | Return header for the HTTP request. | [
"Return",
"header",
"for",
"the",
"HTTP",
"request",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L63-L73 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.http_method | def http_method(self, method):
"""
Execute the given HTTP method and returns if it's success or not
and the response as a string if not success and as python object after
unjson if it's success.
"""
self.build_url()
try:
response = self.get_http_metho... | python | def http_method(self, method):
"""
Execute the given HTTP method and returns if it's success or not
and the response as a string if not success and as python object after
unjson if it's success.
"""
self.build_url()
try:
response = self.get_http_metho... | [
"def",
"http_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"build_url",
"(",
")",
"try",
":",
"response",
"=",
"self",
".",
"get_http_method",
"(",
"method",
")",
"is_success",
"=",
"response",
".",
"ok",
"try",
":",
"response_message",
"="... | Execute the given HTTP method and returns if it's success or not
and the response as a string if not success and as python object after
unjson if it's success. | [
"Execute",
"the",
"given",
"HTTP",
"method",
"and",
"returns",
"if",
"it",
"s",
"success",
"or",
"not",
"and",
"the",
"response",
"as",
"a",
"string",
"if",
"not",
"success",
"and",
"as",
"python",
"object",
"after",
"unjson",
"if",
"it",
"s",
"success",... | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L75-L96 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.get_http_method | def get_http_method(self, method):
"""Gets the http method that will be called from the requests library"""
return self.http_methods[method](self.url, **self.http_method_args) | python | def get_http_method(self, method):
"""Gets the http method that will be called from the requests library"""
return self.http_methods[method](self.url, **self.http_method_args) | [
"def",
"get_http_method",
"(",
"self",
",",
"method",
")",
":",
"return",
"self",
".",
"http_methods",
"[",
"method",
"]",
"(",
"self",
".",
"url",
",",
"*",
"*",
"self",
".",
"http_method_args",
")"
] | Gets the http method that will be called from the requests library | [
"Gets",
"the",
"http",
"method",
"that",
"will",
"be",
"called",
"from",
"the",
"requests",
"library"
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L98-L100 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.get | def get(self, **url_params):
"""
Makes the HTTP GET to the url.
"""
if url_params:
self.http_method_args["params"].update(url_params)
return self.http_method("GET") | python | def get(self, **url_params):
"""
Makes the HTTP GET to the url.
"""
if url_params:
self.http_method_args["params"].update(url_params)
return self.http_method("GET") | [
"def",
"get",
"(",
"self",
",",
"*",
"*",
"url_params",
")",
":",
"if",
"url_params",
":",
"self",
".",
"http_method_args",
"[",
"\"params\"",
"]",
".",
"update",
"(",
"url_params",
")",
"return",
"self",
".",
"http_method",
"(",
"\"GET\"",
")"
] | Makes the HTTP GET to the url. | [
"Makes",
"the",
"HTTP",
"GET",
"to",
"the",
"url",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L109-L115 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.post | def post(self):
"""
Makes the HTTP POST to the url sending post_data.
"""
self._construct_post_data()
post_args = {"json": self.post_data}
self.http_method_args.update(post_args)
return self.http_method("POST") | python | def post(self):
"""
Makes the HTTP POST to the url sending post_data.
"""
self._construct_post_data()
post_args = {"json": self.post_data}
self.http_method_args.update(post_args)
return self.http_method("POST") | [
"def",
"post",
"(",
"self",
")",
":",
"self",
".",
"_construct_post_data",
"(",
")",
"post_args",
"=",
"{",
"\"json\"",
":",
"self",
".",
"post_data",
"}",
"self",
".",
"http_method_args",
".",
"update",
"(",
"post_args",
")",
"return",
"self",
".",
"htt... | Makes the HTTP POST to the url sending post_data. | [
"Makes",
"the",
"HTTP",
"POST",
"to",
"the",
"url",
"sending",
"post_data",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L117-L126 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasRequest.clean_time | def clean_time(self, time):
"""
Transform time field to datetime object if there is any.
"""
if isinstance(time, int):
time = datetime.utcfromtimestamp(time)
elif isinstance(time, str):
time = parser.parse(time)
return time | python | def clean_time(self, time):
"""
Transform time field to datetime object if there is any.
"""
if isinstance(time, int):
time = datetime.utcfromtimestamp(time)
elif isinstance(time, str):
time = parser.parse(time)
return time | [
"def",
"clean_time",
"(",
"self",
",",
"time",
")",
":",
"if",
"isinstance",
"(",
"time",
",",
"int",
")",
":",
"time",
"=",
"datetime",
".",
"utcfromtimestamp",
"(",
"time",
")",
"elif",
"isinstance",
"(",
"time",
",",
"str",
")",
":",
"time",
"=",
... | Transform time field to datetime object if there is any. | [
"Transform",
"time",
"field",
"to",
"datetime",
"object",
"if",
"there",
"is",
"any",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L131-L140 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasCreateRequest._construct_post_data | def _construct_post_data(self):
"""
Constructs the data structure that is required from the atlas API based
on measurements, sources and times user has specified.
"""
definitions = [msm.build_api_struct() for msm in self.measurements]
probes = [source.build_api_struct() f... | python | def _construct_post_data(self):
"""
Constructs the data structure that is required from the atlas API based
on measurements, sources and times user has specified.
"""
definitions = [msm.build_api_struct() for msm in self.measurements]
probes = [source.build_api_struct() f... | [
"def",
"_construct_post_data",
"(",
"self",
")",
":",
"definitions",
"=",
"[",
"msm",
".",
"build_api_struct",
"(",
")",
"for",
"msm",
"in",
"self",
".",
"measurements",
"]",
"probes",
"=",
"[",
"source",
".",
"build_api_struct",
"(",
")",
"for",
"source",... | Constructs the data structure that is required from the atlas API based
on measurements, sources and times user has specified. | [
"Constructs",
"the",
"data",
"structure",
"that",
"is",
"required",
"from",
"the",
"atlas",
"API",
"based",
"on",
"measurements",
"sources",
"and",
"times",
"user",
"has",
"specified",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L180-L206 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasResultsRequest.clean_probes | def clean_probes(self, probe_ids):
"""
Checks format of probe ids and transform it to something API
understands.
"""
if isinstance(probe_ids, (tuple, list)): # tuples & lists > x,y,z
probe_ids = ",".join([str(_) for _ in probe_ids])
return probe_ids | python | def clean_probes(self, probe_ids):
"""
Checks format of probe ids and transform it to something API
understands.
"""
if isinstance(probe_ids, (tuple, list)): # tuples & lists > x,y,z
probe_ids = ",".join([str(_) for _ in probe_ids])
return probe_ids | [
"def",
"clean_probes",
"(",
"self",
",",
"probe_ids",
")",
":",
"if",
"isinstance",
"(",
"probe_ids",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"# tuples & lists > x,y,z",
"probe_ids",
"=",
"\",\"",
".",
"join",
"(",
"[",
"str",
"(",
"_",
")",
"fo... | Checks format of probe ids and transform it to something API
understands. | [
"Checks",
"format",
"of",
"probe",
"ids",
"and",
"transform",
"it",
"to",
"something",
"API",
"understands",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L319-L327 |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/request.py | AtlasResultsRequest.update_http_method_params | def update_http_method_params(self):
"""
Update HTTP url parameters based on msm_id and query filters if
there are any.
"""
url_params = {}
if self.start:
url_params.update(
{"start": int(calendar.timegm(self.start.timetuple()))}
)... | python | def update_http_method_params(self):
"""
Update HTTP url parameters based on msm_id and query filters if
there are any.
"""
url_params = {}
if self.start:
url_params.update(
{"start": int(calendar.timegm(self.start.timetuple()))}
)... | [
"def",
"update_http_method_params",
"(",
"self",
")",
":",
"url_params",
"=",
"{",
"}",
"if",
"self",
".",
"start",
":",
"url_params",
".",
"update",
"(",
"{",
"\"start\"",
":",
"int",
"(",
"calendar",
".",
"timegm",
"(",
"self",
".",
"start",
".",
"ti... | Update HTTP url parameters based on msm_id and query filters if
there are any. | [
"Update",
"HTTP",
"url",
"parameters",
"based",
"on",
"msm_id",
"and",
"query",
"filters",
"if",
"there",
"are",
"any",
"."
] | train | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/request.py#L329-L349 |
fuzeman/trakt.py | trakt/interfaces/search.py | SearchInterface.lookup | def lookup(self, id, service=None, media=None, extended=None, **kwargs):
"""Lookup items by their Trakt, IMDB, TMDB, TVDB, or TVRage ID.
**Note:** If you lookup an identifier without a :code:`media` type specified it
might return multiple items if the :code:`service` is not globally unique.
... | python | def lookup(self, id, service=None, media=None, extended=None, **kwargs):
"""Lookup items by their Trakt, IMDB, TMDB, TVDB, or TVRage ID.
**Note:** If you lookup an identifier without a :code:`media` type specified it
might return multiple items if the :code:`service` is not globally unique.
... | [
"def",
"lookup",
"(",
"self",
",",
"id",
",",
"service",
"=",
"None",
",",
"media",
"=",
"None",
",",
"extended",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Expand tuple `id`",
"if",
"type",
"(",
"id",
")",
"is",
"tuple",
":",
"if",
"len",
... | Lookup items by their Trakt, IMDB, TMDB, TVDB, or TVRage ID.
**Note:** If you lookup an identifier without a :code:`media` type specified it
might return multiple items if the :code:`service` is not globally unique.
:param id: Identifier value to lookup
:type id: :class:`~python:str` o... | [
"Lookup",
"items",
"by",
"their",
"Trakt",
"IMDB",
"TMDB",
"TVDB",
"or",
"TVRage",
"ID",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/search.py#L14-L103 |
fuzeman/trakt.py | trakt/interfaces/search.py | SearchInterface.query | def query(self, query, media=None, year=None, fields=None, extended=None, **kwargs):
"""Search by titles, descriptions, translated titles, aliases, and people.
**Note:** Results are ordered by the most relevant score.
:param query: Search title or description
:type query: :class:`~pyth... | python | def query(self, query, media=None, year=None, fields=None, extended=None, **kwargs):
"""Search by titles, descriptions, translated titles, aliases, and people.
**Note:** Results are ordered by the most relevant score.
:param query: Search title or description
:type query: :class:`~pyth... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"media",
"=",
"None",
",",
"year",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"extended",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Validate parameters",
"if",
"not",
"media",
":",
"warnings... | Search by titles, descriptions, translated titles, aliases, and people.
**Note:** Results are ordered by the most relevant score.
:param query: Search title or description
:type query: :class:`~python:str`
:param media: Desired media type (or :code:`None` to return all matching items)... | [
"Search",
"by",
"titles",
"descriptions",
"translated",
"titles",
"aliases",
"and",
"people",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/search.py#L105-L187 |
fuzeman/trakt.py | trakt/objects/season.py | Season.to_identifier | def to_identifier(self):
"""Return the season identifier which is compatible with requests that require season definitions.
:return: Season identifier/definition
:rtype: :class:`~python:dict`
"""
return {
'number': self.pk,
'episodes': [
... | python | def to_identifier(self):
"""Return the season identifier which is compatible with requests that require season definitions.
:return: Season identifier/definition
:rtype: :class:`~python:dict`
"""
return {
'number': self.pk,
'episodes': [
... | [
"def",
"to_identifier",
"(",
"self",
")",
":",
"return",
"{",
"'number'",
":",
"self",
".",
"pk",
",",
"'episodes'",
":",
"[",
"episode",
".",
"to_dict",
"(",
")",
"for",
"episode",
"in",
"self",
".",
"episodes",
".",
"values",
"(",
")",
"]",
"}"
] | Return the season identifier which is compatible with requests that require season definitions.
:return: Season identifier/definition
:rtype: :class:`~python:dict` | [
"Return",
"the",
"season",
"identifier",
"which",
"is",
"compatible",
"with",
"requests",
"that",
"require",
"season",
"definitions",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/season.py#L49-L62 |
fuzeman/trakt.py | trakt/objects/season.py | Season.to_dict | def to_dict(self):
"""Dump season to a dictionary.
:return: Season dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'ids': dict([
(key, value) for (key, value) in self.keys[1:] # NOTE: keys[0] is th... | python | def to_dict(self):
"""Dump season to a dictionary.
:return: Season dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'ids': dict([
(key, value) for (key, value) in self.keys[1:] # NOTE: keys[0] is th... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"to_identifier",
"(",
")",
"result",
".",
"update",
"(",
"{",
"'ids'",
":",
"dict",
"(",
"[",
"(",
"key",
",",
"value",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
... | Dump season to a dictionary.
:return: Season dictionary
:rtype: :class:`~python:dict` | [
"Dump",
"season",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/season.py#L69-L100 |
fuzeman/trakt.py | trakt/objects/episode.py | Episode.to_dict | def to_dict(self):
"""Dump episode to a dictionary.
:return: Episode dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'title': self.title,
'watched': 1 if self.is_watched else 0,
'collected'... | python | def to_dict(self):
"""Dump episode to a dictionary.
:return: Episode dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'title': self.title,
'watched': 1 if self.is_watched else 0,
'collected'... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"to_identifier",
"(",
")",
"result",
".",
"update",
"(",
"{",
"'title'",
":",
"self",
".",
"title",
",",
"'watched'",
":",
"1",
"if",
"self",
".",
"is_watched",
"else",
"0",
",",
... | Dump episode to a dictionary.
:return: Episode dictionary
:rtype: :class:`~python:dict` | [
"Dump",
"episode",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/episode.py#L72-L117 |
fuzeman/trakt.py | examples/authentication/device.py | Application.on_aborted | def on_aborted(self):
"""Device authentication aborted.
Triggered when device authentication was aborted (either with `DeviceOAuthPoller.stop()`
or via the "poll" event)
"""
print('Authentication aborted')
# Authentication aborted
self.is_authenticating.acquire... | python | def on_aborted(self):
"""Device authentication aborted.
Triggered when device authentication was aborted (either with `DeviceOAuthPoller.stop()`
or via the "poll" event)
"""
print('Authentication aborted')
# Authentication aborted
self.is_authenticating.acquire... | [
"def",
"on_aborted",
"(",
"self",
")",
":",
"print",
"(",
"'Authentication aborted'",
")",
"# Authentication aborted",
"self",
".",
"is_authenticating",
".",
"acquire",
"(",
")",
"self",
".",
"is_authenticating",
".",
"notify_all",
"(",
")",
"self",
".",
"is_aut... | Device authentication aborted.
Triggered when device authentication was aborted (either with `DeviceOAuthPoller.stop()`
or via the "poll" event) | [
"Device",
"authentication",
"aborted",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/examples/authentication/device.py#L70-L82 |
fuzeman/trakt.py | examples/authentication/device.py | Application.on_authenticated | def on_authenticated(self, authorization):
"""Device authenticated.
:param authorization: Authentication token details
:type authorization: dict
"""
# Acquire condition
self.is_authenticating.acquire()
# Store authorization for future calls
self.authori... | python | def on_authenticated(self, authorization):
"""Device authenticated.
:param authorization: Authentication token details
:type authorization: dict
"""
# Acquire condition
self.is_authenticating.acquire()
# Store authorization for future calls
self.authori... | [
"def",
"on_authenticated",
"(",
"self",
",",
"authorization",
")",
":",
"# Acquire condition",
"self",
".",
"is_authenticating",
".",
"acquire",
"(",
")",
"# Store authorization for future calls",
"self",
".",
"authorization",
"=",
"authorization",
"print",
"(",
"'Aut... | Device authenticated.
:param authorization: Authentication token details
:type authorization: dict | [
"Device",
"authenticated",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/examples/authentication/device.py#L84-L101 |
fuzeman/trakt.py | examples/authentication/device.py | Application.on_expired | def on_expired(self):
"""Device authentication expired."""
print('Authentication expired')
# Authentication expired
self.is_authenticating.acquire()
self.is_authenticating.notify_all()
self.is_authenticating.release() | python | def on_expired(self):
"""Device authentication expired."""
print('Authentication expired')
# Authentication expired
self.is_authenticating.acquire()
self.is_authenticating.notify_all()
self.is_authenticating.release() | [
"def",
"on_expired",
"(",
"self",
")",
":",
"print",
"(",
"'Authentication expired'",
")",
"# Authentication expired",
"self",
".",
"is_authenticating",
".",
"acquire",
"(",
")",
"self",
".",
"is_authenticating",
".",
"notify_all",
"(",
")",
"self",
".",
"is_aut... | Device authentication expired. | [
"Device",
"authentication",
"expired",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/examples/authentication/device.py#L103-L111 |
fuzeman/trakt.py | trakt/interfaces/oauth/device.py | DeviceOAuthInterface.poll | def poll(self, device_code, expires_in, interval, **kwargs):
"""Construct the device authentication poller.
:param device_code: Device authentication code
:type device_code: str
:param expires_in: Device authentication code expiry (in seconds)
:type in: int
:pa... | python | def poll(self, device_code, expires_in, interval, **kwargs):
"""Construct the device authentication poller.
:param device_code: Device authentication code
:type device_code: str
:param expires_in: Device authentication code expiry (in seconds)
:type in: int
:pa... | [
"def",
"poll",
"(",
"self",
",",
"device_code",
",",
"expires_in",
",",
"interval",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DeviceOAuthPoller",
"(",
"self",
".",
"client",
",",
"device_code",
",",
"expires_in",
",",
"interval",
")"
] | Construct the device authentication poller.
:param device_code: Device authentication code
:type device_code: str
:param expires_in: Device authentication code expiry (in seconds)
:type in: int
:param interval: Device authentication poll interval
:type interval... | [
"Construct",
"the",
"device",
"authentication",
"poller",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/oauth/device.py#L42-L56 |
fuzeman/trakt.py | trakt/objects/movie.py | Movie.to_dict | def to_dict(self):
"""Dump movie to a dictionary.
:return: Movie dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'watched': 1 if self.is_watched else 0,
'collected': 1 if self.is_collected else 0,
... | python | def to_dict(self):
"""Dump movie to a dictionary.
:return: Movie dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result.update({
'watched': 1 if self.is_watched else 0,
'collected': 1 if self.is_collected else 0,
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"to_identifier",
"(",
")",
"result",
".",
"update",
"(",
"{",
"'watched'",
":",
"1",
"if",
"self",
".",
"is_watched",
"else",
"0",
",",
"'collected'",
":",
"1",
"if",
"self",
".",
... | Dump movie to a dictionary.
:return: Movie dictionary
:rtype: :class:`~python:dict` | [
"Dump",
"movie",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/movie.py#L123-L183 |
fuzeman/trakt.py | trakt/objects/progress.py | Progress.to_dict | def to_dict(self):
"""Dump progress to a dictionary.
:return: Progress dictionary
:rtype: :class:`~python:dict`
"""
result = super(Progress, self).to_dict()
label = LABELS['last_progress_change'][self.progress_type]
result[label] = to_iso8601_datetime(self.last... | python | def to_dict(self):
"""Dump progress to a dictionary.
:return: Progress dictionary
:rtype: :class:`~python:dict`
"""
result = super(Progress, self).to_dict()
label = LABELS['last_progress_change'][self.progress_type]
result[label] = to_iso8601_datetime(self.last... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"result",
"=",
"super",
"(",
"Progress",
",",
"self",
")",
".",
"to_dict",
"(",
")",
"label",
"=",
"LABELS",
"[",
"'last_progress_change'",
"]",
"[",
"self",
".",
"progress_type",
"]",
"result",
"[",
"label",
"]... | Dump progress to a dictionary.
:return: Progress dictionary
:rtype: :class:`~python:dict` | [
"Dump",
"progress",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/progress.py#L108-L142 |
fuzeman/trakt.py | trakt/interfaces/scrobble.py | ScrobbleInterface.action | def action(self, action, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Perform scrobble action.
:param action: Action to perform (either :code:`start`, :code:`pause` or :code:`stop`)
:type action: :class:`~python:str`
:param movie: Movie definition (or `None`)
... | python | def action(self, action, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Perform scrobble action.
:param action: Action to perform (either :code:`start`, :code:`pause` or :code:`stop`)
:type action: :class:`~python:str`
:param movie: Movie definition (or `None`)
... | [
"def",
"action",
"(",
"self",
",",
"action",
",",
"movie",
"=",
"None",
",",
"show",
"=",
"None",
",",
"episode",
"=",
"None",
",",
"progress",
"=",
"0.0",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"movie",
"and",
"(",
"show",
"or",
"episode",
")"... | Perform scrobble action.
:param action: Action to perform (either :code:`start`, :code:`pause` or :code:`stop`)
:type action: :class:`~python:str`
:param movie: Movie definition (or `None`)
**Example:**
.. code-block:: python
{
'ti... | [
"Perform",
"scrobble",
"action",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/scrobble.py#L12-L134 |
fuzeman/trakt.py | trakt/interfaces/scrobble.py | ScrobbleInterface.start | def start(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "start" action.
Use this method when the video initially starts playing or is un-paused. This will
remove any playback progress if it exists.
**Note:** A watching status will auto expire ... | python | def start(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "start" action.
Use this method when the video initially starts playing or is un-paused. This will
remove any playback progress if it exists.
**Note:** A watching status will auto expire ... | [
"def",
"start",
"(",
"self",
",",
"movie",
"=",
"None",
",",
"show",
"=",
"None",
",",
"episode",
"=",
"None",
",",
"progress",
"=",
"0.0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"action",
"(",
"'start'",
",",
"movie",
",",
"sh... | Send the scrobble "start" action.
Use this method when the video initially starts playing or is un-paused. This will
remove any playback progress if it exists.
**Note:** A watching status will auto expire after the remaining runtime has elapsed.
There is no need to re-send every 15 min... | [
"Send",
"the",
"scrobble",
"start",
"action",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/scrobble.py#L138-L238 |
fuzeman/trakt.py | trakt/interfaces/scrobble.py | ScrobbleInterface.pause | def pause(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "pause' action.
Use this method when the video is paused. The playback progress will be saved and
:code:`Trakt['sync/playback'].get()` can be used to resume the video from this exact
posit... | python | def pause(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "pause' action.
Use this method when the video is paused. The playback progress will be saved and
:code:`Trakt['sync/playback'].get()` can be used to resume the video from this exact
posit... | [
"def",
"pause",
"(",
"self",
",",
"movie",
"=",
"None",
",",
"show",
"=",
"None",
",",
"episode",
"=",
"None",
",",
"progress",
"=",
"0.0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"action",
"(",
"'pause'",
",",
"movie",
",",
"sh... | Send the scrobble "pause' action.
Use this method when the video is paused. The playback progress will be saved and
:code:`Trakt['sync/playback'].get()` can be used to resume the video from this exact
position. Un-pause a video by calling the :code:`Trakt['scrobble'].start()` method again.
... | [
"Send",
"the",
"scrobble",
"pause",
"action",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/scrobble.py#L242-L340 |
fuzeman/trakt.py | trakt/interfaces/scrobble.py | ScrobbleInterface.stop | def stop(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "stop" action.
Use this method when the video is stopped or finishes playing on its own. If the
progress is above 80%, the video will be scrobbled and the :code:`action` will be set
to **sc... | python | def stop(self, movie=None, show=None, episode=None, progress=0.0, **kwargs):
"""Send the scrobble "stop" action.
Use this method when the video is stopped or finishes playing on its own. If the
progress is above 80%, the video will be scrobbled and the :code:`action` will be set
to **sc... | [
"def",
"stop",
"(",
"self",
",",
"movie",
"=",
"None",
",",
"show",
"=",
"None",
",",
"episode",
"=",
"None",
",",
"progress",
"=",
"0.0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"action",
"(",
"'stop'",
",",
"movie",
",",
"show... | Send the scrobble "stop" action.
Use this method when the video is stopped or finishes playing on its own. If the
progress is above 80%, the video will be scrobbled and the :code:`action` will be set
to **scrobble**.
If the progress is less than 80%, it will be treated as a *pause* and... | [
"Send",
"the",
"scrobble",
"stop",
"action",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/scrobble.py#L344-L449 |
fuzeman/trakt.py | trakt/objects/list/custom.py | CustomList.delete | def delete(self, **kwargs):
"""Delete the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].delete(s... | python | def delete(self, **kwargs):
"""Delete the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].delete(s... | [
"def",
"delete",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_client",
"[",
"'users/*/lists/*'",
"]",
".",
"delete",
"(",
"self",
".",
"username",
",",
"self",
".",
"id",
",",
"*",
"*",
"kwargs",
")"
] | Delete the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool` | [
"Delete",
"the",
"list",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/list/custom.py#L86-L96 |
fuzeman/trakt.py | trakt/objects/list/custom.py | CustomList.update | def update(self, **kwargs):
"""Update the list with the current object attributes.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
item = self.... | python | def update(self, **kwargs):
"""Update the list with the current object attributes.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
item = self.... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"item",
"=",
"self",
".",
"_client",
"[",
"'users/*/lists/*'",
"]",
".",
"update",
"(",
"self",
".",
"username",
",",
"self",
".",
"id",
",",
"return_type",
"=",
"'data'",
",",
"*",
"... | Update the list with the current object attributes.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool` | [
"Update",
"the",
"list",
"with",
"the",
"current",
"object",
"attributes",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/list/custom.py#L98-L114 |
fuzeman/trakt.py | trakt/objects/list/custom.py | CustomList.remove | def remove(self, items, **kwargs):
"""Remove specified items from the list.
:param items: Items that should be removed from the list
:type items: :class:`~python:list`
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Response
:r... | python | def remove(self, items, **kwargs):
"""Remove specified items from the list.
:param items: Items that should be removed from the list
:type items: :class:`~python:list`
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Response
:r... | [
"def",
"remove",
"(",
"self",
",",
"items",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_client",
"[",
"'users/*/lists/*'",
"]",
".",
"remove",
"(",
"self",
".",
"username",
",",
"self",
".",
"id",
",",
"items",
",",
"*",
"*",
"kwarg... | Remove specified items from the list.
:param items: Items that should be removed from the list
:type items: :class:`~python:list`
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Response
:rtype: :class:`~python:dict` | [
"Remove",
"specified",
"items",
"from",
"the",
"list",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/list/custom.py#L116-L129 |
fuzeman/trakt.py | trakt/objects/list/custom.py | CustomList.like | def like(self, **kwargs):
"""Like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].like(self.us... | python | def like(self, **kwargs):
"""Like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].like(self.us... | [
"def",
"like",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_client",
"[",
"'users/*/lists/*'",
"]",
".",
"like",
"(",
"self",
".",
"username",
",",
"self",
".",
"id",
",",
"*",
"*",
"kwargs",
")"
] | Like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool` | [
"Like",
"the",
"list",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/list/custom.py#L135-L145 |
fuzeman/trakt.py | trakt/objects/list/custom.py | CustomList.unlike | def unlike(self, **kwargs):
"""Un-like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].unlike(... | python | def unlike(self, **kwargs):
"""Un-like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool`
"""
return self._client['users/*/lists/*'].unlike(... | [
"def",
"unlike",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_client",
"[",
"'users/*/lists/*'",
"]",
".",
"unlike",
"(",
"self",
".",
"username",
",",
"self",
".",
"id",
",",
"*",
"*",
"kwargs",
")"
] | Un-like the list.
:param kwargs: Extra request options
:type kwargs: :class:`~python:dict`
:return: Boolean to indicate if the request was successful
:rtype: :class:`~python:bool` | [
"Un",
"-",
"like",
"the",
"list",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/list/custom.py#L147-L157 |
fuzeman/trakt.py | trakt/interfaces/calendars.py | Base.get | def get(self, source, media, collection=None, start_date=None, days=None, query=None, years=None, genres=None,
languages=None, countries=None, runtimes=None, ratings=None, certifications=None, networks=None,
status=None, **kwargs):
"""Retrieve calendar items.
The `all` calendar ... | python | def get(self, source, media, collection=None, start_date=None, days=None, query=None, years=None, genres=None,
languages=None, countries=None, runtimes=None, ratings=None, certifications=None, networks=None,
status=None, **kwargs):
"""Retrieve calendar items.
The `all` calendar ... | [
"def",
"get",
"(",
"self",
",",
"source",
",",
"media",
",",
"collection",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"days",
"=",
"None",
",",
"query",
"=",
"None",
",",
"years",
"=",
"None",
",",
"genres",
"=",
"None",
",",
"languages",
"=... | Retrieve calendar items.
The `all` calendar displays info for all shows airing during the specified period. The `my` calendar displays
episodes for all shows that have been watched, collected, or watchlisted.
:param source: Calendar source (`all` or `my`)
:type source: str
:pa... | [
"Retrieve",
"calendar",
"items",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/interfaces/calendars.py#L24-L135 |
fuzeman/trakt.py | trakt/objects/show.py | Show.episodes | def episodes(self):
"""Return a flat episode iterator.
:returns: Iterator :code:`((season_num, episode_num), Episode)`
:rtype: iterator
"""
for sk, season in iteritems(self.seasons):
# Yield each episode in season
for ek, episode in iteritems(season.epis... | python | def episodes(self):
"""Return a flat episode iterator.
:returns: Iterator :code:`((season_num, episode_num), Episode)`
:rtype: iterator
"""
for sk, season in iteritems(self.seasons):
# Yield each episode in season
for ek, episode in iteritems(season.epis... | [
"def",
"episodes",
"(",
"self",
")",
":",
"for",
"sk",
",",
"season",
"in",
"iteritems",
"(",
"self",
".",
"seasons",
")",
":",
"# Yield each episode in season",
"for",
"ek",
",",
"episode",
"in",
"iteritems",
"(",
"season",
".",
"episodes",
")",
":",
"y... | Return a flat episode iterator.
:returns: Iterator :code:`((season_num, episode_num), Episode)`
:rtype: iterator | [
"Return",
"a",
"flat",
"episode",
"iterator",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/show.py#L138-L148 |
fuzeman/trakt.py | trakt/objects/show.py | Show.to_dict | def to_dict(self):
"""Dump show to a dictionary.
:return: Show dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result['seasons'] = [
season.to_dict()
for season in self.seasons.values()
]
result['in_wa... | python | def to_dict(self):
"""Dump show to a dictionary.
:return: Show dictionary
:rtype: :class:`~python:dict`
"""
result = self.to_identifier()
result['seasons'] = [
season.to_dict()
for season in self.seasons.values()
]
result['in_wa... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"to_identifier",
"(",
")",
"result",
"[",
"'seasons'",
"]",
"=",
"[",
"season",
".",
"to_dict",
"(",
")",
"for",
"season",
"in",
"self",
".",
"seasons",
".",
"values",
"(",
")",
"... | Dump show to a dictionary.
:return: Show dictionary
:rtype: :class:`~python:dict` | [
"Dump",
"show",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/objects/show.py#L168-L231 |
fuzeman/trakt.py | trakt/core/request.py | TraktRequest.construct_url | def construct_url(self):
"""Construct a full trakt request URI, with `params` and `query`."""
path = [self.path]
path.extend(self.params)
# Build URL
url = self.client.base_url + '/'.join(
str(value) for value in path
if value
)
# Append ... | python | def construct_url(self):
"""Construct a full trakt request URI, with `params` and `query`."""
path = [self.path]
path.extend(self.params)
# Build URL
url = self.client.base_url + '/'.join(
str(value) for value in path
if value
)
# Append ... | [
"def",
"construct_url",
"(",
"self",
")",
":",
"path",
"=",
"[",
"self",
".",
"path",
"]",
"path",
".",
"extend",
"(",
"self",
".",
"params",
")",
"# Build URL",
"url",
"=",
"self",
".",
"client",
".",
"base_url",
"+",
"'/'",
".",
"join",
"(",
"str... | Construct a full trakt request URI, with `params` and `query`. | [
"Construct",
"a",
"full",
"trakt",
"request",
"URI",
"with",
"params",
"and",
"query",
"."
] | train | https://github.com/fuzeman/trakt.py/blob/14c6b72e3c13ea2975007aeac0c01ad2222b67f3/trakt/core/request.py#L101-L118 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.search_officers | def search_officers(self, term, disqualified=False, **kwargs):
"""Search for officers by name.
Args:
term (str): Officer name to search on.
disqualified (Optional[bool]): True to search for disqualified
officers
kwargs (dict): additional keywords passed into
... | python | def search_officers(self, term, disqualified=False, **kwargs):
"""Search for officers by name.
Args:
term (str): Officer name to search on.
disqualified (Optional[bool]): True to search for disqualified
officers
kwargs (dict): additional keywords passed into
... | [
"def",
"search_officers",
"(",
"self",
",",
"term",
",",
"disqualified",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"search_type",
"=",
"(",
"'officers'",
"if",
"not",
"disqualified",
"else",
"'disqualified-officers'",
")",
"params",
"=",
"kwargs",
"pa... | Search for officers by name.
Args:
term (str): Officer name to search on.
disqualified (Optional[bool]): True to search for disqualified
officers
kwargs (dict): additional keywords passed into
requests.session.get params keyword. | [
"Search",
"for",
"officers",
"by",
"name",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L68-L85 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.address | def address(self, num):
"""Search for company addresses by company number.
Args:
num (str): Company number to search on.
"""
url_root = "company/{}/registered-office-address"
baseuri = self._BASE_URI + url_root.format(num)
res = self.session.get(baseuri)
... | python | def address(self, num):
"""Search for company addresses by company number.
Args:
num (str): Company number to search on.
"""
url_root = "company/{}/registered-office-address"
baseuri = self._BASE_URI + url_root.format(num)
res = self.session.get(baseuri)
... | [
"def",
"address",
"(",
"self",
",",
"num",
")",
":",
"url_root",
"=",
"\"company/{}/registered-office-address\"",
"baseuri",
"=",
"self",
".",
"_BASE_URI",
"+",
"url_root",
".",
"format",
"(",
"num",
")",
"res",
"=",
"self",
".",
"session",
".",
"get",
"("... | Search for company addresses by company number.
Args:
num (str): Company number to search on. | [
"Search",
"for",
"company",
"addresses",
"by",
"company",
"number",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L100-L110 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.profile | def profile(self, num):
"""Search for company profile by company number.
Args:
num (str): Company number to search on.
"""
baseuri = self._BASE_URI + "company/{}".format(num)
res = self.session.get(baseuri)
self.handle_http_error(res)
return res | python | def profile(self, num):
"""Search for company profile by company number.
Args:
num (str): Company number to search on.
"""
baseuri = self._BASE_URI + "company/{}".format(num)
res = self.session.get(baseuri)
self.handle_http_error(res)
return res | [
"def",
"profile",
"(",
"self",
",",
"num",
")",
":",
"baseuri",
"=",
"self",
".",
"_BASE_URI",
"+",
"\"company/{}\"",
".",
"format",
"(",
"num",
")",
"res",
"=",
"self",
".",
"session",
".",
"get",
"(",
"baseuri",
")",
"self",
".",
"handle_http_error",... | Search for company profile by company number.
Args:
num (str): Company number to search on. | [
"Search",
"for",
"company",
"profile",
"by",
"company",
"number",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L112-L121 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.filing_history | def filing_history(self, num, transaction=None, **kwargs):
"""Search for a company's filling history by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
... | python | def filing_history(self, num, transaction=None, **kwargs):
"""Search for a company's filling history by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
... | [
"def",
"filing_history",
"(",
"self",
",",
"num",
",",
"transaction",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"baseuri",
"=",
"self",
".",
"_BASE_URI",
"+",
"\"company/{}/filing-history\"",
".",
"format",
"(",
"num",
")",
"if",
"transaction",
"is",... | Search for a company's filling history by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
requests.session.get params keyword. | [
"Search",
"for",
"a",
"company",
"s",
"filling",
"history",
"by",
"company",
"number",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L134-L149 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.charges | def charges(self, num, charge_id=None, **kwargs):
"""Search for charges against a company by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
requests.s... | python | def charges(self, num, charge_id=None, **kwargs):
"""Search for charges against a company by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
requests.s... | [
"def",
"charges",
"(",
"self",
",",
"num",
",",
"charge_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"baseuri",
"=",
"self",
".",
"_BASE_URI",
"+",
"\"company/{}/charges\"",
".",
"format",
"(",
"num",
")",
"if",
"charge_id",
"is",
"not",
"None"... | Search for charges against a company by company number.
Args:
num (str): Company number to search on.
transaction (Optional[str]): Filing record number.
kwargs (dict): additional keywords passed into
requests.session.get params keyword. | [
"Search",
"for",
"charges",
"against",
"a",
"company",
"by",
"company",
"number",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L151-L167 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.officers | def officers(self, num, **kwargs):
"""Search for a company's registered officers by company number.
Args:
num (str): Company number to search on.
kwargs (dict): additional keywords passed into
requests.session.get *params* keyword.
"""
baseuri = self._BAS... | python | def officers(self, num, **kwargs):
"""Search for a company's registered officers by company number.
Args:
num (str): Company number to search on.
kwargs (dict): additional keywords passed into
requests.session.get *params* keyword.
"""
baseuri = self._BAS... | [
"def",
"officers",
"(",
"self",
",",
"num",
",",
"*",
"*",
"kwargs",
")",
":",
"baseuri",
"=",
"self",
".",
"_BASE_URI",
"+",
"\"company/{}/officers\"",
".",
"format",
"(",
"num",
")",
"res",
"=",
"self",
".",
"session",
".",
"get",
"(",
"baseuri",
"... | Search for a company's registered officers by company number.
Args:
num (str): Company number to search on.
kwargs (dict): additional keywords passed into
requests.session.get *params* keyword. | [
"Search",
"for",
"a",
"company",
"s",
"registered",
"officers",
"by",
"company",
"number",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L169-L180 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.disqualified | def disqualified(self, num, natural=True, **kwargs):
"""Search for disqualified officers by officer ID.
Searches for natural disqualifications by default. Specify
natural=False to search for corporate disqualifications.
Args:
num (str): Company number to search on.
... | python | def disqualified(self, num, natural=True, **kwargs):
"""Search for disqualified officers by officer ID.
Searches for natural disqualifications by default. Specify
natural=False to search for corporate disqualifications.
Args:
num (str): Company number to search on.
... | [
"def",
"disqualified",
"(",
"self",
",",
"num",
",",
"natural",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"search_type",
"=",
"'natural'",
"if",
"natural",
"else",
"'corporate'",
"baseuri",
"=",
"(",
"self",
".",
"_BASE_URI",
"+",
"'disqualified-offi... | Search for disqualified officers by officer ID.
Searches for natural disqualifications by default. Specify
natural=False to search for corporate disqualifications.
Args:
num (str): Company number to search on.
natural (Optional[bool]): Natural or corporate search
... | [
"Search",
"for",
"disqualified",
"officers",
"by",
"officer",
"ID",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L182-L199 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.persons_significant_control | def persons_significant_control(self, num, statements=False, **kwargs):
"""Search for a list of persons with significant control.
Searches for persons of significant control based on company number for
a specified company. Specify statements=True to only search for
officers with stateme... | python | def persons_significant_control(self, num, statements=False, **kwargs):
"""Search for a list of persons with significant control.
Searches for persons of significant control based on company number for
a specified company. Specify statements=True to only search for
officers with stateme... | [
"def",
"persons_significant_control",
"(",
"self",
",",
"num",
",",
"statements",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"baseuri",
"=",
"(",
"self",
".",
"_BASE_URI",
"+",
"'company/{}/persons-with-significant-control'",
".",
"format",
"(",
"num",
"... | Search for a list of persons with significant control.
Searches for persons of significant control based on company number for
a specified company. Specify statements=True to only search for
officers with statements.
Args:
num (str, int): Company number to search on.
... | [
"Search",
"for",
"a",
"list",
"of",
"persons",
"with",
"significant",
"control",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L201-L224 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.significant_control | def significant_control(self,
num,
entity_id,
entity_type='individual',
**kwargs):
"""Get details of a specific entity with significant control.
Args:
num (str, int): Company numb... | python | def significant_control(self,
num,
entity_id,
entity_type='individual',
**kwargs):
"""Get details of a specific entity with significant control.
Args:
num (str, int): Company numb... | [
"def",
"significant_control",
"(",
"self",
",",
"num",
",",
"entity_id",
",",
"entity_type",
"=",
"'individual'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Dict mapping entity_type strings to url strings",
"entities",
"=",
"{",
"'individual'",
":",
"'individual'",
",",
... | Get details of a specific entity with significant control.
Args:
num (str, int): Company number to search on.
entity_id (str, int): Entity id to request details for
entity_type (str, int): What type of entity to search for. Defaults
to 'individual'. Other pos... | [
"Get",
"details",
"of",
"a",
"specific",
"entity",
"with",
"significant",
"control",
"."
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L226-L265 |
JamesGardiner/chwrapper | chwrapper/services/search.py | Search.document | def document(self, document_id, **kwargs):
"""Requests for a document by the document id.
Normally the response.content can be saved as a pdf file
Args:
document_id (str): The id of the document retrieved.
kwargs (dict): additional keywords passed into
reque... | python | def document(self, document_id, **kwargs):
"""Requests for a document by the document id.
Normally the response.content can be saved as a pdf file
Args:
document_id (str): The id of the document retrieved.
kwargs (dict): additional keywords passed into
reque... | [
"def",
"document",
"(",
"self",
",",
"document_id",
",",
"*",
"*",
"kwargs",
")",
":",
"baseuri",
"=",
"'{}document/{}/content'",
".",
"format",
"(",
"self",
".",
"_DOCUMENT_URI",
",",
"document_id",
")",
"res",
"=",
"self",
".",
"session",
".",
"get",
"... | Requests for a document by the document id.
Normally the response.content can be saved as a pdf file
Args:
document_id (str): The id of the document retrieved.
kwargs (dict): additional keywords passed into
requests.session.get *params* keyword. | [
"Requests",
"for",
"a",
"document",
"by",
"the",
"document",
"id",
".",
"Normally",
"the",
"response",
".",
"content",
"can",
"be",
"saved",
"as",
"a",
"pdf",
"file"
] | train | https://github.com/JamesGardiner/chwrapper/blob/50f9cb2f5264c59505e8cc4e45ee6dc5d5669134/chwrapper/services/search.py#L267-L280 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordWebhook.add_file | def add_file(self, file, filename):
"""
add file to webhook
:param file: file content
:param filename: filename
:return:
"""
self.files['_{}'.format(filename)] = (filename, file) | python | def add_file(self, file, filename):
"""
add file to webhook
:param file: file content
:param filename: filename
:return:
"""
self.files['_{}'.format(filename)] = (filename, file) | [
"def",
"add_file",
"(",
"self",
",",
"file",
",",
"filename",
")",
":",
"self",
".",
"files",
"[",
"'_{}'",
".",
"format",
"(",
"filename",
")",
"]",
"=",
"(",
"filename",
",",
"file",
")"
] | add file to webhook
:param file: file content
:param filename: filename
:return: | [
"add",
"file",
"to",
"webhook",
":",
"param",
"file",
":",
"file",
"content",
":",
"param",
"filename",
":",
"filename",
":",
"return",
":"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L36-L43 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordWebhook.add_embed | def add_embed(self, embed):
"""
add embedded rich content
:param embed: embed object or dict
"""
self.embeds.append(embed.__dict__ if isinstance(embed, DiscordEmbed) else embed) | python | def add_embed(self, embed):
"""
add embedded rich content
:param embed: embed object or dict
"""
self.embeds.append(embed.__dict__ if isinstance(embed, DiscordEmbed) else embed) | [
"def",
"add_embed",
"(",
"self",
",",
"embed",
")",
":",
"self",
".",
"embeds",
".",
"append",
"(",
"embed",
".",
"__dict__",
"if",
"isinstance",
"(",
"embed",
",",
"DiscordEmbed",
")",
"else",
"embed",
")"
] | add embedded rich content
:param embed: embed object or dict | [
"add",
"embedded",
"rich",
"content",
":",
"param",
"embed",
":",
"embed",
"object",
"or",
"dict"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L45-L50 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordWebhook.json | def json(self):
"""
convert webhook data to json
:return webhook data as json:
"""
data = dict()
embeds = self.embeds
self.embeds = list()
# convert DiscordEmbed to dict
for embed in embeds:
self.add_embed(embed)
for key, value ... | python | def json(self):
"""
convert webhook data to json
:return webhook data as json:
"""
data = dict()
embeds = self.embeds
self.embeds = list()
# convert DiscordEmbed to dict
for embed in embeds:
self.add_embed(embed)
for key, value ... | [
"def",
"json",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
")",
"embeds",
"=",
"self",
".",
"embeds",
"self",
".",
"embeds",
"=",
"list",
"(",
")",
"# convert DiscordEmbed to dict",
"for",
"embed",
"in",
"embeds",
":",
"self",
".",
"add_embed",
"(... | convert webhook data to json
:return webhook data as json: | [
"convert",
"webhook",
"data",
"to",
"json",
":",
"return",
"webhook",
"data",
"as",
"json",
":"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L74-L91 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordWebhook.execute | def execute(self):
"""
execute Webhook
:return:
"""
if bool(self.files) is False:
response = requests.post(self.url, json=self.json, proxies=self.proxies)
else:
self.files['payload_json'] = (None, json.dumps(self.json))
response = reque... | python | def execute(self):
"""
execute Webhook
:return:
"""
if bool(self.files) is False:
response = requests.post(self.url, json=self.json, proxies=self.proxies)
else:
self.files['payload_json'] = (None, json.dumps(self.json))
response = reque... | [
"def",
"execute",
"(",
"self",
")",
":",
"if",
"bool",
"(",
"self",
".",
"files",
")",
"is",
"False",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"self",
".",
"url",
",",
"json",
"=",
"self",
".",
"json",
",",
"proxies",
"=",
"self",
".",... | execute Webhook
:return: | [
"execute",
"Webhook",
":",
"return",
":"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L93-L106 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_timestamp | def set_timestamp(self, timestamp=str(datetime.datetime.utcfromtimestamp(time.time()))):
"""
set timestamp of embed content
:param timestamp: (optional) timestamp of embed content
"""
self.timestamp = timestamp | python | def set_timestamp(self, timestamp=str(datetime.datetime.utcfromtimestamp(time.time()))):
"""
set timestamp of embed content
:param timestamp: (optional) timestamp of embed content
"""
self.timestamp = timestamp | [
"def",
"set_timestamp",
"(",
"self",
",",
"timestamp",
"=",
"str",
"(",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
")",
":",
"self",
".",
"timestamp",
"=",
"timestamp"
] | set timestamp of embed content
:param timestamp: (optional) timestamp of embed content | [
"set",
"timestamp",
"of",
"embed",
"content",
":",
"param",
"timestamp",
":",
"(",
"optional",
")",
"timestamp",
"of",
"embed",
"content"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L163-L168 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_footer | def set_footer(self, **kwargs):
"""
set footer information of embed
:keyword text: footer text
:keyword icon_url: url of footer icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of footer icon
"""
self.footer = {
'text... | python | def set_footer(self, **kwargs):
"""
set footer information of embed
:keyword text: footer text
:keyword icon_url: url of footer icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of footer icon
"""
self.footer = {
'text... | [
"def",
"set_footer",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"footer",
"=",
"{",
"'text'",
":",
"kwargs",
".",
"get",
"(",
"'text'",
")",
",",
"'icon_url'",
":",
"kwargs",
".",
"get",
"(",
"'icon_url'",
")",
",",
"'proxy_icon_url... | set footer information of embed
:keyword text: footer text
:keyword icon_url: url of footer icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of footer icon | [
"set",
"footer",
"information",
"of",
"embed",
":",
"keyword",
"text",
":",
"footer",
"text",
":",
"keyword",
"icon_url",
":",
"url",
"of",
"footer",
"icon",
"(",
"only",
"supports",
"http",
"(",
"s",
")",
"and",
"attachments",
")",
":",
"keyword",
"prox... | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L177-L188 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_image | def set_image(self, **kwargs):
"""
set image of embed
:keyword url: source url of image (only supports http(s) and attachments)
:keyword proxy_url: a proxied url of the image
:keyword height: height of image
:keyword width: width of image
"""
self.image = ... | python | def set_image(self, **kwargs):
"""
set image of embed
:keyword url: source url of image (only supports http(s) and attachments)
:keyword proxy_url: a proxied url of the image
:keyword height: height of image
:keyword width: width of image
"""
self.image = ... | [
"def",
"set_image",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"image",
"=",
"{",
"'url'",
":",
"kwargs",
".",
"get",
"(",
"'url'",
")",
",",
"'proxy_url'",
":",
"kwargs",
".",
"get",
"(",
"'proxy_url'",
")",
",",
"'height'",
":",... | set image of embed
:keyword url: source url of image (only supports http(s) and attachments)
:keyword proxy_url: a proxied url of the image
:keyword height: height of image
:keyword width: width of image | [
"set",
"image",
"of",
"embed",
":",
"keyword",
"url",
":",
"source",
"url",
"of",
"image",
"(",
"only",
"supports",
"http",
"(",
"s",
")",
"and",
"attachments",
")",
":",
"keyword",
"proxy_url",
":",
"a",
"proxied",
"url",
"of",
"the",
"image",
":",
... | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L190-L203 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_thumbnail | def set_thumbnail(self, **kwargs):
"""
set thumbnail of embed
:keyword url: source url of thumbnail (only supports http(s) and attachments)
:keyword proxy_url: a proxied thumbnail of the image
:keyword height: height of thumbnail
:keyword width: width of thumbnail
... | python | def set_thumbnail(self, **kwargs):
"""
set thumbnail of embed
:keyword url: source url of thumbnail (only supports http(s) and attachments)
:keyword proxy_url: a proxied thumbnail of the image
:keyword height: height of thumbnail
:keyword width: width of thumbnail
... | [
"def",
"set_thumbnail",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"thumbnail",
"=",
"{",
"'url'",
":",
"kwargs",
".",
"get",
"(",
"'url'",
")",
",",
"'proxy_url'",
":",
"kwargs",
".",
"get",
"(",
"'proxy_url'",
")",
",",
"'height'"... | set thumbnail of embed
:keyword url: source url of thumbnail (only supports http(s) and attachments)
:keyword proxy_url: a proxied thumbnail of the image
:keyword height: height of thumbnail
:keyword width: width of thumbnail | [
"set",
"thumbnail",
"of",
"embed",
":",
"keyword",
"url",
":",
"source",
"url",
"of",
"thumbnail",
"(",
"only",
"supports",
"http",
"(",
"s",
")",
"and",
"attachments",
")",
":",
"keyword",
"proxy_url",
":",
"a",
"proxied",
"thumbnail",
"of",
"the",
"ima... | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L205-L218 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_video | def set_video(self, **kwargs):
"""
set video of embed
:keyword url: source url of video
:keyword height: height of video
:keyword width: width of video
"""
self.video = {
'url': kwargs.get('url'),
'height': kwargs.get('height'),
... | python | def set_video(self, **kwargs):
"""
set video of embed
:keyword url: source url of video
:keyword height: height of video
:keyword width: width of video
"""
self.video = {
'url': kwargs.get('url'),
'height': kwargs.get('height'),
... | [
"def",
"set_video",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"video",
"=",
"{",
"'url'",
":",
"kwargs",
".",
"get",
"(",
"'url'",
")",
",",
"'height'",
":",
"kwargs",
".",
"get",
"(",
"'height'",
")",
",",
"'width'",
":",
"kwa... | set video of embed
:keyword url: source url of video
:keyword height: height of video
:keyword width: width of video | [
"set",
"video",
"of",
"embed",
":",
"keyword",
"url",
":",
"source",
"url",
"of",
"video",
":",
"keyword",
"height",
":",
"height",
"of",
"video",
":",
"keyword",
"width",
":",
"width",
"of",
"video"
] | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L220-L231 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.set_author | def set_author(self, **kwargs):
"""
set author of embed
:keyword name: name of author
:keyword url: url of author
:keyword icon_url: url of author icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of author icon
"""
self.a... | python | def set_author(self, **kwargs):
"""
set author of embed
:keyword name: name of author
:keyword url: url of author
:keyword icon_url: url of author icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of author icon
"""
self.a... | [
"def",
"set_author",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"author",
"=",
"{",
"'name'",
":",
"kwargs",
".",
"get",
"(",
"'name'",
")",
",",
"'url'",
":",
"kwargs",
".",
"get",
"(",
"'url'",
")",
",",
"'icon_url'",
":",
"kw... | set author of embed
:keyword name: name of author
:keyword url: url of author
:keyword icon_url: url of author icon (only supports http(s) and attachments)
:keyword proxy_icon_url: a proxied url of author icon | [
"set",
"author",
"of",
"embed",
":",
"keyword",
"name",
":",
"name",
"of",
"author",
":",
"keyword",
"url",
":",
"url",
"of",
"author",
":",
"keyword",
"icon_url",
":",
"url",
"of",
"author",
"icon",
"(",
"only",
"supports",
"http",
"(",
"s",
")",
"a... | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L244-L257 |
lovvskillz/python-discord-webhook | discord_webhook/webhook.py | DiscordEmbed.add_embed_field | def add_embed_field(self, **kwargs):
"""
set field of embed
:keyword name: name of the field
:keyword value: value of the field
:keyword inline: (optional) whether or not this field should display inline
"""
self.fields.append({
'name': kwargs.get('nam... | python | def add_embed_field(self, **kwargs):
"""
set field of embed
:keyword name: name of the field
:keyword value: value of the field
:keyword inline: (optional) whether or not this field should display inline
"""
self.fields.append({
'name': kwargs.get('nam... | [
"def",
"add_embed_field",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"fields",
".",
"append",
"(",
"{",
"'name'",
":",
"kwargs",
".",
"get",
"(",
"'name'",
")",
",",
"'value'",
":",
"kwargs",
".",
"get",
"(",
"'value'",
")",
",",
... | set field of embed
:keyword name: name of the field
:keyword value: value of the field
:keyword inline: (optional) whether or not this field should display inline | [
"set",
"field",
"of",
"embed",
":",
"keyword",
"name",
":",
"name",
"of",
"the",
"field",
":",
"keyword",
"value",
":",
"value",
"of",
"the",
"field",
":",
"keyword",
"inline",
":",
"(",
"optional",
")",
"whether",
"or",
"not",
"this",
"field",
"should... | train | https://github.com/lovvskillz/python-discord-webhook/blob/5278184078c9da9362b6343c478a92e0904a7f83/discord_webhook/webhook.py#L259-L270 |
LegoStormtroopr/django-spaghetti-and-meatballs | django_spaghetti/views.py | Plate.plate | def plate(self):
"""
Serves up a delicious plate with your models
"""
request = self.request
if self.settings is None:
graph_settings = deepcopy(getattr(settings, 'SPAGHETTI_SAUCE', {}))
graph_settings.update(self.override_settings)
else:
... | python | def plate(self):
"""
Serves up a delicious plate with your models
"""
request = self.request
if self.settings is None:
graph_settings = deepcopy(getattr(settings, 'SPAGHETTI_SAUCE', {}))
graph_settings.update(self.override_settings)
else:
... | [
"def",
"plate",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"request",
"if",
"self",
".",
"settings",
"is",
"None",
":",
"graph_settings",
"=",
"deepcopy",
"(",
"getattr",
"(",
"settings",
",",
"'SPAGHETTI_SAUCE'",
",",
"{",
"}",
")",
")",
"gra... | Serves up a delicious plate with your models | [
"Serves",
"up",
"a",
"delicious",
"plate",
"with",
"your",
"models"
] | train | https://github.com/LegoStormtroopr/django-spaghetti-and-meatballs/blob/19240f0faeddb0e6fdd9e657cb1565d78bf43f10/django_spaghetti/views.py#L44-L153 |
LegoStormtroopr/django-spaghetti-and-meatballs | django_spaghetti/views.py | Plate.get_node_label | def get_node_label(self, model):
"""
Defines how labels are constructed from models.
Default - uses verbose name, lines breaks where sensible
"""
if model.is_proxy:
label = "(P) %s" % (model.name.title())
else:
label = "%s" % (model.name.title())
... | python | def get_node_label(self, model):
"""
Defines how labels are constructed from models.
Default - uses verbose name, lines breaks where sensible
"""
if model.is_proxy:
label = "(P) %s" % (model.name.title())
else:
label = "%s" % (model.name.title())
... | [
"def",
"get_node_label",
"(",
"self",
",",
"model",
")",
":",
"if",
"model",
".",
"is_proxy",
":",
"label",
"=",
"\"(P) %s\"",
"%",
"(",
"model",
".",
"name",
".",
"title",
"(",
")",
")",
"else",
":",
"label",
"=",
"\"%s\"",
"%",
"(",
"model",
".",... | Defines how labels are constructed from models.
Default - uses verbose name, lines breaks where sensible | [
"Defines",
"how",
"labels",
"are",
"constructed",
"from",
"models",
".",
"Default",
"-",
"uses",
"verbose",
"name",
"lines",
"breaks",
"where",
"sensible"
] | train | https://github.com/LegoStormtroopr/django-spaghetti-and-meatballs/blob/19240f0faeddb0e6fdd9e657cb1565d78bf43f10/django_spaghetti/views.py#L155-L176 |
LegoStormtroopr/django-spaghetti-and-meatballs | django_spaghetti/__init__.py | get_version | def get_version(release_level=True):
"""
Return the formatted version information
"""
vers = ["%(major)i.%(minor)i.%(micro)i" % __version_info__]
if release_level and __version_info__['releaselevel'] != 'final':
vers.append('%(releaselevel)s%(serial)i' % __version_info__)
return ''.join(... | python | def get_version(release_level=True):
"""
Return the formatted version information
"""
vers = ["%(major)i.%(minor)i.%(micro)i" % __version_info__]
if release_level and __version_info__['releaselevel'] != 'final':
vers.append('%(releaselevel)s%(serial)i' % __version_info__)
return ''.join(... | [
"def",
"get_version",
"(",
"release_level",
"=",
"True",
")",
":",
"vers",
"=",
"[",
"\"%(major)i.%(minor)i.%(micro)i\"",
"%",
"__version_info__",
"]",
"if",
"release_level",
"and",
"__version_info__",
"[",
"'releaselevel'",
"]",
"!=",
"'final'",
":",
"vers",
".",... | Return the formatted version information | [
"Return",
"the",
"formatted",
"version",
"information"
] | train | https://github.com/LegoStormtroopr/django-spaghetti-and-meatballs/blob/19240f0faeddb0e6fdd9e657cb1565d78bf43f10/django_spaghetti/__init__.py#L10-L17 |
drbild/sslpsk | sslpsk/sslpsk.py | _python_psk_client_callback | def _python_psk_client_callback(ssl_id, hint):
"""Called by _sslpsk.c to return the (psk, identity) tuple for the socket with
the specified ssl socket.
"""
if ssl_id not in _callbacks:
return ("", "")
else:
res = _callbacks[ssl_id](hint)
return res if isinstance(res, tuple) ... | python | def _python_psk_client_callback(ssl_id, hint):
"""Called by _sslpsk.c to return the (psk, identity) tuple for the socket with
the specified ssl socket.
"""
if ssl_id not in _callbacks:
return ("", "")
else:
res = _callbacks[ssl_id](hint)
return res if isinstance(res, tuple) ... | [
"def",
"_python_psk_client_callback",
"(",
"ssl_id",
",",
"hint",
")",
":",
"if",
"ssl_id",
"not",
"in",
"_callbacks",
":",
"return",
"(",
"\"\"",
",",
"\"\"",
")",
"else",
":",
"res",
"=",
"_callbacks",
"[",
"ssl_id",
"]",
"(",
"hint",
")",
"return",
... | Called by _sslpsk.c to return the (psk, identity) tuple for the socket with
the specified ssl socket. | [
"Called",
"by",
"_sslpsk",
".",
"c",
"to",
"return",
"the",
"(",
"psk",
"identity",
")",
"tuple",
"for",
"the",
"socket",
"with",
"the",
"specified",
"ssl",
"socket",
"."
] | train | https://github.com/drbild/sslpsk/blob/583f7b1f775c33ddc1196a400188005c50cfeb0f/sslpsk/sslpsk.py#L38-L47 |
drbild/sslpsk | sslpsk/sslpsk.py | _sslobj | def _sslobj(sock):
"""Returns the underlying PySLLSocket object with which the C extension
functions interface.
"""
pass
if isinstance(sock._sslobj, _ssl._SSLSocket):
return sock._sslobj
else:
return sock._sslobj._sslobj | python | def _sslobj(sock):
"""Returns the underlying PySLLSocket object with which the C extension
functions interface.
"""
pass
if isinstance(sock._sslobj, _ssl._SSLSocket):
return sock._sslobj
else:
return sock._sslobj._sslobj | [
"def",
"_sslobj",
"(",
"sock",
")",
":",
"pass",
"if",
"isinstance",
"(",
"sock",
".",
"_sslobj",
",",
"_ssl",
".",
"_SSLSocket",
")",
":",
"return",
"sock",
".",
"_sslobj",
"else",
":",
"return",
"sock",
".",
"_sslobj",
".",
"_sslobj"
] | Returns the underlying PySLLSocket object with which the C extension
functions interface. | [
"Returns",
"the",
"underlying",
"PySLLSocket",
"object",
"with",
"which",
"the",
"C",
"extension",
"functions",
"interface",
"."
] | train | https://github.com/drbild/sslpsk/blob/583f7b1f775c33ddc1196a400188005c50cfeb0f/sslpsk/sslpsk.py#L49-L58 |
mahmoudimus/nose-timer | nosetimer/plugin.py | _colorize | def _colorize(val, color):
"""Colorize a string using termcolor or colorama.
If any of them are available.
"""
if termcolor is not None:
val = termcolor.colored(val, color)
elif colorama is not None:
val = TERMCOLOR2COLORAMA[color] + val + colorama.Style.RESET_ALL
return val | python | def _colorize(val, color):
"""Colorize a string using termcolor or colorama.
If any of them are available.
"""
if termcolor is not None:
val = termcolor.colored(val, color)
elif colorama is not None:
val = TERMCOLOR2COLORAMA[color] + val + colorama.Style.RESET_ALL
return val | [
"def",
"_colorize",
"(",
"val",
",",
"color",
")",
":",
"if",
"termcolor",
"is",
"not",
"None",
":",
"val",
"=",
"termcolor",
".",
"colored",
"(",
"val",
",",
"color",
")",
"elif",
"colorama",
"is",
"not",
"None",
":",
"val",
"=",
"TERMCOLOR2COLORAMA",... | Colorize a string using termcolor or colorama.
If any of them are available. | [
"Colorize",
"a",
"string",
"using",
"termcolor",
"or",
"colorama",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L83-L93 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin._parse_time | def _parse_time(self, value):
"""Parse string time representation to get number of milliseconds.
Raises the ``ValueError`` for invalid format.
"""
try:
# Default time unit is a second, we should convert it to milliseconds.
return int(value) * 1000
except V... | python | def _parse_time(self, value):
"""Parse string time representation to get number of milliseconds.
Raises the ``ValueError`` for invalid format.
"""
try:
# Default time unit is a second, we should convert it to milliseconds.
return int(value) * 1000
except V... | [
"def",
"_parse_time",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"# Default time unit is a second, we should convert it to milliseconds.",
"return",
"int",
"(",
"value",
")",
"*",
"1000",
"except",
"ValueError",
":",
"# Try to parse if we are unlucky to cast value int... | Parse string time representation to get number of milliseconds.
Raises the ``ValueError`` for invalid format. | [
"Parse",
"string",
"time",
"representation",
"to",
"get",
"number",
"of",
"milliseconds",
".",
"Raises",
"the",
"ValueError",
"for",
"invalid",
"format",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L125-L140 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin.configure | def configure(self, options, config):
"""Configures the test timer plugin."""
super(TimerPlugin, self).configure(options, config)
self.config = config
if self.enabled:
self.timer_top_n = int(options.timer_top_n)
self.timer_ok = self._parse_time(options.timer_ok)
... | python | def configure(self, options, config):
"""Configures the test timer plugin."""
super(TimerPlugin, self).configure(options, config)
self.config = config
if self.enabled:
self.timer_top_n = int(options.timer_top_n)
self.timer_ok = self._parse_time(options.timer_ok)
... | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"config",
")",
":",
"super",
"(",
"TimerPlugin",
",",
"self",
")",
".",
"configure",
"(",
"options",
",",
"config",
")",
"self",
".",
"config",
"=",
"config",
"if",
"self",
".",
"enabled",
":",
"s... | Configures the test timer plugin. | [
"Configures",
"the",
"test",
"timer",
"plugin",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L147-L165 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin.report | def report(self, stream):
"""Report the test times."""
if not self.enabled:
return
# if multiprocessing plugin enabled - get items from results queue
if self.multiprocessing_enabled:
for i in range(_results_queue.qsize()):
try:
... | python | def report(self, stream):
"""Report the test times."""
if not self.enabled:
return
# if multiprocessing plugin enabled - get items from results queue
if self.multiprocessing_enabled:
for i in range(_results_queue.qsize()):
try:
... | [
"def",
"report",
"(",
"self",
",",
"stream",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"return",
"# if multiprocessing plugin enabled - get items from results queue",
"if",
"self",
".",
"multiprocessing_enabled",
":",
"for",
"i",
"in",
"range",
"(",
"_re... | Report the test times. | [
"Report",
"the",
"test",
"times",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L171-L212 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin._get_result_color | def _get_result_color(self, time_taken):
"""Get time taken result color."""
time_taken_ms = time_taken * 1000
if time_taken_ms <= self.timer_ok:
color = 'green'
elif time_taken_ms <= self.timer_warning:
color = 'yellow'
else:
color = 'red'
... | python | def _get_result_color(self, time_taken):
"""Get time taken result color."""
time_taken_ms = time_taken * 1000
if time_taken_ms <= self.timer_ok:
color = 'green'
elif time_taken_ms <= self.timer_warning:
color = 'yellow'
else:
color = 'red'
... | [
"def",
"_get_result_color",
"(",
"self",
",",
"time_taken",
")",
":",
"time_taken_ms",
"=",
"time_taken",
"*",
"1000",
"if",
"time_taken_ms",
"<=",
"self",
".",
"timer_ok",
":",
"color",
"=",
"'green'",
"elif",
"time_taken_ms",
"<=",
"self",
".",
"timer_warnin... | Get time taken result color. | [
"Get",
"time",
"taken",
"result",
"color",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L214-L224 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin.threshold | def threshold(self):
"""Get maximum test time allowed when --timer-fail option is used."""
if self._threshold is None:
self._threshold = {
'error': self.timer_warning,
'warning': self.timer_ok,
}[self.timer_fail]
return self._threshold | python | def threshold(self):
"""Get maximum test time allowed when --timer-fail option is used."""
if self._threshold is None:
self._threshold = {
'error': self.timer_warning,
'warning': self.timer_ok,
}[self.timer_fail]
return self._threshold | [
"def",
"threshold",
"(",
"self",
")",
":",
"if",
"self",
".",
"_threshold",
"is",
"None",
":",
"self",
".",
"_threshold",
"=",
"{",
"'error'",
":",
"self",
".",
"timer_warning",
",",
"'warning'",
":",
"self",
".",
"timer_ok",
",",
"}",
"[",
"self",
"... | Get maximum test time allowed when --timer-fail option is used. | [
"Get",
"maximum",
"test",
"time",
"allowed",
"when",
"--",
"timer",
"-",
"fail",
"option",
"is",
"used",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L227-L234 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin._colored_time | def _colored_time(self, time_taken, color=None):
"""Get formatted and colored string for a given time taken."""
if self.timer_no_color:
return "{0:0.4f}s".format(time_taken)
return _colorize("{0:0.4f}s".format(time_taken), color) | python | def _colored_time(self, time_taken, color=None):
"""Get formatted and colored string for a given time taken."""
if self.timer_no_color:
return "{0:0.4f}s".format(time_taken)
return _colorize("{0:0.4f}s".format(time_taken), color) | [
"def",
"_colored_time",
"(",
"self",
",",
"time_taken",
",",
"color",
"=",
"None",
")",
":",
"if",
"self",
".",
"timer_no_color",
":",
"return",
"\"{0:0.4f}s\"",
".",
"format",
"(",
"time_taken",
")",
"return",
"_colorize",
"(",
"\"{0:0.4f}s\"",
".",
"format... | Get formatted and colored string for a given time taken. | [
"Get",
"formatted",
"and",
"colored",
"string",
"for",
"a",
"given",
"time",
"taken",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L236-L241 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin._format_report_line | def _format_report_line(self, test, time_taken, color, status, percent):
"""Format a single report line."""
return "[{0}] {3:04.2f}% {1}: {2}".format(
status, test, self._colored_time(time_taken, color), percent
) | python | def _format_report_line(self, test, time_taken, color, status, percent):
"""Format a single report line."""
return "[{0}] {3:04.2f}% {1}: {2}".format(
status, test, self._colored_time(time_taken, color), percent
) | [
"def",
"_format_report_line",
"(",
"self",
",",
"test",
",",
"time_taken",
",",
"color",
",",
"status",
",",
"percent",
")",
":",
"return",
"\"[{0}] {3:04.2f}% {1}: {2}\"",
".",
"format",
"(",
"status",
",",
"test",
",",
"self",
".",
"_colored_time",
"(",
"t... | Format a single report line. | [
"Format",
"a",
"single",
"report",
"line",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L243-L247 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin.addSuccess | def addSuccess(self, test, capt=None):
"""Called when a test passes."""
time_taken = self._register_time(test, 'success')
if self.timer_fail is not None and time_taken * 1000.0 > self.threshold:
test.fail('Test was too slow (took {0:0.4f}s, threshold was '
'{1:0... | python | def addSuccess(self, test, capt=None):
"""Called when a test passes."""
time_taken = self._register_time(test, 'success')
if self.timer_fail is not None and time_taken * 1000.0 > self.threshold:
test.fail('Test was too slow (took {0:0.4f}s, threshold was '
'{1:0... | [
"def",
"addSuccess",
"(",
"self",
",",
"test",
",",
"capt",
"=",
"None",
")",
":",
"time_taken",
"=",
"self",
".",
"_register_time",
"(",
"test",
",",
"'success'",
")",
"if",
"self",
".",
"timer_fail",
"is",
"not",
"None",
"and",
"time_taken",
"*",
"10... | Called when a test passes. | [
"Called",
"when",
"a",
"test",
"passes",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L268-L273 |
mahmoudimus/nose-timer | nosetimer/plugin.py | TimerPlugin.options | def options(self, parser, env=os.environ):
"""Register commandline options."""
super(TimerPlugin, self).options(parser, env)
# timer top n
parser.add_option(
"--timer-top-n",
action="store",
default="-1",
dest="timer_top_n",
he... | python | def options(self, parser, env=os.environ):
"""Register commandline options."""
super(TimerPlugin, self).options(parser, env)
# timer top n
parser.add_option(
"--timer-top-n",
action="store",
default="-1",
dest="timer_top_n",
he... | [
"def",
"options",
"(",
"self",
",",
"parser",
",",
"env",
"=",
"os",
".",
"environ",
")",
":",
"super",
"(",
"TimerPlugin",
",",
"self",
")",
".",
"options",
"(",
"parser",
",",
"env",
")",
"# timer top n",
"parser",
".",
"add_option",
"(",
"\"--timer-... | Register commandline options. | [
"Register",
"commandline",
"options",
"."
] | train | https://github.com/mahmoudimus/nose-timer/blob/3d8ff21ce3a68efd6cd018ea67c32f1da27ea3f9/nosetimer/plugin.py#L294-L376 |
jaijuneja/PyTLDR | pytldr/summarize/textrank.py | TextRankSummarizer.summarize | def summarize(self, text, length=5, weighting='frequency', norm=None):
"""
Implements the TextRank summarization algorithm, which follows closely to the PageRank algorithm for ranking
web pages.
:param text: a string of text to be summarized, path to a text file, or URL starting with ht... | python | def summarize(self, text, length=5, weighting='frequency', norm=None):
"""
Implements the TextRank summarization algorithm, which follows closely to the PageRank algorithm for ranking
web pages.
:param text: a string of text to be summarized, path to a text file, or URL starting with ht... | [
"def",
"summarize",
"(",
"self",
",",
"text",
",",
"length",
"=",
"5",
",",
"weighting",
"=",
"'frequency'",
",",
"norm",
"=",
"None",
")",
":",
"text",
"=",
"self",
".",
"_parse_input",
"(",
"text",
")",
"sentences",
",",
"unprocessed_sentences",
"=",
... | Implements the TextRank summarization algorithm, which follows closely to the PageRank algorithm for ranking
web pages.
:param text: a string of text to be summarized, path to a text file, or URL starting with http
:param length: the length of the output summary; either a number of sentences (e... | [
"Implements",
"the",
"TextRank",
"summarization",
"algorithm",
"which",
"follows",
"closely",
"to",
"the",
"PageRank",
"algorithm",
"for",
"ranking",
"web",
"pages",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/summarize/textrank.py#L9-L49 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.remove_stopwords | def remove_stopwords(self, tokens):
"""Remove all stopwords from a list of word tokens or a string of text."""
if isinstance(tokens, (list, tuple)):
return [word for word in tokens if word.lower() not in self._stopwords]
else:
return ' '.join(
[word for wo... | python | def remove_stopwords(self, tokens):
"""Remove all stopwords from a list of word tokens or a string of text."""
if isinstance(tokens, (list, tuple)):
return [word for word in tokens if word.lower() not in self._stopwords]
else:
return ' '.join(
[word for wo... | [
"def",
"remove_stopwords",
"(",
"self",
",",
"tokens",
")",
":",
"if",
"isinstance",
"(",
"tokens",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"[",
"word",
"for",
"word",
"in",
"tokens",
"if",
"word",
".",
"lower",
"(",
")",
"not",
"i... | Remove all stopwords from a list of word tokens or a string of text. | [
"Remove",
"all",
"stopwords",
"from",
"a",
"list",
"of",
"word",
"tokens",
"or",
"a",
"string",
"of",
"text",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L52-L59 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.stem | def stem(self, word):
"""Perform stemming on an input word."""
if self.stemmer:
return unicode_to_ascii(self._stemmer.stem(word))
else:
return word | python | def stem(self, word):
"""Perform stemming on an input word."""
if self.stemmer:
return unicode_to_ascii(self._stemmer.stem(word))
else:
return word | [
"def",
"stem",
"(",
"self",
",",
"word",
")",
":",
"if",
"self",
".",
"stemmer",
":",
"return",
"unicode_to_ascii",
"(",
"self",
".",
"_stemmer",
".",
"stem",
"(",
"word",
")",
")",
"else",
":",
"return",
"word"
] | Perform stemming on an input word. | [
"Perform",
"stemming",
"on",
"an",
"input",
"word",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L61-L66 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.strip_punctuation | def strip_punctuation(text, exclude='', include=''):
"""Strip leading and trailing punctuation from an input string."""
chars_to_strip = ''.join(
set(list(punctuation)).union(set(list(include))) - set(list(exclude))
)
return text.strip(chars_to_strip) | python | def strip_punctuation(text, exclude='', include=''):
"""Strip leading and trailing punctuation from an input string."""
chars_to_strip = ''.join(
set(list(punctuation)).union(set(list(include))) - set(list(exclude))
)
return text.strip(chars_to_strip) | [
"def",
"strip_punctuation",
"(",
"text",
",",
"exclude",
"=",
"''",
",",
"include",
"=",
"''",
")",
":",
"chars_to_strip",
"=",
"''",
".",
"join",
"(",
"set",
"(",
"list",
"(",
"punctuation",
")",
")",
".",
"union",
"(",
"set",
"(",
"list",
"(",
"i... | Strip leading and trailing punctuation from an input string. | [
"Strip",
"leading",
"and",
"trailing",
"punctuation",
"from",
"an",
"input",
"string",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L73-L78 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.tokenize_words | def tokenize_words(self, text):
"""Tokenize an input string into a list of words (with punctuation removed)."""
return [
self.strip_punctuation(word) for word in text.split(' ')
if self.strip_punctuation(word)
] | python | def tokenize_words(self, text):
"""Tokenize an input string into a list of words (with punctuation removed)."""
return [
self.strip_punctuation(word) for word in text.split(' ')
if self.strip_punctuation(word)
] | [
"def",
"tokenize_words",
"(",
"self",
",",
"text",
")",
":",
"return",
"[",
"self",
".",
"strip_punctuation",
"(",
"word",
")",
"for",
"word",
"in",
"text",
".",
"split",
"(",
"' '",
")",
"if",
"self",
".",
"strip_punctuation",
"(",
"word",
")",
"]"
] | Tokenize an input string into a list of words (with punctuation removed). | [
"Tokenize",
"an",
"input",
"string",
"into",
"a",
"list",
"of",
"words",
"(",
"with",
"punctuation",
"removed",
")",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L85-L90 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer._remove_whitespace | def _remove_whitespace(text):
"""Remove excess whitespace from the ends of a given input string."""
# while True:
# old_text = text
# text = text.replace(' ', ' ')
# if text == old_text:
# return text
non_spaces = re.finditer(r'[^ ]', text)
... | python | def _remove_whitespace(text):
"""Remove excess whitespace from the ends of a given input string."""
# while True:
# old_text = text
# text = text.replace(' ', ' ')
# if text == old_text:
# return text
non_spaces = re.finditer(r'[^ ]', text)
... | [
"def",
"_remove_whitespace",
"(",
"text",
")",
":",
"# while True:",
"# old_text = text",
"# text = text.replace(' ', ' ')",
"# if text == old_text:",
"# return text",
"non_spaces",
"=",
"re",
".",
"finditer",
"(",
"r'[^ ]'",
",",
"text",
")",
"if",
"... | Remove excess whitespace from the ends of a given input string. | [
"Remove",
"excess",
"whitespace",
"from",
"the",
"ends",
"of",
"a",
"given",
"input",
"string",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L100-L123 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.tokenize_sentences | def tokenize_sentences(self, text, word_threshold=5):
"""
Returns a list of sentences given an input string of text.
:param text: input string
:param word_threshold: number of significant words that a sentence must contain to be counted
(to count all sentences set equal to 1; 5 ... | python | def tokenize_sentences(self, text, word_threshold=5):
"""
Returns a list of sentences given an input string of text.
:param text: input string
:param word_threshold: number of significant words that a sentence must contain to be counted
(to count all sentences set equal to 1; 5 ... | [
"def",
"tokenize_sentences",
"(",
"self",
",",
"text",
",",
"word_threshold",
"=",
"5",
")",
":",
"punkt_params",
"=",
"PunktParameters",
"(",
")",
"# Not using set literal to allow compatibility with Python 2.6",
"punkt_params",
".",
"abbrev_types",
"=",
"set",
"(",
... | Returns a list of sentences given an input string of text.
:param text: input string
:param word_threshold: number of significant words that a sentence must contain to be counted
(to count all sentences set equal to 1; 5 by default)
:return: list of sentences | [
"Returns",
"a",
"list",
"of",
"sentences",
"given",
"an",
"input",
"string",
"of",
"text",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L125-L169 |
jaijuneja/PyTLDR | pytldr/nlp/tokenizer.py | Tokenizer.tokenize_paragraphs | def tokenize_paragraphs(cls, text):
"""Convert an input string into a list of paragraphs."""
paragraphs = []
paragraphs_first_pass = text.split('\n')
for p in paragraphs_first_pass:
paragraphs_second_pass = re.split('\s{4,}', p)
paragraphs += paragraphs_second_pas... | python | def tokenize_paragraphs(cls, text):
"""Convert an input string into a list of paragraphs."""
paragraphs = []
paragraphs_first_pass = text.split('\n')
for p in paragraphs_first_pass:
paragraphs_second_pass = re.split('\s{4,}', p)
paragraphs += paragraphs_second_pas... | [
"def",
"tokenize_paragraphs",
"(",
"cls",
",",
"text",
")",
":",
"paragraphs",
"=",
"[",
"]",
"paragraphs_first_pass",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
"for",
"p",
"in",
"paragraphs_first_pass",
":",
"paragraphs_second_pass",
"=",
"re",
".",
"sp... | Convert an input string into a list of paragraphs. | [
"Convert",
"an",
"input",
"string",
"into",
"a",
"list",
"of",
"paragraphs",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/nlp/tokenizer.py#L172-L182 |
jaijuneja/PyTLDR | pytldr/summarize/lsa.py | BaseLsaSummarizer._svd | def _svd(cls, matrix, num_concepts=5):
"""
Perform singular value decomposition for dimensionality reduction of the input matrix.
"""
u, s, v = svds(matrix, k=num_concepts)
return u, s, v | python | def _svd(cls, matrix, num_concepts=5):
"""
Perform singular value decomposition for dimensionality reduction of the input matrix.
"""
u, s, v = svds(matrix, k=num_concepts)
return u, s, v | [
"def",
"_svd",
"(",
"cls",
",",
"matrix",
",",
"num_concepts",
"=",
"5",
")",
":",
"u",
",",
"s",
",",
"v",
"=",
"svds",
"(",
"matrix",
",",
"k",
"=",
"num_concepts",
")",
"return",
"u",
",",
"s",
",",
"v"
] | Perform singular value decomposition for dimensionality reduction of the input matrix. | [
"Perform",
"singular",
"value",
"decomposition",
"for",
"dimensionality",
"reduction",
"of",
"the",
"input",
"matrix",
"."
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/summarize/lsa.py#L14-L19 |
jaijuneja/PyTLDR | pytldr/summarize/lsa.py | LsaSteinberger.summarize | def summarize(self, text, topics=4, length=5, binary_matrix=True, topic_sigma_threshold=0.5):
"""
Implements the method of latent semantic analysis described by Steinberger and Jezek in the paper:
J. Steinberger and K. Jezek (2004). Using latent semantic analysis in text summarization and summa... | python | def summarize(self, text, topics=4, length=5, binary_matrix=True, topic_sigma_threshold=0.5):
"""
Implements the method of latent semantic analysis described by Steinberger and Jezek in the paper:
J. Steinberger and K. Jezek (2004). Using latent semantic analysis in text summarization and summa... | [
"def",
"summarize",
"(",
"self",
",",
"text",
",",
"topics",
"=",
"4",
",",
"length",
"=",
"5",
",",
"binary_matrix",
"=",
"True",
",",
"topic_sigma_threshold",
"=",
"0.5",
")",
":",
"text",
"=",
"self",
".",
"_parse_input",
"(",
"text",
")",
"sentence... | Implements the method of latent semantic analysis described by Steinberger and Jezek in the paper:
J. Steinberger and K. Jezek (2004). Using latent semantic analysis in text summarization and summary evaluation.
Proc. ISIM ’04, pp. 93–100.
:param text: a string of text to be summarized, path t... | [
"Implements",
"the",
"method",
"of",
"latent",
"semantic",
"analysis",
"described",
"by",
"Steinberger",
"and",
"Jezek",
"in",
"the",
"paper",
":"
] | train | https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/summarize/lsa.py#L49-L102 |
raphaelm/python-sepaxml | sepaxml/debit.py | SepaDD.check_payment | def check_payment(self, payment):
"""
Check the payment for required fields and validity.
@param payment: The payment dict
@return: True if valid, error string if invalid paramaters where
encountered.
"""
validation = ""
if not isinstance(payment['amount'... | python | def check_payment(self, payment):
"""
Check the payment for required fields and validity.
@param payment: The payment dict
@return: True if valid, error string if invalid paramaters where
encountered.
"""
validation = ""
if not isinstance(payment['amount'... | [
"def",
"check_payment",
"(",
"self",
",",
"payment",
")",
":",
"validation",
"=",
"\"\"",
"if",
"not",
"isinstance",
"(",
"payment",
"[",
"'amount'",
"]",
",",
"int",
")",
":",
"validation",
"+=",
"\"AMOUNT_NOT_INTEGER \"",
"if",
"not",
"isinstance",
"(",
... | Check the payment for required fields and validity.
@param payment: The payment dict
@return: True if valid, error string if invalid paramaters where
encountered. | [
"Check",
"the",
"payment",
"for",
"required",
"fields",
"and",
"validity",
"."
] | train | https://github.com/raphaelm/python-sepaxml/blob/187b699b1673c862002b2bae7e1bd62fe8623aec/sepaxml/debit.py#L38-L61 |
raphaelm/python-sepaxml | sepaxml/debit.py | SepaDD.add_payment | def add_payment(self, payment):
"""
Function to add payments
@param payment: The payment dict
@raise exception: when payment is invalid
"""
if self.clean:
from text_unidecode import unidecode
payment['name'] = unidecode(payment['name'])[:70]
... | python | def add_payment(self, payment):
"""
Function to add payments
@param payment: The payment dict
@raise exception: when payment is invalid
"""
if self.clean:
from text_unidecode import unidecode
payment['name'] = unidecode(payment['name'])[:70]
... | [
"def",
"add_payment",
"(",
"self",
",",
"payment",
")",
":",
"if",
"self",
".",
"clean",
":",
"from",
"text_unidecode",
"import",
"unidecode",
"payment",
"[",
"'name'",
"]",
"=",
"unidecode",
"(",
"payment",
"[",
"'name'",
"]",
")",
"[",
":",
"70",
"]"... | Function to add payments
@param payment: The payment dict
@raise exception: when payment is invalid | [
"Function",
"to",
"add",
"payments"
] | train | https://github.com/raphaelm/python-sepaxml/blob/187b699b1673c862002b2bae7e1bd62fe8623aec/sepaxml/debit.py#L63-L127 |
raphaelm/python-sepaxml | sepaxml/debit.py | SepaDD._create_header | def _create_header(self):
"""
Function to create the GroupHeader (GrpHdr) in the
CstmrDrctDbtInit Node
"""
# Retrieve the node to which we will append the group header.
CstmrDrctDbtInitn_node = self._xml.find('CstmrDrctDbtInitn')
# Create the header nodes.
... | python | def _create_header(self):
"""
Function to create the GroupHeader (GrpHdr) in the
CstmrDrctDbtInit Node
"""
# Retrieve the node to which we will append the group header.
CstmrDrctDbtInitn_node = self._xml.find('CstmrDrctDbtInitn')
# Create the header nodes.
... | [
"def",
"_create_header",
"(",
"self",
")",
":",
"# Retrieve the node to which we will append the group header.",
"CstmrDrctDbtInitn_node",
"=",
"self",
".",
"_xml",
".",
"find",
"(",
"'CstmrDrctDbtInitn'",
")",
"# Create the header nodes.",
"GrpHdr_node",
"=",
"ET",
".",
... | Function to create the GroupHeader (GrpHdr) in the
CstmrDrctDbtInit Node | [
"Function",
"to",
"create",
"the",
"GroupHeader",
"(",
"GrpHdr",
")",
"in",
"the",
"CstmrDrctDbtInit",
"Node"
] | train | https://github.com/raphaelm/python-sepaxml/blob/187b699b1673c862002b2bae7e1bd62fe8623aec/sepaxml/debit.py#L129-L169 |
raphaelm/python-sepaxml | sepaxml/debit.py | SepaDD._create_PmtInf_node | def _create_PmtInf_node(self):
"""
Method to create the blank payment information nodes as a dict.
"""
ED = dict() # ED is element dict
ED['PmtInfNode'] = ET.Element("PmtInf")
ED['PmtInfIdNode'] = ET.Element("PmtInfId")
ED['PmtMtdNode'] = ET.Element("PmtMtd")
... | python | def _create_PmtInf_node(self):
"""
Method to create the blank payment information nodes as a dict.
"""
ED = dict() # ED is element dict
ED['PmtInfNode'] = ET.Element("PmtInf")
ED['PmtInfIdNode'] = ET.Element("PmtInfId")
ED['PmtMtdNode'] = ET.Element("PmtMtd")
... | [
"def",
"_create_PmtInf_node",
"(",
"self",
")",
":",
"ED",
"=",
"dict",
"(",
")",
"# ED is element dict",
"ED",
"[",
"'PmtInfNode'",
"]",
"=",
"ET",
".",
"Element",
"(",
"\"PmtInf\"",
")",
"ED",
"[",
"'PmtInfIdNode'",
"]",
"=",
"ET",
".",
"Element",
"(",... | Method to create the blank payment information nodes as a dict. | [
"Method",
"to",
"create",
"the",
"blank",
"payment",
"information",
"nodes",
"as",
"a",
"dict",
"."
] | train | https://github.com/raphaelm/python-sepaxml/blob/187b699b1673c862002b2bae7e1bd62fe8623aec/sepaxml/debit.py#L171-L207 |
raphaelm/python-sepaxml | sepaxml/debit.py | SepaDD._create_TX_node | def _create_TX_node(self, bic=True):
"""
Method to create the blank transaction nodes as a dict. If bic is True,
the BIC node will also be created.
"""
ED = dict()
ED['DrctDbtTxInfNode'] = ET.Element("DrctDbtTxInf")
ED['PmtIdNode'] = ET.Element("PmtId")
ED... | python | def _create_TX_node(self, bic=True):
"""
Method to create the blank transaction nodes as a dict. If bic is True,
the BIC node will also be created.
"""
ED = dict()
ED['DrctDbtTxInfNode'] = ET.Element("DrctDbtTxInf")
ED['PmtIdNode'] = ET.Element("PmtId")
ED... | [
"def",
"_create_TX_node",
"(",
"self",
",",
"bic",
"=",
"True",
")",
":",
"ED",
"=",
"dict",
"(",
")",
"ED",
"[",
"'DrctDbtTxInfNode'",
"]",
"=",
"ET",
".",
"Element",
"(",
"\"DrctDbtTxInf\"",
")",
"ED",
"[",
"'PmtIdNode'",
"]",
"=",
"ET",
".",
"Elem... | Method to create the blank transaction nodes as a dict. If bic is True,
the BIC node will also be created. | [
"Method",
"to",
"create",
"the",
"blank",
"transaction",
"nodes",
"as",
"a",
"dict",
".",
"If",
"bic",
"is",
"True",
"the",
"BIC",
"node",
"will",
"also",
"be",
"created",
"."
] | train | https://github.com/raphaelm/python-sepaxml/blob/187b699b1673c862002b2bae7e1bd62fe8623aec/sepaxml/debit.py#L209-L234 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.