id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51,400 | gmichaeljaison/cv-utils | cv_utils/img_utils.py | collage | def collage(imgs, size, padding=10, bg=COL_BLACK):
"""
Constructs a collage of same-sized images with specified padding.
:param imgs: Array of images. Either 1d-array or 2d-array.
:param size: (no. of rows, no. of cols)
:param padding: Padding space between each image
:param bg: Background colo... | python | def collage(imgs, size, padding=10, bg=COL_BLACK):
"""
Constructs a collage of same-sized images with specified padding.
:param imgs: Array of images. Either 1d-array or 2d-array.
:param size: (no. of rows, no. of cols)
:param padding: Padding space between each image
:param bg: Background colo... | [
"def",
"collage",
"(",
"imgs",
",",
"size",
",",
"padding",
"=",
"10",
",",
"bg",
"=",
"COL_BLACK",
")",
":",
"# make 2d array",
"if",
"not",
"isinstance",
"(",
"imgs",
"[",
"0",
"]",
",",
"list",
")",
":",
"imgs",
"=",
"[",
"imgs",
"]",
"h",
","... | Constructs a collage of same-sized images with specified padding.
:param imgs: Array of images. Either 1d-array or 2d-array.
:param size: (no. of rows, no. of cols)
:param padding: Padding space between each image
:param bg: Background color for the collage. Default: Black
:return: New collage | [
"Constructs",
"a",
"collage",
"of",
"same",
"-",
"sized",
"images",
"with",
"specified",
"padding",
"."
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/img_utils.py#L223-L258 |
51,401 | gmichaeljaison/cv-utils | cv_utils/img_utils.py | each_img | def each_img(img_dir):
"""
Reads and iterates through each image file in the given directory
"""
for fname in utils.each_img(img_dir):
fname = os.path.join(img_dir, fname)
yield cv.imread(fname), fname | python | def each_img(img_dir):
"""
Reads and iterates through each image file in the given directory
"""
for fname in utils.each_img(img_dir):
fname = os.path.join(img_dir, fname)
yield cv.imread(fname), fname | [
"def",
"each_img",
"(",
"img_dir",
")",
":",
"for",
"fname",
"in",
"utils",
".",
"each_img",
"(",
"img_dir",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"img_dir",
",",
"fname",
")",
"yield",
"cv",
".",
"imread",
"(",
"fname",
")",... | Reads and iterates through each image file in the given directory | [
"Reads",
"and",
"iterates",
"through",
"each",
"image",
"file",
"in",
"the",
"given",
"directory"
] | a8251c870165a7428d8c468a6436aa41d0cf7c09 | https://github.com/gmichaeljaison/cv-utils/blob/a8251c870165a7428d8c468a6436aa41d0cf7c09/cv_utils/img_utils.py#L283-L289 |
51,402 | yyuu/botornado | boto/ec2/cloudwatch/alarm.py | MetricAlarm.set_state | def set_state(self, value, reason, data=None):
""" Temporarily sets the state of an alarm.
:type value: str
:param value: OK | ALARM | INSUFFICIENT_DATA
:type reason: str
:param reason: Reason alarm set (human readable).
:type data: str
:param data: Reason data... | python | def set_state(self, value, reason, data=None):
""" Temporarily sets the state of an alarm.
:type value: str
:param value: OK | ALARM | INSUFFICIENT_DATA
:type reason: str
:param reason: Reason alarm set (human readable).
:type data: str
:param data: Reason data... | [
"def",
"set_state",
"(",
"self",
",",
"value",
",",
"reason",
",",
"data",
"=",
"None",
")",
":",
"return",
"self",
".",
"connection",
".",
"set_alarm_state",
"(",
"self",
".",
"name",
",",
"reason",
",",
"value",
",",
"data",
")"
] | Temporarily sets the state of an alarm.
:type value: str
:param value: OK | ALARM | INSUFFICIENT_DATA
:type reason: str
:param reason: Reason alarm set (human readable).
:type data: str
:param data: Reason data (will be jsonified). | [
"Temporarily",
"sets",
"the",
"state",
"of",
"an",
"alarm",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/cloudwatch/alarm.py#L220-L232 |
51,403 | yyuu/botornado | boto/ec2/cloudwatch/alarm.py | MetricAlarm.add_alarm_action | def add_alarm_action(self, action_arn=None):
"""
Adds an alarm action, represented as an SNS topic, to this alarm.
What do do when alarm is triggered.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the ala... | python | def add_alarm_action(self, action_arn=None):
"""
Adds an alarm action, represented as an SNS topic, to this alarm.
What do do when alarm is triggered.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the ala... | [
"def",
"add_alarm_action",
"(",
"self",
",",
"action_arn",
"=",
"None",
")",
":",
"if",
"not",
"action_arn",
":",
"return",
"# Raise exception instead?",
"self",
".",
"actions_enabled",
"=",
"'true'",
"self",
".",
"alarm_actions",
".",
"append",
"(",
"action_arn... | Adds an alarm action, represented as an SNS topic, to this alarm.
What do do when alarm is triggered.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the alarm goes to state ALARM. | [
"Adds",
"an",
"alarm",
"action",
"represented",
"as",
"an",
"SNS",
"topic",
"to",
"this",
"alarm",
".",
"What",
"do",
"do",
"when",
"alarm",
"is",
"triggered",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/cloudwatch/alarm.py#L250-L262 |
51,404 | yyuu/botornado | boto/ec2/cloudwatch/alarm.py | MetricAlarm.add_insufficient_data_action | def add_insufficient_data_action(self, action_arn=None):
"""
Adds an insufficient_data action, represented as an SNS topic, to
this alarm. What to do when the insufficient_data state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be ... | python | def add_insufficient_data_action(self, action_arn=None):
"""
Adds an insufficient_data action, represented as an SNS topic, to
this alarm. What to do when the insufficient_data state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be ... | [
"def",
"add_insufficient_data_action",
"(",
"self",
",",
"action_arn",
"=",
"None",
")",
":",
"if",
"not",
"action_arn",
":",
"return",
"self",
".",
"actions_enabled",
"=",
"'true'",
"self",
".",
"insufficient_data_actions",
".",
"append",
"(",
"action_arn",
")"... | Adds an insufficient_data action, represented as an SNS topic, to
this alarm. What to do when the insufficient_data state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the alarm goes to state INSUFFICIENT_DATA... | [
"Adds",
"an",
"insufficient_data",
"action",
"represented",
"as",
"an",
"SNS",
"topic",
"to",
"this",
"alarm",
".",
"What",
"to",
"do",
"when",
"the",
"insufficient_data",
"state",
"is",
"reached",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/cloudwatch/alarm.py#L264-L276 |
51,405 | yyuu/botornado | boto/ec2/cloudwatch/alarm.py | MetricAlarm.add_ok_action | def add_ok_action(self, action_arn=None):
"""
Adds an ok action, represented as an SNS topic, to this alarm. What
to do when the ok state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the alarm... | python | def add_ok_action(self, action_arn=None):
"""
Adds an ok action, represented as an SNS topic, to this alarm. What
to do when the ok state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the alarm... | [
"def",
"add_ok_action",
"(",
"self",
",",
"action_arn",
"=",
"None",
")",
":",
"if",
"not",
"action_arn",
":",
"return",
"self",
".",
"actions_enabled",
"=",
"'true'",
"self",
".",
"ok_actions",
".",
"append",
"(",
"action_arn",
")"
] | Adds an ok action, represented as an SNS topic, to this alarm. What
to do when the ok state is reached.
:type action_arn: str
:param action_arn: SNS topics to which notification should be
sent if the alarm goes to state INSUFFICIENT_DATA. | [
"Adds",
"an",
"ok",
"action",
"represented",
"as",
"an",
"SNS",
"topic",
"to",
"this",
"alarm",
".",
"What",
"to",
"do",
"when",
"the",
"ok",
"state",
"is",
"reached",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/cloudwatch/alarm.py#L278-L290 |
51,406 | yyuu/botornado | boto/sts/connection.py | STSConnection.get_session_token | def get_session_token(self, duration=None, force_new=False):
"""
Return a valid session token. Because retrieving new tokens
from the Secure Token Service is a fairly heavyweight operation
this module caches previously retrieved tokens and returns
them when appropriate. Each to... | python | def get_session_token(self, duration=None, force_new=False):
"""
Return a valid session token. Because retrieving new tokens
from the Secure Token Service is a fairly heavyweight operation
this module caches previously retrieved tokens and returns
them when appropriate. Each to... | [
"def",
"get_session_token",
"(",
"self",
",",
"duration",
"=",
"None",
",",
"force_new",
"=",
"False",
")",
":",
"token_key",
"=",
"'%s:%s'",
"%",
"(",
"self",
".",
"region",
".",
"name",
",",
"self",
".",
"provider",
".",
"access_key",
")",
"token",
"... | Return a valid session token. Because retrieving new tokens
from the Secure Token Service is a fairly heavyweight operation
this module caches previously retrieved tokens and returns
them when appropriate. Each token is cached with a key
consisting of the region name of the STS endpoin... | [
"Return",
"a",
"valid",
"session",
"token",
".",
"Because",
"retrieving",
"new",
"tokens",
"from",
"the",
"Secure",
"Token",
"Service",
"is",
"a",
"fairly",
"heavyweight",
"operation",
"this",
"module",
"caches",
"previously",
"retrieved",
"tokens",
"and",
"retu... | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sts/connection.py#L79-L110 |
51,407 | yyuu/botornado | boto/sns/connection.py | SNSConnection.set_topic_attributes | def set_topic_attributes(self, topic, attr_name, attr_value):
"""
Get attributes of a Topic
:type topic: string
:param topic: The ARN of the topic.
:type attr_name: string
:param attr_name: The name of the attribute you want to set.
Only a subs... | python | def set_topic_attributes(self, topic, attr_name, attr_value):
"""
Get attributes of a Topic
:type topic: string
:param topic: The ARN of the topic.
:type attr_name: string
:param attr_name: The name of the attribute you want to set.
Only a subs... | [
"def",
"set_topic_attributes",
"(",
"self",
",",
"topic",
",",
"attr_name",
",",
"attr_value",
")",
":",
"params",
"=",
"{",
"'ContentType'",
":",
"'JSON'",
",",
"'TopicArn'",
":",
"topic",
",",
"'AttributeName'",
":",
"attr_name",
",",
"'AttributeValue'",
":"... | Get attributes of a Topic
:type topic: string
:param topic: The ARN of the topic.
:type attr_name: string
:param attr_name: The name of the attribute you want to set.
Only a subset of the topic's attributes are mutable.
Valid values: ... | [
"Get",
"attributes",
"of",
"a",
"Topic"
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sns/connection.py#L96-L123 |
51,408 | yyuu/botornado | boto/sns/connection.py | SNSConnection.add_permission | def add_permission(self, topic, label, account_ids, actions):
"""
Adds a statement to a topic's access control policy, granting
access for the specified AWS accounts to the specified actions.
:type topic: string
:param topic: The ARN of the topic.
:type label: string
... | python | def add_permission(self, topic, label, account_ids, actions):
"""
Adds a statement to a topic's access control policy, granting
access for the specified AWS accounts to the specified actions.
:type topic: string
:param topic: The ARN of the topic.
:type label: string
... | [
"def",
"add_permission",
"(",
"self",
",",
"topic",
",",
"label",
",",
"account_ids",
",",
"actions",
")",
":",
"params",
"=",
"{",
"'ContentType'",
":",
"'JSON'",
",",
"'TopicArn'",
":",
"topic",
",",
"'Label'",
":",
"label",
"}",
"self",
".",
"build_li... | Adds a statement to a topic's access control policy, granting
access for the specified AWS accounts to the specified actions.
:type topic: string
:param topic: The ARN of the topic.
:type label: string
:param label: A unique identifier for the new policy statement.
:ty... | [
"Adds",
"a",
"statement",
"to",
"a",
"topic",
"s",
"access",
"control",
"policy",
"granting",
"access",
"for",
"the",
"specified",
"AWS",
"accounts",
"to",
"the",
"specified",
"actions",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sns/connection.py#L125-L157 |
51,409 | yyuu/botornado | boto/sns/connection.py | SNSConnection.subscribe_sqs_queue | def subscribe_sqs_queue(self, topic, queue):
"""
Subscribe an SQS queue to a topic.
This is convenience method that handles most of the complexity involved
in using ans SQS queue as an endpoint for an SNS topic. To achieve this
the following operations are performed:
... | python | def subscribe_sqs_queue(self, topic, queue):
"""
Subscribe an SQS queue to a topic.
This is convenience method that handles most of the complexity involved
in using ans SQS queue as an endpoint for an SNS topic. To achieve this
the following operations are performed:
... | [
"def",
"subscribe_sqs_queue",
"(",
"self",
",",
"topic",
",",
"queue",
")",
":",
"t",
"=",
"queue",
".",
"id",
".",
"split",
"(",
"'/'",
")",
"q_arn",
"=",
"'arn:aws:sqs:%s:%s:%s'",
"%",
"(",
"queue",
".",
"connection",
".",
"region",
".",
"name",
",",... | Subscribe an SQS queue to a topic.
This is convenience method that handles most of the complexity involved
in using ans SQS queue as an endpoint for an SNS topic. To achieve this
the following operations are performed:
* The correct ARN is constructed for the SQS queue and tha... | [
"Subscribe",
"an",
"SQS",
"queue",
"to",
"a",
"topic",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sns/connection.py#L289-L329 |
51,410 | yyuu/botornado | boto/sns/connection.py | SNSConnection.unsubscribe | def unsubscribe(self, subscription):
"""
Allows endpoint owner to delete subscription.
Confirmation message will be delivered.
:type subscription: string
:param subscription: The ARN of the subscription to be deleted.
"""
params = {'ContentType' : 'JSON',
... | python | def unsubscribe(self, subscription):
"""
Allows endpoint owner to delete subscription.
Confirmation message will be delivered.
:type subscription: string
:param subscription: The ARN of the subscription to be deleted.
"""
params = {'ContentType' : 'JSON',
... | [
"def",
"unsubscribe",
"(",
"self",
",",
"subscription",
")",
":",
"params",
"=",
"{",
"'ContentType'",
":",
"'JSON'",
",",
"'SubscriptionArn'",
":",
"subscription",
"}",
"response",
"=",
"self",
".",
"make_request",
"(",
"'Unsubscribe'",
",",
"params",
",",
... | Allows endpoint owner to delete subscription.
Confirmation message will be delivered.
:type subscription: string
:param subscription: The ARN of the subscription to be deleted. | [
"Allows",
"endpoint",
"owner",
"to",
"delete",
"subscription",
".",
"Confirmation",
"message",
"will",
"be",
"delivered",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sns/connection.py#L364-L382 |
51,411 | yyuu/botornado | boto/sns/connection.py | SNSConnection.get_all_subscriptions | def get_all_subscriptions(self, next_token=None):
"""
Get list of all subscriptions.
:type next_token: string
:param next_token: Token returned by the previous call to
this method.
"""
params = {'ContentType' : 'JSON'}
if next_token:
... | python | def get_all_subscriptions(self, next_token=None):
"""
Get list of all subscriptions.
:type next_token: string
:param next_token: Token returned by the previous call to
this method.
"""
params = {'ContentType' : 'JSON'}
if next_token:
... | [
"def",
"get_all_subscriptions",
"(",
"self",
",",
"next_token",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'ContentType'",
":",
"'JSON'",
"}",
"if",
"next_token",
":",
"params",
"[",
"'NextToken'",
"]",
"=",
"next_token",
"response",
"=",
"self",
".",
"ma... | Get list of all subscriptions.
:type next_token: string
:param next_token: Token returned by the previous call to
this method. | [
"Get",
"list",
"of",
"all",
"subscriptions",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sns/connection.py#L384-L403 |
51,412 | yyuu/botornado | boto/fps/connection.py | FPSConnection.install_caller_instruction | def install_caller_instruction(self, token_type="Unrestricted",
transaction_id=None):
"""
Set us up as a caller
This will install a new caller_token into the FPS section.
This should really only be called to regenerate the caller token.
"""
... | python | def install_caller_instruction(self, token_type="Unrestricted",
transaction_id=None):
"""
Set us up as a caller
This will install a new caller_token into the FPS section.
This should really only be called to regenerate the caller token.
"""
... | [
"def",
"install_caller_instruction",
"(",
"self",
",",
"token_type",
"=",
"\"Unrestricted\"",
",",
"transaction_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"install_payment_instruction",
"(",
"\"MyRole=='Caller';\"",
",",
"token_type",
"=",
"token_type",... | Set us up as a caller
This will install a new caller_token into the FPS section.
This should really only be called to regenerate the caller token. | [
"Set",
"us",
"up",
"as",
"a",
"caller",
"This",
"will",
"install",
"a",
"new",
"caller_token",
"into",
"the",
"FPS",
"section",
".",
"This",
"should",
"really",
"only",
"be",
"called",
"to",
"regenerate",
"the",
"caller",
"token",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L76-L100 |
51,413 | yyuu/botornado | boto/fps/connection.py | FPSConnection.make_marketplace_registration_url | def make_marketplace_registration_url(self, returnURL, pipelineName,
maxFixedFee=0.0, maxVariableFee=0.0,
recipientPaysFee=True, **params):
"""
Generate the URL with the signature required for signing up a recipient
... | python | def make_marketplace_registration_url(self, returnURL, pipelineName,
maxFixedFee=0.0, maxVariableFee=0.0,
recipientPaysFee=True, **params):
"""
Generate the URL with the signature required for signing up a recipient
... | [
"def",
"make_marketplace_registration_url",
"(",
"self",
",",
"returnURL",
",",
"pipelineName",
",",
"maxFixedFee",
"=",
"0.0",
",",
"maxVariableFee",
"=",
"0.0",
",",
"recipientPaysFee",
"=",
"True",
",",
"*",
"*",
"params",
")",
":",
"# use the sandbox authoriza... | Generate the URL with the signature required for signing up a recipient | [
"Generate",
"the",
"URL",
"with",
"the",
"signature",
"required",
"for",
"signing",
"up",
"a",
"recipient"
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L129-L173 |
51,414 | yyuu/botornado | boto/fps/connection.py | FPSConnection.make_url | def make_url(self, returnURL, paymentReason, pipelineName,
transactionAmount, **params):
"""
Generate the URL with the signature required for a transaction
"""
# use the sandbox authorization endpoint if we're using the
# sandbox for API calls.
endpoint_... | python | def make_url(self, returnURL, paymentReason, pipelineName,
transactionAmount, **params):
"""
Generate the URL with the signature required for a transaction
"""
# use the sandbox authorization endpoint if we're using the
# sandbox for API calls.
endpoint_... | [
"def",
"make_url",
"(",
"self",
",",
"returnURL",
",",
"paymentReason",
",",
"pipelineName",
",",
"transactionAmount",
",",
"*",
"*",
"params",
")",
":",
"# use the sandbox authorization endpoint if we're using the",
"# sandbox for API calls.",
"endpoint_host",
"=",
"'au... | Generate the URL with the signature required for a transaction | [
"Generate",
"the",
"URL",
"with",
"the",
"signature",
"required",
"for",
"a",
"transaction"
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L176-L218 |
51,415 | yyuu/botornado | boto/fps/connection.py | FPSConnection.pay | def pay(self, transactionAmount, senderTokenId,
recipientTokenId=None, callerTokenId=None,
chargeFeeTo="Recipient",
callerReference=None, senderReference=None, recipientReference=None,
senderDescription=None, recipientDescription=None,
callerDescription=None, ... | python | def pay(self, transactionAmount, senderTokenId,
recipientTokenId=None, callerTokenId=None,
chargeFeeTo="Recipient",
callerReference=None, senderReference=None, recipientReference=None,
senderDescription=None, recipientDescription=None,
callerDescription=None, ... | [
"def",
"pay",
"(",
"self",
",",
"transactionAmount",
",",
"senderTokenId",
",",
"recipientTokenId",
"=",
"None",
",",
"callerTokenId",
"=",
"None",
",",
"chargeFeeTo",
"=",
"\"Recipient\"",
",",
"callerReference",
"=",
"None",
",",
"senderReference",
"=",
"None"... | Make a payment transaction. You must specify the amount.
This can also perform a Reserve request if 'reserve' is set to True. | [
"Make",
"a",
"payment",
"transaction",
".",
"You",
"must",
"specify",
"the",
"amount",
".",
"This",
"can",
"also",
"perform",
"a",
"Reserve",
"request",
"if",
"reserve",
"is",
"set",
"to",
"True",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L220-L276 |
51,416 | yyuu/botornado | boto/fps/connection.py | FPSConnection.get_transaction_status | def get_transaction_status(self, transactionId):
"""
Returns the status of a given transaction.
"""
params = {}
params['TransactionId'] = transactionId
response = self.make_request("GetTransactionStatus", params)
body = response.read()
if(response.sta... | python | def get_transaction_status(self, transactionId):
"""
Returns the status of a given transaction.
"""
params = {}
params['TransactionId'] = transactionId
response = self.make_request("GetTransactionStatus", params)
body = response.read()
if(response.sta... | [
"def",
"get_transaction_status",
"(",
"self",
",",
"transactionId",
")",
":",
"params",
"=",
"{",
"}",
"params",
"[",
"'TransactionId'",
"]",
"=",
"transactionId",
"response",
"=",
"self",
".",
"make_request",
"(",
"\"GetTransactionStatus\"",
",",
"params",
")",... | Returns the status of a given transaction. | [
"Returns",
"the",
"status",
"of",
"a",
"given",
"transaction",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L278-L293 |
51,417 | yyuu/botornado | boto/fps/connection.py | FPSConnection.settle | def settle(self, reserveTransactionId, transactionAmount=None):
"""
Charges for a reserved payment.
"""
params = {}
params['ReserveTransactionId'] = reserveTransactionId
if(transactionAmount != None):
params['TransactionAmount'] = transactionAmount
... | python | def settle(self, reserveTransactionId, transactionAmount=None):
"""
Charges for a reserved payment.
"""
params = {}
params['ReserveTransactionId'] = reserveTransactionId
if(transactionAmount != None):
params['TransactionAmount'] = transactionAmount
... | [
"def",
"settle",
"(",
"self",
",",
"reserveTransactionId",
",",
"transactionAmount",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"params",
"[",
"'ReserveTransactionId'",
"]",
"=",
"reserveTransactionId",
"if",
"(",
"transactionAmount",
"!=",
"None",
")",
"... | Charges for a reserved payment. | [
"Charges",
"for",
"a",
"reserved",
"payment",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L314-L331 |
51,418 | yyuu/botornado | boto/fps/connection.py | FPSConnection.refund | def refund(self, callerReference, transactionId, refundAmount=None,
callerDescription=None):
"""
Refund a transaction. This refunds the full amount by default
unless 'refundAmount' is specified.
"""
params = {}
params['CallerReference'] = callerReference
... | python | def refund(self, callerReference, transactionId, refundAmount=None,
callerDescription=None):
"""
Refund a transaction. This refunds the full amount by default
unless 'refundAmount' is specified.
"""
params = {}
params['CallerReference'] = callerReference
... | [
"def",
"refund",
"(",
"self",
",",
"callerReference",
",",
"transactionId",
",",
"refundAmount",
"=",
"None",
",",
"callerDescription",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"params",
"[",
"'CallerReference'",
"]",
"=",
"callerReference",
"params",
... | Refund a transaction. This refunds the full amount by default
unless 'refundAmount' is specified. | [
"Refund",
"a",
"transaction",
".",
"This",
"refunds",
"the",
"full",
"amount",
"by",
"default",
"unless",
"refundAmount",
"is",
"specified",
"."
] | fffb056f5ff2324d1d5c1304014cfb1d899f602e | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/fps/connection.py#L333-L355 |
51,419 | pappasam/latexbuild | latexbuild/__init__.py | build_pdf | def build_pdf(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building a pdf from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex te... | python | def build_pdf(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building a pdf from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex te... | [
"def",
"build_pdf",
"(",
"path_jinja2",
",",
"template_name",
",",
"path_outfile",
",",
"template_kwargs",
"=",
"None",
")",
":",
"latex_template_object",
"=",
"LatexBuild",
"(",
"path_jinja2",
",",
"template_name",
",",
"template_kwargs",
",",
")",
"return",
"lat... | Helper function for building a pdf from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex template
:param path_outfile: the full path to the desired final output file
... | [
"Helper",
"function",
"for",
"building",
"a",
"pdf",
"from",
"a",
"latex",
"jinja2",
"template"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/__init__.py#L22-L38 |
51,420 | pappasam/latexbuild | latexbuild/__init__.py | build_html | def build_html(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building an html from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex... | python | def build_html(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building an html from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex... | [
"def",
"build_html",
"(",
"path_jinja2",
",",
"template_name",
",",
"path_outfile",
",",
"template_kwargs",
"=",
"None",
")",
":",
"latex_template_object",
"=",
"LatexBuild",
"(",
"path_jinja2",
",",
"template_name",
",",
"template_kwargs",
",",
")",
"return",
"la... | Helper function for building an html from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex template
:param path_outfile: the full path to the desired final output file
... | [
"Helper",
"function",
"for",
"building",
"an",
"html",
"from",
"a",
"latex",
"jinja2",
"template"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/__init__.py#L40-L56 |
51,421 | pappasam/latexbuild | latexbuild/__init__.py | build_docx | def build_docx(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building a docx file from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 L... | python | def build_docx(path_jinja2, template_name, path_outfile, template_kwargs=None):
'''Helper function for building a docx file from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 L... | [
"def",
"build_docx",
"(",
"path_jinja2",
",",
"template_name",
",",
"path_outfile",
",",
"template_kwargs",
"=",
"None",
")",
":",
"latex_template_object",
"=",
"LatexBuild",
"(",
"path_jinja2",
",",
"template_name",
",",
"template_kwargs",
",",
")",
"return",
"la... | Helper function for building a docx file from a latex jinja2 template
:param path_jinja2: the root directory for latex jinja2 templates
:param template_name: the relative path, to path_jinja2, to the desired
jinja2 Latex template
:param path_outfile: the full path to the desired final output file
... | [
"Helper",
"function",
"for",
"building",
"a",
"docx",
"file",
"from",
"a",
"latex",
"jinja2",
"template"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/__init__.py#L58-L74 |
51,422 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.read | def read(self, uri=None, resources=None, index_only=False):
"""Read sitemap from a URI including handling sitemapindexes.
If index_only is True then individual sitemaps references in a sitemapindex
will not be read. This will result in no resources being returned and is
useful only to r... | python | def read(self, uri=None, resources=None, index_only=False):
"""Read sitemap from a URI including handling sitemapindexes.
If index_only is True then individual sitemaps references in a sitemapindex
will not be read. This will result in no resources being returned and is
useful only to r... | [
"def",
"read",
"(",
"self",
",",
"uri",
"=",
"None",
",",
"resources",
"=",
"None",
",",
"index_only",
"=",
"False",
")",
":",
"try",
":",
"fh",
"=",
"URLopener",
"(",
")",
".",
"open",
"(",
"uri",
")",
"self",
".",
"num_files",
"+=",
"1",
"excep... | Read sitemap from a URI including handling sitemapindexes.
If index_only is True then individual sitemaps references in a sitemapindex
will not be read. This will result in no resources being returned and is
useful only to read the metadata and links listed in the sitemapindex.
Include... | [
"Read",
"sitemap",
"from",
"a",
"URI",
"including",
"handling",
"sitemapindexes",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L75-L134 |
51,423 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.read_component_sitemap | def read_component_sitemap(
self, sitemapindex_uri, sitemap_uri, sitemap, sitemapindex_is_file):
"""Read a component sitemap of a Resource List with index.
Each component must be a sitemap with the
"""
if (sitemapindex_is_file):
if (not self.is_file_uri(sitemap_u... | python | def read_component_sitemap(
self, sitemapindex_uri, sitemap_uri, sitemap, sitemapindex_is_file):
"""Read a component sitemap of a Resource List with index.
Each component must be a sitemap with the
"""
if (sitemapindex_is_file):
if (not self.is_file_uri(sitemap_u... | [
"def",
"read_component_sitemap",
"(",
"self",
",",
"sitemapindex_uri",
",",
"sitemap_uri",
",",
"sitemap",
",",
"sitemapindex_is_file",
")",
":",
"if",
"(",
"sitemapindex_is_file",
")",
":",
"if",
"(",
"not",
"self",
".",
"is_file_uri",
"(",
"sitemap_uri",
")",
... | Read a component sitemap of a Resource List with index.
Each component must be a sitemap with the | [
"Read",
"a",
"component",
"sitemap",
"of",
"a",
"Resource",
"List",
"with",
"index",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L136-L178 |
51,424 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.requires_multifile | def requires_multifile(self):
"""Return False or the number of component sitemaps required.
In the case that no len() is available for self.resources then
then self.count must be set beforehand to avoid an exception.
"""
if (self.max_sitemap_entries is None or
le... | python | def requires_multifile(self):
"""Return False or the number of component sitemaps required.
In the case that no len() is available for self.resources then
then self.count must be set beforehand to avoid an exception.
"""
if (self.max_sitemap_entries is None or
le... | [
"def",
"requires_multifile",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"max_sitemap_entries",
"is",
"None",
"or",
"len",
"(",
"self",
")",
"<=",
"self",
".",
"max_sitemap_entries",
")",
":",
"return",
"(",
"False",
")",
"return",
"(",
"int",
"(",
... | Return False or the number of component sitemaps required.
In the case that no len() is available for self.resources then
then self.count must be set beforehand to avoid an exception. | [
"Return",
"False",
"or",
"the",
"number",
"of",
"component",
"sitemaps",
"required",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L184-L193 |
51,425 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.as_xml_index | def as_xml_index(self, basename="/tmp/sitemap.xml"):
"""Return a string of the index for a large list that is split.
All we need to do is determine the number of component sitemaps will
be is and generate their URIs based on a pattern.
Q - should there be a flag to select generation of... | python | def as_xml_index(self, basename="/tmp/sitemap.xml"):
"""Return a string of the index for a large list that is split.
All we need to do is determine the number of component sitemaps will
be is and generate their URIs based on a pattern.
Q - should there be a flag to select generation of... | [
"def",
"as_xml_index",
"(",
"self",
",",
"basename",
"=",
"\"/tmp/sitemap.xml\"",
")",
":",
"num_parts",
"=",
"self",
".",
"requires_multifile",
"(",
")",
"if",
"(",
"not",
"num_parts",
")",
":",
"raise",
"ListBaseIndexError",
"(",
"\"Request for sitemapindex for ... | Return a string of the index for a large list that is split.
All we need to do is determine the number of component sitemaps will
be is and generate their URIs based on a pattern.
Q - should there be a flag to select generation of each component sitemap
in order to calculate the md5sum... | [
"Return",
"a",
"string",
"of",
"the",
"index",
"for",
"a",
"large",
"list",
"that",
"is",
"split",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L216-L240 |
51,426 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.as_xml_part | def as_xml_part(self, basename="/tmp/sitemap.xml", part_number=0):
"""Return a string of component sitemap number part_number.
Used in the case of a large list that is split into component
sitemaps.
basename is used to create "index" links to the sitemapindex
Q - what timestam... | python | def as_xml_part(self, basename="/tmp/sitemap.xml", part_number=0):
"""Return a string of component sitemap number part_number.
Used in the case of a large list that is split into component
sitemaps.
basename is used to create "index" links to the sitemapindex
Q - what timestam... | [
"def",
"as_xml_part",
"(",
"self",
",",
"basename",
"=",
"\"/tmp/sitemap.xml\"",
",",
"part_number",
"=",
"0",
")",
":",
"if",
"(",
"not",
"self",
".",
"requires_multifile",
"(",
")",
")",
":",
"raise",
"ListBaseIndexError",
"(",
"\"Request for component sitemap... | Return a string of component sitemap number part_number.
Used in the case of a large list that is split into component
sitemaps.
basename is used to create "index" links to the sitemapindex
Q - what timestamp should be used? | [
"Return",
"a",
"string",
"of",
"component",
"sitemap",
"number",
"part_number",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L242-L270 |
51,427 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.write | def write(self, basename='/tmp/sitemap.xml'):
"""Write one or a set of sitemap files to disk.
resources is a ResourceContainer that may be an ResourceList or
a ChangeList. This may be a generator so data is read as needed
and length is determined at the end.
basename is used as... | python | def write(self, basename='/tmp/sitemap.xml'):
"""Write one or a set of sitemap files to disk.
resources is a ResourceContainer that may be an ResourceList or
a ChangeList. This may be a generator so data is read as needed
and length is determined at the end.
basename is used as... | [
"def",
"write",
"(",
"self",
",",
"basename",
"=",
"'/tmp/sitemap.xml'",
")",
":",
"# Access resources through iterator only",
"resources_iter",
"=",
"iter",
"(",
"self",
".",
"resources",
")",
"(",
"chunk",
",",
"nxt",
")",
"=",
"self",
".",
"get_resources_chun... | Write one or a set of sitemap files to disk.
resources is a ResourceContainer that may be an ResourceList or
a ChangeList. This may be a generator so data is read as needed
and length is determined at the end.
basename is used as the name of the single sitemap file or the
sitem... | [
"Write",
"one",
"or",
"a",
"set",
"of",
"sitemap",
"files",
"to",
"disk",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L272-L350 |
51,428 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.index_as_xml | def index_as_xml(self):
"""XML serialization of this list taken to be sitemapindex entries."""
self.default_capability()
s = self.new_sitemap()
return s.resources_as_xml(self, sitemapindex=True) | python | def index_as_xml(self):
"""XML serialization of this list taken to be sitemapindex entries."""
self.default_capability()
s = self.new_sitemap()
return s.resources_as_xml(self, sitemapindex=True) | [
"def",
"index_as_xml",
"(",
"self",
")",
":",
"self",
".",
"default_capability",
"(",
")",
"s",
"=",
"self",
".",
"new_sitemap",
"(",
")",
"return",
"s",
".",
"resources_as_xml",
"(",
"self",
",",
"sitemapindex",
"=",
"True",
")"
] | XML serialization of this list taken to be sitemapindex entries. | [
"XML",
"serialization",
"of",
"this",
"list",
"taken",
"to",
"be",
"sitemapindex",
"entries",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L352-L356 |
51,429 | resync/resync | resync/list_base_with_index.py | ListBaseWithIndex.get_resources_chunk | def get_resources_chunk(self, resource_iter, first=None):
"""Return next chunk of resources from resource_iter, and next item.
If first parameter is specified then this will be prepended to
the list.
The chunk will contain self.max_sitemap_entries if the iterator
returns that m... | python | def get_resources_chunk(self, resource_iter, first=None):
"""Return next chunk of resources from resource_iter, and next item.
If first parameter is specified then this will be prepended to
the list.
The chunk will contain self.max_sitemap_entries if the iterator
returns that m... | [
"def",
"get_resources_chunk",
"(",
"self",
",",
"resource_iter",
",",
"first",
"=",
"None",
")",
":",
"chunk",
"=",
"ListBase",
"(",
"md",
"=",
"self",
".",
"md",
".",
"copy",
"(",
")",
",",
"ln",
"=",
"list",
"(",
"self",
".",
"ln",
")",
")",
"c... | Return next chunk of resources from resource_iter, and next item.
If first parameter is specified then this will be prepended to
the list.
The chunk will contain self.max_sitemap_entries if the iterator
returns that many. next will have the value of the next value from
the iter... | [
"Return",
"next",
"chunk",
"of",
"resources",
"from",
"resource_iter",
"and",
"next",
"item",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L360-L385 |
51,430 | davidrpugh/pyCollocation | pycollocation/basis_functions/basis_splines.py | BSplineBasis._basis_spline_factory | def _basis_spline_factory(coef, degree, knots, der, ext):
"""Return a B-Spline given some coefficients."""
return functools.partial(interpolate.splev, tck=(knots, coef, degree), der=der, ext=ext) | python | def _basis_spline_factory(coef, degree, knots, der, ext):
"""Return a B-Spline given some coefficients."""
return functools.partial(interpolate.splev, tck=(knots, coef, degree), der=der, ext=ext) | [
"def",
"_basis_spline_factory",
"(",
"coef",
",",
"degree",
",",
"knots",
",",
"der",
",",
"ext",
")",
":",
"return",
"functools",
".",
"partial",
"(",
"interpolate",
".",
"splev",
",",
"tck",
"=",
"(",
"knots",
",",
"coef",
",",
"degree",
")",
",",
... | Return a B-Spline given some coefficients. | [
"Return",
"a",
"B",
"-",
"Spline",
"given",
"some",
"coefficients",
"."
] | 9376f3488a992dc416cfd2a4dbb396d094927569 | https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/basis_splines.py#L18-L20 |
51,431 | davidrpugh/pyCollocation | pycollocation/basis_functions/basis_splines.py | BSplineBasis.derivatives_factory | def derivatives_factory(cls, coef, degree, knots, ext, **kwargs):
"""
Given some coefficients, return a the derivative of a B-spline.
"""
return cls._basis_spline_factory(coef, degree, knots, 1, ext) | python | def derivatives_factory(cls, coef, degree, knots, ext, **kwargs):
"""
Given some coefficients, return a the derivative of a B-spline.
"""
return cls._basis_spline_factory(coef, degree, knots, 1, ext) | [
"def",
"derivatives_factory",
"(",
"cls",
",",
"coef",
",",
"degree",
",",
"knots",
",",
"ext",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"cls",
".",
"_basis_spline_factory",
"(",
"coef",
",",
"degree",
",",
"knots",
",",
"1",
",",
"ext",
")"
] | Given some coefficients, return a the derivative of a B-spline. | [
"Given",
"some",
"coefficients",
"return",
"a",
"the",
"derivative",
"of",
"a",
"B",
"-",
"spline",
"."
] | 9376f3488a992dc416cfd2a4dbb396d094927569 | https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/basis_splines.py#L23-L28 |
51,432 | davidrpugh/pyCollocation | pycollocation/basis_functions/basis_splines.py | BSplineBasis.functions_factory | def functions_factory(cls, coef, degree, knots, ext, **kwargs):
"""
Given some coefficients, return a B-spline.
"""
return cls._basis_spline_factory(coef, degree, knots, 0, ext) | python | def functions_factory(cls, coef, degree, knots, ext, **kwargs):
"""
Given some coefficients, return a B-spline.
"""
return cls._basis_spline_factory(coef, degree, knots, 0, ext) | [
"def",
"functions_factory",
"(",
"cls",
",",
"coef",
",",
"degree",
",",
"knots",
",",
"ext",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"cls",
".",
"_basis_spline_factory",
"(",
"coef",
",",
"degree",
",",
"knots",
",",
"0",
",",
"ext",
")"
] | Given some coefficients, return a B-spline. | [
"Given",
"some",
"coefficients",
"return",
"a",
"B",
"-",
"spline",
"."
] | 9376f3488a992dc416cfd2a4dbb396d094927569 | https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/basis_splines.py#L36-L41 |
51,433 | resync/resync | resync/url_authority.py | UrlAuthority.set_master | def set_master(self, url):
"""Set the master url that this object works with."""
m = urlparse(url)
self.master_scheme = m.scheme
self.master_netloc = m.netloc
self.master_path = os.path.dirname(m.path) | python | def set_master(self, url):
"""Set the master url that this object works with."""
m = urlparse(url)
self.master_scheme = m.scheme
self.master_netloc = m.netloc
self.master_path = os.path.dirname(m.path) | [
"def",
"set_master",
"(",
"self",
",",
"url",
")",
":",
"m",
"=",
"urlparse",
"(",
"url",
")",
"self",
".",
"master_scheme",
"=",
"m",
".",
"scheme",
"self",
".",
"master_netloc",
"=",
"m",
".",
"netloc",
"self",
".",
"master_path",
"=",
"os",
".",
... | Set the master url that this object works with. | [
"Set",
"the",
"master",
"url",
"that",
"this",
"object",
"works",
"with",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/url_authority.py#L50-L55 |
51,434 | resync/resync | resync/url_authority.py | UrlAuthority.has_authority_over | def has_authority_over(self, url):
"""Return True of the current master has authority over url.
In strict mode checks scheme, server and path. Otherwise checks
just that the server names match or the query url is a
sub-domain of the master.
"""
s = urlparse(url)
... | python | def has_authority_over(self, url):
"""Return True of the current master has authority over url.
In strict mode checks scheme, server and path. Otherwise checks
just that the server names match or the query url is a
sub-domain of the master.
"""
s = urlparse(url)
... | [
"def",
"has_authority_over",
"(",
"self",
",",
"url",
")",
":",
"s",
"=",
"urlparse",
"(",
"url",
")",
"if",
"(",
"s",
".",
"scheme",
"!=",
"self",
".",
"master_scheme",
")",
":",
"return",
"(",
"False",
")",
"if",
"(",
"s",
".",
"netloc",
"!=",
... | Return True of the current master has authority over url.
In strict mode checks scheme, server and path. Otherwise checks
just that the server names match or the query url is a
sub-domain of the master. | [
"Return",
"True",
"of",
"the",
"current",
"master",
"has",
"authority",
"over",
"url",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/url_authority.py#L57-L77 |
51,435 | inveniosoftware/invenio-admin | invenio_admin/permissions.py | admin_permission_factory | def admin_permission_factory(admin_view):
"""Default factory for creating a permission for an admin.
It tries to load a :class:`invenio_access.permissions.Permission`
instance if `invenio_access` is installed.
Otherwise, it loads a :class:`flask_principal.Permission` instance.
:param admin_view: I... | python | def admin_permission_factory(admin_view):
"""Default factory for creating a permission for an admin.
It tries to load a :class:`invenio_access.permissions.Permission`
instance if `invenio_access` is installed.
Otherwise, it loads a :class:`flask_principal.Permission` instance.
:param admin_view: I... | [
"def",
"admin_permission_factory",
"(",
"admin_view",
")",
":",
"try",
":",
"pkg_resources",
".",
"get_distribution",
"(",
"'invenio-access'",
")",
"from",
"invenio_access",
"import",
"Permission",
"except",
"pkg_resources",
".",
"DistributionNotFound",
":",
"from",
"... | Default factory for creating a permission for an admin.
It tries to load a :class:`invenio_access.permissions.Permission`
instance if `invenio_access` is installed.
Otherwise, it loads a :class:`flask_principal.Permission` instance.
:param admin_view: Instance of administration view which is currently... | [
"Default",
"factory",
"for",
"creating",
"a",
"permission",
"for",
"an",
"admin",
"."
] | b5ff8f7de66d1d6b67efc9f81ff094eb2428f969 | https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/permissions.py#L18-L35 |
51,436 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | get_conns | def get_conns(cred, providers):
"""Collect node data asynchronously using gevent lib."""
cld_svc_map = {"aws": conn_aws,
"azure": conn_az,
"gcp": conn_gcp,
"alicloud": conn_ali}
sys.stdout.write("\rEstablishing Connections: ")
sys.stdout.flush()
... | python | def get_conns(cred, providers):
"""Collect node data asynchronously using gevent lib."""
cld_svc_map = {"aws": conn_aws,
"azure": conn_az,
"gcp": conn_gcp,
"alicloud": conn_ali}
sys.stdout.write("\rEstablishing Connections: ")
sys.stdout.flush()
... | [
"def",
"get_conns",
"(",
"cred",
",",
"providers",
")",
":",
"cld_svc_map",
"=",
"{",
"\"aws\"",
":",
"conn_aws",
",",
"\"azure\"",
":",
"conn_az",
",",
"\"gcp\"",
":",
"conn_gcp",
",",
"\"alicloud\"",
":",
"conn_ali",
"}",
"sys",
".",
"stdout",
".",
"wr... | Collect node data asynchronously using gevent lib. | [
"Collect",
"node",
"data",
"asynchronously",
"using",
"gevent",
"lib",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L41-L63 |
51,437 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | get_data | def get_data(conn_objs, providers):
"""Refresh node data using existing connection-objects."""
cld_svc_map = {"aws": nodes_aws,
"azure": nodes_az,
"gcp": nodes_gcp,
"alicloud": nodes_ali}
sys.stdout.write("\rCollecting Info: ")
sys.stdout.flush()... | python | def get_data(conn_objs, providers):
"""Refresh node data using existing connection-objects."""
cld_svc_map = {"aws": nodes_aws,
"azure": nodes_az,
"gcp": nodes_gcp,
"alicloud": nodes_ali}
sys.stdout.write("\rCollecting Info: ")
sys.stdout.flush()... | [
"def",
"get_data",
"(",
"conn_objs",
",",
"providers",
")",
":",
"cld_svc_map",
"=",
"{",
"\"aws\"",
":",
"nodes_aws",
",",
"\"azure\"",
":",
"nodes_az",
",",
"\"gcp\"",
":",
"nodes_gcp",
",",
"\"alicloud\"",
":",
"nodes_ali",
"}",
"sys",
".",
"stdout",
".... | Refresh node data using existing connection-objects. | [
"Refresh",
"node",
"data",
"using",
"existing",
"connection",
"-",
"objects",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L66-L85 |
51,438 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | busy_disp_off | def busy_disp_off(dobj):
"""Turn OFF busy_display to indicate completion."""
dobj.kill(block=False)
sys.stdout.write("\033[D \033[D")
sys.stdout.flush() | python | def busy_disp_off(dobj):
"""Turn OFF busy_display to indicate completion."""
dobj.kill(block=False)
sys.stdout.write("\033[D \033[D")
sys.stdout.flush() | [
"def",
"busy_disp_off",
"(",
"dobj",
")",
":",
"dobj",
".",
"kill",
"(",
"block",
"=",
"False",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\033[D \\033[D\"",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | Turn OFF busy_display to indicate completion. | [
"Turn",
"OFF",
"busy_display",
"to",
"indicate",
"completion",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L108-L112 |
51,439 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | busy_display | def busy_display():
"""Display animation to show activity."""
sys.stdout.write("\033[?25l") # cursor off
sys.stdout.flush()
for x in range(1800):
symb = ['\\', '|', '/', '-']
sys.stdout.write("\033[D{}".format(symb[x % 4]))
sys.stdout.flush()
gevent.sleep(0.1) | python | def busy_display():
"""Display animation to show activity."""
sys.stdout.write("\033[?25l") # cursor off
sys.stdout.flush()
for x in range(1800):
symb = ['\\', '|', '/', '-']
sys.stdout.write("\033[D{}".format(symb[x % 4]))
sys.stdout.flush()
gevent.sleep(0.1) | [
"def",
"busy_display",
"(",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\033[?25l\"",
")",
"# cursor off",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"1800",
")",
":",
"symb",
"=",
"[",
"'\\\\'",
",",
"... | Display animation to show activity. | [
"Display",
"animation",
"to",
"show",
"activity",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L115-L123 |
51,440 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | conn_aws | def conn_aws(cred, crid):
"""Establish connection to AWS service."""
driver = get_driver(Provider.EC2)
try:
aws_obj = driver(cred['aws_access_key_id'],
cred['aws_secret_access_key'],
region=cred['aws_default_region'])
except SSLError as e:
... | python | def conn_aws(cred, crid):
"""Establish connection to AWS service."""
driver = get_driver(Provider.EC2)
try:
aws_obj = driver(cred['aws_access_key_id'],
cred['aws_secret_access_key'],
region=cred['aws_default_region'])
except SSLError as e:
... | [
"def",
"conn_aws",
"(",
"cred",
",",
"crid",
")",
":",
"driver",
"=",
"get_driver",
"(",
"Provider",
".",
"EC2",
")",
"try",
":",
"aws_obj",
"=",
"driver",
"(",
"cred",
"[",
"'aws_access_key_id'",
"]",
",",
"cred",
"[",
"'aws_secret_access_key'",
"]",
",... | Establish connection to AWS service. | [
"Establish",
"connection",
"to",
"AWS",
"service",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L134-L145 |
51,441 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | nodes_aws | def nodes_aws(c_obj):
"""Get node objects from AWS."""
aws_nodes = []
try:
aws_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with AWS: {}".format(e))
aws_nodes = adj_nodes_aws(aws_nodes)
return aws_nodes | python | def nodes_aws(c_obj):
"""Get node objects from AWS."""
aws_nodes = []
try:
aws_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with AWS: {}".format(e))
aws_nodes = adj_nodes_aws(aws_nodes)
return aws_nodes | [
"def",
"nodes_aws",
"(",
"c_obj",
")",
":",
"aws_nodes",
"=",
"[",
"]",
"try",
":",
"aws_nodes",
"=",
"c_obj",
".",
"list_nodes",
"(",
")",
"except",
"BaseHTTPError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r HTTP Error with AWS: {}\"",
".",
"format",
"(",
... | Get node objects from AWS. | [
"Get",
"node",
"objects",
"from",
"AWS",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L148-L156 |
51,442 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | adj_nodes_aws | def adj_nodes_aws(aws_nodes):
"""Adjust details specific to AWS."""
for node in aws_nodes:
node.cloud = "aws"
node.cloud_disp = "AWS"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['availability']
... | python | def adj_nodes_aws(aws_nodes):
"""Adjust details specific to AWS."""
for node in aws_nodes:
node.cloud = "aws"
node.cloud_disp = "AWS"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['availability']
... | [
"def",
"adj_nodes_aws",
"(",
"aws_nodes",
")",
":",
"for",
"node",
"in",
"aws_nodes",
":",
"node",
".",
"cloud",
"=",
"\"aws\"",
"node",
".",
"cloud_disp",
"=",
"\"AWS\"",
"node",
".",
"private_ips",
"=",
"ip_to_str",
"(",
"node",
".",
"private_ips",
")",
... | Adjust details specific to AWS. | [
"Adjust",
"details",
"specific",
"to",
"AWS",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L159-L169 |
51,443 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | conn_az | def conn_az(cred, crid):
"""Establish connection to Azure service."""
driver = get_driver(Provider.AZURE_ARM)
try:
az_obj = driver(tenant_id=cred['az_tenant_id'],
subscription_id=cred['az_sub_id'],
key=cred['az_app_id'],
secret=... | python | def conn_az(cred, crid):
"""Establish connection to Azure service."""
driver = get_driver(Provider.AZURE_ARM)
try:
az_obj = driver(tenant_id=cred['az_tenant_id'],
subscription_id=cred['az_sub_id'],
key=cred['az_app_id'],
secret=... | [
"def",
"conn_az",
"(",
"cred",
",",
"crid",
")",
":",
"driver",
"=",
"get_driver",
"(",
"Provider",
".",
"AZURE_ARM",
")",
"try",
":",
"az_obj",
"=",
"driver",
"(",
"tenant_id",
"=",
"cred",
"[",
"'az_tenant_id'",
"]",
",",
"subscription_id",
"=",
"cred"... | Establish connection to Azure service. | [
"Establish",
"connection",
"to",
"Azure",
"service",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L172-L184 |
51,444 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | nodes_az | def nodes_az(c_obj):
"""Get node objects from Azure."""
az_nodes = []
try:
az_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with Azure: {}".format(e))
az_nodes = adj_nodes_az(az_nodes)
return az_nodes | python | def nodes_az(c_obj):
"""Get node objects from Azure."""
az_nodes = []
try:
az_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with Azure: {}".format(e))
az_nodes = adj_nodes_az(az_nodes)
return az_nodes | [
"def",
"nodes_az",
"(",
"c_obj",
")",
":",
"az_nodes",
"=",
"[",
"]",
"try",
":",
"az_nodes",
"=",
"c_obj",
".",
"list_nodes",
"(",
")",
"except",
"BaseHTTPError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r HTTP Error with Azure: {}\"",
".",
"format",
"(",
"... | Get node objects from Azure. | [
"Get",
"node",
"objects",
"from",
"Azure",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L187-L195 |
51,445 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | adj_nodes_az | def adj_nodes_az(az_nodes):
"""Adjust details specific to Azure."""
for node in az_nodes:
node.cloud = "azure"
node.cloud_disp = "Azure"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['location']
... | python | def adj_nodes_az(az_nodes):
"""Adjust details specific to Azure."""
for node in az_nodes:
node.cloud = "azure"
node.cloud_disp = "Azure"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['location']
... | [
"def",
"adj_nodes_az",
"(",
"az_nodes",
")",
":",
"for",
"node",
"in",
"az_nodes",
":",
"node",
".",
"cloud",
"=",
"\"azure\"",
"node",
".",
"cloud_disp",
"=",
"\"Azure\"",
"node",
".",
"private_ips",
"=",
"ip_to_str",
"(",
"node",
".",
"private_ips",
")",... | Adjust details specific to Azure. | [
"Adjust",
"details",
"specific",
"to",
"Azure",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L198-L211 |
51,446 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | conn_gcp | def conn_gcp(cred, crid):
"""Establish connection to GCP."""
gcp_auth_type = cred.get('gcp_auth_type', "S")
if gcp_auth_type == "A": # Application Auth
gcp_crd_ia = CONFIG_DIR + ".gcp_libcloud_a_auth." + cred['gcp_proj_id']
gcp_crd = {'user_id': cred['gcp_client_id'],
'ke... | python | def conn_gcp(cred, crid):
"""Establish connection to GCP."""
gcp_auth_type = cred.get('gcp_auth_type', "S")
if gcp_auth_type == "A": # Application Auth
gcp_crd_ia = CONFIG_DIR + ".gcp_libcloud_a_auth." + cred['gcp_proj_id']
gcp_crd = {'user_id': cred['gcp_client_id'],
'ke... | [
"def",
"conn_gcp",
"(",
"cred",
",",
"crid",
")",
":",
"gcp_auth_type",
"=",
"cred",
".",
"get",
"(",
"'gcp_auth_type'",
",",
"\"S\"",
")",
"if",
"gcp_auth_type",
"==",
"\"A\"",
":",
"# Application Auth",
"gcp_crd_ia",
"=",
"CONFIG_DIR",
"+",
"\".gcp_libcloud_... | Establish connection to GCP. | [
"Establish",
"connection",
"to",
"GCP",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L214-L238 |
51,447 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | nodes_gcp | def nodes_gcp(c_obj):
"""Get node objects from GCP."""
gcp_nodes = []
try:
gcp_nodes = c_obj.list_nodes(ex_use_disk_cache=True)
except BaseHTTPError as e:
abort_err("\r HTTP Error with GCP: {}".format(e))
gcp_nodes = adj_nodes_gcp(gcp_nodes)
return gcp_nodes | python | def nodes_gcp(c_obj):
"""Get node objects from GCP."""
gcp_nodes = []
try:
gcp_nodes = c_obj.list_nodes(ex_use_disk_cache=True)
except BaseHTTPError as e:
abort_err("\r HTTP Error with GCP: {}".format(e))
gcp_nodes = adj_nodes_gcp(gcp_nodes)
return gcp_nodes | [
"def",
"nodes_gcp",
"(",
"c_obj",
")",
":",
"gcp_nodes",
"=",
"[",
"]",
"try",
":",
"gcp_nodes",
"=",
"c_obj",
".",
"list_nodes",
"(",
"ex_use_disk_cache",
"=",
"True",
")",
"except",
"BaseHTTPError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r HTTP Error with ... | Get node objects from GCP. | [
"Get",
"node",
"objects",
"from",
"GCP",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L241-L249 |
51,448 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | adj_nodes_gcp | def adj_nodes_gcp(gcp_nodes):
"""Adjust details specific to GCP."""
for node in gcp_nodes:
node.cloud = "gcp"
node.cloud_disp = "GCP"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['zone'].name
return... | python | def adj_nodes_gcp(gcp_nodes):
"""Adjust details specific to GCP."""
for node in gcp_nodes:
node.cloud = "gcp"
node.cloud_disp = "GCP"
node.private_ips = ip_to_str(node.private_ips)
node.public_ips = ip_to_str(node.public_ips)
node.zone = node.extra['zone'].name
return... | [
"def",
"adj_nodes_gcp",
"(",
"gcp_nodes",
")",
":",
"for",
"node",
"in",
"gcp_nodes",
":",
"node",
".",
"cloud",
"=",
"\"gcp\"",
"node",
".",
"cloud_disp",
"=",
"\"GCP\"",
"node",
".",
"private_ips",
"=",
"ip_to_str",
"(",
"node",
".",
"private_ips",
")",
... | Adjust details specific to GCP. | [
"Adjust",
"details",
"specific",
"to",
"GCP",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L252-L260 |
51,449 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | conn_ali | def conn_ali(cred, crid):
"""Establish connection to AliCloud service."""
driver = get_driver(Provider.ALIYUN_ECS)
try:
ali_obj = driver(cred['ali_access_key_id'],
cred['ali_access_key_secret'],
region=cred['ali_region'])
except SSLError as e:
... | python | def conn_ali(cred, crid):
"""Establish connection to AliCloud service."""
driver = get_driver(Provider.ALIYUN_ECS)
try:
ali_obj = driver(cred['ali_access_key_id'],
cred['ali_access_key_secret'],
region=cred['ali_region'])
except SSLError as e:
... | [
"def",
"conn_ali",
"(",
"cred",
",",
"crid",
")",
":",
"driver",
"=",
"get_driver",
"(",
"Provider",
".",
"ALIYUN_ECS",
")",
"try",
":",
"ali_obj",
"=",
"driver",
"(",
"cred",
"[",
"'ali_access_key_id'",
"]",
",",
"cred",
"[",
"'ali_access_key_secret'",
"]... | Establish connection to AliCloud service. | [
"Establish",
"connection",
"to",
"AliCloud",
"service",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L263-L274 |
51,450 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | nodes_ali | def nodes_ali(c_obj):
"""Get node objects from AliCloud."""
ali_nodes = []
try:
ali_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with AliCloud: {}".format(e))
ali_nodes = adj_nodes_ali(ali_nodes)
return ali_nodes | python | def nodes_ali(c_obj):
"""Get node objects from AliCloud."""
ali_nodes = []
try:
ali_nodes = c_obj.list_nodes()
except BaseHTTPError as e:
abort_err("\r HTTP Error with AliCloud: {}".format(e))
ali_nodes = adj_nodes_ali(ali_nodes)
return ali_nodes | [
"def",
"nodes_ali",
"(",
"c_obj",
")",
":",
"ali_nodes",
"=",
"[",
"]",
"try",
":",
"ali_nodes",
"=",
"c_obj",
".",
"list_nodes",
"(",
")",
"except",
"BaseHTTPError",
"as",
"e",
":",
"abort_err",
"(",
"\"\\r HTTP Error with AliCloud: {}\"",
".",
"format",
"(... | Get node objects from AliCloud. | [
"Get",
"node",
"objects",
"from",
"AliCloud",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L277-L285 |
51,451 | robertpeteuil/multi-cloud-control | mcc/cldcnct.py | adj_nodes_ali | def adj_nodes_ali(ali_nodes):
"""Adjust details specific to AliCloud."""
for node in ali_nodes:
node.cloud = "alicloud"
node.cloud_disp = "AliCloud"
node.private_ips = ip_to_str(node.extra['vpc_attributes']['private_ip_address'])
node.public_ips = ip_to_str(node.public_ips)
... | python | def adj_nodes_ali(ali_nodes):
"""Adjust details specific to AliCloud."""
for node in ali_nodes:
node.cloud = "alicloud"
node.cloud_disp = "AliCloud"
node.private_ips = ip_to_str(node.extra['vpc_attributes']['private_ip_address'])
node.public_ips = ip_to_str(node.public_ips)
... | [
"def",
"adj_nodes_ali",
"(",
"ali_nodes",
")",
":",
"for",
"node",
"in",
"ali_nodes",
":",
"node",
".",
"cloud",
"=",
"\"alicloud\"",
"node",
".",
"cloud_disp",
"=",
"\"AliCloud\"",
"node",
".",
"private_ips",
"=",
"ip_to_str",
"(",
"node",
".",
"extra",
"... | Adjust details specific to AliCloud. | [
"Adjust",
"details",
"specific",
"to",
"AliCloud",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L288-L299 |
51,452 | lucuma/Clay | clay/markdown_ext/md_captions.py | FigcaptionExtension.extendMarkdown | def extendMarkdown(self, md, md_globals):
""" Add an instance of FigcaptionProcessor to BlockParser. """
# def_list = 'def_list' in md.registeredExtensions
md.parser.blockprocessors.add(
'figcaption', FigcaptionProcessor(md.parser), '<ulist') | python | def extendMarkdown(self, md, md_globals):
""" Add an instance of FigcaptionProcessor to BlockParser. """
# def_list = 'def_list' in md.registeredExtensions
md.parser.blockprocessors.add(
'figcaption', FigcaptionProcessor(md.parser), '<ulist') | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"# def_list = 'def_list' in md.registeredExtensions",
"md",
".",
"parser",
".",
"blockprocessors",
".",
"add",
"(",
"'figcaption'",
",",
"FigcaptionProcessor",
"(",
"md",
".",
"parser",
... | Add an instance of FigcaptionProcessor to BlockParser. | [
"Add",
"an",
"instance",
"of",
"FigcaptionProcessor",
"to",
"BlockParser",
"."
] | 620d37086b712bdc4d13930ced43a5b7c9a5f46d | https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/markdown_ext/md_captions.py#L98-L103 |
51,453 | resync/resync | resync/list_base.py | ListBase.parse | def parse(self, uri=None, fh=None, str_data=None, **kwargs):
"""Parse a single XML document for this list.
Accepts either a uri (uri or default if parameter not specified),
or a filehandle (fh) or a string (str_data). Note that this method
does not handle the case of a sitemapindex+site... | python | def parse(self, uri=None, fh=None, str_data=None, **kwargs):
"""Parse a single XML document for this list.
Accepts either a uri (uri or default if parameter not specified),
or a filehandle (fh) or a string (str_data). Note that this method
does not handle the case of a sitemapindex+site... | [
"def",
"parse",
"(",
"self",
",",
"uri",
"=",
"None",
",",
"fh",
"=",
"None",
",",
"str_data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"uri",
"is",
"not",
"None",
")",
":",
"try",
":",
"fh",
"=",
"URLopener",
"(",
")",
".",... | Parse a single XML document for this list.
Accepts either a uri (uri or default if parameter not specified),
or a filehandle (fh) or a string (str_data). Note that this method
does not handle the case of a sitemapindex+sitemaps.
LEGACY SUPPORT - the parameter str may be used in place o... | [
"Parse",
"a",
"single",
"XML",
"document",
"for",
"this",
"list",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base.py#L87-L121 |
51,454 | resync/resync | resync/list_base.py | ListBase.write | def write(self, basename="/tmp/resynclist.xml"):
"""Write a single sitemap or sitemapindex XML document.
Must be overridden to support multi-file lists.
"""
self.default_capability()
fh = open(basename, 'w')
s = self.new_sitemap()
s.resources_as_xml(self, fh=fh, ... | python | def write(self, basename="/tmp/resynclist.xml"):
"""Write a single sitemap or sitemapindex XML document.
Must be overridden to support multi-file lists.
"""
self.default_capability()
fh = open(basename, 'w')
s = self.new_sitemap()
s.resources_as_xml(self, fh=fh, ... | [
"def",
"write",
"(",
"self",
",",
"basename",
"=",
"\"/tmp/resynclist.xml\"",
")",
":",
"self",
".",
"default_capability",
"(",
")",
"fh",
"=",
"open",
"(",
"basename",
",",
"'w'",
")",
"s",
"=",
"self",
".",
"new_sitemap",
"(",
")",
"s",
".",
"resourc... | Write a single sitemap or sitemapindex XML document.
Must be overridden to support multi-file lists. | [
"Write",
"a",
"single",
"sitemap",
"or",
"sitemapindex",
"XML",
"document",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base.py#L135-L144 |
51,455 | resync/resync | resync/change_list.py | ChangeList.add_if_changed | def add_if_changed(self, resource):
"""Add resource if change is not None else ChangeTypeError."""
if (resource.change is not None):
self.resources.append(resource)
else:
raise ChangeTypeError(resource.change) | python | def add_if_changed(self, resource):
"""Add resource if change is not None else ChangeTypeError."""
if (resource.change is not None):
self.resources.append(resource)
else:
raise ChangeTypeError(resource.change) | [
"def",
"add_if_changed",
"(",
"self",
",",
"resource",
")",
":",
"if",
"(",
"resource",
".",
"change",
"is",
"not",
"None",
")",
":",
"self",
".",
"resources",
".",
"append",
"(",
"resource",
")",
"else",
":",
"raise",
"ChangeTypeError",
"(",
"resource",... | Add resource if change is not None else ChangeTypeError. | [
"Add",
"resource",
"if",
"change",
"is",
"not",
"None",
"else",
"ChangeTypeError",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/change_list.py#L35-L40 |
51,456 | resync/resync | resync/change_list.py | ChangeList.add | def add(self, resource):
"""Add a resource change or an iterable collection of them.
Allows multiple resource_change objects for the same
resource (ie. URI) and preserves the order of addition.
"""
if isinstance(resource, collections.Iterable):
for r in resource:
... | python | def add(self, resource):
"""Add a resource change or an iterable collection of them.
Allows multiple resource_change objects for the same
resource (ie. URI) and preserves the order of addition.
"""
if isinstance(resource, collections.Iterable):
for r in resource:
... | [
"def",
"add",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"collections",
".",
"Iterable",
")",
":",
"for",
"r",
"in",
"resource",
":",
"self",
".",
"add_if_changed",
"(",
"r",
")",
"else",
":",
"self",
".",
"add_... | Add a resource change or an iterable collection of them.
Allows multiple resource_change objects for the same
resource (ie. URI) and preserves the order of addition. | [
"Add",
"a",
"resource",
"change",
"or",
"an",
"iterable",
"collection",
"of",
"them",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/change_list.py#L42-L52 |
51,457 | resync/resync | resync/change_list.py | ChangeList.add_changed_resources | def add_changed_resources(self, resources, change=None):
"""Add items from a ResourceContainer resources.
If change is specified then the attribute is set in the Resource
objects created.
"""
for resource in resources:
rc = Resource(resource=resource, change=change)
... | python | def add_changed_resources(self, resources, change=None):
"""Add items from a ResourceContainer resources.
If change is specified then the attribute is set in the Resource
objects created.
"""
for resource in resources:
rc = Resource(resource=resource, change=change)
... | [
"def",
"add_changed_resources",
"(",
"self",
",",
"resources",
",",
"change",
"=",
"None",
")",
":",
"for",
"resource",
"in",
"resources",
":",
"rc",
"=",
"Resource",
"(",
"resource",
"=",
"resource",
",",
"change",
"=",
"change",
")",
"self",
".",
"add"... | Add items from a ResourceContainer resources.
If change is specified then the attribute is set in the Resource
objects created. | [
"Add",
"items",
"from",
"a",
"ResourceContainer",
"resources",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/change_list.py#L54-L62 |
51,458 | lucuma/Clay | clay/markdown_ext/md_fencedcode.py | FencedBlockPreprocessor.run | def run(self, lines):
""" Match and store Fenced Code Blocks in the HtmlStash.
"""
text = "\n".join(lines)
while 1:
m = FENCED_BLOCK_RE.search(text)
if not m:
break
lang = m.group('lang')
linenums = bool(m.group('linenums'))... | python | def run(self, lines):
""" Match and store Fenced Code Blocks in the HtmlStash.
"""
text = "\n".join(lines)
while 1:
m = FENCED_BLOCK_RE.search(text)
if not m:
break
lang = m.group('lang')
linenums = bool(m.group('linenums'))... | [
"def",
"run",
"(",
"self",
",",
"lines",
")",
":",
"text",
"=",
"\"\\n\"",
".",
"join",
"(",
"lines",
")",
"while",
"1",
":",
"m",
"=",
"FENCED_BLOCK_RE",
".",
"search",
"(",
"text",
")",
"if",
"not",
"m",
":",
"break",
"lang",
"=",
"m",
".",
"... | Match and store Fenced Code Blocks in the HtmlStash. | [
"Match",
"and",
"store",
"Fenced",
"Code",
"Blocks",
"in",
"the",
"HtmlStash",
"."
] | 620d37086b712bdc4d13930ced43a5b7c9a5f46d | https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/markdown_ext/md_fencedcode.py#L97-L115 |
51,459 | resync/resync | resync/hashes.py | Hashes.initialize_hashes | def initialize_hashes(self):
"""Create new hashlib objects for each hash we are going to calculate."""
if ('md5' in self.hashes):
self.md5_calc = hashlib.md5()
if ('sha-1' in self.hashes):
self.sha1_calc = hashlib.sha1()
if ('sha-256' in self.hashes):
... | python | def initialize_hashes(self):
"""Create new hashlib objects for each hash we are going to calculate."""
if ('md5' in self.hashes):
self.md5_calc = hashlib.md5()
if ('sha-1' in self.hashes):
self.sha1_calc = hashlib.sha1()
if ('sha-256' in self.hashes):
... | [
"def",
"initialize_hashes",
"(",
"self",
")",
":",
"if",
"(",
"'md5'",
"in",
"self",
".",
"hashes",
")",
":",
"self",
".",
"md5_calc",
"=",
"hashlib",
".",
"md5",
"(",
")",
"if",
"(",
"'sha-1'",
"in",
"self",
".",
"hashes",
")",
":",
"self",
".",
... | Create new hashlib objects for each hash we are going to calculate. | [
"Create",
"new",
"hashlib",
"objects",
"for",
"each",
"hash",
"we",
"are",
"going",
"to",
"calculate",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/hashes.py#L55-L62 |
51,460 | resync/resync | resync/hashes.py | Hashes.compute_for_file | def compute_for_file(self, file, block_size=2**14):
"""Compute hash digests for a file.
Calculate the hashes based on one read through the file.
Optional block_size parameter controls memory used to do
calculations. This should be a multiple of 128 bytes.
"""
self.initia... | python | def compute_for_file(self, file, block_size=2**14):
"""Compute hash digests for a file.
Calculate the hashes based on one read through the file.
Optional block_size parameter controls memory used to do
calculations. This should be a multiple of 128 bytes.
"""
self.initia... | [
"def",
"compute_for_file",
"(",
"self",
",",
"file",
",",
"block_size",
"=",
"2",
"**",
"14",
")",
":",
"self",
".",
"initialize_hashes",
"(",
")",
"f",
"=",
"open",
"(",
"file",
",",
"'rb'",
")",
"while",
"True",
":",
"data",
"=",
"f",
".",
"read"... | Compute hash digests for a file.
Calculate the hashes based on one read through the file.
Optional block_size parameter controls memory used to do
calculations. This should be a multiple of 128 bytes. | [
"Compute",
"hash",
"digests",
"for",
"a",
"file",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/hashes.py#L64-L83 |
51,461 | secnot/django-isbn-field | isbn_field/fields.py | ISBNField.pre_save | def pre_save(self, model_instance, add):
"""Remove dashes, spaces, and convert isbn to uppercase before saving
when clean_isbn is enabled"""
value = getattr(model_instance, self.attname)
if self.clean_isbn and value not in EMPTY_VALUES:
cleaned_isbn = value.replace(' ', '').r... | python | def pre_save(self, model_instance, add):
"""Remove dashes, spaces, and convert isbn to uppercase before saving
when clean_isbn is enabled"""
value = getattr(model_instance, self.attname)
if self.clean_isbn and value not in EMPTY_VALUES:
cleaned_isbn = value.replace(' ', '').r... | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"value",
"=",
"getattr",
"(",
"model_instance",
",",
"self",
".",
"attname",
")",
"if",
"self",
".",
"clean_isbn",
"and",
"value",
"not",
"in",
"EMPTY_VALUES",
":",
"cleaned_isbn"... | Remove dashes, spaces, and convert isbn to uppercase before saving
when clean_isbn is enabled | [
"Remove",
"dashes",
"spaces",
"and",
"convert",
"isbn",
"to",
"uppercase",
"before",
"saving",
"when",
"clean_isbn",
"is",
"enabled"
] | 203b7c94a644ab9901370b615d995c2f388219f5 | https://github.com/secnot/django-isbn-field/blob/203b7c94a644ab9901370b615d995c2f388219f5/isbn_field/fields.py#L32-L39 |
51,462 | mryellow/maze_explorer | mazeexp/engine/world.py | WorldLayer.update | def update(self, dt):
"""
Updates game engine each tick
"""
# if not playing dont update model
if self.win_status != 'undecided':
return
# Step known time for agents
if self.force_fps > 0:
dt = 1 / self.force_fps
# update target
... | python | def update(self, dt):
"""
Updates game engine each tick
"""
# if not playing dont update model
if self.win_status != 'undecided':
return
# Step known time for agents
if self.force_fps > 0:
dt = 1 / self.force_fps
# update target
... | [
"def",
"update",
"(",
"self",
",",
"dt",
")",
":",
"# if not playing dont update model",
"if",
"self",
".",
"win_status",
"!=",
"'undecided'",
":",
"return",
"# Step known time for agents",
"if",
"self",
".",
"force_fps",
">",
"0",
":",
"dt",
"=",
"1",
"/",
... | Updates game engine each tick | [
"Updates",
"game",
"engine",
"each",
"tick"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world.py#L203-L285 |
51,463 | mryellow/maze_explorer | mazeexp/engine/world.py | WorldLayer.update_visited | def update_visited(self):
"""
Updates exploration map visited status
"""
assert isinstance(self.player.cshape.center, eu.Vector2)
pos = self.player.cshape.center
# Helper function
def set_visited(layer, cell):
if cell and not cell.properties.get('visi... | python | def update_visited(self):
"""
Updates exploration map visited status
"""
assert isinstance(self.player.cshape.center, eu.Vector2)
pos = self.player.cshape.center
# Helper function
def set_visited(layer, cell):
if cell and not cell.properties.get('visi... | [
"def",
"update_visited",
"(",
"self",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"player",
".",
"cshape",
".",
"center",
",",
"eu",
".",
"Vector2",
")",
"pos",
"=",
"self",
".",
"player",
".",
"cshape",
".",
"center",
"# Helper function",
"def",... | Updates exploration map visited status | [
"Updates",
"exploration",
"map",
"visited",
"status"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world.py#L318-L353 |
51,464 | mryellow/maze_explorer | mazeexp/engine/world.py | WorldLayer.update_sensors | def update_sensors(self):
"""
Check path for each sensor and record wall proximity
"""
assert isinstance(self.player.cshape.center, eu.Vector2)
pos = self.player.cshape.center
a = math.radians(self.player.rotation)
for sensor in self.player.sensors:
s... | python | def update_sensors(self):
"""
Check path for each sensor and record wall proximity
"""
assert isinstance(self.player.cshape.center, eu.Vector2)
pos = self.player.cshape.center
a = math.radians(self.player.rotation)
for sensor in self.player.sensors:
s... | [
"def",
"update_sensors",
"(",
"self",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"player",
".",
"cshape",
".",
"center",
",",
"eu",
".",
"Vector2",
")",
"pos",
"=",
"self",
".",
"player",
".",
"cshape",
".",
"center",
"a",
"=",
"math",
".",
... | Check path for each sensor and record wall proximity | [
"Check",
"path",
"for",
"each",
"sensor",
"and",
"record",
"wall",
"proximity"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world.py#L355-L400 |
51,465 | mryellow/maze_explorer | mazeexp/engine/world.py | WorldLayer.get_state | def get_state(self):
"""
Create state from sensors and battery
"""
# Include battery level in state
battery = self.player.stats['battery']/100
# Create observation from sensor proximities
# TODO: Have state persist, then update columns by `sensed_type`
# ... | python | def get_state(self):
"""
Create state from sensors and battery
"""
# Include battery level in state
battery = self.player.stats['battery']/100
# Create observation from sensor proximities
# TODO: Have state persist, then update columns by `sensed_type`
# ... | [
"def",
"get_state",
"(",
"self",
")",
":",
"# Include battery level in state",
"battery",
"=",
"self",
".",
"player",
".",
"stats",
"[",
"'battery'",
"]",
"/",
"100",
"# Create observation from sensor proximities",
"# TODO: Have state persist, then update columns by `sensed_t... | Create state from sensors and battery | [
"Create",
"state",
"from",
"sensors",
"and",
"battery"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world.py#L402-L434 |
51,466 | mryellow/maze_explorer | mazeexp/engine/player.py | Player.update_rotation | def update_rotation(self, dt, buttons):
"""
Updates rotation and impulse direction
"""
assert isinstance(buttons, dict)
ma = buttons['right'] - buttons['left']
if ma != 0:
self.stats['battery'] -= self.battery_use['angular']
self.rotation += ma * ... | python | def update_rotation(self, dt, buttons):
"""
Updates rotation and impulse direction
"""
assert isinstance(buttons, dict)
ma = buttons['right'] - buttons['left']
if ma != 0:
self.stats['battery'] -= self.battery_use['angular']
self.rotation += ma * ... | [
"def",
"update_rotation",
"(",
"self",
",",
"dt",
",",
"buttons",
")",
":",
"assert",
"isinstance",
"(",
"buttons",
",",
"dict",
")",
"ma",
"=",
"buttons",
"[",
"'right'",
"]",
"-",
"buttons",
"[",
"'left'",
"]",
"if",
"ma",
"!=",
"0",
":",
"self",
... | Updates rotation and impulse direction | [
"Updates",
"rotation",
"and",
"impulse",
"direction"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/player.py#L82-L95 |
51,467 | CiscoTestAutomation/yang | connector/setup.py | read | def read(*paths):
'''read and return txt content of file'''
with open(os.path.join(os.path.dirname(__file__), *paths)) as fp:
return fp.read() | python | def read(*paths):
'''read and return txt content of file'''
with open(os.path.join(os.path.dirname(__file__), *paths)) as fp:
return fp.read() | [
"def",
"read",
"(",
"*",
"paths",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"*",
"paths",
")",
")",
"as",
"fp",
":",
"return",
"fp",
".",
"read",
"(",
")"... | read and return txt content of file | [
"read",
"and",
"return",
"txt",
"content",
"of",
"file"
] | c70ec5ac5a91f276c4060009203770ece92e76b4 | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/connector/setup.py#L104-L107 |
51,468 | resync/resync | resync/resource_list_builder.py | ResourceListBuilder.compile_excludes | def compile_excludes(self):
"""Compile a set of regexps for files to be exlcuded from scans."""
self.compiled_exclude_files = []
for pattern in self.exclude_files:
try:
self.compiled_exclude_files.append(re.compile(pattern))
except re.error as e:
... | python | def compile_excludes(self):
"""Compile a set of regexps for files to be exlcuded from scans."""
self.compiled_exclude_files = []
for pattern in self.exclude_files:
try:
self.compiled_exclude_files.append(re.compile(pattern))
except re.error as e:
... | [
"def",
"compile_excludes",
"(",
"self",
")",
":",
"self",
".",
"compiled_exclude_files",
"=",
"[",
"]",
"for",
"pattern",
"in",
"self",
".",
"exclude_files",
":",
"try",
":",
"self",
".",
"compiled_exclude_files",
".",
"append",
"(",
"re",
".",
"compile",
... | Compile a set of regexps for files to be exlcuded from scans. | [
"Compile",
"a",
"set",
"of",
"regexps",
"for",
"files",
"to",
"be",
"exlcuded",
"from",
"scans",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list_builder.py#L65-L73 |
51,469 | resync/resync | resync/resource_list_builder.py | ResourceListBuilder.exclude_file | def exclude_file(self, file):
"""True if file should be exclude based on name pattern."""
for pattern in self.compiled_exclude_files:
if (pattern.match(file)):
return(True)
return(False) | python | def exclude_file(self, file):
"""True if file should be exclude based on name pattern."""
for pattern in self.compiled_exclude_files:
if (pattern.match(file)):
return(True)
return(False) | [
"def",
"exclude_file",
"(",
"self",
",",
"file",
")",
":",
"for",
"pattern",
"in",
"self",
".",
"compiled_exclude_files",
":",
"if",
"(",
"pattern",
".",
"match",
"(",
"file",
")",
")",
":",
"return",
"(",
"True",
")",
"return",
"(",
"False",
")"
] | True if file should be exclude based on name pattern. | [
"True",
"if",
"file",
"should",
"be",
"exclude",
"based",
"on",
"name",
"pattern",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list_builder.py#L75-L80 |
51,470 | resync/resync | resync/resource_list_builder.py | ResourceListBuilder.from_disk | def from_disk(self, resource_list=None, paths=None):
"""Create or extend resource_list with resources from disk scan.
Assumes very simple disk path to URL mapping (in self.mapping): chop
path and replace with url_path. Returns the new or extended ResourceList
object.
If a resou... | python | def from_disk(self, resource_list=None, paths=None):
"""Create or extend resource_list with resources from disk scan.
Assumes very simple disk path to URL mapping (in self.mapping): chop
path and replace with url_path. Returns the new or extended ResourceList
object.
If a resou... | [
"def",
"from_disk",
"(",
"self",
",",
"resource_list",
"=",
"None",
",",
"paths",
"=",
"None",
")",
":",
"num",
"=",
"0",
"# Either use resource_list passed in or make a new one",
"if",
"(",
"resource_list",
"is",
"None",
")",
":",
"resource_list",
"=",
"Resourc... | Create or extend resource_list with resources from disk scan.
Assumes very simple disk path to URL mapping (in self.mapping): chop
path and replace with url_path. Returns the new or extended ResourceList
object.
If a resource_list is specified then items are added to that rather
... | [
"Create",
"or",
"extend",
"resource_list",
"with",
"resources",
"from",
"disk",
"scan",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list_builder.py#L82-L128 |
51,471 | resync/resync | resync/resource_list_builder.py | ResourceListBuilder.from_disk_add_path | def from_disk_add_path(self, path=None, resource_list=None):
"""Add to resource_list with resources from disk scan starting at path."""
# sanity
if (path is None or resource_list is None or self.mapper is None):
raise ValueError("Must specify path, resource_list and mapper")
... | python | def from_disk_add_path(self, path=None, resource_list=None):
"""Add to resource_list with resources from disk scan starting at path."""
# sanity
if (path is None or resource_list is None or self.mapper is None):
raise ValueError("Must specify path, resource_list and mapper")
... | [
"def",
"from_disk_add_path",
"(",
"self",
",",
"path",
"=",
"None",
",",
"resource_list",
"=",
"None",
")",
":",
"# sanity",
"if",
"(",
"path",
"is",
"None",
"or",
"resource_list",
"is",
"None",
"or",
"self",
".",
"mapper",
"is",
"None",
")",
":",
"rai... | Add to resource_list with resources from disk scan starting at path. | [
"Add",
"to",
"resource_list",
"with",
"resources",
"from",
"disk",
"scan",
"starting",
"at",
"path",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list_builder.py#L130-L156 |
51,472 | resync/resync | resync/resource_list_builder.py | ResourceListBuilder.add_file | def add_file(self, resource_list=None, dir=None, file=None):
"""Add a single file to resource_list.
Follows object settings of set_path, set_hashes and set_length.
"""
try:
if self.exclude_file(file):
self.logger.debug("Excluding file %s" % (file))
... | python | def add_file(self, resource_list=None, dir=None, file=None):
"""Add a single file to resource_list.
Follows object settings of set_path, set_hashes and set_length.
"""
try:
if self.exclude_file(file):
self.logger.debug("Excluding file %s" % (file))
... | [
"def",
"add_file",
"(",
"self",
",",
"resource_list",
"=",
"None",
",",
"dir",
"=",
"None",
",",
"file",
"=",
"None",
")",
":",
"try",
":",
"if",
"self",
".",
"exclude_file",
"(",
"file",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Exclu... | Add a single file to resource_list.
Follows object settings of set_path, set_hashes and set_length. | [
"Add",
"a",
"single",
"file",
"to",
"resource_list",
"."
] | 98292c17b2c00f2d6f5191c6ab51fef8c292a018 | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_list_builder.py#L158-L196 |
51,473 | pappasam/latexbuild | latexbuild/assertions.py | has_file_extension | def has_file_extension(filepath, ext_required):
'''Assert that a filepath has the required file extension
:param filepath: string filepath presumably containing a file extension
:param ext_required: the expected file extension
examples: ".pdf", ".html", ".tex"
'''
ext = os.path.splitext(fil... | python | def has_file_extension(filepath, ext_required):
'''Assert that a filepath has the required file extension
:param filepath: string filepath presumably containing a file extension
:param ext_required: the expected file extension
examples: ".pdf", ".html", ".tex"
'''
ext = os.path.splitext(fil... | [
"def",
"has_file_extension",
"(",
"filepath",
",",
"ext_required",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filepath",
")",
"[",
"-",
"1",
"]",
"if",
"ext",
"!=",
"ext_required",
":",
"msg_tmpl",
"=",
"\"The extension for {}, which is ... | Assert that a filepath has the required file extension
:param filepath: string filepath presumably containing a file extension
:param ext_required: the expected file extension
examples: ".pdf", ".html", ".tex" | [
"Assert",
"that",
"a",
"filepath",
"has",
"the",
"required",
"file",
"extension"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/assertions.py#L13-L25 |
51,474 | pappasam/latexbuild | latexbuild/assertions.py | is_binary | def is_binary(system_binary_str):
'''Assert that a string represents a system binary
Return true if a string represents a system binary
Raise TypeError if the system_binary_str is not a string
Raise ValueError if the system_binary_str is not a system binary
:param system_binary_str: STR string rep... | python | def is_binary(system_binary_str):
'''Assert that a string represents a system binary
Return true if a string represents a system binary
Raise TypeError if the system_binary_str is not a string
Raise ValueError if the system_binary_str is not a system binary
:param system_binary_str: STR string rep... | [
"def",
"is_binary",
"(",
"system_binary_str",
")",
":",
"if",
"not",
"isinstance",
"(",
"system_binary_str",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"{} must be of type STR\"",
".",
"format",
"(",
"system_binary_str",
")",
")",
"binary_str",
"=",
"shu... | Assert that a string represents a system binary
Return true if a string represents a system binary
Raise TypeError if the system_binary_str is not a string
Raise ValueError if the system_binary_str is not a system binary
:param system_binary_str: STR string representing a system binary | [
"Assert",
"that",
"a",
"string",
"represents",
"a",
"system",
"binary"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/assertions.py#L27-L42 |
51,475 | pappasam/latexbuild | latexbuild/assertions.py | list_is_type | def list_is_type(ls, t):
'''Assert that a list contains only elements of type t
Return True if list contains elements of type t
Raise TypeError if t is not a class
Raise TypeError if ls is not a list
Raise TypeError if ls contains non-t elements
:param ls: LIST
:param t: python class
'... | python | def list_is_type(ls, t):
'''Assert that a list contains only elements of type t
Return True if list contains elements of type t
Raise TypeError if t is not a class
Raise TypeError if ls is not a list
Raise TypeError if ls contains non-t elements
:param ls: LIST
:param t: python class
'... | [
"def",
"list_is_type",
"(",
"ls",
",",
"t",
")",
":",
"if",
"not",
"isclass",
"(",
"t",
")",
":",
"raise",
"TypeError",
"(",
"\"{} is not a class\"",
".",
"format",
"(",
"t",
")",
")",
"elif",
"not",
"isinstance",
"(",
"ls",
",",
"list",
")",
":",
... | Assert that a list contains only elements of type t
Return True if list contains elements of type t
Raise TypeError if t is not a class
Raise TypeError if ls is not a list
Raise TypeError if ls contains non-t elements
:param ls: LIST
:param t: python class | [
"Assert",
"that",
"a",
"list",
"contains",
"only",
"elements",
"of",
"type",
"t"
] | 596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5 | https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/assertions.py#L44-L63 |
51,476 | inveniosoftware/invenio-oauth2server | invenio_oauth2server/decorators.py | require_api_auth | def require_api_auth(allow_anonymous=False):
"""Decorator to require API authentication using OAuth token.
:param allow_anonymous: Allow access without OAuth token
(default: ``False``).
"""
def wrapper(f):
"""Wrap function with oauth require decorator."""
f_oauth_required = oaut... | python | def require_api_auth(allow_anonymous=False):
"""Decorator to require API authentication using OAuth token.
:param allow_anonymous: Allow access without OAuth token
(default: ``False``).
"""
def wrapper(f):
"""Wrap function with oauth require decorator."""
f_oauth_required = oaut... | [
"def",
"require_api_auth",
"(",
"allow_anonymous",
"=",
"False",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"\"\"\"Wrap function with oauth require decorator.\"\"\"",
"f_oauth_required",
"=",
"oauth2",
".",
"require_oauth",
"(",
")",
"(",
"f",
")",
"@",
"wrap... | Decorator to require API authentication using OAuth token.
:param allow_anonymous: Allow access without OAuth token
(default: ``False``). | [
"Decorator",
"to",
"require",
"API",
"authentication",
"using",
"OAuth",
"token",
"."
] | 7033d3495c1a2b830e101e43918e92a37bbb49f2 | https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/decorators.py#L23-L51 |
51,477 | inveniosoftware/invenio-oauth2server | invenio_oauth2server/decorators.py | require_oauth_scopes | def require_oauth_scopes(*scopes):
r"""Decorator to require a list of OAuth scopes.
Decorator must be preceded by a ``require_api_auth()`` decorator.
Note, API key authentication is bypassing this check.
:param \*scopes: List of scopes required.
"""
required_scopes = set(scopes)
def wrapp... | python | def require_oauth_scopes(*scopes):
r"""Decorator to require a list of OAuth scopes.
Decorator must be preceded by a ``require_api_auth()`` decorator.
Note, API key authentication is bypassing this check.
:param \*scopes: List of scopes required.
"""
required_scopes = set(scopes)
def wrapp... | [
"def",
"require_oauth_scopes",
"(",
"*",
"scopes",
")",
":",
"required_scopes",
"=",
"set",
"(",
"scopes",
")",
"def",
"wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"... | r"""Decorator to require a list of OAuth scopes.
Decorator must be preceded by a ``require_api_auth()`` decorator.
Note, API key authentication is bypassing this check.
:param \*scopes: List of scopes required. | [
"r",
"Decorator",
"to",
"require",
"a",
"list",
"of",
"OAuth",
"scopes",
"."
] | 7033d3495c1a2b830e101e43918e92a37bbb49f2 | https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/decorators.py#L54-L75 |
51,478 | robertpeteuil/multi-cloud-control | mcc/tables.py | indx_table | def indx_table(node_dict, tbl_mode=False):
"""Print Table for dict=formatted list conditionally include numbers."""
nt = PrettyTable()
nt.header = False
nt.padding_width = 2
nt.border = False
clr_num = C_TI + "NUM"
clr_name = C_TI + "NAME"
clr_state = "STATE" + C_NORM
t_lu = {True: [... | python | def indx_table(node_dict, tbl_mode=False):
"""Print Table for dict=formatted list conditionally include numbers."""
nt = PrettyTable()
nt.header = False
nt.padding_width = 2
nt.border = False
clr_num = C_TI + "NUM"
clr_name = C_TI + "NAME"
clr_state = "STATE" + C_NORM
t_lu = {True: [... | [
"def",
"indx_table",
"(",
"node_dict",
",",
"tbl_mode",
"=",
"False",
")",
":",
"nt",
"=",
"PrettyTable",
"(",
")",
"nt",
".",
"header",
"=",
"False",
"nt",
".",
"padding_width",
"=",
"2",
"nt",
".",
"border",
"=",
"False",
"clr_num",
"=",
"C_TI",
"+... | Print Table for dict=formatted list conditionally include numbers. | [
"Print",
"Table",
"for",
"dict",
"=",
"formatted",
"list",
"conditionally",
"include",
"numbers",
"."
] | f1565af1c0b6ed465ff312d3ccc592ba0609f4a2 | https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/tables.py#L30-L60 |
51,479 | lucuma/Clay | clay/manage.py | run | def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'):
"""Run the development server
"""
path = abspath(path)
c = Clay(path)
c.run(host=host, port=port) | python | def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'):
"""Run the development server
"""
path = abspath(path)
c = Clay(path)
c.run(host=host, port=port) | [
"def",
"run",
"(",
"host",
"=",
"DEFAULT_HOST",
",",
"port",
"=",
"DEFAULT_PORT",
",",
"path",
"=",
"'.'",
")",
":",
"path",
"=",
"abspath",
"(",
"path",
")",
"c",
"=",
"Clay",
"(",
"path",
")",
"c",
".",
"run",
"(",
"host",
"=",
"host",
",",
"... | Run the development server | [
"Run",
"the",
"development",
"server"
] | 620d37086b712bdc4d13930ced43a5b7c9a5f46d | https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/manage.py#L44-L49 |
51,480 | lucuma/Clay | clay/manage.py | build | def build(pattern=None, path='.'):
"""Generates a static copy of the sources
"""
path = abspath(path)
c = Clay(path)
c.build(pattern) | python | def build(pattern=None, path='.'):
"""Generates a static copy of the sources
"""
path = abspath(path)
c = Clay(path)
c.build(pattern) | [
"def",
"build",
"(",
"pattern",
"=",
"None",
",",
"path",
"=",
"'.'",
")",
":",
"path",
"=",
"abspath",
"(",
"path",
")",
"c",
"=",
"Clay",
"(",
"path",
")",
"c",
".",
"build",
"(",
"pattern",
")"
] | Generates a static copy of the sources | [
"Generates",
"a",
"static",
"copy",
"of",
"the",
"sources"
] | 620d37086b712bdc4d13930ced43a5b7c9a5f46d | https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/manage.py#L68-L73 |
51,481 | CameronLonsdale/lantern | lantern/analysis/frequency.py | frequency_to_probability | def frequency_to_probability(frequency_map, decorator=lambda f: f):
"""Transform a ``frequency_map`` into a map of probability using the sum of all frequencies as the total.
Example:
>>> frequency_to_probability({'a': 2, 'b': 2})
{'a': 0.5, 'b': 0.5}
Args:
frequency_map (dict): The... | python | def frequency_to_probability(frequency_map, decorator=lambda f: f):
"""Transform a ``frequency_map`` into a map of probability using the sum of all frequencies as the total.
Example:
>>> frequency_to_probability({'a': 2, 'b': 2})
{'a': 0.5, 'b': 0.5}
Args:
frequency_map (dict): The... | [
"def",
"frequency_to_probability",
"(",
"frequency_map",
",",
"decorator",
"=",
"lambda",
"f",
":",
"f",
")",
":",
"total",
"=",
"sum",
"(",
"frequency_map",
".",
"values",
"(",
")",
")",
"return",
"{",
"k",
":",
"decorator",
"(",
"v",
"/",
"total",
")... | Transform a ``frequency_map`` into a map of probability using the sum of all frequencies as the total.
Example:
>>> frequency_to_probability({'a': 2, 'b': 2})
{'a': 0.5, 'b': 0.5}
Args:
frequency_map (dict): The dictionary to transform
decorator (function): A function to manipu... | [
"Transform",
"a",
"frequency_map",
"into",
"a",
"map",
"of",
"probability",
"using",
"the",
"sum",
"of",
"all",
"frequencies",
"as",
"the",
"total",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L34-L49 |
51,482 | CameronLonsdale/lantern | lantern/analysis/frequency.py | index_of_coincidence | def index_of_coincidence(*texts):
"""Calculate the index of coincidence for one or more ``texts``.
The results are averaged over multiple texts to return the delta index of coincidence.
Examples:
>>> index_of_coincidence("aabbc")
0.2
>>> index_of_coincidence("aabbc", "abbcc")
... | python | def index_of_coincidence(*texts):
"""Calculate the index of coincidence for one or more ``texts``.
The results are averaged over multiple texts to return the delta index of coincidence.
Examples:
>>> index_of_coincidence("aabbc")
0.2
>>> index_of_coincidence("aabbc", "abbcc")
... | [
"def",
"index_of_coincidence",
"(",
"*",
"texts",
")",
":",
"if",
"not",
"texts",
":",
"raise",
"ValueError",
"(",
"\"texts must not be empty\"",
")",
"return",
"statistics",
".",
"mean",
"(",
"_calculate_index_of_coincidence",
"(",
"frequency_analyze",
"(",
"text",... | Calculate the index of coincidence for one or more ``texts``.
The results are averaged over multiple texts to return the delta index of coincidence.
Examples:
>>> index_of_coincidence("aabbc")
0.2
>>> index_of_coincidence("aabbc", "abbcc")
0.2
Args:
*texts (variabl... | [
"Calculate",
"the",
"index",
"of",
"coincidence",
"for",
"one",
"or",
"more",
"texts",
".",
"The",
"results",
"are",
"averaged",
"over",
"multiple",
"texts",
"to",
"return",
"the",
"delta",
"index",
"of",
"coincidence",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L52-L76 |
51,483 | CameronLonsdale/lantern | lantern/analysis/frequency.py | _calculate_index_of_coincidence | def _calculate_index_of_coincidence(frequency_map, length):
"""A measure of how similar frequency_map is to the uniform distribution.
Or the probability that two letters picked randomly are alike.
"""
if length <= 1:
return 0
# We cannot error here as length can legitimiately be 1.
... | python | def _calculate_index_of_coincidence(frequency_map, length):
"""A measure of how similar frequency_map is to the uniform distribution.
Or the probability that two letters picked randomly are alike.
"""
if length <= 1:
return 0
# We cannot error here as length can legitimiately be 1.
... | [
"def",
"_calculate_index_of_coincidence",
"(",
"frequency_map",
",",
"length",
")",
":",
"if",
"length",
"<=",
"1",
":",
"return",
"0",
"# We cannot error here as length can legitimiately be 1.",
"# Imagine a ciphertext of length 3 and a key of length 2.",
"# Spliting this text up ... | A measure of how similar frequency_map is to the uniform distribution.
Or the probability that two letters picked randomly are alike. | [
"A",
"measure",
"of",
"how",
"similar",
"frequency_map",
"is",
"to",
"the",
"uniform",
"distribution",
".",
"Or",
"the",
"probability",
"that",
"two",
"letters",
"picked",
"randomly",
"are",
"alike",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L79-L96 |
51,484 | CameronLonsdale/lantern | lantern/analysis/frequency.py | chi_squared | def chi_squared(source_frequency, target_frequency):
"""Calculate the Chi Squared statistic by comparing ``source_frequency`` with ``target_frequency``.
Example:
>>> chi_squared({'a': 2, 'b': 3}, {'a': 1, 'b': 2})
0.1
Args:
source_frequency (dict): Frequency map of the text you are... | python | def chi_squared(source_frequency, target_frequency):
"""Calculate the Chi Squared statistic by comparing ``source_frequency`` with ``target_frequency``.
Example:
>>> chi_squared({'a': 2, 'b': 3}, {'a': 1, 'b': 2})
0.1
Args:
source_frequency (dict): Frequency map of the text you are... | [
"def",
"chi_squared",
"(",
"source_frequency",
",",
"target_frequency",
")",
":",
"# Ignore any symbols from source that are not in target.",
"# TODO: raise Error if source_len is 0?",
"target_prob",
"=",
"frequency_to_probability",
"(",
"target_frequency",
")",
"source_len",
"=",
... | Calculate the Chi Squared statistic by comparing ``source_frequency`` with ``target_frequency``.
Example:
>>> chi_squared({'a': 2, 'b': 3}, {'a': 1, 'b': 2})
0.1
Args:
source_frequency (dict): Frequency map of the text you are analyzing
target_frequency (dict): Frequency map of... | [
"Calculate",
"the",
"Chi",
"Squared",
"statistic",
"by",
"comparing",
"source_frequency",
"with",
"target_frequency",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L99-L123 |
51,485 | CameronLonsdale/lantern | lantern/analysis/frequency.py | _calculate_chi_squared | def _calculate_chi_squared(source_freq, target_prob, source_len):
"""A measure of the observed frequency of the symbol versus the expected frequency.
If the value is 0 then the texts are exactly alike for that symbol.
"""
expected = source_len * target_prob
return (source_freq - expected)**2 / expec... | python | def _calculate_chi_squared(source_freq, target_prob, source_len):
"""A measure of the observed frequency of the symbol versus the expected frequency.
If the value is 0 then the texts are exactly alike for that symbol.
"""
expected = source_len * target_prob
return (source_freq - expected)**2 / expec... | [
"def",
"_calculate_chi_squared",
"(",
"source_freq",
",",
"target_prob",
",",
"source_len",
")",
":",
"expected",
"=",
"source_len",
"*",
"target_prob",
"return",
"(",
"source_freq",
"-",
"expected",
")",
"**",
"2",
"/",
"expected"
] | A measure of the observed frequency of the symbol versus the expected frequency.
If the value is 0 then the texts are exactly alike for that symbol. | [
"A",
"measure",
"of",
"the",
"observed",
"frequency",
"of",
"the",
"symbol",
"versus",
"the",
"expected",
"frequency",
".",
"If",
"the",
"value",
"is",
"0",
"then",
"the",
"texts",
"are",
"exactly",
"alike",
"for",
"that",
"symbol",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L126-L131 |
51,486 | CameronLonsdale/lantern | lantern/analysis/frequency.py | _load_ngram | def _load_ngram(name):
"""Dynamically import the python module with the ngram defined as a dictionary.
Since bigger ngrams are large files its wasteful to always statically import them if they're not used.
"""
module = importlib.import_module('lantern.analysis.english_ngrams.{}'.format(name))
return... | python | def _load_ngram(name):
"""Dynamically import the python module with the ngram defined as a dictionary.
Since bigger ngrams are large files its wasteful to always statically import them if they're not used.
"""
module = importlib.import_module('lantern.analysis.english_ngrams.{}'.format(name))
return... | [
"def",
"_load_ngram",
"(",
"name",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"'lantern.analysis.english_ngrams.{}'",
".",
"format",
"(",
"name",
")",
")",
"return",
"getattr",
"(",
"module",
",",
"name",
")"
] | Dynamically import the python module with the ngram defined as a dictionary.
Since bigger ngrams are large files its wasteful to always statically import them if they're not used. | [
"Dynamically",
"import",
"the",
"python",
"module",
"with",
"the",
"ngram",
"defined",
"as",
"a",
"dictionary",
".",
"Since",
"bigger",
"ngrams",
"are",
"large",
"files",
"its",
"wasteful",
"to",
"always",
"statically",
"import",
"them",
"if",
"they",
"re",
... | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/frequency.py#L134-L139 |
51,487 | CameronLonsdale/lantern | lantern/score.py | score | def score(text, *score_functions):
"""Score ``text`` using ``score_functions``.
Examples:
>>> score("abc", function_a)
>>> score("abc", function_a, function_b)
Args:
text (str): The text to score
*score_functions (variable length argument list): functions to score with
... | python | def score(text, *score_functions):
"""Score ``text`` using ``score_functions``.
Examples:
>>> score("abc", function_a)
>>> score("abc", function_a, function_b)
Args:
text (str): The text to score
*score_functions (variable length argument list): functions to score with
... | [
"def",
"score",
"(",
"text",
",",
"*",
"score_functions",
")",
":",
"if",
"not",
"score_functions",
":",
"raise",
"ValueError",
"(",
"\"score_functions must not be empty\"",
")",
"return",
"statistics",
".",
"mean",
"(",
"func",
"(",
"text",
")",
"for",
"func"... | Score ``text`` using ``score_functions``.
Examples:
>>> score("abc", function_a)
>>> score("abc", function_a, function_b)
Args:
text (str): The text to score
*score_functions (variable length argument list): functions to score with
Returns:
Arithmetic mean of score... | [
"Score",
"text",
"using",
"score_functions",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/score.py#L9-L29 |
51,488 | CameronLonsdale/lantern | lantern/fitness/patternmatch.py | PatternMatch | def PatternMatch(regex):
"""Compute the score of a text by determing if a pattern matches.
Example:
>>> fitness = PatternMatch("flag{.*}")
>>> fitness("flag{example}")
0
>>> fitness("junk")
-1
Args:
regex (str): regular expression string to use as a pattern... | python | def PatternMatch(regex):
"""Compute the score of a text by determing if a pattern matches.
Example:
>>> fitness = PatternMatch("flag{.*}")
>>> fitness("flag{example}")
0
>>> fitness("junk")
-1
Args:
regex (str): regular expression string to use as a pattern... | [
"def",
"PatternMatch",
"(",
"regex",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"return",
"lambda",
"text",
":",
"-",
"1",
"if",
"pattern",
".",
"search",
"(",
"text",
")",
"is",
"None",
"else",
"0"
] | Compute the score of a text by determing if a pattern matches.
Example:
>>> fitness = PatternMatch("flag{.*}")
>>> fitness("flag{example}")
0
>>> fitness("junk")
-1
Args:
regex (str): regular expression string to use as a pattern | [
"Compute",
"the",
"score",
"of",
"a",
"text",
"by",
"determing",
"if",
"a",
"pattern",
"matches",
"."
] | 235e163e96bf0719d49c54204ee576b2ca93abb6 | https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/fitness/patternmatch.py#L6-L21 |
51,489 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal._request | def _request(self, url, params={}):
"""Makes a request using the currently open session.
:param url: A url fragment to use in the creation of the master url
"""
r = self._session.get(url=url, params=params, headers=DEFAULT_ORIGIN)
return r | python | def _request(self, url, params={}):
"""Makes a request using the currently open session.
:param url: A url fragment to use in the creation of the master url
"""
r = self._session.get(url=url, params=params, headers=DEFAULT_ORIGIN)
return r | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"params",
"=",
"{",
"}",
")",
":",
"r",
"=",
"self",
".",
"_session",
".",
"get",
"(",
"url",
"=",
"url",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"DEFAULT_ORIGIN",
")",
"return",
"r"
] | Makes a request using the currently open session.
:param url: A url fragment to use in the creation of the master url | [
"Makes",
"a",
"request",
"using",
"the",
"currently",
"open",
"session",
"."
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L29-L35 |
51,490 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal.emit | def emit(self, event, *args, **kwargs):
"""Send out an event and call it's associated functions
:param event: Name of the event to trigger
"""
for func in self._registered_events[event].values():
func(*args, **kwargs) | python | def emit(self, event, *args, **kwargs):
"""Send out an event and call it's associated functions
:param event: Name of the event to trigger
"""
for func in self._registered_events[event].values():
func(*args, **kwargs) | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func",
"in",
"self",
".",
"_registered_events",
"[",
"event",
"]",
".",
"values",
"(",
")",
":",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kw... | Send out an event and call it's associated functions
:param event: Name of the event to trigger | [
"Send",
"out",
"an",
"event",
"and",
"call",
"it",
"s",
"associated",
"functions"
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L78-L84 |
51,491 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal.remove_all_listeners | def remove_all_listeners(self, event=None):
"""Remove all functions for all events, or one event if one is specifed.
:param event: Optional event you wish to remove all functions from
"""
if event is not None:
self._registered_events[event] = OrderedDict()
else:
... | python | def remove_all_listeners(self, event=None):
"""Remove all functions for all events, or one event if one is specifed.
:param event: Optional event you wish to remove all functions from
"""
if event is not None:
self._registered_events[event] = OrderedDict()
else:
... | [
"def",
"remove_all_listeners",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"event",
"is",
"not",
"None",
":",
"self",
".",
"_registered_events",
"[",
"event",
"]",
"=",
"OrderedDict",
"(",
")",
"else",
":",
"self",
".",
"_registered_events",
... | Remove all functions for all events, or one event if one is specifed.
:param event: Optional event you wish to remove all functions from | [
"Remove",
"all",
"functions",
"for",
"all",
"events",
"or",
"one",
"event",
"if",
"one",
"is",
"specifed",
"."
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L94-L102 |
51,492 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal.version | def version(self):
"""Spotify version information"""
url: str = get_url("/service/version.json")
params = {"service": "remote"}
r = self._request(url=url, params=params)
return r.json() | python | def version(self):
"""Spotify version information"""
url: str = get_url("/service/version.json")
params = {"service": "remote"}
r = self._request(url=url, params=params)
return r.json() | [
"def",
"version",
"(",
"self",
")",
":",
"url",
":",
"str",
"=",
"get_url",
"(",
"\"/service/version.json\"",
")",
"params",
"=",
"{",
"\"service\"",
":",
"\"remote\"",
"}",
"r",
"=",
"self",
".",
"_request",
"(",
"url",
"=",
"url",
",",
"params",
"=",... | Spotify version information | [
"Spotify",
"version",
"information"
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L112-L117 |
51,493 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal.get_current_status | def get_current_status(self):
"""Returns the current state of the local spotify client"""
url = get_url("/remote/status.json")
params = {"oauth": self._oauth_token, "csrf": self._csrf_token}
r = self._request(url=url, params=params)
return r.json() | python | def get_current_status(self):
"""Returns the current state of the local spotify client"""
url = get_url("/remote/status.json")
params = {"oauth": self._oauth_token, "csrf": self._csrf_token}
r = self._request(url=url, params=params)
return r.json() | [
"def",
"get_current_status",
"(",
"self",
")",
":",
"url",
"=",
"get_url",
"(",
"\"/remote/status.json\"",
")",
"params",
"=",
"{",
"\"oauth\"",
":",
"self",
".",
"_oauth_token",
",",
"\"csrf\"",
":",
"self",
".",
"_csrf_token",
"}",
"r",
"=",
"self",
".",... | Returns the current state of the local spotify client | [
"Returns",
"the",
"current",
"state",
"of",
"the",
"local",
"spotify",
"client"
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L119-L124 |
51,494 | erinxocon/spotify-local | src/spotify_local/core.py | SpotifyLocal.pause | def pause(self, pause=True):
"""Pauses the spotify player
:param pause: boolean value to choose the pause/play state
"""
url: str = get_url("/remote/pause.json")
params = {
"oauth": self._oauth_token,
"csrf": self._csrf_token,
"pause": "true" ... | python | def pause(self, pause=True):
"""Pauses the spotify player
:param pause: boolean value to choose the pause/play state
"""
url: str = get_url("/remote/pause.json")
params = {
"oauth": self._oauth_token,
"csrf": self._csrf_token,
"pause": "true" ... | [
"def",
"pause",
"(",
"self",
",",
"pause",
"=",
"True",
")",
":",
"url",
":",
"str",
"=",
"get_url",
"(",
"\"/remote/pause.json\"",
")",
"params",
"=",
"{",
"\"oauth\"",
":",
"self",
".",
"_oauth_token",
",",
"\"csrf\"",
":",
"self",
".",
"_csrf_token",
... | Pauses the spotify player
:param pause: boolean value to choose the pause/play state | [
"Pauses",
"the",
"spotify",
"player"
] | 8188eef221e3d8b9f408ff430d80e74560360459 | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L126-L137 |
51,495 | cmck/pybrowserstack-screenshots | browserstack_screenshots/__init__.py | Screenshots.authenticate | def authenticate(self):
"""
Authenticate with the api
"""
resp = self.session.get(self.api_url, auth=self.auth)
resp = self._process_response(resp)
return resp | python | def authenticate(self):
"""
Authenticate with the api
"""
resp = self.session.get(self.api_url, auth=self.auth)
resp = self._process_response(resp)
return resp | [
"def",
"authenticate",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"api_url",
",",
"auth",
"=",
"self",
".",
"auth",
")",
"resp",
"=",
"self",
".",
"_process_response",
"(",
"resp",
")",
"return",
"resp"
... | Authenticate with the api | [
"Authenticate",
"with",
"the",
"api"
] | 598358fc5b9a41678b3f913f2c082a288011322d | https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/browserstack_screenshots/__init__.py#L63-L69 |
51,496 | cmck/pybrowserstack-screenshots | browserstack_screenshots/__init__.py | Screenshots.generate_screenshots | def generate_screenshots(self):
"""
Take a config file as input and generate screenshots
"""
headers = {'content-type': 'application/json', 'Accept': 'application/json'}
resp = requests.post(self.api_url, data=json.dumps(self.config), \
headers=header... | python | def generate_screenshots(self):
"""
Take a config file as input and generate screenshots
"""
headers = {'content-type': 'application/json', 'Accept': 'application/json'}
resp = requests.post(self.api_url, data=json.dumps(self.config), \
headers=header... | [
"def",
"generate_screenshots",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'content-type'",
":",
"'application/json'",
",",
"'Accept'",
":",
"'application/json'",
"}",
"resp",
"=",
"requests",
".",
"post",
"(",
"self",
".",
"api_url",
",",
"data",
"=",
"jso... | Take a config file as input and generate screenshots | [
"Take",
"a",
"config",
"file",
"as",
"input",
"and",
"generate",
"screenshots"
] | 598358fc5b9a41678b3f913f2c082a288011322d | https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/browserstack_screenshots/__init__.py#L79-L87 |
51,497 | cmck/pybrowserstack-screenshots | browserstack_screenshots/__init__.py | Screenshots.screenshots_done | def screenshots_done(self, jobid):
"""
Return true if the screenshots job is done
"""
resp = self.session.get(os.path.join(self.api_url, '{0}.json'.format(jobid)))
resp = self._process_response(resp)
return True if resp.json()['state'] == 'done' else False | python | def screenshots_done(self, jobid):
"""
Return true if the screenshots job is done
"""
resp = self.session.get(os.path.join(self.api_url, '{0}.json'.format(jobid)))
resp = self._process_response(resp)
return True if resp.json()['state'] == 'done' else False | [
"def",
"screenshots_done",
"(",
"self",
",",
"jobid",
")",
":",
"resp",
"=",
"self",
".",
"session",
".",
"get",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"api_url",
",",
"'{0}.json'",
".",
"format",
"(",
"jobid",
")",
")",
")",
"resp"... | Return true if the screenshots job is done | [
"Return",
"true",
"if",
"the",
"screenshots",
"job",
"is",
"done"
] | 598358fc5b9a41678b3f913f2c082a288011322d | https://github.com/cmck/pybrowserstack-screenshots/blob/598358fc5b9a41678b3f913f2c082a288011322d/browserstack_screenshots/__init__.py#L89-L95 |
51,498 | mryellow/maze_explorer | mazeexp/engine/world_items.py | WorldItems.create_items | def create_items(self):
"""
Create collidable items
"""
if not self.mode['items'] or len(self.mode['items']) == 0: return
# FIXME: Check if already contains
self.collman.add(self.player)
for k in self.mode['items']:
item = self.mode['items'][k]
... | python | def create_items(self):
"""
Create collidable items
"""
if not self.mode['items'] or len(self.mode['items']) == 0: return
# FIXME: Check if already contains
self.collman.add(self.player)
for k in self.mode['items']:
item = self.mode['items'][k]
... | [
"def",
"create_items",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"mode",
"[",
"'items'",
"]",
"or",
"len",
"(",
"self",
".",
"mode",
"[",
"'items'",
"]",
")",
"==",
"0",
":",
"return",
"# FIXME: Check if already contains",
"self",
".",
"collman",
... | Create collidable items | [
"Create",
"collidable",
"items"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_items.py#L37-L51 |
51,499 | mryellow/maze_explorer | mazeexp/engine/world_items.py | WorldItems.add_item | def add_item(self, radius, item_type):
"""
Add a single item in random open position
"""
assert isinstance(radius, int) or isinstance(radius, float)
assert isinstance(item_type, str)
separation_scale = 1.1
min_separation = separation_scale * radius
# Rem... | python | def add_item(self, radius, item_type):
"""
Add a single item in random open position
"""
assert isinstance(radius, int) or isinstance(radius, float)
assert isinstance(item_type, str)
separation_scale = 1.1
min_separation = separation_scale * radius
# Rem... | [
"def",
"add_item",
"(",
"self",
",",
"radius",
",",
"item_type",
")",
":",
"assert",
"isinstance",
"(",
"radius",
",",
"int",
")",
"or",
"isinstance",
"(",
"radius",
",",
"float",
")",
"assert",
"isinstance",
"(",
"item_type",
",",
"str",
")",
"separatio... | Add a single item in random open position | [
"Add",
"a",
"single",
"item",
"in",
"random",
"open",
"position"
] | ab8a25ccd05105d2fe57e0213d690cfc07e45827 | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_items.py#L71-L114 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.