partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | LockDb.info | Check if a resource is locked.
If a resource has an explicit status we use that, else
we defer to the parent resource lock status. | tools/sandbox/c7n_sphere11/c7n_sphere11/db.py | def info(self, account_id, resource_id, parent_id):
"""Check if a resource is locked.
If a resource has an explicit status we use that, else
we defer to the parent resource lock status.
"""
resource = self.record(account_id, resource_id)
if resource is None and not paren... | def info(self, account_id, resource_id, parent_id):
"""Check if a resource is locked.
If a resource has an explicit status we use that, else
we defer to the parent resource lock status.
"""
resource = self.record(account_id, resource_id)
if resource is None and not paren... | [
"Check",
"if",
"a",
"resource",
"is",
"locked",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/db.py#L67-L90 | [
"def",
"info",
"(",
"self",
",",
"account_id",
",",
"resource_id",
",",
"parent_id",
")",
":",
"resource",
"=",
"self",
".",
"record",
"(",
"account_id",
",",
"resource_id",
")",
"if",
"resource",
"is",
"None",
"and",
"not",
"parent_id",
":",
"return",
"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | process_eni_metrics | ENI flow stream processor that rollups, enhances,
and indexes the stream by time period. | tools/sandbox/zerodark/zerodark/floweni.py | def process_eni_metrics(
stream_eni, myips, stream,
start, end, period, sample_size,
resolver, sink_uri):
"""ENI flow stream processor that rollups, enhances,
and indexes the stream by time period."""
stats = Counter()
period_counters = flow_stream_stats(myips, stream, period)... | def process_eni_metrics(
stream_eni, myips, stream,
start, end, period, sample_size,
resolver, sink_uri):
"""ENI flow stream processor that rollups, enhances,
and indexes the stream by time period."""
stats = Counter()
period_counters = flow_stream_stats(myips, stream, period)... | [
"ENI",
"flow",
"stream",
"processor",
"that",
"rollups",
"enhances",
"and",
"indexes",
"the",
"stream",
"by",
"time",
"period",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L166-L211 | [
"def",
"process_eni_metrics",
"(",
"stream_eni",
",",
"myips",
",",
"stream",
",",
"start",
",",
"end",
",",
"period",
",",
"sample_size",
",",
"resolver",
",",
"sink_uri",
")",
":",
"stats",
"=",
"Counter",
"(",
")",
"period_counters",
"=",
"flow_stream_sta... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | analyze_app | Analyze flow log records for application and generate metrics per period | tools/sandbox/zerodark/zerodark/floweni.py | def analyze_app(
app, env, account_id,
bucket, prefix, store_dir,
resources, ipdb, ipranges,
start, end, tz,
sink, period, sample_count,
debug):
"""Analyze flow log records for application and generate metrics per period"""
logging.basicConfig(level=logging.INFO)
... | def analyze_app(
app, env, account_id,
bucket, prefix, store_dir,
resources, ipdb, ipranges,
start, end, tz,
sink, period, sample_count,
debug):
"""Analyze flow log records for application and generate metrics per period"""
logging.basicConfig(level=logging.INFO)
... | [
"Analyze",
"flow",
"log",
"records",
"for",
"application",
"and",
"generate",
"metrics",
"per",
"period"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/floweni.py#L309-L390 | [
"def",
"analyze_app",
"(",
"app",
",",
"env",
",",
"account_id",
",",
"bucket",
",",
"prefix",
",",
"store_dir",
",",
"resources",
",",
"ipdb",
",",
"ipranges",
",",
"start",
",",
"end",
",",
"tz",
",",
"sink",
",",
"period",
",",
"sample_count",
",",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudFunctionManager.list_functions | List extant cloud functions. | tools/c7n_gcp/c7n_gcp/mu.py | def list_functions(self, prefix=None):
"""List extant cloud functions."""
return self.client.execute_command(
'list',
{'parent': "projects/{}/locations/{}".format(
self.session.get_default_project(),
self.region)}
).get('functions', []) | def list_functions(self, prefix=None):
"""List extant cloud functions."""
return self.client.execute_command(
'list',
{'parent': "projects/{}/locations/{}".format(
self.session.get_default_project(),
self.region)}
).get('functions', []) | [
"List",
"extant",
"cloud",
"functions",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L67-L74 | [
"def",
"list_functions",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"return",
"self",
".",
"client",
".",
"execute_command",
"(",
"'list'",
",",
"{",
"'parent'",
":",
"\"projects/{}/locations/{}\"",
".",
"format",
"(",
"self",
".",
"session",
".",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudFunctionManager.publish | publish the given function. | tools/c7n_gcp/c7n_gcp/mu.py | def publish(self, func):
"""publish the given function."""
project = self.session.get_default_project()
func_name = "projects/{}/locations/{}/functions/{}".format(
project, self.region, func.name)
func_info = self.get(func.name)
source_url = None
archive = fu... | def publish(self, func):
"""publish the given function."""
project = self.session.get_default_project()
func_name = "projects/{}/locations/{}/functions/{}".format(
project, self.region, func.name)
func_info = self.get(func.name)
source_url = None
archive = fu... | [
"publish",
"the",
"given",
"function",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L90-L134 | [
"def",
"publish",
"(",
"self",
",",
"func",
")",
":",
"project",
"=",
"self",
".",
"session",
".",
"get_default_project",
"(",
")",
"func_name",
"=",
"\"projects/{}/locations/{}/functions/{}\"",
".",
"format",
"(",
"project",
",",
"self",
".",
"region",
",",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudFunctionManager.get | Get the details on a given function. | tools/c7n_gcp/c7n_gcp/mu.py | def get(self, func_name, qualifier=None):
"""Get the details on a given function."""
project = self.session.get_default_project()
func_name = "projects/{}/locations/{}/functions/{}".format(
project, self.region, func_name)
try:
return self.client.execute_query('ge... | def get(self, func_name, qualifier=None):
"""Get the details on a given function."""
project = self.session.get_default_project()
func_name = "projects/{}/locations/{}/functions/{}".format(
project, self.region, func_name)
try:
return self.client.execute_query('ge... | [
"Get",
"the",
"details",
"on",
"a",
"given",
"function",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L142-L151 | [
"def",
"get",
"(",
"self",
",",
"func_name",
",",
"qualifier",
"=",
"None",
")",
":",
"project",
"=",
"self",
".",
"session",
".",
"get_default_project",
"(",
")",
"func_name",
"=",
"\"projects/{}/locations/{}/functions/{}\"",
".",
"format",
"(",
"project",
",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudFunctionManager._upload | Upload function source and return source url | tools/c7n_gcp/c7n_gcp/mu.py | def _upload(self, archive, region):
"""Upload function source and return source url
"""
# Generate source upload url
url = self.client.execute_command(
'generateUploadUrl',
{'parent': 'projects/{}/locations/{}'.format(
self.session.get_default_proj... | def _upload(self, archive, region):
"""Upload function source and return source url
"""
# Generate source upload url
url = self.client.execute_command(
'generateUploadUrl',
{'parent': 'projects/{}/locations/{}'.format(
self.session.get_default_proj... | [
"Upload",
"function",
"source",
"and",
"return",
"source",
"url"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L171-L194 | [
"def",
"_upload",
"(",
"self",
",",
"archive",
",",
"region",
")",
":",
"# Generate source upload url",
"url",
"=",
"self",
".",
"client",
".",
"execute_command",
"(",
"'generateUploadUrl'",
",",
"{",
"'parent'",
":",
"'projects/{}/locations/{}'",
".",
"format",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | PubSubSource.ensure_topic | Verify the pub/sub topic exists.
Returns the topic qualified name. | tools/c7n_gcp/c7n_gcp/mu.py | def ensure_topic(self):
"""Verify the pub/sub topic exists.
Returns the topic qualified name.
"""
client = self.session.client('pubsub', 'v1', 'projects.topics')
topic = self.get_topic_param()
try:
client.execute_command('get', {'topic': topic})
excep... | def ensure_topic(self):
"""Verify the pub/sub topic exists.
Returns the topic qualified name.
"""
client = self.session.client('pubsub', 'v1', 'projects.topics')
topic = self.get_topic_param()
try:
client.execute_command('get', {'topic': topic})
excep... | [
"Verify",
"the",
"pub",
"/",
"sub",
"topic",
"exists",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L416-L434 | [
"def",
"ensure_topic",
"(",
"self",
")",
":",
"client",
"=",
"self",
".",
"session",
".",
"client",
"(",
"'pubsub'",
",",
"'v1'",
",",
"'projects.topics'",
")",
"topic",
"=",
"self",
".",
"get_topic_param",
"(",
")",
"try",
":",
"client",
".",
"execute_c... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | PubSubSource.ensure_iam | Ensure the given identities are in the iam role bindings for the topic. | tools/c7n_gcp/c7n_gcp/mu.py | def ensure_iam(self, publisher=None):
"""Ensure the given identities are in the iam role bindings for the topic.
"""
topic = self.get_topic_param()
client = self.session.client('pubsub', 'v1', 'projects.topics')
policy = client.execute_command('getIamPolicy', {'resource': topic})... | def ensure_iam(self, publisher=None):
"""Ensure the given identities are in the iam role bindings for the topic.
"""
topic = self.get_topic_param()
client = self.session.client('pubsub', 'v1', 'projects.topics')
policy = client.execute_command('getIamPolicy', {'resource': topic})... | [
"Ensure",
"the",
"given",
"identities",
"are",
"in",
"the",
"iam",
"role",
"bindings",
"for",
"the",
"topic",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L436-L457 | [
"def",
"ensure_iam",
"(",
"self",
",",
"publisher",
"=",
"None",
")",
":",
"topic",
"=",
"self",
".",
"get_topic_param",
"(",
")",
"client",
"=",
"self",
".",
"session",
".",
"client",
"(",
"'pubsub'",
",",
"'v1'",
",",
"'projects.topics'",
")",
"policy"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | LogSubscriber.get_parent | Get the parent container for the log sink | tools/c7n_gcp/c7n_gcp/mu.py | def get_parent(self, log_info):
"""Get the parent container for the log sink"""
if self.data.get('scope', 'log') == 'log':
if log_info.scope_type != 'projects':
raise ValueError("Invalid log subscriber scope")
parent = "%s/%s" % (log_info.scope_type, log_info.scop... | def get_parent(self, log_info):
"""Get the parent container for the log sink"""
if self.data.get('scope', 'log') == 'log':
if log_info.scope_type != 'projects':
raise ValueError("Invalid log subscriber scope")
parent = "%s/%s" % (log_info.scope_type, log_info.scop... | [
"Get",
"the",
"parent",
"container",
"for",
"the",
"log",
"sink"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L612-L630 | [
"def",
"get_parent",
"(",
"self",
",",
"log_info",
")",
":",
"if",
"self",
".",
"data",
".",
"get",
"(",
"'scope'",
",",
"'log'",
")",
"==",
"'log'",
":",
"if",
"log_info",
".",
"scope_type",
"!=",
"'projects'",
":",
"raise",
"ValueError",
"(",
"\"Inva... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | LogSubscriber.ensure_sink | Ensure the log sink and its pub sub topic exist. | tools/c7n_gcp/c7n_gcp/mu.py | def ensure_sink(self):
"""Ensure the log sink and its pub sub topic exist."""
topic_info = self.pubsub.ensure_topic()
scope, sink_path, sink_info = self.get_sink(topic_info)
client = self.session.client('logging', 'v2', '%s.sinks' % scope)
try:
sink = client.execute_c... | def ensure_sink(self):
"""Ensure the log sink and its pub sub topic exist."""
topic_info = self.pubsub.ensure_topic()
scope, sink_path, sink_info = self.get_sink(topic_info)
client = self.session.client('logging', 'v2', '%s.sinks' % scope)
try:
sink = client.execute_c... | [
"Ensure",
"the",
"log",
"sink",
"and",
"its",
"pub",
"sub",
"topic",
"exist",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L658-L680 | [
"def",
"ensure_sink",
"(",
"self",
")",
":",
"topic_info",
"=",
"self",
".",
"pubsub",
".",
"ensure_topic",
"(",
")",
"scope",
",",
"sink_path",
",",
"sink_info",
"=",
"self",
".",
"get_sink",
"(",
"topic_info",
")",
"client",
"=",
"self",
".",
"session"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | LogSubscriber.remove | Remove any provisioned log sink if auto created | tools/c7n_gcp/c7n_gcp/mu.py | def remove(self, func):
"""Remove any provisioned log sink if auto created"""
if not self.data['name'].startswith(self.prefix):
return
parent = self.get_parent(self.get_log())
_, sink_path, _ = self.get_sink()
client = self.session.client(
'logging', 'v2',... | def remove(self, func):
"""Remove any provisioned log sink if auto created"""
if not self.data['name'].startswith(self.prefix):
return
parent = self.get_parent(self.get_log())
_, sink_path, _ = self.get_sink()
client = self.session.client(
'logging', 'v2',... | [
"Remove",
"any",
"provisioned",
"log",
"sink",
"if",
"auto",
"created"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/mu.py#L686-L699 | [
"def",
"remove",
"(",
"self",
",",
"func",
")",
":",
"if",
"not",
"self",
".",
"data",
"[",
"'name'",
"]",
".",
"startswith",
"(",
"self",
".",
"prefix",
")",
":",
"return",
"parent",
"=",
"self",
".",
"get_parent",
"(",
"self",
".",
"get_log",
"("... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | process_log_event | Format log events and relay via sns/email | c7n/ufuncs/logsub.py | def process_log_event(event, context):
"""Format log events and relay via sns/email"""
init()
serialized = event['awslogs'].pop('data')
data = json.loads(zlib.decompress(
base64.b64decode(serialized), 16 + zlib.MAX_WBITS))
# Fetch additional logs for context (20s window)
timestamps = [e... | def process_log_event(event, context):
"""Format log events and relay via sns/email"""
init()
serialized = event['awslogs'].pop('data')
data = json.loads(zlib.decompress(
base64.b64decode(serialized), 16 + zlib.MAX_WBITS))
# Fetch additional logs for context (20s window)
timestamps = [e... | [
"Format",
"log",
"events",
"and",
"relay",
"via",
"sns",
"/",
"email"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/ufuncs/logsub.py#L46-L89 | [
"def",
"process_log_event",
"(",
"event",
",",
"context",
")",
":",
"init",
"(",
")",
"serialized",
"=",
"event",
"[",
"'awslogs'",
"]",
".",
"pop",
"(",
"'data'",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"zlib",
".",
"decompress",
"(",
"base64",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | get_function | Lambda function provisioning.
Self contained within the component, to allow for easier reuse. | c7n/ufuncs/logsub.py | def get_function(session_factory, name, role, sns_topic, log_groups,
subject="Lambda Error", pattern="Traceback"):
"""Lambda function provisioning.
Self contained within the component, to allow for easier reuse.
"""
# Lazy import to avoid runtime dependency
from c7n.mu import (
... | def get_function(session_factory, name, role, sns_topic, log_groups,
subject="Lambda Error", pattern="Traceback"):
"""Lambda function provisioning.
Self contained within the component, to allow for easier reuse.
"""
# Lazy import to avoid runtime dependency
from c7n.mu import (
... | [
"Lambda",
"function",
"provisioning",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/ufuncs/logsub.py#L92-L124 | [
"def",
"get_function",
"(",
"session_factory",
",",
"name",
",",
"role",
",",
"sns_topic",
",",
"log_groups",
",",
"subject",
"=",
"\"Lambda Error\"",
",",
"pattern",
"=",
"\"Traceback\"",
")",
":",
"# Lazy import to avoid runtime dependency",
"from",
"c7n",
".",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudWatchEvents.match | Match a given cwe event as cloudtrail with an api call
That has its information filled out. | c7n/cwe.py | def match(cls, event):
"""Match a given cwe event as cloudtrail with an api call
That has its information filled out.
"""
if 'detail' not in event:
return False
if 'eventName' not in event['detail']:
return False
k = event['detail']['eventName']
... | def match(cls, event):
"""Match a given cwe event as cloudtrail with an api call
That has its information filled out.
"""
if 'detail' not in event:
return False
if 'eventName' not in event['detail']:
return False
k = event['detail']['eventName']
... | [
"Match",
"a",
"given",
"cwe",
"event",
"as",
"cloudtrail",
"with",
"an",
"api",
"call"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cwe.py#L96-L117 | [
"def",
"match",
"(",
"cls",
",",
"event",
")",
":",
"if",
"'detail'",
"not",
"in",
"event",
":",
"return",
"False",
"if",
"'eventName'",
"not",
"in",
"event",
"[",
"'detail'",
"]",
":",
"return",
"False",
"k",
"=",
"event",
"[",
"'detail'",
"]",
"[",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | CloudWatchEvents.get_trail_ids | extract resources ids from a cloud trail event. | c7n/cwe.py | def get_trail_ids(cls, event, mode):
"""extract resources ids from a cloud trail event."""
resource_ids = ()
event_name = event['detail']['eventName']
event_source = event['detail']['eventSource']
for e in mode.get('events', []):
if not isinstance(e, dict):
... | def get_trail_ids(cls, event, mode):
"""extract resources ids from a cloud trail event."""
resource_ids = ()
event_name = event['detail']['eventName']
event_source = event['detail']['eventSource']
for e in mode.get('events', []):
if not isinstance(e, dict):
... | [
"extract",
"resources",
"ids",
"from",
"a",
"cloud",
"trail",
"event",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cwe.py#L120-L147 | [
"def",
"get_trail_ids",
"(",
"cls",
",",
"event",
",",
"mode",
")",
":",
"resource_ids",
"=",
"(",
")",
"event_name",
"=",
"event",
"[",
"'detail'",
"]",
"[",
"'eventName'",
"]",
"event_source",
"=",
"event",
"[",
"'detail'",
"]",
"[",
"'eventSource'",
"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | main | Generate a c7n-org accounts config file using AWS Organizations
With c7n-org you can then run policies or arbitrary scripts across
accounts. | tools/c7n_org/scripts/orgaccounts.py | def main(role, ou, assume, profile, output, regions, active):
"""Generate a c7n-org accounts config file using AWS Organizations
With c7n-org you can then run policies or arbitrary scripts across
accounts.
"""
session = get_session(assume, 'c7n-org', profile)
client = session.client('organizat... | def main(role, ou, assume, profile, output, regions, active):
"""Generate a c7n-org accounts config file using AWS Organizations
With c7n-org you can then run policies or arbitrary scripts across
accounts.
"""
session = get_session(assume, 'c7n-org', profile)
client = session.client('organizat... | [
"Generate",
"a",
"c7n",
"-",
"org",
"accounts",
"config",
"file",
"using",
"AWS",
"Organizations"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/scripts/orgaccounts.py#L40-L75 | [
"def",
"main",
"(",
"role",
",",
"ou",
",",
"assume",
",",
"profile",
",",
"output",
",",
"regions",
",",
"active",
")",
":",
"session",
"=",
"get_session",
"(",
"assume",
",",
"'c7n-org'",
",",
"profile",
")",
"client",
"=",
"session",
".",
"client",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | download | Download a traildb file for a given account/day/region | tools/c7n_traildb/c7n_traildb/trailts.py | def download(config, account, day, region, output):
"""Download a traildb file for a given account/day/region"""
with open(config) as fh:
config = yaml.safe_load(fh.read())
jsonschema.validate(config, CONFIG_SCHEMA)
found = None
for info in config['accounts']:
if info['name'] == a... | def download(config, account, day, region, output):
"""Download a traildb file for a given account/day/region"""
with open(config) as fh:
config = yaml.safe_load(fh.read())
jsonschema.validate(config, CONFIG_SCHEMA)
found = None
for info in config['accounts']:
if info['name'] == a... | [
"Download",
"a",
"traildb",
"file",
"for",
"a",
"given",
"account",
"/",
"day",
"/",
"region"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L309-L337 | [
"def",
"download",
"(",
"config",
",",
"account",
",",
"day",
",",
"region",
",",
"output",
")",
":",
"with",
"open",
"(",
"config",
")",
"as",
"fh",
":",
"config",
"=",
"yaml",
".",
"safe_load",
"(",
"fh",
".",
"read",
"(",
")",
")",
"jsonschema",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | status | time series lastest record time by account. | tools/c7n_traildb/c7n_traildb/trailts.py | def status(config):
"""time series lastest record time by account."""
with open(config) as fh:
config = yaml.safe_load(fh.read())
jsonschema.validate(config, CONFIG_SCHEMA)
last_index = get_incremental_starts(config, None)
accounts = {}
for (a, region), last in last_index.items():
... | def status(config):
"""time series lastest record time by account."""
with open(config) as fh:
config = yaml.safe_load(fh.read())
jsonschema.validate(config, CONFIG_SCHEMA)
last_index = get_incremental_starts(config, None)
accounts = {}
for (a, region), last in last_index.items():
... | [
"time",
"series",
"lastest",
"record",
"time",
"by",
"account",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L342-L351 | [
"def",
"status",
"(",
"config",
")",
":",
"with",
"open",
"(",
"config",
")",
"as",
"fh",
":",
"config",
"=",
"yaml",
".",
"safe_load",
"(",
"fh",
".",
"read",
"(",
")",
")",
"jsonschema",
".",
"validate",
"(",
"config",
",",
"CONFIG_SCHEMA",
")",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | index | index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with key path
specified by key_template in config file for each account | tools/c7n_traildb/c7n_traildb/trailts.py | def index(config, start, end, incremental=False, concurrency=5, accounts=None,
verbose=False):
"""index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with key path
specified by key_template in config file for each account
"""
with op... | def index(config, start, end, incremental=False, concurrency=5, accounts=None,
verbose=False):
"""index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with key path
specified by key_template in config file for each account
"""
with op... | [
"index",
"traildbs",
"directly",
"from",
"s3",
"for",
"multiple",
"accounts",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailts.py#L363-L405 | [
"def",
"index",
"(",
"config",
",",
"start",
",",
"end",
",",
"incremental",
"=",
"False",
",",
"concurrency",
"=",
"5",
",",
"accounts",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"with",
"open",
"(",
"config",
")",
"as",
"fh",
":",
"con... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | dict_factory | Returns a sqlite row factory that returns a dictionary | tools/c7n_traildb/c7n_traildb/trailes.py | def dict_factory(cursor, row):
"""Returns a sqlite row factory that returns a dictionary"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | def dict_factory(cursor, row):
"""Returns a sqlite row factory that returns a dictionary"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | [
"Returns",
"a",
"sqlite",
"row",
"factory",
"that",
"returns",
"a",
"dictionary"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L97-L102 | [
"def",
"dict_factory",
"(",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"d",
"[",
"col",
"[",
"0",
"]",
"]",
"=",
"row",
"[",
"idx",
"]",
"return"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | fetch_events | Generator that returns the events | tools/c7n_traildb/c7n_traildb/trailes.py | def fetch_events(cursor, config, account_name):
"""Generator that returns the events"""
query = config['indexer'].get('query',
'select * from events where user_agent glob \'*CloudCustodian*\'')
for event in cursor.execute(query):
event['account'] = account_name
event['_index'] = con... | def fetch_events(cursor, config, account_name):
"""Generator that returns the events"""
query = config['indexer'].get('query',
'select * from events where user_agent glob \'*CloudCustodian*\'')
for event in cursor.execute(query):
event['account'] = account_name
event['_index'] = con... | [
"Generator",
"that",
"returns",
"the",
"events"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L105-L114 | [
"def",
"fetch_events",
"(",
"cursor",
",",
"config",
",",
"account_name",
")",
":",
"query",
"=",
"config",
"[",
"'indexer'",
"]",
".",
"get",
"(",
"'query'",
",",
"'select * from events where user_agent glob \\'*CloudCustodian*\\''",
")",
"for",
"event",
"in",
"c... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | valid_date | traildb bucket folders are not zero-padded so this validation
checks that the keys returned by the paginator are
*really after* the config date | tools/c7n_traildb/c7n_traildb/trailes.py | def valid_date(key, config_date):
""" traildb bucket folders are not zero-padded so this validation
checks that the keys returned by the paginator are
*really after* the config date
"""
key_date = "/".join(key.split("/")[4:7])
return parse_date(key_date) > parse_date(config_date) | def valid_date(key, config_date):
""" traildb bucket folders are not zero-padded so this validation
checks that the keys returned by the paginator are
*really after* the config date
"""
key_date = "/".join(key.split("/")[4:7])
return parse_date(key_date) > parse_date(config_date) | [
"traildb",
"bucket",
"folders",
"are",
"not",
"zero",
"-",
"padded",
"so",
"this",
"validation",
"checks",
"that",
"the",
"keys",
"returned",
"by",
"the",
"paginator",
"are",
"*",
"really",
"after",
"*",
"the",
"config",
"date"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L132-L138 | [
"def",
"valid_date",
"(",
"key",
",",
"config_date",
")",
":",
"key_date",
"=",
"\"/\"",
".",
"join",
"(",
"key",
".",
"split",
"(",
"\"/\"",
")",
"[",
"4",
":",
"7",
"]",
")",
"return",
"parse_date",
"(",
"key_date",
")",
">",
"parse_date",
"(",
"... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | index | index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with dated key path | tools/c7n_traildb/c7n_traildb/trailes.py | def index(
config, date=None, directory=None, concurrency=5, accounts=None,
tag=None, verbose=False):
"""index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with dated key path
"""
logging.basicConfig(level=(verbose and logging.DEBUG or lo... | def index(
config, date=None, directory=None, concurrency=5, accounts=None,
tag=None, verbose=False):
"""index traildbs directly from s3 for multiple accounts.
context: assumes a daily traildb file in s3 with dated key path
"""
logging.basicConfig(level=(verbose and logging.DEBUG or lo... | [
"index",
"traildbs",
"directly",
"from",
"s3",
"for",
"multiple",
"accounts",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_traildb/c7n_traildb/trailes.py#L214-L268 | [
"def",
"index",
"(",
"config",
",",
"date",
"=",
"None",
",",
"directory",
"=",
"None",
",",
"concurrency",
"=",
"5",
",",
"accounts",
"=",
"None",
",",
"tag",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"logging",
".",
"basicConfig",
"(",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | Session._initialize_session | Creates a session using available authentication type.
Auth priority:
1. Token Auth
2. Tenant Auth
3. Azure CLI Auth | tools/c7n_azure/c7n_azure/session.py | def _initialize_session(self):
"""
Creates a session using available authentication type.
Auth priority:
1. Token Auth
2. Tenant Auth
3. Azure CLI Auth
"""
# Only run once
if self.credentials is not None:
return
tenant_auth_... | def _initialize_session(self):
"""
Creates a session using available authentication type.
Auth priority:
1. Token Auth
2. Tenant Auth
3. Azure CLI Auth
"""
# Only run once
if self.credentials is not None:
return
tenant_auth_... | [
"Creates",
"a",
"session",
"using",
"available",
"authentication",
"type",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L58-L139 | [
"def",
"_initialize_session",
"(",
"self",
")",
":",
"# Only run once",
"if",
"self",
".",
"credentials",
"is",
"not",
"None",
":",
"return",
"tenant_auth_variables",
"=",
"[",
"constants",
".",
"ENV_TENANT_ID",
",",
"constants",
".",
"ENV_SUB_ID",
",",
"constan... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | Session.resource_api_version | latest non-preview api version for resource | tools/c7n_azure/c7n_azure/session.py | def resource_api_version(self, resource_id):
""" latest non-preview api version for resource """
namespace = ResourceIdParser.get_namespace(resource_id)
resource_type = ResourceIdParser.get_resource_type(resource_id)
cache_id = namespace + resource_type
if cache_id in self._pr... | def resource_api_version(self, resource_id):
""" latest non-preview api version for resource """
namespace = ResourceIdParser.get_namespace(resource_id)
resource_type = ResourceIdParser.get_resource_type(resource_id)
cache_id = namespace + resource_type
if cache_id in self._pr... | [
"latest",
"non",
"-",
"preview",
"api",
"version",
"for",
"resource"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L188-L209 | [
"def",
"resource_api_version",
"(",
"self",
",",
"resource_id",
")",
":",
"namespace",
"=",
"ResourceIdParser",
".",
"get_namespace",
"(",
"resource_id",
")",
"resource_type",
"=",
"ResourceIdParser",
".",
"get_resource_type",
"(",
"resource_id",
")",
"cache_id",
"=... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | Session.get_functions_auth_string | Build auth json string for deploying
Azure Functions. Look for dedicated
Functions environment variables or
fall back to normal Service Principal
variables. | tools/c7n_azure/c7n_azure/session.py | def get_functions_auth_string(self, target_subscription_id):
"""
Build auth json string for deploying
Azure Functions. Look for dedicated
Functions environment variables or
fall back to normal Service Principal
variables.
"""
self._initialize_session()
... | def get_functions_auth_string(self, target_subscription_id):
"""
Build auth json string for deploying
Azure Functions. Look for dedicated
Functions environment variables or
fall back to normal Service Principal
variables.
"""
self._initialize_session()
... | [
"Build",
"auth",
"json",
"string",
"for",
"deploying",
"Azure",
"Functions",
".",
"Look",
"for",
"dedicated",
"Functions",
"environment",
"variables",
"or",
"fall",
"back",
"to",
"normal",
"Service",
"Principal",
"variables",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/session.py#L236-L282 | [
"def",
"get_functions_auth_string",
"(",
"self",
",",
"target_subscription_id",
")",
":",
"self",
".",
"_initialize_session",
"(",
")",
"function_auth_variables",
"=",
"[",
"constants",
".",
"ENV_FUNCTION_TENANT_ID",
",",
"constants",
".",
"ENV_FUNCTION_CLIENT_ID",
",",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | ResourceQuery.filter | Query a set of resources. | c7n/query.py | def filter(self, resource_manager, **params):
"""Query a set of resources."""
m = self.resolve(resource_manager.resource_type)
client = local_session(self.session_factory).client(
m.service, resource_manager.config.region)
enum_op, path, extra_args = m.enum_spec
if ex... | def filter(self, resource_manager, **params):
"""Query a set of resources."""
m = self.resolve(resource_manager.resource_type)
client = local_session(self.session_factory).client(
m.service, resource_manager.config.region)
enum_op, path, extra_args = m.enum_spec
if ex... | [
"Query",
"a",
"set",
"of",
"resources",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L80-L90 | [
"def",
"filter",
"(",
"self",
",",
"resource_manager",
",",
"*",
"*",
"params",
")",
":",
"m",
"=",
"self",
".",
"resolve",
"(",
"resource_manager",
".",
"resource_type",
")",
"client",
"=",
"local_session",
"(",
"self",
".",
"session_factory",
")",
".",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | ResourceQuery.get | Get resources by identities | c7n/query.py | def get(self, resource_manager, identities):
"""Get resources by identities
"""
m = self.resolve(resource_manager.resource_type)
params = {}
client_filter = False
# Try to formulate server side query
if m.filter_name:
if m.filter_type == 'list':
... | def get(self, resource_manager, identities):
"""Get resources by identities
"""
m = self.resolve(resource_manager.resource_type)
params = {}
client_filter = False
# Try to formulate server side query
if m.filter_name:
if m.filter_type == 'list':
... | [
"Get",
"resources",
"by",
"identities"
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L92-L118 | [
"def",
"get",
"(",
"self",
",",
"resource_manager",
",",
"identities",
")",
":",
"m",
"=",
"self",
".",
"resolve",
"(",
"resource_manager",
".",
"resource_type",
")",
"params",
"=",
"{",
"}",
"client_filter",
"=",
"False",
"# Try to formulate server side query",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | ChildResourceQuery.filter | Query a set of resources. | c7n/query.py | def filter(self, resource_manager, **params):
"""Query a set of resources."""
m = self.resolve(resource_manager.resource_type)
client = local_session(self.session_factory).client(m.service)
enum_op, path, extra_args = m.enum_spec
if extra_args:
params.update(extra_ar... | def filter(self, resource_manager, **params):
"""Query a set of resources."""
m = self.resolve(resource_manager.resource_type)
client = local_session(self.session_factory).client(m.service)
enum_op, path, extra_args = m.enum_spec
if extra_args:
params.update(extra_ar... | [
"Query",
"a",
"set",
"of",
"resources",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/query.py#L136-L171 | [
"def",
"filter",
"(",
"self",
",",
"resource_manager",
",",
"*",
"*",
"params",
")",
":",
"m",
"=",
"self",
".",
"resolve",
"(",
"resource_manager",
".",
"resource_type",
")",
"client",
"=",
"local_session",
"(",
"self",
".",
"session_factory",
")",
".",
... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | create_gw_response | Create an api gw response from a wsgi app and environ. | tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py | def create_gw_response(app, wsgi_env):
"""Create an api gw response from a wsgi app and environ.
"""
response = {}
buf = []
result = []
def start_response(status, headers, exc_info=None):
result[:] = [status, headers]
return buf.append
appr = app(wsgi_env, start_response)
... | def create_gw_response(app, wsgi_env):
"""Create an api gw response from a wsgi app and environ.
"""
response = {}
buf = []
result = []
def start_response(status, headers, exc_info=None):
result[:] = [status, headers]
return buf.append
appr = app(wsgi_env, start_response)
... | [
"Create",
"an",
"api",
"gw",
"response",
"from",
"a",
"wsgi",
"app",
"and",
"environ",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py#L25-L53 | [
"def",
"create_gw_response",
"(",
"app",
",",
"wsgi_env",
")",
":",
"response",
"=",
"{",
"}",
"buf",
"=",
"[",
"]",
"result",
"=",
"[",
"]",
"def",
"start_response",
"(",
"status",
",",
"headers",
",",
"exc_info",
"=",
"None",
")",
":",
"result",
"[... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | create_wsgi_request | Create a wsgi environment from an apigw request. | tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py | def create_wsgi_request(event, server_name='apigw'):
"""Create a wsgi environment from an apigw request.
"""
path = urllib.url2pathname(event['path'])
script_name = (
event['headers']['Host'].endswith('.amazonaws.com') and
event['requestContext']['stage'] or '').encode('utf8')
query ... | def create_wsgi_request(event, server_name='apigw'):
"""Create a wsgi environment from an apigw request.
"""
path = urllib.url2pathname(event['path'])
script_name = (
event['headers']['Host'].endswith('.amazonaws.com') and
event['requestContext']['stage'] or '').encode('utf8')
query ... | [
"Create",
"a",
"wsgi",
"environment",
"from",
"an",
"apigw",
"request",
"."
] | cloud-custodian/cloud-custodian | python | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/wsgigw.py#L56-L118 | [
"def",
"create_wsgi_request",
"(",
"event",
",",
"server_name",
"=",
"'apigw'",
")",
":",
"path",
"=",
"urllib",
".",
"url2pathname",
"(",
"event",
"[",
"'path'",
"]",
")",
"script_name",
"=",
"(",
"event",
"[",
"'headers'",
"]",
"[",
"'Host'",
"]",
".",... | 52ef732eb3d7bc939d1579faf519314814695c08 |
train | LogRetriever.create_from_lambda_arn | Create a LogRetriever from a client and lambda arn.
:type client: botocore.client.Logs
:param client: A ``logs`` client.
:type lambda_arn: str
:param lambda_arn: The ARN of the lambda function.
:return: An instance of ``LogRetriever``. | chalice/logs.py | def create_from_lambda_arn(cls, client, lambda_arn):
# type: (TypedAWSClient, str) -> LogRetriever
"""Create a LogRetriever from a client and lambda arn.
:type client: botocore.client.Logs
:param client: A ``logs`` client.
:type lambda_arn: str
:param lambda_arn: The AR... | def create_from_lambda_arn(cls, client, lambda_arn):
# type: (TypedAWSClient, str) -> LogRetriever
"""Create a LogRetriever from a client and lambda arn.
:type client: botocore.client.Logs
:param client: A ``logs`` client.
:type lambda_arn: str
:param lambda_arn: The AR... | [
"Create",
"a",
"LogRetriever",
"from",
"a",
"client",
"and",
"lambda",
"arn",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/logs.py#L33-L48 | [
"def",
"create_from_lambda_arn",
"(",
"cls",
",",
"client",
",",
"lambda_arn",
")",
":",
"# type: (TypedAWSClient, str) -> LogRetriever",
"lambda_name",
"=",
"lambda_arn",
".",
"split",
"(",
"':'",
")",
"[",
"6",
"]",
"log_group_name",
"=",
"'/aws/lambda/%s'",
"%",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | LogRetriever.retrieve_logs | Retrieve logs from a log group.
:type include_lambda_messages: boolean
:param include_lambda_messages: Include logs generated by the AWS
Lambda service. If this value is False, only chalice logs will be
included.
:type max_entries: int
:param max_entries: Maxim... | chalice/logs.py | def retrieve_logs(self, include_lambda_messages=True, max_entries=None):
# type: (bool, Optional[int]) -> Iterator[Dict[str, Any]]
"""Retrieve logs from a log group.
:type include_lambda_messages: boolean
:param include_lambda_messages: Include logs generated by the AWS
Lamb... | def retrieve_logs(self, include_lambda_messages=True, max_entries=None):
# type: (bool, Optional[int]) -> Iterator[Dict[str, Any]]
"""Retrieve logs from a log group.
:type include_lambda_messages: boolean
:param include_lambda_messages: Include logs generated by the AWS
Lamb... | [
"Retrieve",
"logs",
"from",
"a",
"log",
"group",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/logs.py#L67-L109 | [
"def",
"retrieve_logs",
"(",
"self",
",",
"include_lambda_messages",
"=",
"True",
",",
"max_entries",
"=",
"None",
")",
":",
"# type: (bool, Optional[int]) -> Iterator[Dict[str, Any]]",
"# TODO: Add support for startTime/endTime.",
"shown",
"=",
"0",
"for",
"event",
"in",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | validate_configuration | Validate app configuration.
The purpose of this method is to provide a fail fast mechanism
for anything we know is going to fail deployment.
We can detect common error cases and provide the user with helpful
error messages. | chalice/deploy/validate.py | def validate_configuration(config):
# type: (Config) -> None
"""Validate app configuration.
The purpose of this method is to provide a fail fast mechanism
for anything we know is going to fail deployment.
We can detect common error cases and provide the user with helpful
error messages.
""... | def validate_configuration(config):
# type: (Config) -> None
"""Validate app configuration.
The purpose of this method is to provide a fail fast mechanism
for anything we know is going to fail deployment.
We can detect common error cases and provide the user with helpful
error messages.
""... | [
"Validate",
"app",
"configuration",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/validate.py#L28-L44 | [
"def",
"validate_configuration",
"(",
"config",
")",
":",
"# type: (Config) -> None",
"routes",
"=",
"config",
".",
"chalice_app",
".",
"routes",
"validate_routes",
"(",
"routes",
")",
"validate_route_content_types",
"(",
"routes",
",",
"config",
".",
"chalice_app",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | validate_python_version | Validate configuration matches a specific python version.
If the ``actual_py_version`` is not provided, it will default
to the major/minor version of the currently running python
interpreter.
:param actual_py_version: The major/minor python version in
the form "pythonX.Y", e.g "python2.7", "py... | chalice/deploy/validate.py | def validate_python_version(config, actual_py_version=None):
# type: (Config, Optional[str]) -> None
"""Validate configuration matches a specific python version.
If the ``actual_py_version`` is not provided, it will default
to the major/minor version of the currently running python
interpreter.
... | def validate_python_version(config, actual_py_version=None):
# type: (Config, Optional[str]) -> None
"""Validate configuration matches a specific python version.
If the ``actual_py_version`` is not provided, it will default
to the major/minor version of the currently running python
interpreter.
... | [
"Validate",
"configuration",
"matches",
"a",
"specific",
"python",
"version",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/validate.py#L74-L97 | [
"def",
"validate_python_version",
"(",
"config",
",",
"actual_py_version",
"=",
"None",
")",
":",
"# type: (Config, Optional[str]) -> None",
"lambda_version",
"=",
"config",
".",
"lambda_python_version",
"if",
"actual_py_version",
"is",
"None",
":",
"actual_py_version",
"... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | PipRunner._execute | Execute a pip command with the given arguments. | chalice/deploy/packager.py | def _execute(self,
command, # type: str
args, # type: List[str]
env_vars=None, # type: EnvVars
shim=None # type: OptStr
):
# type: (...) -> Tuple[int, bytes, bytes]
"""Execute a pip command with ... | def _execute(self,
command, # type: str
args, # type: List[str]
env_vars=None, # type: EnvVars
shim=None # type: OptStr
):
# type: (...) -> Tuple[int, bytes, bytes]
"""Execute a pip command with ... | [
"Execute",
"a",
"pip",
"command",
"with",
"the",
"given",
"arguments",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L696-L708 | [
"def",
"_execute",
"(",
"self",
",",
"command",
",",
"# type: str",
"args",
",",
"# type: List[str]",
"env_vars",
"=",
"None",
",",
"# type: EnvVars",
"shim",
"=",
"None",
"# type: OptStr",
")",
":",
"# type: (...) -> Tuple[int, bytes, bytes]",
"main_args",
"=",
"["... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | PipRunner.build_wheel | Build an sdist into a wheel file. | chalice/deploy/packager.py | def build_wheel(self, wheel, directory, compile_c=True):
# type: (str, str, bool) -> None
"""Build an sdist into a wheel file."""
arguments = ['--no-deps', '--wheel-dir', directory, wheel]
env_vars = self._osutils.environ()
shim = ''
if not compile_c:
env_vars... | def build_wheel(self, wheel, directory, compile_c=True):
# type: (str, str, bool) -> None
"""Build an sdist into a wheel file."""
arguments = ['--no-deps', '--wheel-dir', directory, wheel]
env_vars = self._osutils.environ()
shim = ''
if not compile_c:
env_vars... | [
"Build",
"an",
"sdist",
"into",
"a",
"wheel",
"file",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L710-L723 | [
"def",
"build_wheel",
"(",
"self",
",",
"wheel",
",",
"directory",
",",
"compile_c",
"=",
"True",
")",
":",
"# type: (str, str, bool) -> None",
"arguments",
"=",
"[",
"'--no-deps'",
",",
"'--wheel-dir'",
",",
"directory",
",",
"wheel",
"]",
"env_vars",
"=",
"s... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | PipRunner.download_all_dependencies | Download all dependencies as sdist or wheel. | chalice/deploy/packager.py | def download_all_dependencies(self, requirements_filename, directory):
# type: (str, str) -> None
"""Download all dependencies as sdist or wheel."""
arguments = ['-r', requirements_filename, '--dest', directory]
rc, out, err = self._execute('download', arguments)
# When downloadi... | def download_all_dependencies(self, requirements_filename, directory):
# type: (str, str) -> None
"""Download all dependencies as sdist or wheel."""
arguments = ['-r', requirements_filename, '--dest', directory]
rc, out, err = self._execute('download', arguments)
# When downloadi... | [
"Download",
"all",
"dependencies",
"as",
"sdist",
"or",
"wheel",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L725-L758 | [
"def",
"download_all_dependencies",
"(",
"self",
",",
"requirements_filename",
",",
"directory",
")",
":",
"# type: (str, str) -> None",
"arguments",
"=",
"[",
"'-r'",
",",
"requirements_filename",
",",
"'--dest'",
",",
"directory",
"]",
"rc",
",",
"out",
",",
"er... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | PipRunner.download_manylinux_wheels | Download wheel files for manylinux for all the given packages. | chalice/deploy/packager.py | def download_manylinux_wheels(self, abi, packages, directory):
# type: (str, List[str], str) -> None
"""Download wheel files for manylinux for all the given packages."""
# If any one of these dependencies fails pip will bail out. Since we
# are only interested in all the ones we can down... | def download_manylinux_wheels(self, abi, packages, directory):
# type: (str, List[str], str) -> None
"""Download wheel files for manylinux for all the given packages."""
# If any one of these dependencies fails pip will bail out. Since we
# are only interested in all the ones we can down... | [
"Download",
"wheel",
"files",
"for",
"manylinux",
"for",
"all",
"the",
"given",
"packages",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/deploy/packager.py#L760-L775 | [
"def",
"download_manylinux_wheels",
"(",
"self",
",",
"abi",
",",
"packages",
",",
"directory",
")",
":",
"# type: (str, List[str], str) -> None",
"# If any one of these dependencies fails pip will bail out. Since we",
"# are only interested in all the ones we can download, we need to fe... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | to_cfn_resource_name | Transform a name to a valid cfn name.
This will convert the provided name to a CamelCase name.
It's possible that the conversion to a CFN resource name
can result in name collisions. It's up to the caller
to handle name collisions appropriately. | chalice/utils.py | def to_cfn_resource_name(name):
# type: (str) -> str
"""Transform a name to a valid cfn name.
This will convert the provided name to a CamelCase name.
It's possible that the conversion to a CFN resource name
can result in name collisions. It's up to the caller
to handle name collisions appropr... | def to_cfn_resource_name(name):
# type: (str) -> str
"""Transform a name to a valid cfn name.
This will convert the provided name to a CamelCase name.
It's possible that the conversion to a CFN resource name
can result in name collisions. It's up to the caller
to handle name collisions appropr... | [
"Transform",
"a",
"name",
"to",
"a",
"valid",
"cfn",
"name",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L30-L46 | [
"def",
"to_cfn_resource_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"\"Invalid name: %r\"",
"%",
"name",
")",
"word_separators",
"=",
"[",
"'-'",
",",
"'_'",
"]",
"for",
"word_separator",
"in",
"w... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | remove_stage_from_deployed_values | Delete a top level key from the deployed JSON file. | chalice/utils.py | def remove_stage_from_deployed_values(key, filename):
# type: (str, str) -> None
"""Delete a top level key from the deployed JSON file."""
final_values = {} # type: Dict[str, Any]
try:
with open(filename, 'r') as f:
final_values = json.load(f)
except IOError:
# If there ... | def remove_stage_from_deployed_values(key, filename):
# type: (str, str) -> None
"""Delete a top level key from the deployed JSON file."""
final_values = {} # type: Dict[str, Any]
try:
with open(filename, 'r') as f:
final_values = json.load(f)
except IOError:
# If there ... | [
"Delete",
"a",
"top",
"level",
"key",
"from",
"the",
"deployed",
"JSON",
"file",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L49-L67 | [
"def",
"remove_stage_from_deployed_values",
"(",
"key",
",",
"filename",
")",
":",
"# type: (str, str) -> None",
"final_values",
"=",
"{",
"}",
"# type: Dict[str, Any]",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"final_values",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | record_deployed_values | Record deployed values to a JSON file.
This allows subsequent deploys to lookup previously deployed values. | chalice/utils.py | def record_deployed_values(deployed_values, filename):
# type: (Dict[str, Any], str) -> None
"""Record deployed values to a JSON file.
This allows subsequent deploys to lookup previously deployed values.
"""
final_values = {} # type: Dict[str, Any]
if os.path.isfile(filename):
with op... | def record_deployed_values(deployed_values, filename):
# type: (Dict[str, Any], str) -> None
"""Record deployed values to a JSON file.
This allows subsequent deploys to lookup previously deployed values.
"""
final_values = {} # type: Dict[str, Any]
if os.path.isfile(filename):
with op... | [
"Record",
"deployed",
"values",
"to",
"a",
"JSON",
"file",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L70-L84 | [
"def",
"record_deployed_values",
"(",
"deployed_values",
",",
"filename",
")",
":",
"# type: (Dict[str, Any], str) -> None",
"final_values",
"=",
"{",
"}",
"# type: Dict[str, Any]",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | create_zip_file | Create a zip file from a source input directory.
This function is intended to be an equivalent to
`zip -r`. You give it a source directory, `source_dir`,
and it will recursively zip up the files into a zipfile
specified by the `outfile` argument. | chalice/utils.py | def create_zip_file(source_dir, outfile):
# type: (str, str) -> None
"""Create a zip file from a source input directory.
This function is intended to be an equivalent to
`zip -r`. You give it a source directory, `source_dir`,
and it will recursively zip up the files into a zipfile
specified by... | def create_zip_file(source_dir, outfile):
# type: (str, str) -> None
"""Create a zip file from a source input directory.
This function is intended to be an equivalent to
`zip -r`. You give it a source directory, `source_dir`,
and it will recursively zip up the files into a zipfile
specified by... | [
"Create",
"a",
"zip",
"file",
"from",
"a",
"source",
"input",
"directory",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L99-L115 | [
"def",
"create_zip_file",
"(",
"source_dir",
",",
"outfile",
")",
":",
"# type: (str, str) -> None",
"with",
"zipfile",
".",
"ZipFile",
"(",
"outfile",
",",
"'w'",
",",
"compression",
"=",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"as",
"z",
":",
"for",
"root",
"... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.update_function | Update a Lambda function's code and configuration.
This method only updates the values provided to it. If a parameter
is not provided, no changes will be made for that that parameter on
the targeted lambda function. | chalice/awsclient.py | def update_function(self,
function_name, # type: str
zip_contents, # type: str
environment_variables=None, # type: StrMap
runtime=None, # type: OptStr
tags... | def update_function(self,
function_name, # type: str
zip_contents, # type: str
environment_variables=None, # type: StrMap
runtime=None, # type: OptStr
tags... | [
"Update",
"a",
"Lambda",
"function",
"s",
"code",
"and",
"configuration",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L252-L287 | [
"def",
"update_function",
"(",
"self",
",",
"function_name",
",",
"# type: str",
"zip_contents",
",",
"# type: str",
"environment_variables",
"=",
"None",
",",
"# type: StrMap",
"runtime",
"=",
"None",
",",
"# type: OptStr",
"tags",
"=",
"None",
",",
"# type: StrMap... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.delete_role | Delete a role by first deleting all inline policies. | chalice/awsclient.py | def delete_role(self, name):
# type: (str) -> None
"""Delete a role by first deleting all inline policies."""
client = self._client('iam')
inline_policies = client.list_role_policies(
RoleName=name
)['PolicyNames']
for policy_name in inline_policies:
... | def delete_role(self, name):
# type: (str) -> None
"""Delete a role by first deleting all inline policies."""
client = self._client('iam')
inline_policies = client.list_role_policies(
RoleName=name
)['PolicyNames']
for policy_name in inline_policies:
... | [
"Delete",
"a",
"role",
"by",
"first",
"deleting",
"all",
"inline",
"policies",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L424-L433 | [
"def",
"delete_role",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> None",
"client",
"=",
"self",
".",
"_client",
"(",
"'iam'",
")",
"inline_policies",
"=",
"client",
".",
"list_role_policies",
"(",
"RoleName",
"=",
"name",
")",
"[",
"'PolicyNames'",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.get_rest_api_id | Get rest api id associated with an API name.
:type name: str
:param name: The name of the rest api.
:rtype: str
:return: If the rest api exists, then the restApiId
is returned, otherwise None. | chalice/awsclient.py | def get_rest_api_id(self, name):
# type: (str) -> Optional[str]
"""Get rest api id associated with an API name.
:type name: str
:param name: The name of the rest api.
:rtype: str
:return: If the rest api exists, then the restApiId
is returned, otherwise None... | def get_rest_api_id(self, name):
# type: (str) -> Optional[str]
"""Get rest api id associated with an API name.
:type name: str
:param name: The name of the rest api.
:rtype: str
:return: If the rest api exists, then the restApiId
is returned, otherwise None... | [
"Get",
"rest",
"api",
"id",
"associated",
"with",
"an",
"API",
"name",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L435-L451 | [
"def",
"get_rest_api_id",
"(",
"self",
",",
"name",
")",
":",
"# type: (str) -> Optional[str]",
"rest_apis",
"=",
"self",
".",
"_client",
"(",
"'apigateway'",
")",
".",
"get_rest_apis",
"(",
")",
"[",
"'items'",
"]",
"for",
"api",
"in",
"rest_apis",
":",
"if... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.rest_api_exists | Check if an an API Gateway REST API exists. | chalice/awsclient.py | def rest_api_exists(self, rest_api_id):
# type: (str) -> bool
"""Check if an an API Gateway REST API exists."""
client = self._client('apigateway')
try:
client.get_rest_api(restApiId=rest_api_id)
return True
except client.exceptions.NotFoundException:
... | def rest_api_exists(self, rest_api_id):
# type: (str) -> bool
"""Check if an an API Gateway REST API exists."""
client = self._client('apigateway')
try:
client.get_rest_api(restApiId=rest_api_id)
return True
except client.exceptions.NotFoundException:
... | [
"Check",
"if",
"an",
"an",
"API",
"Gateway",
"REST",
"API",
"exists",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L453-L461 | [
"def",
"rest_api_exists",
"(",
"self",
",",
"rest_api_id",
")",
":",
"# type: (str) -> bool",
"client",
"=",
"self",
".",
"_client",
"(",
"'apigateway'",
")",
"try",
":",
"client",
".",
"get_rest_api",
"(",
"restApiId",
"=",
"rest_api_id",
")",
"return",
"True... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.add_permission_for_apigateway | Authorize API gateway to invoke a lambda function is needed.
This method will first check if API gateway has permission to call
the lambda function, and only if necessary will it invoke
``self.add_permission_for_apigateway(...). | chalice/awsclient.py | def add_permission_for_apigateway(self, function_name,
region_name, account_id,
rest_api_id, random_id=None):
# type: (str, str, str, str, Optional[str]) -> None
"""Authorize API gateway to invoke a lambda function is needed.
... | def add_permission_for_apigateway(self, function_name,
region_name, account_id,
rest_api_id, random_id=None):
# type: (str, str, str, str, Optional[str]) -> None
"""Authorize API gateway to invoke a lambda function is needed.
... | [
"Authorize",
"API",
"gateway",
"to",
"invoke",
"a",
"lambda",
"function",
"is",
"needed",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L496-L513 | [
"def",
"add_permission_for_apigateway",
"(",
"self",
",",
"function_name",
",",
"region_name",
",",
"account_id",
",",
"rest_api_id",
",",
"random_id",
"=",
"None",
")",
":",
"# type: (str, str, str, str, Optional[str]) -> None",
"source_arn",
"=",
"self",
".",
"_build_... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.get_function_policy | Return the function policy for a lambda function.
This function will extract the policy string as a json document
and return the json.loads(...) version of the policy. | chalice/awsclient.py | def get_function_policy(self, function_name):
# type: (str) -> Dict[str, Any]
"""Return the function policy for a lambda function.
This function will extract the policy string as a json document
and return the json.loads(...) version of the policy.
"""
client = self._cl... | def get_function_policy(self, function_name):
# type: (str) -> Dict[str, Any]
"""Return the function policy for a lambda function.
This function will extract the policy string as a json document
and return the json.loads(...) version of the policy.
"""
client = self._cl... | [
"Return",
"the",
"function",
"policy",
"for",
"a",
"lambda",
"function",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L515-L528 | [
"def",
"get_function_policy",
"(",
"self",
",",
"function_name",
")",
":",
"# type: (str) -> Dict[str, Any]",
"client",
"=",
"self",
".",
"_client",
"(",
"'lambda'",
")",
"try",
":",
"policy",
"=",
"client",
".",
"get_policy",
"(",
"FunctionName",
"=",
"function... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.download_sdk | Download an SDK to a directory.
This will generate an SDK and download it to the provided
``output_dir``. If you're using ``get_sdk_download_stream()``,
you have to handle downloading the stream and unzipping the
contents yourself. This method handles that for you. | chalice/awsclient.py | def download_sdk(self, rest_api_id, output_dir,
api_gateway_stage=DEFAULT_STAGE_NAME,
sdk_type='javascript'):
# type: (str, str, str, str) -> None
"""Download an SDK to a directory.
This will generate an SDK and download it to the provided
``out... | def download_sdk(self, rest_api_id, output_dir,
api_gateway_stage=DEFAULT_STAGE_NAME,
sdk_type='javascript'):
# type: (str, str, str, str) -> None
"""Download an SDK to a directory.
This will generate an SDK and download it to the provided
``out... | [
"Download",
"an",
"SDK",
"to",
"a",
"directory",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L530-L564 | [
"def",
"download_sdk",
"(",
"self",
",",
"rest_api_id",
",",
"output_dir",
",",
"api_gateway_stage",
"=",
"DEFAULT_STAGE_NAME",
",",
"sdk_type",
"=",
"'javascript'",
")",
":",
"# type: (str, str, str, str) -> None",
"zip_stream",
"=",
"self",
".",
"get_sdk_download_stre... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.get_sdk_download_stream | Generate an SDK for a given SDK.
Returns a file like object that streams a zip contents for the
generated SDK. | chalice/awsclient.py | def get_sdk_download_stream(self, rest_api_id,
api_gateway_stage=DEFAULT_STAGE_NAME,
sdk_type='javascript'):
# type: (str, str, str) -> file
"""Generate an SDK for a given SDK.
Returns a file like object that streams a zip contents... | def get_sdk_download_stream(self, rest_api_id,
api_gateway_stage=DEFAULT_STAGE_NAME,
sdk_type='javascript'):
# type: (str, str, str) -> file
"""Generate an SDK for a given SDK.
Returns a file like object that streams a zip contents... | [
"Generate",
"an",
"SDK",
"for",
"a",
"given",
"SDK",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L566-L579 | [
"def",
"get_sdk_download_stream",
"(",
"self",
",",
"rest_api_id",
",",
"api_gateway_stage",
"=",
"DEFAULT_STAGE_NAME",
",",
"sdk_type",
"=",
"'javascript'",
")",
":",
"# type: (str, str, str) -> file",
"response",
"=",
"self",
".",
"_client",
"(",
"'apigateway'",
")"... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.verify_sns_subscription_current | Verify a subscription arn matches the topic and function name.
Given a subscription arn, verify that the associated topic name
and function arn match up to the parameters passed in. | chalice/awsclient.py | def verify_sns_subscription_current(self, subscription_arn, topic_name,
function_arn):
# type: (str, str, str) -> bool
"""Verify a subscription arn matches the topic and function name.
Given a subscription arn, verify that the associated topic name
... | def verify_sns_subscription_current(self, subscription_arn, topic_name,
function_arn):
# type: (str, str, str) -> bool
"""Verify a subscription arn matches the topic and function name.
Given a subscription arn, verify that the associated topic name
... | [
"Verify",
"a",
"subscription",
"arn",
"matches",
"the",
"topic",
"and",
"function",
"name",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L594-L614 | [
"def",
"verify_sns_subscription_current",
"(",
"self",
",",
"subscription_arn",
",",
"topic_name",
",",
"function_arn",
")",
":",
"# type: (str, str, str) -> bool",
"sns_client",
"=",
"self",
".",
"_client",
"(",
"'sns'",
")",
"try",
":",
"attributes",
"=",
"sns_cli... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.connect_s3_bucket_to_lambda | Configure S3 bucket to invoke a lambda function.
The S3 bucket must already have permission to invoke the
lambda function before you call this function, otherwise
the service will return an error. You can add permissions
by using the ``add_permission_for_s3_event`` below. The
... | chalice/awsclient.py | def connect_s3_bucket_to_lambda(self, bucket, function_arn, events,
prefix=None, suffix=None):
# type: (str, str, List[str], OptStr, OptStr) -> None
"""Configure S3 bucket to invoke a lambda function.
The S3 bucket must already have permission to invoke the
... | def connect_s3_bucket_to_lambda(self, bucket, function_arn, events,
prefix=None, suffix=None):
# type: (str, str, List[str], OptStr, OptStr) -> None
"""Configure S3 bucket to invoke a lambda function.
The S3 bucket must already have permission to invoke the
... | [
"Configure",
"S3",
"bucket",
"to",
"invoke",
"a",
"lambda",
"function",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L741-L782 | [
"def",
"connect_s3_bucket_to_lambda",
"(",
"self",
",",
"bucket",
",",
"function_arn",
",",
"events",
",",
"prefix",
"=",
"None",
",",
"suffix",
"=",
"None",
")",
":",
"# type: (str, str, List[str], OptStr, OptStr) -> None",
"s3",
"=",
"self",
".",
"_client",
"(",... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | TypedAWSClient.verify_event_source_current | Check if the uuid matches the resource and function arn provided.
Given a uuid representing an event source mapping for a lambda
function, verify that the associated source arn
and function arn match up to the parameters passed in.
Instead of providing the event source arn, the resourc... | chalice/awsclient.py | def verify_event_source_current(self, event_uuid, resource_name,
service_name, function_arn):
# type: (str, str, str, str) -> bool
"""Check if the uuid matches the resource and function arn provided.
Given a uuid representing an event source mapping for a lam... | def verify_event_source_current(self, event_uuid, resource_name,
service_name, function_arn):
# type: (str, str, str, str) -> bool
"""Check if the uuid matches the resource and function arn provided.
Given a uuid representing an event source mapping for a lam... | [
"Check",
"if",
"the",
"uuid",
"matches",
"the",
"resource",
"and",
"function",
"arn",
"provided",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/awsclient.py#L951-L977 | [
"def",
"verify_event_source_current",
"(",
"self",
",",
"event_uuid",
",",
"resource_name",
",",
"service_name",
",",
"function_arn",
")",
":",
"# type: (str, str, str, str) -> bool",
"client",
"=",
"self",
".",
"_client",
"(",
"'lambda'",
")",
"try",
":",
"attribut... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | CLIFactory.load_project_config | Load the chalice config file from the project directory.
:raise: OSError/IOError if unable to load the config file. | chalice/cli/factory.py | def load_project_config(self):
# type: () -> Dict[str, Any]
"""Load the chalice config file from the project directory.
:raise: OSError/IOError if unable to load the config file.
"""
config_file = os.path.join(self.project_dir, '.chalice', 'config.json')
with open(confi... | def load_project_config(self):
# type: () -> Dict[str, Any]
"""Load the chalice config file from the project directory.
:raise: OSError/IOError if unable to load the config file.
"""
config_file = os.path.join(self.project_dir, '.chalice', 'config.json')
with open(confi... | [
"Load",
"the",
"chalice",
"config",
"file",
"from",
"the",
"project",
"directory",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/factory.py#L269-L278 | [
"def",
"load_project_config",
"(",
"self",
")",
":",
"# type: () -> Dict[str, Any]",
"config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"project_dir",
",",
"'.chalice'",
",",
"'config.json'",
")",
"with",
"open",
"(",
"config_file",
")",
"as... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | invoke | Invoke the deployed lambda function NAME. | chalice/cli/__init__.py | def invoke(ctx, name, profile, stage):
# type: (click.Context, str, str, str) -> None
"""Invoke the deployed lambda function NAME."""
factory = ctx.obj['factory'] # type: CLIFactory
factory.profile = profile
try:
invoke_handler = factory.create_lambda_invoke_handler(name, stage)
pa... | def invoke(ctx, name, profile, stage):
# type: (click.Context, str, str, str) -> None
"""Invoke the deployed lambda function NAME."""
factory = ctx.obj['factory'] # type: CLIFactory
factory.profile = profile
try:
invoke_handler = factory.create_lambda_invoke_handler(name, stage)
pa... | [
"Invoke",
"the",
"deployed",
"lambda",
"function",
"NAME",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/__init__.py#L217-L247 | [
"def",
"invoke",
"(",
"ctx",
",",
"name",
",",
"profile",
",",
"stage",
")",
":",
"# type: (click.Context, str, str, str) -> None",
"factory",
"=",
"ctx",
".",
"obj",
"[",
"'factory'",
"]",
"# type: CLIFactory",
"factory",
".",
"profile",
"=",
"profile",
"try",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | generate_pipeline | Generate a cloudformation template for a starter CD pipeline.
This command will write a starter cloudformation template to
the filename you provide. It contains a CodeCommit repo,
a CodeBuild stage for packaging your chalice app, and a
CodePipeline stage to deploy your application using cloudformation... | chalice/cli/__init__.py | def generate_pipeline(ctx, codebuild_image, source, buildspec_file, filename):
# type: (click.Context, str, str, str, str) -> None
"""Generate a cloudformation template for a starter CD pipeline.
This command will write a starter cloudformation template to
the filename you provide. It contains a CodeC... | def generate_pipeline(ctx, codebuild_image, source, buildspec_file, filename):
# type: (click.Context, str, str, str, str) -> None
"""Generate a cloudformation template for a starter CD pipeline.
This command will write a starter cloudformation template to
the filename you provide. It contains a CodeC... | [
"Generate",
"a",
"cloudformation",
"template",
"for",
"a",
"starter",
"CD",
"pipeline",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/cli/__init__.py#L419-L453 | [
"def",
"generate_pipeline",
"(",
"ctx",
",",
"codebuild_image",
",",
"source",
",",
"buildspec_file",
",",
"filename",
")",
":",
"# type: (click.Context, str, str, str, str) -> None",
"from",
"chalice",
"import",
"pipeline",
"factory",
"=",
"ctx",
".",
"obj",
"[",
"... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | Config.deployed_resources | Return resources associated with a given stage.
If a deployment to a given stage has never happened,
this method will return a value of None. | chalice/config.py | def deployed_resources(self, chalice_stage_name):
# type: (str) -> DeployedResources
"""Return resources associated with a given stage.
If a deployment to a given stage has never happened,
this method will return a value of None.
"""
# This is arguably the wrong level o... | def deployed_resources(self, chalice_stage_name):
# type: (str) -> DeployedResources
"""Return resources associated with a given stage.
If a deployment to a given stage has never happened,
this method will return a value of None.
"""
# This is arguably the wrong level o... | [
"Return",
"resources",
"associated",
"with",
"a",
"given",
"stage",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/config.py#L326-L346 | [
"def",
"deployed_resources",
"(",
"self",
",",
"chalice_stage_name",
")",
":",
"# type: (str) -> DeployedResources",
"# This is arguably the wrong level of abstraction.",
"# We might be able to move this elsewhere.",
"deployed_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"s... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | AppPolicyGenerator.generate_policy | Auto generate policy for an application. | chalice/policy.py | def generate_policy(self, config):
# type: (Config) -> Dict[str, Any]
"""Auto generate policy for an application."""
# Admittedly, this is pretty bare bones logic for the time
# being. All it really does it work out, given a Config instance,
# which files need to analyzed and th... | def generate_policy(self, config):
# type: (Config) -> Dict[str, Any]
"""Auto generate policy for an application."""
# Admittedly, this is pretty bare bones logic for the time
# being. All it really does it work out, given a Config instance,
# which files need to analyzed and th... | [
"Auto",
"generate",
"policy",
"for",
"an",
"application",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/policy.py#L81-L96 | [
"def",
"generate_policy",
"(",
"self",
",",
"config",
")",
":",
"# type: (Config) -> Dict[str, Any]",
"# Admittedly, this is pretty bare bones logic for the time",
"# being. All it really does it work out, given a Config instance,",
"# which files need to analyzed and then delegates to the",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | get_client_calls | Return all clients calls made in provided source code.
:returns: A dict of service_name -> set([client calls]).
Example: {"s3": set(["list_objects", "create_bucket"]),
"dynamodb": set(["describe_table"])} | chalice/analyzer.py | def get_client_calls(source_code):
# type: (str) -> APICallT
"""Return all clients calls made in provided source code.
:returns: A dict of service_name -> set([client calls]).
Example: {"s3": set(["list_objects", "create_bucket"]),
"dynamodb": set(["describe_table"])}
"""
... | def get_client_calls(source_code):
# type: (str) -> APICallT
"""Return all clients calls made in provided source code.
:returns: A dict of service_name -> set([client calls]).
Example: {"s3": set(["list_objects", "create_bucket"]),
"dynamodb": set(["describe_table"])}
"""
... | [
"Return",
"all",
"clients",
"calls",
"made",
"in",
"provided",
"source",
"code",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/analyzer.py#L47-L60 | [
"def",
"get_client_calls",
"(",
"source_code",
")",
":",
"# type: (str) -> APICallT",
"parsed",
"=",
"parse_code",
"(",
"source_code",
")",
"t",
"=",
"SymbolTableTypeInfer",
"(",
"parsed",
")",
"binder",
"=",
"t",
".",
"bind_types",
"(",
")",
"collector",
"=",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | get_client_calls_for_app | Return client calls for a chalice app.
This is similar to ``get_client_calls`` except it will
automatically traverse into chalice views with the assumption
that they will be called. | chalice/analyzer.py | def get_client_calls_for_app(source_code):
# type: (str) -> APICallT
"""Return client calls for a chalice app.
This is similar to ``get_client_calls`` except it will
automatically traverse into chalice views with the assumption
that they will be called.
"""
parsed = parse_code(source_code)... | def get_client_calls_for_app(source_code):
# type: (str) -> APICallT
"""Return client calls for a chalice app.
This is similar to ``get_client_calls`` except it will
automatically traverse into chalice views with the assumption
that they will be called.
"""
parsed = parse_code(source_code)... | [
"Return",
"client",
"calls",
"for",
"a",
"chalice",
"app",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/analyzer.py#L63-L79 | [
"def",
"get_client_calls_for_app",
"(",
"source_code",
")",
":",
"# type: (str) -> APICallT",
"parsed",
"=",
"parse_code",
"(",
"source_code",
")",
"parsed",
".",
"parsed_ast",
"=",
"AppViewTransformer",
"(",
")",
".",
"visit",
"(",
"parsed",
".",
"parsed_ast",
")... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | RouteMatcher.match_route | Match the url against known routes.
This method takes a concrete route "/foo/bar", and
matches it against a set of routes. These routes can
use param substitution corresponding to API gateway patterns.
For example::
match_route('/foo/bar') -> '/foo/{name}' | chalice/local.py | def match_route(self, url):
# type: (str) -> MatchResult
"""Match the url against known routes.
This method takes a concrete route "/foo/bar", and
matches it against a set of routes. These routes can
use param substitution corresponding to API gateway patterns.
For exam... | def match_route(self, url):
# type: (str) -> MatchResult
"""Match the url against known routes.
This method takes a concrete route "/foo/bar", and
matches it against a set of routes. These routes can
use param substitution corresponding to API gateway patterns.
For exam... | [
"Match",
"the",
"url",
"against",
"known",
"routes",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/local.py#L113-L147 | [
"def",
"match_route",
"(",
"self",
",",
"url",
")",
":",
"# type: (str) -> MatchResult",
"# Otherwise we need to check for param substitution",
"parsed_url",
"=",
"urlparse",
"(",
"url",
")",
"parsed_qs",
"=",
"parse_qs",
"(",
"parsed_url",
".",
"query",
",",
"keep_bl... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | LocalGatewayAuthorizer._prepare_authorizer_event | Translate event for an authorizer input. | chalice/local.py | def _prepare_authorizer_event(self, arn, lambda_event, lambda_context):
# type: (str, EventType, LambdaContext) -> EventType
"""Translate event for an authorizer input."""
authorizer_event = lambda_event.copy()
authorizer_event['type'] = 'TOKEN'
try:
authorizer_event[... | def _prepare_authorizer_event(self, arn, lambda_event, lambda_context):
# type: (str, EventType, LambdaContext) -> EventType
"""Translate event for an authorizer input."""
authorizer_event = lambda_event.copy()
authorizer_event['type'] = 'TOKEN'
try:
authorizer_event[... | [
"Translate",
"event",
"for",
"an",
"authorizer",
"input",
"."
] | aws/chalice | python | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/local.py#L378-L392 | [
"def",
"_prepare_authorizer_event",
"(",
"self",
",",
"arn",
",",
"lambda_event",
",",
"lambda_context",
")",
":",
"# type: (str, EventType, LambdaContext) -> EventType",
"authorizer_event",
"=",
"lambda_event",
".",
"copy",
"(",
")",
"authorizer_event",
"[",
"'type'",
... | 10d7fb52e68bd1c52aae251c97e3939fc0190412 |
train | GeneratorTabController.bootstrap_modulator | Set initial parameters for default modulator if it was not edited by user previously
:return: | src/urh/controller/GeneratorTabController.py | def bootstrap_modulator(self, protocol: ProtocolAnalyzer):
"""
Set initial parameters for default modulator if it was not edited by user previously
:return:
"""
if len(self.modulators) != 1 or len(self.table_model.protocol.messages) == 0:
return
modulator = s... | def bootstrap_modulator(self, protocol: ProtocolAnalyzer):
"""
Set initial parameters for default modulator if it was not edited by user previously
:return:
"""
if len(self.modulators) != 1 or len(self.table_model.protocol.messages) == 0:
return
modulator = s... | [
"Set",
"initial",
"parameters",
"for",
"default",
"modulator",
"if",
"it",
"was",
"not",
"edited",
"by",
"user",
"previously",
":",
"return",
":"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L206-L224 | [
"def",
"bootstrap_modulator",
"(",
"self",
",",
"protocol",
":",
"ProtocolAnalyzer",
")",
":",
"if",
"len",
"(",
"self",
".",
"modulators",
")",
"!=",
"1",
"or",
"len",
"(",
"self",
".",
"table_model",
".",
"protocol",
".",
"messages",
")",
"==",
"0",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | GeneratorTabController.modulate_data | :param buffer: Buffer in which the modulated data shall be written, initialized with zeros
:return: | src/urh/controller/GeneratorTabController.py | def modulate_data(self, buffer: np.ndarray) -> np.ndarray:
"""
:param buffer: Buffer in which the modulated data shall be written, initialized with zeros
:return:
"""
self.ui.prBarGeneration.show()
self.ui.prBarGeneration.setValue(0)
self.ui.prBarGenerat... | def modulate_data(self, buffer: np.ndarray) -> np.ndarray:
"""
:param buffer: Buffer in which the modulated data shall be written, initialized with zeros
:return:
"""
self.ui.prBarGeneration.show()
self.ui.prBarGeneration.setValue(0)
self.ui.prBarGenerat... | [
":",
"param",
"buffer",
":",
"Buffer",
"in",
"which",
"the",
"modulated",
"data",
"shall",
"be",
"written",
"initialized",
"with",
"zeros",
":",
"return",
":"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L413-L437 | [
"def",
"modulate_data",
"(",
"self",
",",
"buffer",
":",
"np",
".",
"ndarray",
")",
"->",
"np",
".",
"ndarray",
":",
"self",
".",
"ui",
".",
"prBarGeneration",
".",
"show",
"(",
")",
"self",
".",
"ui",
".",
"prBarGeneration",
".",
"setValue",
"(",
"0... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | GeneratorTabController.refresh_existing_encodings | Refresh existing encodings for messages, when encoding was changed by user in dialog
:return: | src/urh/controller/GeneratorTabController.py | def refresh_existing_encodings(self, encodings_from_file):
"""
Refresh existing encodings for messages, when encoding was changed by user in dialog
:return:
"""
update = False
for msg in self.table_model.protocol.messages:
i = next((i for i, d in enumerate(e... | def refresh_existing_encodings(self, encodings_from_file):
"""
Refresh existing encodings for messages, when encoding was changed by user in dialog
:return:
"""
update = False
for msg in self.table_model.protocol.messages:
i = next((i for i, d in enumerate(e... | [
"Refresh",
"existing",
"encodings",
"for",
"messages",
"when",
"encoding",
"was",
"changed",
"by",
"user",
"in",
"dialog"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/GeneratorTabController.py#L499-L517 | [
"def",
"refresh_existing_encodings",
"(",
"self",
",",
"encodings_from_file",
")",
":",
"update",
"=",
"False",
"for",
"msg",
"in",
"self",
".",
"table_model",
".",
"protocol",
".",
"messages",
":",
"i",
"=",
"next",
"(",
"(",
"i",
"for",
"i",
",",
"d",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | CompareFrameController.protocols | :rtype: dict[int, list of ProtocolAnalyzer] | src/urh/controller/CompareFrameController.py | def protocols(self):
"""
:rtype: dict[int, list of ProtocolAnalyzer]
"""
if self.__protocols is None:
self.__protocols = self.proto_tree_model.protocols
return self.__protocols | def protocols(self):
"""
:rtype: dict[int, list of ProtocolAnalyzer]
"""
if self.__protocols is None:
self.__protocols = self.proto_tree_model.protocols
return self.__protocols | [
":",
"rtype",
":",
"dict",
"[",
"int",
"list",
"of",
"ProtocolAnalyzer",
"]"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L201-L207 | [
"def",
"protocols",
"(",
"self",
")",
":",
"if",
"self",
".",
"__protocols",
"is",
"None",
":",
"self",
".",
"__protocols",
"=",
"self",
".",
"proto_tree_model",
".",
"protocols",
"return",
"self",
".",
"__protocols"
] | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | CompareFrameController.protocol_list | :return: visible protocols
:rtype: list of ProtocolAnalyzer | src/urh/controller/CompareFrameController.py | def protocol_list(self):
"""
:return: visible protocols
:rtype: list of ProtocolAnalyzer
"""
result = []
for group in self.groups:
result.extend(group.protocols)
return result | def protocol_list(self):
"""
:return: visible protocols
:rtype: list of ProtocolAnalyzer
"""
result = []
for group in self.groups:
result.extend(group.protocols)
return result | [
":",
"return",
":",
"visible",
"protocols",
":",
"rtype",
":",
"list",
"of",
"ProtocolAnalyzer"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L210-L218 | [
"def",
"protocol_list",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"result",
".",
"extend",
"(",
"group",
".",
"protocols",
")",
"return",
"result"
] | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | CompareFrameController.full_protocol_list | :return: all protocols including not shown ones
:rtype: list of ProtocolAnalyzer | src/urh/controller/CompareFrameController.py | def full_protocol_list(self):
"""
:return: all protocols including not shown ones
:rtype: list of ProtocolAnalyzer
"""
result = []
for group in self.groups:
result.extend(group.all_protocols)
return result | def full_protocol_list(self):
"""
:return: all protocols including not shown ones
:rtype: list of ProtocolAnalyzer
"""
result = []
for group in self.groups:
result.extend(group.all_protocols)
return result | [
":",
"return",
":",
"all",
"protocols",
"including",
"not",
"shown",
"ones",
":",
"rtype",
":",
"list",
"of",
"ProtocolAnalyzer"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L221-L229 | [
"def",
"full_protocol_list",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"result",
".",
"extend",
"(",
"group",
".",
"all_protocols",
")",
"return",
"result"
] | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | CompareFrameController.refresh_existing_encodings | Refresh existing encodings for messages, when encoding was changed by user in dialog
:return: | src/urh/controller/CompareFrameController.py | def refresh_existing_encodings(self):
"""
Refresh existing encodings for messages, when encoding was changed by user in dialog
:return:
"""
update = False
for msg in self.proto_analyzer.messages:
i = next((i for i, d in enumerate(self.decodings) if d.name ==... | def refresh_existing_encodings(self):
"""
Refresh existing encodings for messages, when encoding was changed by user in dialog
:return:
"""
update = False
for msg in self.proto_analyzer.messages:
i = next((i for i, d in enumerate(self.decodings) if d.name ==... | [
"Refresh",
"existing",
"encodings",
"for",
"messages",
"when",
"encoding",
"was",
"changed",
"by",
"user",
"in",
"dialog"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L383-L401 | [
"def",
"refresh_existing_encodings",
"(",
"self",
")",
":",
"update",
"=",
"False",
"for",
"msg",
"in",
"self",
".",
"proto_analyzer",
".",
"messages",
":",
"i",
"=",
"next",
"(",
"(",
"i",
"for",
"i",
",",
"d",
"in",
"enumerate",
"(",
"self",
".",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | CompareFrameController.set_show_only_status | Handles the different combinations of the show only checkboxes, namely:
- Show only labels
- Show only Diffs | src/urh/controller/CompareFrameController.py | def set_show_only_status(self):
"""
Handles the different combinations of the show only checkboxes, namely:
- Show only labels
- Show only Diffs
"""
if self.ui.chkBoxShowOnlyDiffs.isChecked() and not self.ui.cbShowDiffs.isChecked():
self.ui.cbShowDiffs.setCh... | def set_show_only_status(self):
"""
Handles the different combinations of the show only checkboxes, namely:
- Show only labels
- Show only Diffs
"""
if self.ui.chkBoxShowOnlyDiffs.isChecked() and not self.ui.cbShowDiffs.isChecked():
self.ui.cbShowDiffs.setCh... | [
"Handles",
"the",
"different",
"combinations",
"of",
"the",
"show",
"only",
"checkboxes",
"namely",
":",
"-",
"Show",
"only",
"labels",
"-",
"Show",
"only",
"Diffs"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/CompareFrameController.py#L862-L881 | [
"def",
"set_show_only_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"ui",
".",
"chkBoxShowOnlyDiffs",
".",
"isChecked",
"(",
")",
"and",
"not",
"self",
".",
"ui",
".",
"cbShowDiffs",
".",
"isChecked",
"(",
")",
":",
"self",
".",
"ui",
".",
"cbShow... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Component.find_field | Wrapper method selecting the backend to assign the protocol field.
Various strategies are possible e.g.:
1) Heuristics e.g. for Preamble
2) Scoring based e.g. for Length
3) Fulltext search for addresses based on participant subgroups
:param messages: messages a field shall be se... | src/urh/awre/components/Component.py | def find_field(self, messages):
"""
Wrapper method selecting the backend to assign the protocol field.
Various strategies are possible e.g.:
1) Heuristics e.g. for Preamble
2) Scoring based e.g. for Length
3) Fulltext search for addresses based on participant subgroups
... | def find_field(self, messages):
"""
Wrapper method selecting the backend to assign the protocol field.
Various strategies are possible e.g.:
1) Heuristics e.g. for Preamble
2) Scoring based e.g. for Length
3) Fulltext search for addresses based on participant subgroups
... | [
"Wrapper",
"method",
"selecting",
"the",
"backend",
"to",
"assign",
"the",
"protocol",
"field",
".",
"Various",
"strategies",
"are",
"possible",
"e",
".",
"g",
".",
":",
"1",
")",
"Heuristics",
"e",
".",
"g",
".",
"for",
"Preamble",
"2",
")",
"Scoring",
... | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Component.py#L45-L66 | [
"def",
"find_field",
"(",
"self",
",",
"messages",
")",
":",
"try",
":",
"if",
"self",
".",
"backend",
"==",
"self",
".",
"Backend",
".",
"python",
":",
"self",
".",
"_py_find_field",
"(",
"messages",
")",
"elif",
"self",
".",
"backend",
"==",
"self",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Component.assign_messagetypes | Assign message types based on the clusters. Following rules:
1) Messages from different clusters will get different message types
2) Messages from same clusters will get same message type
3) The new message type will copy over the existing labels
4) No new message type will be set for me... | src/urh/awre/components/Component.py | def assign_messagetypes(self, messages, clusters):
"""
Assign message types based on the clusters. Following rules:
1) Messages from different clusters will get different message types
2) Messages from same clusters will get same message type
3) The new message type will copy ove... | def assign_messagetypes(self, messages, clusters):
"""
Assign message types based on the clusters. Following rules:
1) Messages from different clusters will get different message types
2) Messages from same clusters will get same message type
3) The new message type will copy ove... | [
"Assign",
"message",
"types",
"based",
"on",
"the",
"clusters",
".",
"Following",
"rules",
":",
"1",
")",
"Messages",
"from",
"different",
"clusters",
"will",
"get",
"different",
"message",
"types",
"2",
")",
"Messages",
"from",
"same",
"clusters",
"will",
"... | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Component.py#L78-L111 | [
"def",
"assign_messagetypes",
"(",
"self",
",",
"messages",
",",
"clusters",
")",
":",
"for",
"clustername",
",",
"clustercontent",
"in",
"clusters",
".",
"items",
"(",
")",
":",
"if",
"clustername",
"==",
"\"default\"",
":",
"# Do not force the default message ty... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Spectrogram.stft | Perform Short-time Fourier transform to get the spectrogram for the given samples
:return: short-time Fourier transform of the given signal | src/urh/signalprocessing/Spectrogram.py | def stft(self, samples: np.ndarray):
"""
Perform Short-time Fourier transform to get the spectrogram for the given samples
:return: short-time Fourier transform of the given signal
"""
window = self.window_function(self.window_size)
hop_size = self.hop_size
if le... | def stft(self, samples: np.ndarray):
"""
Perform Short-time Fourier transform to get the spectrogram for the given samples
:return: short-time Fourier transform of the given signal
"""
window = self.window_function(self.window_size)
hop_size = self.hop_size
if le... | [
"Perform",
"Short",
"-",
"time",
"Fourier",
"transform",
"to",
"get",
"the",
"spectrogram",
"for",
"the",
"given",
"samples",
":",
"return",
":",
"short",
"-",
"time",
"Fourier",
"transform",
"of",
"the",
"given",
"signal"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L78-L98 | [
"def",
"stft",
"(",
"self",
",",
"samples",
":",
"np",
".",
"ndarray",
")",
":",
"window",
"=",
"self",
".",
"window_function",
"(",
"self",
".",
"window_size",
")",
"hop_size",
"=",
"self",
".",
"hop_size",
"if",
"len",
"(",
"samples",
")",
"<",
"se... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Spectrogram.export_to_fta | Export to Frequency, Time, Amplitude file.
Frequency is double, Time (nanosecond) is uint32, Amplitude is float32
:return: | src/urh/signalprocessing/Spectrogram.py | def export_to_fta(self, sample_rate, filename: str, include_amplitude=False):
"""
Export to Frequency, Time, Amplitude file.
Frequency is double, Time (nanosecond) is uint32, Amplitude is float32
:return:
"""
spectrogram = self.__calculate_spectrogram(self.samples)
... | def export_to_fta(self, sample_rate, filename: str, include_amplitude=False):
"""
Export to Frequency, Time, Amplitude file.
Frequency is double, Time (nanosecond) is uint32, Amplitude is float32
:return:
"""
spectrogram = self.__calculate_spectrogram(self.samples)
... | [
"Export",
"to",
"Frequency",
"Time",
"Amplitude",
"file",
".",
"Frequency",
"is",
"double",
"Time",
"(",
"nanosecond",
")",
"is",
"uint32",
"Amplitude",
"is",
"float32"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L100-L126 | [
"def",
"export_to_fta",
"(",
"self",
",",
"sample_rate",
",",
"filename",
":",
"str",
",",
"include_amplitude",
"=",
"False",
")",
":",
"spectrogram",
"=",
"self",
".",
"__calculate_spectrogram",
"(",
"self",
".",
"samples",
")",
"spectrogram",
"=",
"np",
".... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Spectrogram.create_image | Create QImage from ARGB array.
The ARGB must have shape (width, height, 4) and dtype=ubyte.
NOTE: The order of values in the 3rd axis must be (blue, green, red, alpha).
:return: | src/urh/signalprocessing/Spectrogram.py | def create_image(data: np.ndarray, colormap, data_min=None, data_max=None, normalize=True) -> QImage:
"""
Create QImage from ARGB array.
The ARGB must have shape (width, height, 4) and dtype=ubyte.
NOTE: The order of values in the 3rd axis must be (blue, green, red, alpha).
:retu... | def create_image(data: np.ndarray, colormap, data_min=None, data_max=None, normalize=True) -> QImage:
"""
Create QImage from ARGB array.
The ARGB must have shape (width, height, 4) and dtype=ubyte.
NOTE: The order of values in the 3rd axis must be (blue, green, red, alpha).
:retu... | [
"Create",
"QImage",
"from",
"ARGB",
"array",
".",
"The",
"ARGB",
"must",
"have",
"shape",
"(",
"width",
"height",
"4",
")",
"and",
"dtype",
"=",
"ubyte",
".",
"NOTE",
":",
"The",
"order",
"of",
"values",
"in",
"the",
"3rd",
"axis",
"must",
"be",
"(",... | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L164-L185 | [
"def",
"create_image",
"(",
"data",
":",
"np",
".",
"ndarray",
",",
"colormap",
",",
"data_min",
"=",
"None",
",",
"data_max",
"=",
"None",
",",
"normalize",
"=",
"True",
")",
"->",
"QImage",
":",
"image_data",
"=",
"Spectrogram",
".",
"apply_bgra_lookup",... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Signal.modulation_type | 0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)"
:param value:
:return: | src/urh/signalprocessing/Signal.py | def modulation_type(self, value: int):
"""
0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)"
:param value:
:return:
"""
if self.__modulation_type != value:
self.__modulation_type = value
self._qad = None
self.modulation_type_changed.e... | def modulation_type(self, value: int):
"""
0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)"
:param value:
:return:
"""
if self.__modulation_type != value:
self.__modulation_type = value
self._qad = None
self.modulation_type_changed.e... | [
"0",
"-",
"ASK",
"1",
"-",
"FSK",
"2",
"-",
"PSK",
"3",
"-",
"APSK",
"(",
"QAM",
")"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Signal.py#L171-L184 | [
"def",
"modulation_type",
"(",
"self",
",",
"value",
":",
"int",
")",
":",
"if",
"self",
".",
"__modulation_type",
"!=",
"value",
":",
"self",
".",
"__modulation_type",
"=",
"value",
"self",
".",
"_qad",
"=",
"None",
"self",
".",
"modulation_type_changed",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Signal.estimate_frequency | Estimate the frequency of the baseband signal using FFT
:param start: Start of the area that shall be investigated
:param end: End of the area that shall be investigated
:param sample_rate: Sample rate of the signal
:return: | src/urh/signalprocessing/Signal.py | def estimate_frequency(self, start: int, end: int, sample_rate: float):
"""
Estimate the frequency of the baseband signal using FFT
:param start: Start of the area that shall be investigated
:param end: End of the area that shall be investigated
:param sample_rate: Sample rate o... | def estimate_frequency(self, start: int, end: int, sample_rate: float):
"""
Estimate the frequency of the baseband signal using FFT
:param start: Start of the area that shall be investigated
:param end: End of the area that shall be investigated
:param sample_rate: Sample rate o... | [
"Estimate",
"the",
"frequency",
"of",
"the",
"baseband",
"signal",
"using",
"FFT"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Signal.py#L410-L433 | [
"def",
"estimate_frequency",
"(",
"self",
",",
"start",
":",
"int",
",",
"end",
":",
"int",
",",
"sample_rate",
":",
"float",
")",
":",
"# ensure power of 2 for faster fft",
"length",
"=",
"2",
"**",
"int",
"(",
"math",
".",
"log2",
"(",
"end",
"-",
"sta... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | FuzzingTableView.selection_range | :rtype: int, int, int, int | src/urh/ui/views/FuzzingTableView.py | def selection_range(self):
"""
:rtype: int, int, int, int
"""
selected = self.selectionModel().selection()
""":type: QItemSelection """
if selected.isEmpty():
return -1, -1, -1, -1
min_row = numpy.min([rng.top() for rng in selected])
max_row ... | def selection_range(self):
"""
:rtype: int, int, int, int
"""
selected = self.selectionModel().selection()
""":type: QItemSelection """
if selected.isEmpty():
return -1, -1, -1, -1
min_row = numpy.min([rng.top() for rng in selected])
max_row ... | [
":",
"rtype",
":",
"int",
"int",
"int",
"int"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/FuzzingTableView.py#L22-L37 | [
"def",
"selection_range",
"(",
"self",
")",
":",
"selected",
"=",
"self",
".",
"selectionModel",
"(",
")",
".",
"selection",
"(",
")",
"\"\"\":type: QItemSelection \"\"\"",
"if",
"selected",
".",
"isEmpty",
"(",
")",
":",
"return",
"-",
"1",
",",
"-",
"1",... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | fix_windows_stdout_stderr | Processes can't write to stdout/stderr on frozen windows apps because they do not exist here
if process tries it anyway we get a nasty dialog window popping up, so we redirect the streams to a dummy
see https://github.com/jopohl/urh/issues/370 | src/urh/main.py | def fix_windows_stdout_stderr():
"""
Processes can't write to stdout/stderr on frozen windows apps because they do not exist here
if process tries it anyway we get a nasty dialog window popping up, so we redirect the streams to a dummy
see https://github.com/jopohl/urh/issues/370
"""
if hasattr... | def fix_windows_stdout_stderr():
"""
Processes can't write to stdout/stderr on frozen windows apps because they do not exist here
if process tries it anyway we get a nasty dialog window popping up, so we redirect the streams to a dummy
see https://github.com/jopohl/urh/issues/370
"""
if hasattr... | [
"Processes",
"can",
"t",
"write",
"to",
"stdout",
"/",
"stderr",
"on",
"frozen",
"windows",
"apps",
"because",
"they",
"do",
"not",
"exist",
"here",
"if",
"process",
"tries",
"it",
"anyway",
"we",
"get",
"a",
"nasty",
"dialog",
"window",
"popping",
"up",
... | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/main.py#L23-L47 | [
"def",
"fix_windows_stdout_stderr",
"(",
")",
":",
"if",
"hasattr",
"(",
"sys",
",",
"\"frozen\"",
")",
"and",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"try",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\n\"",
")",
"sys",
".",
"stdout",
".... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | FormatFinder.build_component_order | Build the order of component based on their priority and predecessors
:rtype: list of Component | src/urh/awre/FormatFinder.py | def build_component_order(self):
"""
Build the order of component based on their priority and predecessors
:rtype: list of Component
"""
present_components = [item for item in self.__dict__.values() if isinstance(item, Component) and item.enabled]
result = [None] * len(p... | def build_component_order(self):
"""
Build the order of component based on their priority and predecessors
:rtype: list of Component
"""
present_components = [item for item in self.__dict__.values() if isinstance(item, Component) and item.enabled]
result = [None] * len(p... | [
"Build",
"the",
"order",
"of",
"component",
"based",
"on",
"their",
"priority",
"and",
"predecessors"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/FormatFinder.py#L48-L70 | [
"def",
"build_component_order",
"(",
"self",
")",
":",
"present_components",
"=",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"__dict__",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"item",
",",
"Component",
")",
"and",
"item",
".",
"enabled",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | FormatFinder.cluster_lengths | This method clusters some bitvectors based on their length. An example output is
2: [0.5, 1]
4: [1, 0.75, 1, 1]
Meaning there were two message lengths: 2 and 4 bit.
(0.5, 1) means, the first bit was equal in 50% of cases (meaning maximum difference) and bit 2 was equal in all messages
... | src/urh/awre/FormatFinder.py | def cluster_lengths(self):
"""
This method clusters some bitvectors based on their length. An example output is
2: [0.5, 1]
4: [1, 0.75, 1, 1]
Meaning there were two message lengths: 2 and 4 bit.
(0.5, 1) means, the first bit was equal in 50% of cases (meaning maximum d... | def cluster_lengths(self):
"""
This method clusters some bitvectors based on their length. An example output is
2: [0.5, 1]
4: [1, 0.75, 1, 1]
Meaning there were two message lengths: 2 and 4 bit.
(0.5, 1) means, the first bit was equal in 50% of cases (meaning maximum d... | [
"This",
"method",
"clusters",
"some",
"bitvectors",
"based",
"on",
"their",
"length",
".",
"An",
"example",
"output",
"is"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/FormatFinder.py#L77-L106 | [
"def",
"cluster_lengths",
"(",
"self",
")",
":",
"number_ones",
"=",
"dict",
"(",
")",
"# dict of tuple. 0 = number ones vector, 1 = number of blocks for this vector",
"for",
"vector",
"in",
"self",
".",
"bitvectors",
":",
"vec_len",
"=",
"4",
"*",
"(",
"len",
"(",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Address.find_candidates | Find candidate addresses using LCS algorithm
perform a scoring based on how often a candidate appears in a longer candidate
Input is something like
------------------------
['1b6033', '1b6033fd57', '701b603378e289', '20701b603378e289000c62',
'1b603300', '78e289757e', '7078e2891b... | src/urh/awre/components/Address.py | def find_candidates(candidates):
"""
Find candidate addresses using LCS algorithm
perform a scoring based on how often a candidate appears in a longer candidate
Input is something like
------------------------
['1b6033', '1b6033fd57', '701b603378e289', '20701b603378e2890... | def find_candidates(candidates):
"""
Find candidate addresses using LCS algorithm
perform a scoring based on how often a candidate appears in a longer candidate
Input is something like
------------------------
['1b6033', '1b6033fd57', '701b603378e289', '20701b603378e2890... | [
"Find",
"candidate",
"addresses",
"using",
"LCS",
"algorithm",
"perform",
"a",
"scoring",
"based",
"on",
"how",
"often",
"a",
"candidate",
"appears",
"in",
"a",
"longer",
"candidate"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Address.py#L190-L217 | [
"def",
"find_candidates",
"(",
"candidates",
")",
":",
"result",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"i",
",",
"c_i",
"in",
"enumerate",
"(",
"candidates",
")",
":",
"for",
"j",
"in",
"range",
"(",
"i",
",",
"len",
"(",
"candidates",
")",
")"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Address.choose_candidate_pair | Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones
:type candidates: dict[str, int]
:param candidates: Count how often the longest common substrings appeared in the messages
:return: | src/urh/awre/components/Address.py | def choose_candidate_pair(candidates):
"""
Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones
:type candidates: dict[str, int]
:param candidates: Count how often the longest common substrings appeared in the messages
... | def choose_candidate_pair(candidates):
"""
Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones
:type candidates: dict[str, int]
:param candidates: Count how often the longest common substrings appeared in the messages
... | [
"Choose",
"a",
"pair",
"of",
"address",
"candidates",
"ensuring",
"they",
"have",
"the",
"same",
"length",
"and",
"starting",
"with",
"the",
"highest",
"scored",
"ones"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Address.py#L220-L232 | [
"def",
"choose_candidate_pair",
"(",
"candidates",
")",
":",
"highscored",
"=",
"sorted",
"(",
"candidates",
",",
"key",
"=",
"candidates",
".",
"get",
",",
"reverse",
"=",
"True",
")",
"for",
"i",
",",
"h_i",
"in",
"enumerate",
"(",
"highscored",
")",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | uncompress_archives | Extract each archive from the list of filenames.
Normal files stay untouched.
Add all files to the Recent Files.
:type file_names: list of str
:type temp_dir: str
:rtype: list of str | src/urh/util/FileOperator.py | def uncompress_archives(file_names, temp_dir):
"""
Extract each archive from the list of filenames.
Normal files stay untouched.
Add all files to the Recent Files.
:type file_names: list of str
:type temp_dir: str
:rtype: list of str
"""
result = []
for filename in file_names:
... | def uncompress_archives(file_names, temp_dir):
"""
Extract each archive from the list of filenames.
Normal files stay untouched.
Add all files to the Recent Files.
:type file_names: list of str
:type temp_dir: str
:rtype: list of str
"""
result = []
for filename in file_names:
... | [
"Extract",
"each",
"archive",
"from",
"the",
"list",
"of",
"filenames",
".",
"Normal",
"files",
"stay",
"untouched",
".",
"Add",
"all",
"files",
"to",
"the",
"Recent",
"Files",
".",
":",
"type",
"file_names",
":",
"list",
"of",
"str",
":",
"type",
"temp_... | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/FileOperator.py#L63-L95 | [
"def",
"uncompress_archives",
"(",
"file_names",
",",
"temp_dir",
")",
":",
"result",
"=",
"[",
"]",
"for",
"filename",
"in",
"file_names",
":",
"if",
"filename",
".",
"endswith",
"(",
"\".tar\"",
")",
"or",
"filename",
".",
"endswith",
"(",
"\".tar.gz\"",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | ProjectManager.write_modulators_to_project_file | :type modulators: list of Modulator
:return: | src/urh/util/ProjectManager.py | def write_modulators_to_project_file(self, tree=None):
"""
:type modulators: list of Modulator
:return:
"""
if self.project_file is None or not self.modulators:
return
if tree is None:
tree = ET.parse(self.project_file)
root = tree.getroo... | def write_modulators_to_project_file(self, tree=None):
"""
:type modulators: list of Modulator
:return:
"""
if self.project_file is None or not self.modulators:
return
if tree is None:
tree = ET.parse(self.project_file)
root = tree.getroo... | [
":",
"type",
"modulators",
":",
"list",
"of",
"Modulator",
":",
"return",
":"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/ProjectManager.py#L331-L345 | [
"def",
"write_modulators_to_project_file",
"(",
"self",
",",
"tree",
"=",
"None",
")",
":",
"if",
"self",
".",
"project_file",
"is",
"None",
"or",
"not",
"self",
".",
"modulators",
":",
"return",
"if",
"tree",
"is",
"None",
":",
"tree",
"=",
"ET",
".",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | cwt_haar | continuous haar wavelet transform based on the paper
"A practical guide to wavelet analysis" by Christopher Torrence and Gilbert P Compo | src/urh/ainterpretation/Wavelet.py | def cwt_haar(x: np.ndarray, scale=10):
"""
continuous haar wavelet transform based on the paper
"A practical guide to wavelet analysis" by Christopher Torrence and Gilbert P Compo
"""
next_power_two = 2 ** int(np.log2(len(x)))
x = x[0:next_power_two]
num_data = len(x)
# get FFT of x (... | def cwt_haar(x: np.ndarray, scale=10):
"""
continuous haar wavelet transform based on the paper
"A practical guide to wavelet analysis" by Christopher Torrence and Gilbert P Compo
"""
next_power_two = 2 ** int(np.log2(len(x)))
x = x[0:next_power_two]
num_data = len(x)
# get FFT of x (... | [
"continuous",
"haar",
"wavelet",
"transform",
"based",
"on",
"the",
"paper",
"A",
"practical",
"guide",
"to",
"wavelet",
"analysis",
"by",
"Christopher",
"Torrence",
"and",
"Gilbert",
"P",
"Compo"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ainterpretation/Wavelet.py#L15-L39 | [
"def",
"cwt_haar",
"(",
"x",
":",
"np",
".",
"ndarray",
",",
"scale",
"=",
"10",
")",
":",
"next_power_two",
"=",
"2",
"**",
"int",
"(",
"np",
".",
"log2",
"(",
"len",
"(",
"x",
")",
")",
")",
"x",
"=",
"x",
"[",
"0",
":",
"next_power_two",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Preamble.__find_sync_range | Finding the synchronization works by finding the first difference between two messages.
This is performed for all messages and the most frequent first difference is chosen
:type messages: list of Message
:param preamble_end: End of preamble = start of search
:param search_end: End of se... | src/urh/awre/components/Preamble.py | def __find_sync_range(self, messages, preamble_end: int, search_end: int):
"""
Finding the synchronization works by finding the first difference between two messages.
This is performed for all messages and the most frequent first difference is chosen
:type messages: list of Message
... | def __find_sync_range(self, messages, preamble_end: int, search_end: int):
"""
Finding the synchronization works by finding the first difference between two messages.
This is performed for all messages and the most frequent first difference is chosen
:type messages: list of Message
... | [
"Finding",
"the",
"synchronization",
"works",
"by",
"finding",
"the",
"first",
"difference",
"between",
"two",
"messages",
".",
"This",
"is",
"performed",
"for",
"all",
"messages",
"and",
"the",
"most",
"frequent",
"first",
"difference",
"is",
"chosen"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Preamble.py#L95-L121 | [
"def",
"__find_sync_range",
"(",
"self",
",",
"messages",
",",
"preamble_end",
":",
"int",
",",
"search_end",
":",
"int",
")",
":",
"possible_sync_pos",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"i",
",",
"msg",
"in",
"enumerate",
"(",
"messages",
")",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | TableModel.__pad_until_index | Pad message in given row with zeros until given column so user can enter values behind end of message
:return: | src/urh/models/TableModel.py | def __pad_until_index(self, row: int, bit_pos: int):
"""
Pad message in given row with zeros until given column so user can enter values behind end of message
:return:
"""
try:
new_bits = array.array("B", [0] * max(0, bit_pos - len(self.protocol.messages[row])))
... | def __pad_until_index(self, row: int, bit_pos: int):
"""
Pad message in given row with zeros until given column so user can enter values behind end of message
:return:
"""
try:
new_bits = array.array("B", [0] * max(0, bit_pos - len(self.protocol.messages[row])))
... | [
"Pad",
"message",
"in",
"given",
"row",
"with",
"zeros",
"until",
"given",
"column",
"so",
"user",
"can",
"enter",
"values",
"behind",
"end",
"of",
"message",
":",
"return",
":"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/TableModel.py#L84-L101 | [
"def",
"__pad_until_index",
"(",
"self",
",",
"row",
":",
"int",
",",
"bit_pos",
":",
"int",
")",
":",
"try",
":",
"new_bits",
"=",
"array",
".",
"array",
"(",
"\"B\"",
",",
"[",
"0",
"]",
"*",
"max",
"(",
"0",
",",
"bit_pos",
"-",
"len",
"(",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | TableModel.find_differences | Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]] | src/urh/models/TableModel.py | def find_differences(self, refindex: int):
"""
Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]]
"""
differences = defaultdict(set)
if refindex >= len(self.proto... | def find_differences(self, refindex: int):
"""
Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]]
"""
differences = defaultdict(set)
if refindex >= len(self.proto... | [
"Search",
"all",
"differences",
"between",
"protocol",
"messages",
"regarding",
"a",
"reference",
"message"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/TableModel.py#L337-L373 | [
"def",
"find_differences",
"(",
"self",
",",
"refindex",
":",
"int",
")",
":",
"differences",
"=",
"defaultdict",
"(",
"set",
")",
"if",
"refindex",
">=",
"len",
"(",
"self",
".",
"protocol",
".",
"messages",
")",
":",
"return",
"differences",
"if",
"sel... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | ProtocolSniffer.__demodulate_data | Demodulates received IQ data and adds demodulated bits to messages
:param data:
:return: | src/urh/signalprocessing/ProtocolSniffer.py | def __demodulate_data(self, data):
"""
Demodulates received IQ data and adds demodulated bits to messages
:param data:
:return:
"""
if len(data) == 0:
return
power_spectrum = data.real ** 2 + data.imag ** 2
is_above_noise = np.sqrt(np.mean(pow... | def __demodulate_data(self, data):
"""
Demodulates received IQ data and adds demodulated bits to messages
:param data:
:return:
"""
if len(data) == 0:
return
power_spectrum = data.real ** 2 + data.imag ** 2
is_above_noise = np.sqrt(np.mean(pow... | [
"Demodulates",
"received",
"IQ",
"data",
"and",
"adds",
"demodulated",
"bits",
"to",
"messages",
":",
"param",
"data",
":",
":",
"return",
":"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolSniffer.py#L155-L203 | [
"def",
"__demodulate_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"return",
"power_spectrum",
"=",
"data",
".",
"real",
"**",
"2",
"+",
"data",
".",
"imag",
"**",
"2",
"is_above_noise",
"=",
"np",
".",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | SceneManager.create_rectangle | :type proto_bits: list of str | src/urh/ui/painting/SceneManager.py | def create_rectangle(proto_bits, pulse_len=100):
"""
:type proto_bits: list of str
"""
ones = np.ones(pulse_len, dtype=np.float32) * 1
zeros = np.ones(pulse_len, dtype=np.float32) * -1
n = 0
y = []
for msg in proto_bits:
for bit in msg:
... | def create_rectangle(proto_bits, pulse_len=100):
"""
:type proto_bits: list of str
"""
ones = np.ones(pulse_len, dtype=np.float32) * 1
zeros = np.ones(pulse_len, dtype=np.float32) * -1
n = 0
y = []
for msg in proto_bits:
for bit in msg:
... | [
":",
"type",
"proto_bits",
":",
"list",
"of",
"str"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/painting/SceneManager.py#L107-L133 | [
"def",
"create_rectangle",
"(",
"proto_bits",
",",
"pulse_len",
"=",
"100",
")",
":",
"ones",
"=",
"np",
".",
"ones",
"(",
"pulse_len",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"*",
"1",
"zeros",
"=",
"np",
".",
"ones",
"(",
"pulse_len",
",",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | SpectrogramSceneManager.set_parameters | Return true if redraw is needed | src/urh/ui/painting/SpectrogramSceneManager.py | def set_parameters(self, samples: np.ndarray, window_size, data_min, data_max) -> bool:
"""
Return true if redraw is needed
"""
redraw_needed = False
if self.samples_need_update:
self.spectrogram.samples = samples
redraw_needed = True
self.samp... | def set_parameters(self, samples: np.ndarray, window_size, data_min, data_max) -> bool:
"""
Return true if redraw is needed
"""
redraw_needed = False
if self.samples_need_update:
self.spectrogram.samples = samples
redraw_needed = True
self.samp... | [
"Return",
"true",
"if",
"redraw",
"is",
"needed"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/painting/SpectrogramSceneManager.py#L24-L46 | [
"def",
"set_parameters",
"(",
"self",
",",
"samples",
":",
"np",
".",
"ndarray",
",",
"window_size",
",",
"data_min",
",",
"data_max",
")",
"->",
"bool",
":",
"redraw_needed",
"=",
"False",
"if",
"self",
".",
"samples_need_update",
":",
"self",
".",
"spect... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | MessageBreakPlugin.get_action | :type parent: QTableView
:type undo_stack: QUndoStack
:type protocol_analyzers: list of ProtocolAnalyzer | src/urh/plugins/MessageBreak/MessageBreakPlugin.py | def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int):
"""
:type parent: QTableView
:type undo_stack: QUndoStack
:type protocol_analyzers: list of ProtocolAnalyzer
"""
min_row, max_row, start, end = sel_range
if min... | def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int):
"""
:type parent: QTableView
:type undo_stack: QUndoStack
:type protocol_analyzers: list of ProtocolAnalyzer
"""
min_row, max_row, start, end = sel_range
if min... | [
":",
"type",
"parent",
":",
"QTableView",
":",
"type",
"undo_stack",
":",
"QUndoStack",
":",
"type",
"protocol_analyzers",
":",
"list",
"of",
"ProtocolAnalyzer"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/MessageBreak/MessageBreakPlugin.py#L16-L36 | [
"def",
"get_action",
"(",
"self",
",",
"parent",
",",
"undo_stack",
":",
"QUndoStack",
",",
"sel_range",
",",
"protocol",
":",
"ProtocolAnalyzer",
",",
"view",
":",
"int",
")",
":",
"min_row",
",",
"max_row",
",",
"start",
",",
"end",
"=",
"sel_range",
"... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Message.get_byte_length | Return the length of this message in byte. | src/urh/signalprocessing/Message.py | def get_byte_length(self, decoded=True) -> int:
"""
Return the length of this message in byte.
"""
end = len(self.decoded_bits) if decoded else len(self.__plain_bits)
end = self.convert_index(end, 0, 2, decoded=decoded)[0]
return int(end) | def get_byte_length(self, decoded=True) -> int:
"""
Return the length of this message in byte.
"""
end = len(self.decoded_bits) if decoded else len(self.__plain_bits)
end = self.convert_index(end, 0, 2, decoded=decoded)[0]
return int(end) | [
"Return",
"the",
"length",
"of",
"this",
"message",
"in",
"byte",
"."
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L155-L162 | [
"def",
"get_byte_length",
"(",
"self",
",",
"decoded",
"=",
"True",
")",
"->",
"int",
":",
"end",
"=",
"len",
"(",
"self",
".",
"decoded_bits",
")",
"if",
"decoded",
"else",
"len",
"(",
"self",
".",
"__plain_bits",
")",
"end",
"=",
"self",
".",
"conv... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Message.get_src_address_from_data | Return the SRC address of a message if SRC_ADDRESS label is present in message type of the message
Return None otherwise
:param decoded:
:return: | src/urh/signalprocessing/Message.py | def get_src_address_from_data(self, decoded=True):
"""
Return the SRC address of a message if SRC_ADDRESS label is present in message type of the message
Return None otherwise
:param decoded:
:return:
"""
src_address_label = next((lbl for lbl in self.message_type... | def get_src_address_from_data(self, decoded=True):
"""
Return the SRC address of a message if SRC_ADDRESS label is present in message type of the message
Return None otherwise
:param decoded:
:return:
"""
src_address_label = next((lbl for lbl in self.message_type... | [
"Return",
"the",
"SRC",
"address",
"of",
"a",
"message",
"if",
"SRC_ADDRESS",
"label",
"is",
"present",
"in",
"message",
"type",
"of",
"the",
"message",
"Return",
"None",
"otherwise"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L360-L379 | [
"def",
"get_src_address_from_data",
"(",
"self",
",",
"decoded",
"=",
"True",
")",
":",
"src_address_label",
"=",
"next",
"(",
"(",
"lbl",
"for",
"lbl",
"in",
"self",
".",
"message_type",
"if",
"lbl",
".",
"field_type",
"and",
"lbl",
".",
"field_type",
"."... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | Message.split | Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View)
:rtype: list of array.array | src/urh/signalprocessing/Message.py | def split(self, decode=True):
"""
Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View)
:rtype: list of array.array
"""
start = 0
result = []
message = self.decoded_bits if decode else self.plain_bits
bit_alignments = set()
if self.align_labe... | def split(self, decode=True):
"""
Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View)
:rtype: list of array.array
"""
start = 0
result = []
message = self.decoded_bits if decode else self.plain_bits
bit_alignments = set()
if self.align_labe... | [
"Für",
"das",
"Bit",
"-",
"Alignment",
"(",
"neu",
"Ausrichten",
"von",
"Hex",
"ASCII",
"-",
"View",
")"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L409-L431 | [
"def",
"split",
"(",
"self",
",",
"decode",
"=",
"True",
")",
":",
"start",
"=",
"0",
"result",
"=",
"[",
"]",
"message",
"=",
"self",
".",
"decoded_bits",
"if",
"decode",
"else",
"self",
".",
"plain_bits",
"bit_alignments",
"=",
"set",
"(",
")",
"if... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | DecoderDialog.set_e | :type: encoding | src/urh/controller/dialogs/DecoderDialog.py | def set_e(self):
if self.ui.combobox_decodings.count() < 1: # Empty list
return
self.e = copy.deepcopy(self.decodings[self.ui.combobox_decodings.currentIndex()])
""":type: encoding """
chain = self.e.get_chain()
self.ui.decoderchain.clear()
self.chainoptions... | def set_e(self):
if self.ui.combobox_decodings.count() < 1: # Empty list
return
self.e = copy.deepcopy(self.decodings[self.ui.combobox_decodings.currentIndex()])
""":type: encoding """
chain = self.e.get_chain()
self.ui.decoderchain.clear()
self.chainoptions... | [
":",
"type",
":",
"encoding"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/dialogs/DecoderDialog.py#L202-L230 | [
"def",
"set_e",
"(",
"self",
")",
":",
"if",
"self",
".",
"ui",
".",
"combobox_decodings",
".",
"count",
"(",
")",
"<",
"1",
":",
"# Empty list",
"return",
"self",
".",
"e",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"decodings",
"[",
"self",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
train | ProtocolTreeModel.protocols | :rtype: dict[int, list of ProtocolAnalyzer] | src/urh/models/ProtocolTreeModel.py | def protocols(self):
"""
:rtype: dict[int, list of ProtocolAnalyzer]
"""
result = {}
for i, group in enumerate(self.rootItem.children):
result[i] = [child.protocol for child in group.children]
return result | def protocols(self):
"""
:rtype: dict[int, list of ProtocolAnalyzer]
"""
result = {}
for i, group in enumerate(self.rootItem.children):
result[i] = [child.protocol for child in group.children]
return result | [
":",
"rtype",
":",
"dict",
"[",
"int",
"list",
"of",
"ProtocolAnalyzer",
"]"
] | jopohl/urh | python | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeModel.py#L25-L33 | [
"def",
"protocols",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"i",
",",
"group",
"in",
"enumerate",
"(",
"self",
".",
"rootItem",
".",
"children",
")",
":",
"result",
"[",
"i",
"]",
"=",
"[",
"child",
".",
"protocol",
"for",
"child",
... | 2eb33b125c8407964cd1092843cde5010eb88aae |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.