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 _build_resources_from_scratch(self) -> None: """Builds function from scratch and assigns build_graph and artifacts_folder""" with ExitStack() as exit_stack: if self.has_locks(): exit_stack.enter_context(self._get_lock_chain()) rmtree_if_exists(self._function....
Builds function from scratch and assigns build_graph and artifacts_folder
_build_resources_from_scratch
python
aws/aws-sam-cli
samcli/lib/sync/flows/zip_function_sync_flow.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/sync/flows/zip_function_sync_flow.py
Apache-2.0
def _is_codeship(environ: Mapping) -> bool: """ Use environ to determine whether it is running in CodeShip. According to the doc, https://docs.cloudbees.com/docs/cloudbees-codeship/latest/basic-builds-and-configuration/set-environment-variables > CI_NAME # Always CodeShip. Ex: codeshi...
Use environ to determine whether it is running in CodeShip. According to the doc, https://docs.cloudbees.com/docs/cloudbees-codeship/latest/basic-builds-and-configuration/set-environment-variables > CI_NAME # Always CodeShip. Ex: codeship to handle both "CodeShip" and "codeship," he...
_is_codeship
python
aws/aws-sam-cli
samcli/lib/telemetry/cicd.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/cicd.py
Apache-2.0
def _is_cicd_platform(cicd_platform: CICDPlatform, environ: Mapping) -> bool: """ Check whether sam-cli run in a particular CI/CD platform based on certain environment variables. Parameters ---------- cicd_platform an enum CICDPlatform object indicating which CI/CD platform to check agains...
Check whether sam-cli run in a particular CI/CD platform based on certain environment variables. Parameters ---------- cicd_platform an enum CICDPlatform object indicating which CI/CD platform to check against. environ the mapping to look for environment variables, for example, os...
_is_cicd_platform
python
aws/aws-sam-cli
samcli/lib/telemetry/cicd.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/cicd.py
Apache-2.0
def get_accepted_values(event_name: EventName) -> List[str]: """Get all acceptable values for a given Event name.""" if event_name not in EventType._event_values: return [] return EventType._event_values[event_name]
Get all acceptable values for a given Event name.
get_accepted_values
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def _verify_event(event_name: str, event_value: str) -> None: """Raise an EventCreationError if either the event name or value is not valid.""" if event_name not in Event._get_event_names(): raise EventCreationError(f"Event '{event_name}' does not exist.") if event_value not in Event...
Raise an EventCreationError if either the event name or value is not valid.
_verify_event
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def track_event( event_name: str, event_value: str, session_id: Optional[str] = None, thread_id: Optional[UUID] = None, exception_name: Optional[str] = None, ): """Method to track an event where and when it occurs. Place this method in the codepath of the eve...
Method to track an event where and when it occurs. Place this method in the codepath of the event that you would like to track. For instance, if you would like to track when FeatureX is used, append this method to the end of that function. Parameters ---------- event_na...
track_event
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def clear_trackers(): """Clear the current list of tracked Events before the next session.""" with EventTracker._event_lock: EventTracker._events = []
Clear the current list of tracked Events before the next session.
clear_trackers
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def send_events() -> threading.Thread: """Call a thread to send the current list of Events via Telemetry.""" send_thread = threading.Thread(target=EventTracker._send_events_in_thread) send_thread.start() return send_thread
Call a thread to send the current list of Events via Telemetry.
send_events
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def _send_events_in_thread(): """Send the current list of Events via Telemetry.""" from samcli.lib.telemetry.metric import Metric # pylint: disable=cyclic-import msa = {} with EventTracker._event_lock: if not EventTracker._events: # Don't do anything if there are no event...
Send the current list of Events via Telemetry.
_send_events_in_thread
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def track_long_event( start_event_name: str, start_event_value: str, end_event_name: str, end_event_value: str, thread_id: Optional[UUID] = None, ): """Decorator for tracking events that occur at start and end of a function. The decorator tracks two Events total, where the first Event occur...
Decorator for tracking events that occur at start and end of a function. The decorator tracks two Events total, where the first Event occurs at the start of the decorated function's execution (prior to its first line) and the second Event occurs after the function has ended (after the final line of the...
track_long_event
python
aws/aws-sam-cli
samcli/lib/telemetry/event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/event.py
Apache-2.0
def decorator(func): """ Actual decorator method with warning names """ def wrapped(*args, **kwargs): telemetry = Telemetry() template_warning_checker = TemplateWarningsChecker() ctx = Context.get_current_context() try: ct...
Actual decorator method with warning names
decorator
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def track_command(func): """ Decorator to track execution of a command. This method executes the function, gathers all relevant metrics, reports the metrics and returns. If you have a Click command, you can track as follows: .. code:: python @click.command(...) @click.options(...) ...
Decorator to track execution of a command. This method executes the function, gathers all relevant metrics, reports the metrics and returns. If you have a Click command, you can track as follows: .. code:: python @click.command(...) @click.options(...) @track_command d...
track_command
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def _timer(): """ Timer to measure the elapsed time between two calls in milliseconds. When you first call this method, we will automatically start the timer. The return value is another method that, when called, will end the timer and return the duration between the two calls. ..code: >>> impo...
Timer to measure the elapsed time between two calls in milliseconds. When you first call this method, we will automatically start the timer. The return value is another method that, when called, will end the timer and return the duration between the two calls. ..code: >>> import time >>> durat...
_timer
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def capture_parameter(metric_name, key, parameter_identifier, parameter_nested_identifier=None, as_list=False): """ Decorator for capturing one parameter of the function. :param metric_name Name of the metric :param key Key for storing the captured parameter :param parameter_identifier Either a str...
Decorator for capturing one parameter of the function. :param metric_name Name of the metric :param key Key for storing the captured parameter :param parameter_identifier Either a string for named parameter or int for positional parameter. "self" can be accessed with 0. :param parameter_ne...
capture_parameter
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def capture_return_value(metric_name, key, as_list=False): """ Decorator for capturing the return value of the function. :param metric_name Name of the metric :param key Key for storing the captured parameter :param as_list Default to False. Setting to True will append the captured parameter into ...
Decorator for capturing the return value of the function. :param metric_name Name of the metric :param key Key for storing the captured parameter :param as_list Default to False. Setting to True will append the captured parameter into a list instead of overriding the previous one.
capture_return_value
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def _default_session_id() -> Optional[str]: """ Get the default SessionId from Click Context. Fail silently if Context does not exist. """ try: ctx = Context.get_current_context() if ctx: return ctx.session_id return None ...
Get the default SessionId from Click Context. Fail silently if Context does not exist.
_default_session_id
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def _get_execution_environment(self) -> str: """ Returns the environment in which SAM CLI is running. Possible options are: CLI (default) - SAM CLI was executed from terminal or a script. other CICD platform name - SAM CLI was executed in CICD Returns -...
Returns the environment in which SAM CLI is running. Possible options are: CLI (default) - SAM CLI was executed from terminal or a script. other CICD platform name - SAM CLI was executed in CICD Returns ------- str Name of the environment w...
_get_execution_environment
python
aws/aws-sam-cli
samcli/lib/telemetry/metric.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/telemetry/metric.py
Apache-2.0
def get_git_remote_origin_url() -> Optional[str]: """ Retrieve an hashed version of the project's git remote origin url, if it exists. Returns ------- str | None A SHA256 hexdigest string of the git remote origin url, formatted such that the hashed value follows the pattern <hostnam...
Retrieve an hashed version of the project's git remote origin url, if it exists. Returns ------- str | None A SHA256 hexdigest string of the git remote origin url, formatted such that the hashed value follows the pattern <hostname>/<owner>/<project_name>.git. If telemetry is op...
get_git_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 get_project_name() -> Optional[str]: """ Retrieve an hashed version of the project's name, as defined by the .git folder (or directory name if no .git). Returns ------- str | None A SHA256 hexdigest string of either the name of the project, or the name of the current working dir...
Retrieve an hashed version of the project's name, as defined by the .git folder (or directory name if no .git). Returns ------- str | None A SHA256 hexdigest string of either the name of the project, or the name of the current working directory that the command is running in. I...
get_project_name
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 _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 __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._observed_images: Dict[str, str...
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 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