code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _parse_remote_origin_url(url: str) -> Optional[str]:
"""
Parse a `git remote origin url` into a formatted "hostname/project" string
Returns
-------
str
formatted project origin url
"""
parsed = urlparse(url)
if not parsed.path:
return None
formatted = (parsed.ho... |
Parse a `git remote origin url` into a formatted "hostname/project" string
Returns
-------
str
formatted project origin url
| _parse_remote_origin_url | python | aws/aws-sam-cli | samcli/lib/telemetry/project_metadata.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/project_metadata.py | Apache-2.0 |
def _hash_value(value: str) -> str:
"""Hash a string, and then return the hashed value as a byte string."""
h = hashlib.sha256()
h.update(value.encode("utf-8"))
return h.hexdigest() | Hash a string, and then return the hashed value as a byte string. | _hash_value | python | aws/aws-sam-cli | samcli/lib/telemetry/project_metadata.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/project_metadata.py | Apache-2.0 |
def __init__(self, url=None):
"""
Initialize the Telemetry object.
Parameters
----------
url : str
Optional, URL where the metrics should be published to
"""
self._url = url or DEFAULT_ENDPOINT_URL
LOG.debug("Telemetry endpoint configured to b... |
Initialize the Telemetry object.
Parameters
----------
url : str
Optional, URL where the metrics should be published to
| __init__ | python | aws/aws-sam-cli | samcli/lib/telemetry/telemetry.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/telemetry.py | Apache-2.0 |
def _send(self, metric, wait_for_response=False):
"""
Serializes the metric data to JSON and sends to the backend.
Parameters
----------
metric : dict
Dictionary of metric data to send to backend.
wait_for_response : bool
If set to True, this me... |
Serializes the metric data to JSON and sends to the backend.
Parameters
----------
metric : dict
Dictionary of metric data to send to backend.
wait_for_response : bool
If set to True, this method will wait until the HTTP server returns a response. If n... | _send | python | aws/aws-sam-cli | samcli/lib/telemetry/telemetry.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/telemetry.py | Apache-2.0 |
def __init__(
self,
sam_template: dict,
managed_policy_loader: ManagedPolicyLoader,
profile: Optional[str] = None,
region: Optional[str] = None,
parameter_overrides: Optional[dict] = None,
):
"""
Construct a SamTemplateValidator
Design Details... |
Construct a SamTemplateValidator
Design Details:
managed_policy_loader is injected into the `__init__` to allow future expansion
and overriding capabilities. A typically pattern is to pass the name of the class into
the `__init__` as keyword args. As long as the class 'conform... | __init__ | python | aws/aws-sam-cli | samcli/lib/translate/sam_template_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/translate/sam_template_validator.py | Apache-2.0 |
def get_translated_template_if_valid(self):
"""
Runs the SAM Translator to determine if the template provided is valid. This is similar to running a
ChangeSet in CloudFormation for a SAM Template
Raises
-------
InvalidSamDocumentException
If the template is ... |
Runs the SAM Translator to determine if the template provided is valid. This is similar to running a
ChangeSet in CloudFormation for a SAM Template
Raises
-------
InvalidSamDocumentException
If the template is not valid, an InvalidSamDocumentException is raised
... | get_translated_template_if_valid | python | aws/aws-sam-cli | samcli/lib/translate/sam_template_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/translate/sam_template_validator.py | Apache-2.0 |
def _replace_local_codeuri(self):
"""
Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in AWS::Serverless::Api and
AWS::Serverless::HttpApi to a fake S3 Uri. This is to support running the SAM Translator with
valid values for these fields. If this in not done, the temp... |
Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in AWS::Serverless::Api and
AWS::Serverless::HttpApi to a fake S3 Uri. This is to support running the SAM Translator with
valid values for these fields. If this in not done, the template is invalid in the eyes of SAM
Tr... | _replace_local_codeuri | python | aws/aws-sam-cli | samcli/lib/translate/sam_template_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/translate/sam_template_validator.py | Apache-2.0 |
def _replace_local_image(self):
"""
Adds fake ImageUri to AWS::Serverless::Functions that reference a local image using Metadata.
This ensures sam validate works without having to package the app or use ImageUri.
"""
resources = self.sam_template.get("Resources", {})
for ... |
Adds fake ImageUri to AWS::Serverless::Functions that reference a local image using Metadata.
This ensures sam validate works without having to package the app or use ImageUri.
| _replace_local_image | python | aws/aws-sam-cli | samcli/lib/translate/sam_template_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/translate/sam_template_validator.py | Apache-2.0 |
def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value="s3://bucket/value"):
"""
Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value'
Note: The function will mutate the resource_property_dict that is pass in
Parameters
----... |
Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value'
Note: The function will mutate the resource_property_dict that is pass in
Parameters
----------
property_key str, required
Key in the resource_property_dict
resource_p... | _update_to_s3_uri | python | aws/aws-sam-cli | samcli/lib/translate/sam_template_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/translate/sam_template_validator.py | Apache-2.0 |
def validate_architecture_runtime(function: "Function") -> None:
"""
Validates that a function runtime and architecture are compatible for invoking
Parameters
----------
function : samcli.commands.local.lib.provider.Function
Lambda function
Raises
------
samcli.commands.local.l... |
Validates that a function runtime and architecture are compatible for invoking
Parameters
----------
function : samcli.commands.local.lib.provider.Function
Lambda function
Raises
------
samcli.commands.local.lib.exceptions.UnsupportedRuntimeArchitectureError
If the runtime... | validate_architecture_runtime | python | aws/aws-sam-cli | samcli/lib/utils/architecture.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/architecture.py | Apache-2.0 |
def validate_architecture(architecture: str) -> None:
"""
Validates an architecture value
Parameters
----------
architecture : str
Value
Raises
------
InvalidArchitecture
If the architecture is unknown
"""
if architecture not in [ARM64, X86_64]:
raise In... |
Validates an architecture value
Parameters
----------
architecture : str
Value
Raises
------
InvalidArchitecture
If the architecture is unknown
| validate_architecture | python | aws/aws-sam-cli | samcli/lib/utils/architecture.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/architecture.py | Apache-2.0 |
async def _run_given_tasks_async(
tasks: List[Callable], event_loop: AbstractEventLoop, executor: Optional[ThreadPoolExecutor] = None
) -> list:
"""
Given list of Task objects, this method executes all tasks in the given event loop (or default one)
and returns list of the results.
The list of the re... |
Given list of Task objects, this method executes all tasks in the given event loop (or default one)
and returns list of the results.
The list of the results are in the same order as the list of the input.
Ex; If we say we are going to execute
Task1, Task2 and Task3; and their results are Result1, ... | _run_given_tasks_async | python | aws/aws-sam-cli | samcli/lib/utils/async_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/async_utils.py | Apache-2.0 |
def run_given_tasks_async(
tasks: List[Callable], event_loop: AbstractEventLoop, executor: Optional[ThreadPoolExecutor] = None
) -> list:
"""
Runs the given list of tasks in the given (or default) event loop.
This function will wait for execution to be completed
See _run_given_tasks_async for detai... |
Runs the given list of tasks in the given (or default) event loop.
This function will wait for execution to be completed
See _run_given_tasks_async for details
Parameters
----------
tasks: list of Task definitions that will be executed
event_loop: EventLoop instance that will be used to ... | run_given_tasks_async | python | aws/aws-sam-cli | samcli/lib/utils/async_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/async_utils.py | Apache-2.0 |
def run_async(self, default_executor: bool = True) -> list:
"""
Will run all collected functions in async context, and return their results in order
Parameters
----------
default_executor: bool
Determines if the async object will run using the default executor, or wi... |
Will run all collected functions in async context, and return their results in order
Parameters
----------
default_executor: bool
Determines if the async object will run using the default executor, or with a new created executor
Returns
-------
List... | run_async | python | aws/aws-sam-cli | samcli/lib/utils/async_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/async_utils.py | Apache-2.0 |
def get_boto_config_with_user_agent(**kwargs) -> Config:
"""
Automatically add user agent string to boto configs.
Parameters
----------
kwargs :
key=value params which will be added to the Config object
Returns
-------
Config
Returns config instance which contains given... |
Automatically add user agent string to boto configs.
Parameters
----------
kwargs :
key=value params which will be added to the Config object
Returns
-------
Config
Returns config instance which contains given parameters in it
| get_boto_config_with_user_agent | python | aws/aws-sam-cli | samcli/lib/utils/boto_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/boto_utils.py | Apache-2.0 |
def get_boto_client_provider_with_config(
region: Optional[str] = None, profile: Optional[str] = None, **kwargs
) -> BotoProviderType:
"""
Returns a wrapper function for boto client with given configuration. It can be used like;
client_provider = get_boto_client_wrapper_with_config(region_name=region)
... |
Returns a wrapper function for boto client with given configuration. It can be used like;
client_provider = get_boto_client_wrapper_with_config(region_name=region)
lambda_client = client_provider("lambda")
Parameters
----------
region: Optional[str]
AWS region name
profile: Option... | get_boto_client_provider_with_config | python | aws/aws-sam-cli | samcli/lib/utils/boto_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/boto_utils.py | Apache-2.0 |
def get_boto_resource_provider_with_config(
region: Optional[str] = None, profile: Optional[str] = None, **kwargs
) -> BotoProviderType:
"""
Returns a wrapper function for boto resource with given configuration. It can be used like;
resource_provider = get_boto_resource_wrapper_with_config(region_name=... |
Returns a wrapper function for boto resource with given configuration. It can be used like;
resource_provider = get_boto_resource_wrapper_with_config(region_name=region)
cloudformation_resource = resource_provider("cloudformation")
Parameters
----------
region: Optional[str]
AWS regio... | get_boto_resource_provider_with_config | python | aws/aws-sam-cli | samcli/lib/utils/boto_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/boto_utils.py | Apache-2.0 |
def get_resource_summaries(
boto_resource_provider: BotoProviderType,
boto_client_provider: BotoProviderType,
stack_name: str,
resource_types: Optional[Set[str]] = None,
nested_stack_prefix: Optional[str] = None,
) -> Dict[str, CloudFormationResourceSummary]:
"""
Collects information about C... |
Collects information about CFN resources and return their summary as list
Parameters
----------
boto_resource_provider : BotoProviderType
A callable which will return boto3 resource
boto_client_provider : BotoProviderType
A callable which will return boto3 client
stack_name : s... | get_resource_summaries | python | aws/aws-sam-cli | samcli/lib/utils/cloudformation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/cloudformation.py | Apache-2.0 |
def get_resource_summary(
boto_resource_provider: BotoProviderType,
boto_client_provider: BotoProviderType,
stack_name: str,
resource_logical_id: str,
) -> Optional[CloudFormationResourceSummary]:
"""
Returns resource summary of given single resource with its logical id
Parameters
-----... |
Returns resource summary of given single resource with its logical id
Parameters
----------
boto_resource_provider : BotoProviderType
A callable which will return boto3 resource
boto_client_provider : BotoProviderType
A callable which will return boto3 client
stack_name : str
... | get_resource_summary | python | aws/aws-sam-cli | samcli/lib/utils/cloudformation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/cloudformation.py | Apache-2.0 |
def get_resource_summary_from_physical_id(
boto_client_provider: BotoProviderType, resource_physical_id: str
) -> Optional[CloudFormationResourceSummary]:
"""
Returns resource summary from the physical id of the resource. Returns None if no resource can be found
Parameters
----------
boto_clien... |
Returns resource summary from the physical id of the resource. Returns None if no resource can be found
Parameters
----------
boto_client_provider : BotoProviderType
A callable which will return boto3 client
resource_physical_id : str
Physical ID of the resource that will be return... | get_resource_summary_from_physical_id | python | aws/aws-sam-cli | samcli/lib/utils/cloudformation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/cloudformation.py | Apache-2.0 |
def list_active_stack_names(boto_client_provider: BotoProviderType, show_nested_stacks: bool = False) -> Iterable[str]:
"""
Returns list of active cloudformation stack names
Parameters
----------
boto_client_provider : BotoProviderType
A callable which will return boto3 client
show_nest... |
Returns list of active cloudformation stack names
Parameters
----------
boto_client_provider : BotoProviderType
A callable which will return boto3 client
show_nested_stacks : bool
True; will display nested stack names as well. False; will hide nested stack names from the list.
... | list_active_stack_names | python | aws/aws-sam-cli | samcli/lib/utils/cloudformation.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/cloudformation.py | Apache-2.0 |
def resolve_code_path(cwd, codeuri):
"""
Returns path to the function code resolved based on current working directory.
Parameters
----------
cwd : str
Current working directory
codeuri : str
CodeURI of the function. This should contain the path to the function code
Returns... |
Returns path to the function code resolved based on current working directory.
Parameters
----------
cwd : str
Current working directory
codeuri : str
CodeURI of the function. This should contain the path to the function code
Returns
-------
str
Absolute path t... | resolve_code_path | python | aws/aws-sam-cli | samcli/lib/utils/codeuri.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/codeuri.py | Apache-2.0 |
def create_trigger(
self, resource_identifier: ResourceIdentifier, on_code_change: Callable, watch_exclude: List[str]
) -> Optional[CodeResourceTrigger]:
"""Create Trigger for the resource type
Parameters
----------
resource_identifier : ResourceIdentifier
Resour... | Create Trigger for the resource type
Parameters
----------
resource_identifier : ResourceIdentifier
Resource associated with the trigger
on_code_change : Callable
Callback for code change
Returns
-------
Optional[CodeResourceTrigger]
... | create_trigger | python | aws/aws-sam-cli | samcli/lib/utils/code_trigger_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/code_trigger_factory.py | Apache-2.0 |
def __init__(self, colorize=True):
"""
Initialize the object
Parameters
----------
colorize : bool
Optional. Set this to True to turn on coloring. False will turn off coloring
"""
self.rich_logging = any(
isinstance(handler, RichHandler) f... |
Initialize the object
Parameters
----------
colorize : bool
Optional. Set this to True to turn on coloring. False will turn off coloring
| __init__ | python | aws/aws-sam-cli | samcli/lib/utils/colors.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/colors.py | Apache-2.0 |
def underline_log(self, msg):
"""Underline the input such that underlying Rich Logger understands it (if configured)."""
if self.rich_logging:
_color_msg = Text(msg, style=Style(underline=True))
return _color_msg.markup if self.colorize else msg
else:
return c... | Underline the input such that underlying Rich Logger understands it (if configured). | underline_log | python | aws/aws-sam-cli | samcli/lib/utils/colors.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/colors.py | Apache-2.0 |
def _color(self, msg, color):
"""Internal helper method to add colors to input"""
kwargs = {"fg": color}
return click.style(msg, **kwargs) if self.colorize else msg | Internal helper method to add colors to input | _color | python | aws/aws-sam-cli | samcli/lib/utils/colors.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/colors.py | Apache-2.0 |
def _color_log(self, msg, color):
"""Marked up text with color used for logging with a logger"""
_color_msg = Text(msg, style=Style(color=color))
return _color_msg.markup if self.colorize else msg | Marked up text with color used for logging with a logger | _color_log | python | aws/aws-sam-cli | samcli/lib/utils/colors.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/colors.py | Apache-2.0 |
def __init__(self, path: Path, detect_change: bool = True, initialize_data: bool = True) -> None:
"""
Validator for JSON and YAML files.
Calling validate_change() will return True if the definition is valid and has changes.
Parameters
----------
path : Path
P... |
Validator for JSON and YAML files.
Calling validate_change() will return True if the definition is valid and has changes.
Parameters
----------
path : Path
Path to the definition file
detect_change : bool, optional
validation will only be success... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/definition_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/definition_validator.py | Apache-2.0 |
def validate_change(self, event: Optional[FileSystemEvent] = None) -> bool:
"""Validate change on json or yaml file.
Returns
-------
bool
True if it is valid, False otherwise.
If detect_change is set, False will also be returned if there is
no change ... | Validate change on json or yaml file.
Returns
-------
bool
True if it is valid, False otherwise.
If detect_change is set, False will also be returned if there is
no change compared to the previous validation.
| validate_change | python | aws/aws-sam-cli | samcli/lib/utils/definition_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/definition_validator.py | Apache-2.0 |
def validate_file(self) -> bool:
"""Validate json or yaml file.
Returns
-------
bool
True if it is valid path and yaml file, False otherwise.
"""
if not self._path.exists():
LOG.debug(
"File %s failed to validate due to file path d... | Validate json or yaml file.
Returns
-------
bool
True if it is valid path and yaml file, False otherwise.
| validate_file | python | aws/aws-sam-cli | samcli/lib/utils/definition_validator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/definition_validator.py | Apache-2.0 |
def watch(self, resource: str) -> None:
"""
Start watching the input resource.
Parameters
----------
resource: str
The resource that should be observed for modifications
Raises
------
ObserverException:
if the input resource is no... |
Start watching the input resource.
Parameters
----------
resource: str
The resource that should be observed for modifications
Raises
------
ObserverException:
if the input resource is not exist
| watch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def unwatch(self, resource: str) -> None:
"""
Remove the input resource form the observed resorces
Parameters
----------
resource: str
The resource to be unobserved
""" |
Remove the input resource form the observed resorces
Parameters
----------
resource: str
The resource to be unobserved
| unwatch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def __init__(self, on_change: Callable) -> None:
"""
Initialize the Image observer
Parameters
----------
on_change:
Reference to the function that will be called if there is a change in aby of the observed image
"""
self._observers: Dict[str, ResourceO... |
Initialize the Image observer
Parameters
----------
on_change:
Reference to the function that will be called if there is a change in aby of the observed image
| __init__ | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def _get_zip_lambda_function_paths(function_config: FunctionConfig) -> List[str]:
"""
Returns a list of ZIP package type lambda function source code paths
Parameters
----------
function_config: FunctionConfig
The lambda function configuration ... |
Returns a list of ZIP package type lambda function source code paths
Parameters
----------
function_config: FunctionConfig
The lambda function configuration that will be observed
Returns
-------
list[str]
... | _get_zip_lambda_function_paths | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def _on_change(self, resources: List[str], package_type: str) -> None:
"""
It got executed once there is a change in one of the watched lambda functions' resources.
Parameters
----------
resources: list[str]
the changed lambda functions' resources (either source code... |
It got executed once there is a change in one of the watched lambda functions' resources.
Parameters
----------
resources: list[str]
the changed lambda functions' resources (either source code path pr image names)
package_type: str
determine if the chang... | _on_change | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def watch(self, function_config: FunctionConfig) -> None:
"""
Start watching the input lambda function.
Parameters
----------
function_config: FunctionConfig
The lambda function configuration that will be observed
Raises
------
ObserverExcept... |
Start watching the input lambda function.
Parameters
----------
function_config: FunctionConfig
The lambda function configuration that will be observed
Raises
------
ObserverException:
if not able to observe the input function source pat... | watch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def unwatch(self, function_config: FunctionConfig) -> None:
"""
Remove the input lambda function from the observed functions
Parameters
----------
function_config: FunctionConfig
The lambda function configuration that will be observed
"""
if self.get_... |
Remove the input lambda function from the observed functions
Parameters
----------
function_config: FunctionConfig
The lambda function configuration that will be observed
| unwatch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def broken_pipe_handler(func: Callable) -> Callable:
"""
Decorator to handle the Windows API BROKEN_PIPE_ERROR error.
Parameters
----------
func: Callable
The method to wrap around
"""
# NOTE: As of right now, this checks for the Windows API error 109
# specifically. This could... |
Decorator to handle the Windows API BROKEN_PIPE_ERROR error.
Parameters
----------
func: Callable
The method to wrap around
| broken_pipe_handler | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def watch(self, resource: str) -> None:
"""
Start watching the input image.
Parameters
----------
resource: str
The container image name that will be observed
Raises
------
ImageObserverException:
if the input image_name is not ex... |
Start watching the input image.
Parameters
----------
resource: str
The container image name that will be observed
Raises
------
ImageObserverException:
if the input image_name is not exist
| watch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def __init__(self, on_change: Callable) -> None:
"""
Initialize the file observer
Parameters
----------
on_change:
Reference to the function that will be called if there is a change in aby of the observed paths
"""
self._group = str(uuid.uuid4())
... |
Initialize the file observer
Parameters
----------
on_change:
Reference to the function that will be called if there is a change in aby of the observed paths
| __init__ | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def on_change(self, event: FileSystemEvent) -> None:
"""
It got executed once there is a change in one of the paths that watchdog is observing.
This method will check if any of the input paths is really changed, and based on that it will
invoke the input on_change function with the chang... |
It got executed once there is a change in one of the paths that watchdog is observing.
This method will check if any of the input paths is really changed, and based on that it will
invoke the input on_change function with the changed paths
Parameters
----------
event: w... | on_change | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def add_group(self, group: str, on_change: Callable) -> None:
"""
Add new group to file observer. This enable FileObserver to watch the same path for
multiple purposes.
Parameters
----------
group: str
unique string define a new group of paths to be watched.
... |
Add new group to file observer. This enable FileObserver to watch the same path for
multiple purposes.
Parameters
----------
group: str
unique string define a new group of paths to be watched.
on_change: Callable
The method to be called in case ... | add_group | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def watch(self, resource: str, group: str) -> None:
"""
Start watching the input path. File Observer will keep track of the input path with its hash, to check it later
if it got really changed or not.
File Observer will send the parent path to watchdog for to be observed to avoid the mis... |
Start watching the input path. File Observer will keep track of the input path with its hash, to check it later
if it got really changed or not.
File Observer will send the parent path to watchdog for to be observed to avoid the missing events if the input
paths got deleted.
Pa... | watch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def _watch_path(
self, watch_dog_path: str, original_path: str, watcher_handler: FileSystemEventHandler, recursive: bool
) -> None:
"""
update the observed paths data structure, and call watch dog observer to observe the input watch dog path
if it is not observed before
Para... |
update the observed paths data structure, and call watch dog observer to observe the input watch dog path
if it is not observed before
Parameters
----------
watch_dog_path: str
The file/dir path to be observed by watch dog
original_path: str
The ... | _watch_path | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def unwatch(self, resource: str, group: str) -> None:
"""
Remove the input path form the observed paths, and stop watching this path.
Parameters
----------
resource: str
The file/dir path to be unobserved
group: str
unique string define a new grou... |
Remove the input path form the observed paths, and stop watching this path.
Parameters
----------
resource: str
The file/dir path to be unobserved
group: str
unique string define a new group of paths to be watched.
| unwatch | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def _unwatch_path(self, watch_dog_path: str, original_path: str, group: str, recursive: bool) -> None:
"""
update the observed paths data structure, and call watch dog observer to unobserve the input watch dog path
if it is not observed before
Parameters
----------
watch... |
update the observed paths data structure, and call watch dog observer to unobserve the input watch dog path
if it is not observed before
Parameters
----------
watch_dog_path: str
The file/dir path to be unobserved by watch dog
original_path: str
... | _unwatch_path | python | aws/aws-sam-cli | samcli/lib/utils/file_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/file_observer.py | Apache-2.0 |
def find_all_paths_and_values(property_name: str, graphql_dict: Dict[str, Any]) -> List[Tuple[str, Union[str, Dict]]]:
"""Find paths to the all properties with property_name and their (properties) values.
It leverages the knowledge of GraphQLApi structure instead of doing generic search in the graph.
Para... | Find paths to the all properties with property_name and their (properties) values.
It leverages the knowledge of GraphQLApi structure instead of doing generic search in the graph.
Parameters
----------
property_name
Name of the property to look up, for example 'CodeUri'
graphql_dict
... | find_all_paths_and_values | python | aws/aws-sam-cli | samcli/lib/utils/graphql_api.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/graphql_api.py | Apache-2.0 |
def file_checksum(file_name: str, hash_generator: Any = None) -> str:
"""
Parameters
----------
file_name : str
file name of the file for which md5 checksum is required.
hash_generator : hashlib._Hash
hashlib _Hash object for generating hashes. Defaults to hashlib.md5.
Returns
... |
Parameters
----------
file_name : str
file name of the file for which md5 checksum is required.
hash_generator : hashlib._Hash
hashlib _Hash object for generating hashes. Defaults to hashlib.md5.
Returns
-------
checksum of the given file.
| file_checksum | python | aws/aws-sam-cli | samcli/lib/utils/hash.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/hash.py | Apache-2.0 |
def dir_checksum(
directory: str, followlinks: bool = True, ignore_list: Optional[List[str]] = None, hash_generator: Any = None
) -> str:
"""
Parameters
----------
directory : dict
A directory with an absolute path
followlinks : bool
Follow symbolic links through the given direc... |
Parameters
----------
directory : dict
A directory with an absolute path
followlinks : bool
Follow symbolic links through the given directory
ignore_list : list(str)
The list of file/directory names to ignore in checksum
hash_generator : hashlib._Hash
The hashin... | dir_checksum | python | aws/aws-sam-cli | samcli/lib/utils/hash.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/hash.py | Apache-2.0 |
def str_checksum(content: str, hash_generator: Any = None) -> str:
"""
return a md5 checksum of a given string
Parameters
----------
content: string
the string to be hashed
hash_generator : hashlib._Hash
The hashing method (hashlib _Hash object) that generates checksum. Default... |
return a md5 checksum of a given string
Parameters
----------
content: string
the string to be hashed
hash_generator : hashlib._Hash
The hashing method (hashlib _Hash object) that generates checksum. Defaults to hashlib.md5.
Returns
-------
md5 checksum of content
| str_checksum | python | aws/aws-sam-cli | samcli/lib/utils/hash.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/hash.py | Apache-2.0 |
def __init__(
self,
lock_type: LockDistributorType = LockDistributorType.THREAD,
manager: Optional[multiprocessing.managers.SyncManager] = None,
):
"""[summary]
Parameters
----------
lock_type : LockDistributorType, optional
Whether locking with t... | [summary]
Parameters
----------
lock_type : LockDistributorType, optional
Whether locking with threads or processes, by default LockDistributorType.THREAD
manager : Optional[multiprocessing.managers.SyncManager], optional
Optional process sync mananger for creati... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/lock_distributor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/lock_distributor.py | Apache-2.0 |
def _create_new_lock(self) -> threading.Lock:
"""Create a new lock based on lock type
Returns
-------
threading.Lock
Newly created lock
"""
if self._lock_type == LockDistributorType.THREAD:
return threading.Lock()
return self._manager.Loc... | Create a new lock based on lock type
Returns
-------
threading.Lock
Newly created lock
| _create_new_lock | python | aws/aws-sam-cli | samcli/lib/utils/lock_distributor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/lock_distributor.py | Apache-2.0 |
def get_lock(self, key: str) -> threading.Lock:
"""Retrieve a lock associating with the key
If the lock does not exist, a new lock will be created.
Parameters
----------
key : Key for retrieving the lock
Returns
-------
threading.Lock
Lock as... | Retrieve a lock associating with the key
If the lock does not exist, a new lock will be created.
Parameters
----------
key : Key for retrieving the lock
Returns
-------
threading.Lock
Lock associated with the key
| get_lock | python | aws/aws-sam-cli | samcli/lib/utils/lock_distributor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/lock_distributor.py | Apache-2.0 |
def get_locks(self, keys: Set[str]) -> Dict[str, threading.Lock]:
"""Retrieve a list of locks associating with keys
Parameters
----------
keys : Set[str]
Set of keys for retrieving the locks
Returns
-------
Dict[str, threading.Lock]
Dicti... | Retrieve a list of locks associating with keys
Parameters
----------
keys : Set[str]
Set of keys for retrieving the locks
Returns
-------
Dict[str, threading.Lock]
Dictionary mapping keys to locks
| get_locks | python | aws/aws-sam-cli | samcli/lib/utils/lock_distributor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/lock_distributor.py | Apache-2.0 |
def update_stack(
region: Optional[str],
stack_name: str,
template_body: str,
profile: Optional[str] = None,
parameter_overrides: Optional[Dict[str, Union[str, List[str]]]] = None,
) -> StackOutput:
"""
create or update a CloudFormation stack
Parameters
----------
region: str
... |
create or update a CloudFormation stack
Parameters
----------
region: str
AWS region for the CloudFormation stack
stack_name: str
CloudFormation stack name
template_body: str
CloudFormation template's content
profile: Optional[str]
AWS named profile for the ... | update_stack | python | aws/aws-sam-cli | samcli/lib/utils/managed_cloudformation_stack.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/managed_cloudformation_stack.py | Apache-2.0 |
def manage_stack(
region: Optional[str],
stack_name: str,
template_body: str,
profile: Optional[str] = None,
parameter_overrides: Optional[Dict[str, Union[str, List[str]]]] = None,
) -> StackOutput:
"""
get or create a CloudFormation stack
Parameters
----------
region: str
... |
get or create a CloudFormation stack
Parameters
----------
region: str
AWS region for the CloudFormation stack
stack_name: str
CloudFormation stack name
template_body: str
CloudFormation template's content
profile: Optional[str]
AWS named profile for the AWS... | manage_stack | python | aws/aws-sam-cli | samcli/lib/utils/managed_cloudformation_stack.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/managed_cloudformation_stack.py | Apache-2.0 |
def mkdir_temp(mode=0o755, ignore_errors=False):
"""
Context manager that makes a temporary directory and yields it name. Directory is deleted
after the context exits
Parameters
----------
mode : octal
Permissions to apply to the directory. Defaults to '755' because don't want directori... |
Context manager that makes a temporary directory and yields it name. Directory is deleted
after the context exits
Parameters
----------
mode : octal
Permissions to apply to the directory. Defaults to '755' because don't want directories world writable
ignore_errors : boolean
I... | mkdir_temp | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def rmtree_callback(function, path, excinfo):
"""
Callback function for shutil.rmtree to change permissions on the file path, so that
it's delete-able incase the file path is read-only.
:param function: platform and implementation dependent function.
:param path: argument to the function that caused... |
Callback function for shutil.rmtree to change permissions on the file path, so that
it's delete-able incase the file path is read-only.
:param function: platform and implementation dependent function.
:param path: argument to the function that caused it to fail.
:param excinfo: tuple returned by sy... | rmtree_callback | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def rmtree_if_exists(path: Union[str, Path]):
"""Removes given path if the path exists"""
path_obj = Path(str(path))
if path_obj.exists():
LOG.debug("Cleaning up path %s", str(path))
shutil.rmtree(path_obj) | Removes given path if the path exists | rmtree_if_exists | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def stdout() -> io.TextIOWrapper:
"""
Returns the stdout as a byte stream in a Py2/PY3 compatible manner
Returns
-------
io.BytesIO
Byte stream of Stdout
"""
# ensure stdout is utf8
stdout_text_io = cast(io.TextIOWrapper, sys.stdout)
stdout_text_io.reconfigure(encoding="utf... |
Returns the stdout as a byte stream in a Py2/PY3 compatible manner
Returns
-------
io.BytesIO
Byte stream of Stdout
| stdout | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def stderr() -> io.TextIOWrapper:
"""
Returns the stderr as a byte stream in a Py2/PY3 compatible manner
Returns
-------
io.BytesIO
Byte stream of stderr
"""
# ensure stderr is utf8
stderr_text_io = cast(io.TextIOWrapper, sys.stderr)
stderr_text_io.reconfigure(encoding="utf-... |
Returns the stderr as a byte stream in a Py2/PY3 compatible manner
Returns
-------
io.BytesIO
Byte stream of stderr
| stderr | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def create_symlink_or_copy(source: str, destination: str) -> None:
"""Tries to create symlink, if it fails it will copy source into destination"""
LOG.debug("Creating symlink; source: %s, destination: %s", source, destination)
try:
os.symlink(Path(source).absolute(), Path(destination).absolute())
... | Tries to create symlink, if it fails it will copy source into destination | create_symlink_or_copy | python | aws/aws-sam-cli | samcli/lib/utils/osutils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/osutils.py | Apache-2.0 |
def __init__(self, observer: "HandlerObserver", initial_watch: ObservedWatch, path_handler: PathHandler):
"""[summary]
Parameters
----------
observer : HandlerObserver
HandlerObserver
initial_watch : ObservedWatch
Initial watch for the folder to be watche... | [summary]
Parameters
----------
observer : HandlerObserver
HandlerObserver
initial_watch : ObservedWatch
Initial watch for the folder to be watched that gets returned by HandlerObserver
path_handler : PathHandler
PathHandler of the folder to b... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/path_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_observer.py | Apache-2.0 |
def _on_parent_change(self, event: FileSystemEvent) -> None:
"""
Callback for changes detected in the parent folder
Parameters
----------
event: FileSystemEvent
event
"""
if event.event_type == EVENT_TYPE_OPENED:
LOG.debug("Ignoring file s... |
Callback for changes detected in the parent folder
Parameters
----------
event: FileSystemEvent
event
| _on_parent_change | python | aws/aws-sam-cli | samcli/lib/utils/path_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_observer.py | Apache-2.0 |
def get_dir_parent_path_handler(self) -> PathHandler:
"""Get PathHandler that watches the folder changes from the parent folder.
Returns
-------
PathHandler
PathHandler for the parent folder. This should be added back into the HandlerObserver.
"""
dir_path = ... | Get PathHandler that watches the folder changes from the parent folder.
Returns
-------
PathHandler
PathHandler for the parent folder. This should be added back into the HandlerObserver.
| get_dir_parent_path_handler | python | aws/aws-sam-cli | samcli/lib/utils/path_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_observer.py | Apache-2.0 |
def schedule_handlers(self, path_handlers: List[PathHandler]) -> List[ObservedWatch]:
"""Schedule a list of PathHandlers
Parameters
----------
path_handlers : List[PathHandler]
List of PathHandlers to be scheduled
Returns
-------
List[ObservedWatch]
... | Schedule a list of PathHandlers
Parameters
----------
path_handlers : List[PathHandler]
List of PathHandlers to be scheduled
Returns
-------
List[ObservedWatch]
List of ObservedWatch corresponding to path_handlers in the same order.
| schedule_handlers | python | aws/aws-sam-cli | samcli/lib/utils/path_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_observer.py | Apache-2.0 |
def schedule_handler(self, path_handler: PathHandler) -> ObservedWatch:
"""Schedule a PathHandler
Parameters
----------
path_handler : PathHandler
PathHandler to be scheduled
Returns
-------
ObservedWatch
ObservedWatch corresponding to th... | Schedule a PathHandler
Parameters
----------
path_handler : PathHandler
PathHandler to be scheduled
Returns
-------
ObservedWatch
ObservedWatch corresponding to the PathHandler.
If static_folder is True, the parent folder watch will b... | schedule_handler | python | aws/aws-sam-cli | samcli/lib/utils/path_observer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_observer.py | Apache-2.0 |
def check_path_valid_type(path) -> bool:
"""
Checks the input to see if is a valid type to be a path, returning false if otherwise
Parameters
----------
path: str
the path to be checked
Returns
-------
bool
if the input is a valid path type
"""
if isinstance(path... |
Checks the input to see if is a valid type to be a path, returning false if otherwise
Parameters
----------
path: str
the path to be checked
Returns
-------
bool
if the input is a valid path type
| check_path_valid_type | python | aws/aws-sam-cli | samcli/lib/utils/path_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/path_utils.py | Apache-2.0 |
def get_packageable_resource_paths():
"""
Resource Types with respective Locations that are package-able.
Returns
------
_resource_property_dict : Dict
Resource Dictionary containing packageable resource types and their locations as a list.
"""
_resource_property_dict = defaultdict(... |
Resource Types with respective Locations that are package-able.
Returns
------
_resource_property_dict : Dict
Resource Dictionary containing packageable resource types and their locations as a list.
| get_packageable_resource_paths | python | aws/aws-sam-cli | samcli/lib/utils/resources.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resources.py | Apache-2.0 |
def resources_generator():
"""
Generator to yield set of resources and their locations that are supported for package operations
Yields
------
resource : Dict
The resource dictionary
location : str
The location of the resource
"""
for resource, location_list in get_packa... |
Generator to yield set of resources and their locations that are supported for package operations
Yields
------
resource : Dict
The resource dictionary
location : str
The location of the resource
| resources_generator | python | aws/aws-sam-cli | samcli/lib/utils/resources.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resources.py | Apache-2.0 |
def get_single_file_path_handler(file_path: Path) -> PathHandler:
"""Get PathHandler for watching a single file
Parameters
----------
file_path : Path
File path object
Returns
-------
PathHandler
The PathHandler for the file specified
... | Get PathHandler for watching a single file
Parameters
----------
file_path : Path
File path object
Returns
-------
PathHandler
The PathHandler for the file specified
| get_single_file_path_handler | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def get_dir_path_handler(dir_path: Path, ignore_regexes: Optional[List[str]] = None) -> PathHandler:
"""Get PathHandler for watching a single directory
Parameters
----------
dir_path : Path
Folder path object
ignore_regexes : List[str], Optional
List of r... | Get PathHandler for watching a single directory
Parameters
----------
dir_path : Path
Folder path object
ignore_regexes : List[str], Optional
List of regexes that should be ignored
Returns
-------
PathHandler
The PathHandler f... | get_dir_path_handler | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def __init__(self, template_file: str, stack_name: str, on_template_change: OnChangeCallback) -> None:
"""
Parameters
----------
template_file : str
Template file to be watched
stack_name: str
Stack name of the template
on_template_change : OnChang... |
Parameters
----------
template_file : str
Template file to be watched
stack_name: str
Stack name of the template
on_template_change : OnChangeCallback
Callback when template changes
| __init__ | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def _validator_wrapper(self, event: Optional[FileSystemEvent] = None) -> None:
"""Wrapper for callback that only executes if the template is valid and non-trivial changes are detected.
Parameters
----------
event : Optional[FileSystemEvent], optional
"""
if event and eve... | Wrapper for callback that only executes if the template is valid and non-trivial changes are detected.
Parameters
----------
event : Optional[FileSystemEvent], optional
| _validator_wrapper | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def __init__(
self,
resource_identifier: ResourceIdentifier,
stacks: List[Stack],
base_dir: Path,
on_code_change: OnChangeCallback,
watch_exclude: Optional[List[str]] = None,
):
"""
Parameters
----------
resource_identifier : ResourceId... |
Parameters
----------
resource_identifier : ResourceIdentifier
ResourceIdentifier
stacks : List[Stack]
List of stacks
base_dir: Path
Base directory for the resource. This should be the path to template file in most cases.
on_code_chang... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def __init__(
self,
function_identifier: ResourceIdentifier,
stacks: List[Stack],
base_dir: Path,
on_code_change: OnChangeCallback,
watch_exclude: Optional[List[str]] = None,
):
"""
Parameters
----------
function_identifier : ResourceId... |
Parameters
----------
function_identifier : ResourceIdentifier
ResourceIdentifier for the function
stacks : List[Stack]
List of stacks
base_dir: Path
Base directory for the function. This should be the path to template file in most cases.
... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def get_path_handlers(self) -> List[PathHandler]:
"""
Returns
-------
List[PathHandler]
PathHandlers for the code folder associated with the function
"""
dir_path_handler = ResourceTrigger.get_dir_path_handler(
self.base_dir.joinpath(self._code_uri... |
Returns
-------
List[PathHandler]
PathHandlers for the code folder associated with the function
| get_path_handlers | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def __init__(
self,
layer_identifier: ResourceIdentifier,
stacks: List[Stack],
base_dir: Path,
on_code_change: OnChangeCallback,
watch_exclude: Optional[List[str]] = None,
):
"""
Parameters
----------
layer_identifier : ResourceIdentifi... |
Parameters
----------
layer_identifier : ResourceIdentifier
ResourceIdentifier for the layer
stacks : List[Stack]
List of stacks
base_dir: Path
Base directory for the layer. This should be the path to template file in most cases.
on_co... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def get_path_handlers(self) -> List[PathHandler]:
"""
Returns
-------
List[PathHandler]
PathHandlers for the code folder associated with the layer
"""
dir_path_handler = ResourceTrigger.get_dir_path_handler(
self.base_dir.joinpath(self._code_uri), ... |
Returns
-------
List[PathHandler]
PathHandlers for the code folder associated with the layer
| get_path_handlers | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def __init__(
self,
resource_identifier: ResourceIdentifier,
resource_type: str,
stacks: List[Stack],
base_dir: Path,
on_code_change: OnChangeCallback,
):
"""
Parameters
----------
resource_identifier : ResourceIdentifier
Re... |
Parameters
----------
resource_identifier : ResourceIdentifier
ResourceIdentifier for the Resource
resource_type : str
Resource type
stacks : List[Stack]
List of stacks
base_dir: Path
Base directory for the definition file.... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def _get_definition_file(self) -> str:
"""
Returns
-------
str
JSON/YAML definition file path
Raises
------
MissingLocalDefinition
raised when resource property related to definition path is not specified.
"""
property_name... |
Returns
-------
str
JSON/YAML definition file path
Raises
------
MissingLocalDefinition
raised when resource property related to definition path is not specified.
| _get_definition_file | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def get_path_handlers(self) -> List[PathHandler]:
"""
Returns
-------
List[PathHandler]
A single PathHandler for watching the definition file.
"""
file_path_handler = ResourceTrigger.get_single_file_path_handler(self.base_dir.joinpath(self._definition_file))
... |
Returns
-------
List[PathHandler]
A single PathHandler for watching the definition file.
| get_path_handlers | python | aws/aws-sam-cli | samcli/lib/utils/resource_trigger.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_trigger.py | Apache-2.0 |
def _get_resource_type(self, resource_identifier: ResourceIdentifier) -> Optional[str]:
"""Get resource type of the resource
Parameters
----------
resource_identifier : ResourceIdentifier
Returns
-------
Optional[str]
Resource type of the resource
... | Get resource type of the resource
Parameters
----------
resource_identifier : ResourceIdentifier
Returns
-------
Optional[str]
Resource type of the resource
| _get_resource_type | python | aws/aws-sam-cli | samcli/lib/utils/resource_type_based_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_type_based_factory.py | Apache-2.0 |
def _get_generator_function(self, resource_identifier: ResourceIdentifier) -> Optional[Callable]:
"""Create an appropriate T object based on stack resource type
Parameters
----------
resource_identifier : ResourceIdentifier
Resource identifier of the resource
Return... | Create an appropriate T object based on stack resource type
Parameters
----------
resource_identifier : ResourceIdentifier
Resource identifier of the resource
Returns
-------
Optional[T]
Object T for the resource. Returns None if resource cannot ... | _get_generator_function | python | aws/aws-sam-cli | samcli/lib/utils/resource_type_based_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/resource_type_based_factory.py | Apache-2.0 |
def retry(exc, attempts=3, delay=0.05, exc_raise=Exception, exc_raise_msg=""):
"""
Retry decorator which defaults to 3 attempts based on exponential backoff
and a delay of 50ms.
After retries are exhausted, a custom Exception and Error message are raised.
:param exc: Exception to be caught for retr... |
Retry decorator which defaults to 3 attempts based on exponential backoff
and a delay of 50ms.
After retries are exhausted, a custom Exception and Error message are raised.
:param exc: Exception to be caught for retry
:param attempts: number of attempts before exception is allowed to be raised.
... | retry | python | aws/aws-sam-cli | samcli/lib/utils/retry.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/retry.py | Apache-2.0 |
def _parse_s3_format_url(
url: Any,
bucket_name_property: str = "Bucket",
object_key_property: str = "Key",
version_property: Optional[str] = None,
) -> Dict:
"""
Method for parsing s3 urls that begin with s3://
e.g. s3://bucket/key
"""
parsed = urlparse(url)
query = parse_qs(par... |
Method for parsing s3 urls that begin with s3://
e.g. s3://bucket/key
| _parse_s3_format_url | python | aws/aws-sam-cli | samcli/lib/utils/s3.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/s3.py | Apache-2.0 |
def _parse_path_style_s3_url(
url: Any,
bucket_name_property: str = "Bucket",
object_key_property: str = "Key",
) -> Dict:
"""
Static method for parsing path style s3 urls.
e.g. https://s3.us-east-1.amazonaws.com/bucket/key
"""
parsed = urlparse(url)
result = dict()
# parsed.path... |
Static method for parsing path style s3 urls.
e.g. https://s3.us-east-1.amazonaws.com/bucket/key
| _parse_path_style_s3_url | python | aws/aws-sam-cli | samcli/lib/utils/s3.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/s3.py | Apache-2.0 |
def configure_logger(logger, formatter, level):
"""
Configure a Logger with the level provided and also the first handler's formatter.
If there is no handler in the logger, a new StreamHandler will be added.
Parameters
----------
logger logging.getLogger
Logg... |
Configure a Logger with the level provided and also the first handler's formatter.
If there is no handler in the logger, a new StreamHandler will be added.
Parameters
----------
logger logging.getLogger
Logger to configure
formatter logging.formatter
... | configure_logger | python | aws/aws-sam-cli | samcli/lib/utils/sam_logging.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/sam_logging.py | Apache-2.0 |
def __init__(self, stream: TextIO, stream_bytes: Optional[Union[TextIO, BytesIO]] = None, auto_flush: bool = False):
"""
Instatiates new StreamWriter to the specified stream
Parameters
----------
stream io.RawIOBase
Stream to wrap
stream_bytes io.TextIO | io.... |
Instatiates new StreamWriter to the specified stream
Parameters
----------
stream io.RawIOBase
Stream to wrap
stream_bytes io.TextIO | io.BytesIO
Stream to wrap if bytes are being written
auto_flush bool
Whether to autoflush the strea... | __init__ | python | aws/aws-sam-cli | samcli/lib/utils/stream_writer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/stream_writer.py | Apache-2.0 |
def write_bytes(self, output: bytes):
"""
Writes specified text to the underlying stream
Parameters
----------
output bytes-like object
Bytes to write into buffer
"""
# all these ifs are to satisfy the linting/type checking
if not self._stream_... |
Writes specified text to the underlying stream
Parameters
----------
output bytes-like object
Bytes to write into buffer
| write_bytes | python | aws/aws-sam-cli | samcli/lib/utils/stream_writer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/stream_writer.py | Apache-2.0 |
def write_str(self, output: str):
"""
Writes specified text to the underlying stream
Parameters
----------
output string object
String to write
"""
self._stream.write(output)
if self._auto_flush:
self._stream.flush() |
Writes specified text to the underlying stream
Parameters
----------
output string object
String to write
| write_str | python | aws/aws-sam-cli | samcli/lib/utils/stream_writer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/stream_writer.py | Apache-2.0 |
def default_loading_pattern(stream_writer: Optional[StreamWriter] = None, loading_pattern_rate: float = 0.5) -> None:
"""
A loading pattern that just prints '.' to the terminal
Parameters
----------
stream_writer: Optional[StreamWriter]
The stream to which to write the pattern
loading_p... |
A loading pattern that just prints '.' to the terminal
Parameters
----------
stream_writer: Optional[StreamWriter]
The stream to which to write the pattern
loading_pattern_rate: int
How frequently to generate the pattern
| default_loading_pattern | python | aws/aws-sam-cli | samcli/lib/utils/subprocess_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/subprocess_utils.py | Apache-2.0 |
def invoke_subprocess_with_loading_pattern(
command_args: Dict[str, Any],
loading_pattern: Callable[[StreamWriter], None] = default_loading_pattern,
stream_writer: Optional[StreamWriter] = None,
is_running_terraform_command: Optional[bool] = None,
) -> Optional[Union[str, bytes]]:
"""
Wrapper fo... |
Wrapper for Popen to asynchronously invoke a subprocess while
printing a given pattern until the subprocess is complete.
If the log level is lower than INFO, stream the process stdout instead.
Parameters
----------
command_args: Dict[str, Any]
The arguments to give to the Popen call, s... | invoke_subprocess_with_loading_pattern | python | aws/aws-sam-cli | samcli/lib/utils/subprocess_utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/subprocess_utils.py | Apache-2.0 |
def gather_system_info() -> Dict[str, str]:
"""
Gather system info
Returns
-------
dict[str, str]
"""
from platform import platform, python_version
info = {
"python": python_version(),
"os": platform(),
}
return info |
Gather system info
Returns
-------
dict[str, str]
| gather_system_info | python | aws/aws-sam-cli | samcli/lib/utils/system_info.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/system_info.py | Apache-2.0 |
def gather_additional_dependencies_info() -> Dict[str, str]:
"""
Gather additional depedencies info
Returns
-------
dict[str, str]
A dictionary with the key representing the info we need
and value being the version number
"""
info = {
"docker_engine": _gather_docker_... |
Gather additional depedencies info
Returns
-------
dict[str, str]
A dictionary with the key representing the info we need
and value being the version number
| gather_additional_dependencies_info | python | aws/aws-sam-cli | samcli/lib/utils/system_info.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/system_info.py | Apache-2.0 |
def _gather_docker_info() -> str:
"""
Get Docker Engine version
Returns
-------
str
Version number of Docker Engine if available. Otherwise "Not available"
"""
import contextlib
import docker
from samcli.lib.constants import DOCKER_MIN_API_VERSION
from samcli.local.doc... |
Get Docker Engine version
Returns
-------
str
Version number of Docker Engine if available. Otherwise "Not available"
| _gather_docker_info | python | aws/aws-sam-cli | samcli/lib/utils/system_info.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/system_info.py | Apache-2.0 |
def _gather_cdk_info():
"""
Get AWS CDK version numbner.
AWS SAM CLI does not invoke CDK, but only uses the CFN templates generated from `cdk synth`.
Knowing the CDK version number will help us diagnose if any issue is caused by a new version of CDK.
Returns
-------
str
Version num... |
Get AWS CDK version numbner.
AWS SAM CLI does not invoke CDK, but only uses the CFN templates generated from `cdk synth`.
Knowing the CDK version number will help us diagnose if any issue is caused by a new version of CDK.
Returns
-------
str
Version number of AWS CDK if available, e.... | _gather_cdk_info | python | aws/aws-sam-cli | samcli/lib/utils/system_info.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/system_info.py | Apache-2.0 |
def _gather_terraform_info():
"""
Get Terraform version numbner.
AWS SAM CLI invokes Terraform for Terraform applications.
Knowing the Terraform version number will help us diagnose if any issue is caused by a new version of Terraform.
Returns
-------
str
Version number of Terrafor... |
Get Terraform version numbner.
AWS SAM CLI invokes Terraform for Terraform applications.
Knowing the Terraform version number will help us diagnose if any issue is caused by a new version of Terraform.
Returns
-------
str
Version number of Terraform if available, e.g. "1.2.1"
... | _gather_terraform_info | python | aws/aws-sam-cli | samcli/lib/utils/system_info.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/system_info.py | Apache-2.0 |
def create_tarball(
tar_paths: Dict[Union[str, Path], str],
tar_filter: Optional[Callable[[tarfile.TarInfo], Union[None, tarfile.TarInfo]]] = None,
mode: Literal["x", "x:", "a", "a:", "w", "w:", "w:tar"] = "w",
dereference: bool = False,
):
"""
Context Manger that creates the tarball of the Dock... |
Context Manger that creates the tarball of the Docker Context to use for building the image
Parameters
----------
tar_paths: Dict[Union[str, Path], str]
Key representing a full path to the file or directory and the Value representing the path within the tarball
tar_filter: Optional[Callabl... | create_tarball | python | aws/aws-sam-cli | samcli/lib/utils/tar.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/tar.py | Apache-2.0 |
def _validate_destinations_exists(tar_paths: Union[List[Union[str, Path]], List[Path]]) -> bool:
"""
Validates whether the destination of a symlink exists by resolving the link
and checking the resolved path.
Parameters
----------
tar_paths: List[Union[str, Path]]
A list of Paths to che... |
Validates whether the destination of a symlink exists by resolving the link
and checking the resolved path.
Parameters
----------
tar_paths: List[Union[str, Path]]
A list of Paths to check
Return
------
bool:
True all the checked paths exist, otherwise returns false
... | _validate_destinations_exists | python | aws/aws-sam-cli | samcli/lib/utils/tar.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/tar.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.