_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q8100
Import.open
train
def open(self, options, loaded_schemata): """ Open and import the referenced schema. @param options: An options dictionary. @type options: L{options.Options} @param loaded_schemata: Already loaded schemata cache (URL --> Schema). @type loaded_schemata: dict @retu...
python
{ "resource": "" }
q8101
Import.__locate
train
def __locate(self): """Find the schema locally.""" if self.ns[1] != self.schema.tns[1]: return self.schema.locate(self.ns)
python
{ "resource": "" }
q8102
Import.__download
train
def __download(self, url, loaded_schemata, options): """Download the schema.""" try: reader = DocumentReader(options) d = reader.open(url) root = d.root() root.set("url", url) return self.schema.instance(root, url, loaded_schemata, options) ...
python
{ "resource": "" }
q8103
Include.__applytns
train
def __applytns(self, root): """Make sure included schema has the same target namespace.""" TNS = "targetNamespace" tns = root.get(TNS) if tns is None: tns = self.schema.tns[1] root.set(TNS, tns) else: if self.schema.tns[1] != tns: ...
python
{ "resource": "" }
q8104
Definitions.add_methods
train
def add_methods(self, service): """Build method view for service.""" bindings = { "document/literal": Document(self), "rpc/literal": RPC(self), "rpc/encoded": Encoded(self)} for p in service.ports: binding = p.binding ptype = p.binding....
python
{ "resource": "" }
q8105
PortType.operation
train
def operation(self, name): """ Shortcut used to get a contained operation by name. @param name: An operation name. @type name: str @return: The named operation. @rtype: Operation @raise L{MethodNotFound}: When not found. """ try: retu...
python
{ "resource": "" }
q8106
Service.port
train
def port(self, name): """ Locate a port by name. @param name: A port name. @type name: str @return: The port object. @rtype: L{Port} """ for p in self.ports: if p.name == name: return p
python
{ "resource": "" }
q8107
Service.do_resolve
train
def do_resolve(self, definitions): """ Resolve named references to other WSDL objects. Ports without SOAP bindings are discarded. @param definitions: A definitions object. @type definitions: L{Definitions} """ filtered = [] for p in self.ports: ...
python
{ "resource": "" }
q8108
FileCache._getf
train
def _getf(self, id): """Open a cached file with the given id for reading.""" try: filename = self.__filename(id) self.__remove_if_expired(filename) return self.__open(filename, "rb") except Exception: pass
python
{ "resource": "" }
q8109
FileCache.__filename
train
def __filename(self, id): """Return the cache file name for an entry with a given id.""" suffix = self.fnsuffix() filename = "%s-%s.%s" % (self.fnprefix, id, suffix) return os.path.join(self.location, filename)
python
{ "resource": "" }
q8110
FileCache.__get_default_location
train
def __get_default_location(): """ Returns the current process's default cache location folder. The folder is determined lazily on first call. """ if not FileCache.__default_location: tmp = tempfile.mkdtemp("suds-default-cache") FileCache.__default_locati...
python
{ "resource": "" }
q8111
FileCache.__remove_if_expired
train
def __remove_if_expired(self, filename): """ Remove a cached file entry if it expired. @param filename: The file name. @type filename: str """ if not self.duration: return created = datetime.datetime.fromtimestamp(os.path.getctime(filename)) ...
python
{ "resource": "" }
q8112
any_contains_any
train
def any_contains_any(strings, candidates): """Whether any of the strings contains any of the candidates.""" for string in strings: for c in candidates: if c in string: return True
python
{ "resource": "" }
q8113
path_to_URL
train
def path_to_URL(path, escape=True): """Convert a local file path to a absolute path file protocol URL.""" # We do not use urllib's builtin pathname2url() function since: # - it has been commented with 'not recommended for general use' # - it does not seem to work the same on Windows and non-Window...
python
{ "resource": "" }
q8114
requirement_spec
train
def requirement_spec(package_name, *args): """Identifier used when specifying a requirement to pip or setuptools.""" if not args or args == (None,): return package_name version_specs = [] for version_spec in args: if isinstance(version_spec, (list, tuple)): operator, v...
python
{ "resource": "" }
q8115
path_iter
train
def path_iter(path): """Returns an iterator over all the file & folder names in a path.""" parts = [] while path: path, item = os.path.split(path) if item: parts.append(item) return reversed(parts)
python
{ "resource": "" }
q8116
Document.mkparam
train
def mkparam(self, method, pdef, object): """ Expand list parameters into individual parameters each with the type information. This is because in document arrays are simply multi-occurrence elements. """ if isinstance(object, (list, tuple)): return [self.mkpa...
python
{ "resource": "" }
q8117
Document.param_defs
train
def param_defs(self, method): """Get parameter definitions for document literal.""" pts = self.bodypart_types(method) if not method.soap.input.body.wrapped: return pts pt = pts[0][1].resolve() return [(c.name, c, a) for c, a in pt if not c.isattr()]
python
{ "resource": "" }
q8118
byte_str
train
def byte_str(s="", encoding="utf-8", input_encoding="utf-8", errors="strict"): """ Returns a byte string version of 's', encoded as specified in 'encoding'. Accepts str & unicode objects, interpreting non-unicode strings as byte strings encoded using the given input encoding. """ assert isinst...
python
{ "resource": "" }
q8119
_date_from_match
train
def _date_from_match(match_object): """ Create a date object from a regular expression match. The regular expression match is expected to be from _RE_DATE or _RE_DATETIME. @param match_object: The regular expression match. @type match_object: B{re}.I{MatchObject} @return: A date object. ...
python
{ "resource": "" }
q8120
_parse
train
def _parse(string): """ Parses given XML document content. Returns the resulting root XML element node or None if the given XML content is empty. @param string: XML document content to parse. @type string: I{bytes} @return: Resulting root XML element node or None. @rtype: L{Element}|I{...
python
{ "resource": "" }
q8121
Factory.create
train
def create(self, name): """ Create a WSDL type by name. @param name: The name of a type defined in the WSDL. @type name: str @return: The requested object. @rtype: L{Object} """ timer = metrics.Timer() timer.start() type = self.resolver.f...
python
{ "resource": "" }
q8122
RequestContext.process_reply
train
def process_reply(self, reply, status=None, description=None): """ Re-entry for processing a successful reply. Depending on how the ``retxml`` option is set, may return the SOAP reply XML or process it and return the Python object representing the returned value. @param...
python
{ "resource": "" }
q8123
_SoapClient.send
train
def send(self, soapenv): """ Send SOAP message. Depending on how the ``nosend`` & ``retxml`` options are set, may do one of the following: * Return a constructed web service operation request without sending it to the web service. * Invoke the web service...
python
{ "resource": "" }
q8124
_SoapClient.process_reply
train
def process_reply(self, reply, status, description): """ Process a web service operation SOAP reply. Depending on how the ``retxml`` option is set, may return the SOAP reply XML or process it and return the Python object representing the returned value. @param reply: Th...
python
{ "resource": "" }
q8125
_SoapClient.__get_fault
train
def __get_fault(self, replyroot): """ Extract fault information from a SOAP reply. Returns an I{unmarshalled} fault L{Object} or None in case the given XML document does not contain a SOAP <Fault> element. @param replyroot: A SOAP reply message root XML element or None. ...
python
{ "resource": "" }
q8126
_SimClient.invoke
train
def invoke(self, args, kwargs): """ Invoke a specified web service method. Uses an injected SOAP request/response instead of a regularly constructed/received one. Depending on how the ``nosend`` & ``retxml`` options are set, may do one of the following: * Retu...
python
{ "resource": "" }
q8127
Request.__set_URL
train
def __set_URL(self, url): """ URL is stored as a str internally and must not contain ASCII chars. Raised exception in case of detected non-ASCII URL characters may be either UnicodeEncodeError or UnicodeDecodeError, depending on the used Python version's str type and the exact v...
python
{ "resource": "" }
q8128
PathResolver.root
train
def root(self, parts): """ Find the path root. @param parts: A list of path parts. @type parts: [str,..] @return: The root. @rtype: L{xsd.sxbase.SchemaObject} """ result = None name = parts[0] log.debug('searching schema for (%s)', name) ...
python
{ "resource": "" }
q8129
PathResolver.branch
train
def branch(self, root, parts): """ Traverse the path until a leaf is reached. @param parts: A list of path parts. @type parts: [str,..] @param root: The root. @type root: L{xsd.sxbase.SchemaObject} @return: The end of the branch. @rtype: L{xsd.sxbase.Schem...
python
{ "resource": "" }
q8130
TreeResolver.getchild
train
def getchild(self, name, parent): """Get a child by name.""" log.debug('searching parent (%s) for (%s)', Repr(parent), name) if name.startswith('@'): return parent.get_attribute(name[1:]) return parent.get_child(name)
python
{ "resource": "" }
q8131
_Archiver.__path_prefix
train
def __path_prefix(self, folder): """ Path prefix to be used when archiving any items from the given folder. Expects the folder to be located under the base folder path and the returned path prefix does not include the base folder information. This makes sure we include jus...
python
{ "resource": "" }
q8132
XDecimal._decimal_to_xsd_format
train
def _decimal_to_xsd_format(value): """ Converts a decimal.Decimal value to its XSD decimal type value. Result is a string containing the XSD decimal type's lexical value representation. The conversion is done without any precision loss. Note that Python's native decimal.Decimal...
python
{ "resource": "" }
q8133
_reuse_pre_installed_setuptools
train
def _reuse_pre_installed_setuptools(env, installer): """ Return whether a pre-installed setuptools distribution should be reused. """ if not env.setuptools_version: return # no prior setuptools ==> no reuse reuse_old = config.reuse_old_setuptools reuse_best = config.reuse_best_...
python
{ "resource": "" }
q8134
download_pip
train
def download_pip(env, requirements): """Download pip and its requirements using setuptools.""" if config.installation_cache_folder() is None: raise EnvironmentSetupError("Local installation cache folder not " "defined but required for downloading a pip installation.") # Installation...
python
{ "resource": "" }
q8135
setuptools_install_options
train
def setuptools_install_options(local_storage_folder): """ Return options to make setuptools use installations from the given folder. No other installation source is allowed. """ if local_storage_folder is None: return [] # setuptools expects its find-links parameter to contain...
python
{ "resource": "" }
q8136
install_pip
train
def install_pip(env, requirements): """Install pip and its requirements using setuptools.""" try: installation_source_folder = config.installation_cache_folder() options = setuptools_install_options(installation_source_folder) if installation_source_folder is not None: ...
python
{ "resource": "" }
q8137
download_pip_based_installations
train
def download_pip_based_installations(env, pip_invocation, requirements, download_cache_folder): """Download requirements for pip based installation.""" if config.installation_cache_folder() is None: raise EnvironmentSetupError("Local installation cache folder not " "defined but ...
python
{ "resource": "" }
q8138
enabled_actions_for_env
train
def enabled_actions_for_env(env): """Returns actions to perform when processing the given environment.""" def enabled(config_value, required): if config_value is Config.TriBool.No: return False if config_value is Config.TriBool.Yes: return True assert confi...
python
{ "resource": "" }
q8139
_ez_setup_script.__setuptools_version
train
def __setuptools_version(self): """Read setuptools version from the underlying ez_setup script.""" # Read the script directly as a file instead of importing it as a # Python module and reading the value from the loaded module's global # DEFAULT_VERSION variable. Not all ez_setup scri...
python
{ "resource": "" }
q8140
Element.rename
train
def rename(self, name): """ Rename the element. @param name: A new name for the element. @type name: basestring """ if name is None: raise Exception("name (%s) not-valid" % (name,)) self.prefix, self.name = splitPrefix(name)
python
{ "resource": "" }
q8141
Element.clone
train
def clone(self, parent=None): """ Deep clone of this element and children. @param parent: An optional parent for the copied fragment. @type parent: I{Element} @return: A deep copy parented by I{parent} @rtype: I{Element} """ root = Element(self.qname(), ...
python
{ "resource": "" }
q8142
Element.get
train
def get(self, name, ns=None, default=None): """ Get the value of an attribute by name. @param name: The name of the attribute. @type name: basestring @param ns: The optional attribute's namespace. @type ns: (I{prefix}, I{name}) @param default: An optional value t...
python
{ "resource": "" }
q8143
Element.namespace
train
def namespace(self): """ Get the element's namespace. @return: The element's namespace by resolving the prefix, the explicit namespace or the inherited namespace. @rtype: (I{prefix}, I{name}) """ if self.prefix is None: return self.defaultNamespa...
python
{ "resource": "" }
q8144
Element.append
train
def append(self, objects): """ Append the specified child based on whether it is an element or an attribute. @param objects: A (single|collection) of attribute(s) or element(s) to be added as children. @type objects: (L{Element}|L{Attribute}) @return: self ...
python
{ "resource": "" }
q8145
Element.promotePrefixes
train
def promotePrefixes(self): """ Push prefix declarations up the tree as far as possible. Prefix mapping are pushed to its parent unless the parent has the prefix mapped to another URI or the parent has the prefix. This is propagated up the tree until the top is reached. ...
python
{ "resource": "" }
q8146
Element.isempty
train
def isempty(self, content=True): """ Get whether the element has no children. @param content: Test content (children & text) only. @type content: boolean @return: True when element has not children. @rtype: boolean """ nochildren = not self.children ...
python
{ "resource": "" }
q8147
Element.applyns
train
def applyns(self, ns): """ Apply the namespace to this node. If the prefix is I{None} then this element's explicit namespace I{expns} is set to the URI defined by I{ns}. Otherwise, the I{ns} is simply mapped. @param ns: A namespace. @type ns: (I{prefix}, I{URI})...
python
{ "resource": "" }
q8148
DocumentReader.__fetch
train
def __fetch(self, url): """ Fetch document content from an external source. The document content will first be looked up in the registered document store, and if not found there, downloaded using the registered transport system. Before being returned, the fetched docume...
python
{ "resource": "" }
q8149
Environment.__construct_python_version
train
def __construct_python_version(self): """ Construct a setuptools compatible Python version string. Constructed based on the environment's reported sys.version_info. """ major, minor, micro, release_level, serial = self.sys_version_info assert release_level in ("...
python
{ "resource": "" }
q8150
Environment.__parse_scanned_version_info
train
def __parse_scanned_version_info(self): """Parses the environment's formatted version info string.""" string = self.sys_version_info_formatted try: major, minor, micro, release_level, serial = string.split(",") if (release_level in ("alfa", "beta", "candidate", "fina...
python
{ "resource": "" }
q8151
Typed.node
train
def node(self, content): """ Create an XML node. The XML node is namespace qualified as defined by the corresponding schema element. """ ns = content.type.namespace() if content.type.form_qualified: node = Element(content.tag, ns=ns) if n...
python
{ "resource": "" }
q8152
_detect_eggs_in_folder
train
def _detect_eggs_in_folder(folder): """ Detect egg distributions located in the given folder. Only direct folder content is considered and subfolders are not searched recursively. """ eggs = {} for x in os.listdir(folder): zip = x.endswith(_zip_ext) if zip: ...
python
{ "resource": "" }
q8153
_Egg.normalize
train
def normalize(self): """ Makes sure this egg distribution is stored only as an egg file. The egg file will be created from another existing distribution format if needed. """ if self.has_egg_file(): if self.has_zip(): self.__remove_...
python
{ "resource": "" }
q8154
parse_args
train
def parse_args(method_name, param_defs, args, kwargs, external_param_processor, extra_parameter_errors): """ Parse arguments for suds web service operation invocation functions. Suds prepares Python function objects for invoking web service operations. This function implements generic binding agnos...
python
{ "resource": "" }
q8155
_ArgParser.__all_parameters_processed
train
def __all_parameters_processed(self): """ Finish the argument processing. Should be called after all the web service operation's parameters have been successfully processed and, afterwards, no further parameter processing is allowed. Returns a 2-tuple containing the num...
python
{ "resource": "" }
q8156
_ArgParser.__check_for_extra_arguments
train
def __check_for_extra_arguments(self, args_required, args_allowed): """ Report an error in case any extra arguments are detected. Does nothing if reporting extra arguments as exceptions has not been enabled. May only be called after the argument processing has been completed. ...
python
{ "resource": "" }
q8157
_ArgParser.__frame_factory
train
def __frame_factory(self, ancestry_item): """Construct a new frame representing the given ancestry item.""" frame_class = Frame if ancestry_item is not None and ancestry_item.choice(): frame_class = ChoiceFrame return frame_class(ancestry_item, self.__error, self....
python
{ "resource": "" }
q8158
_ArgParser.__get_param_value
train
def __get_param_value(self, name): """ Extract a parameter value from the remaining given arguments. Returns a 2-tuple consisting of the following: * Boolean indicating whether an argument has been specified for the requested input parameter. * Parameter value. ...
python
{ "resource": "" }
q8159
_ArgParser.__in_choice_context
train
def __in_choice_context(self): """ Whether we are currently processing a choice parameter group. This includes processing a parameter defined directly or indirectly within such a group. May only be called during parameter processing or the result will be calculated base...
python
{ "resource": "" }
q8160
_ArgParser.__init_run
train
def __init_run(self, args, kwargs, extra_parameter_errors): """Initializes data for a new argument parsing run.""" assert not self.active() self.__args = list(args) self.__kwargs = dict(kwargs) self.__extra_parameter_errors = extra_parameter_errors self.__args_count = len...
python
{ "resource": "" }
q8161
_ArgParser.__match_ancestry
train
def __match_ancestry(self, ancestry): """ Find frames matching the given ancestry. Returns a tuple containing the following: * Topmost frame matching the given ancestry or the bottom-most sentry frame if no frame matches. * Unmatched ancestry part. """ ...
python
{ "resource": "" }
q8162
_ArgParser.__pop_frames_above
train
def __pop_frames_above(self, frame): """Pops all the frames above, but not including the given frame.""" while self.__stack[-1] is not frame: self.__pop_top_frame() assert self.__stack
python
{ "resource": "" }
q8163
_ArgParser.__pop_top_frame
train
def __pop_top_frame(self): """Pops the top frame off the frame stack.""" popped = self.__stack.pop() if self.__stack: self.__stack[-1].process_subframe(popped)
python
{ "resource": "" }
q8164
_ArgParser.__process_parameter
train
def __process_parameter(self, param_name, param_type, ancestry=None): """Collect values for a given web service operation input parameter.""" assert self.active() param_optional = param_type.optional() has_argument, value = self.__get_param_value(param_name) if has_argument: ...
python
{ "resource": "" }
q8165
_ArgParser.__push_frame
train
def __push_frame(self, ancestry_item): """Push a new frame on top of the frame stack.""" frame = self.__frame_factory(ancestry_item) self.__stack.append(frame)
python
{ "resource": "" }
q8166
DocumentStore.open
train
def open(self, url): """ Open a document at the specified URL. The document URL's needs not contain a protocol identifier, and if it does, that protocol identifier is ignored when looking up the store content. Missing documents referenced using the internal 'suds' proto...
python
{ "resource": "" }
q8167
read_python_code
train
def read_python_code(filename): "Returns the given Python source file's compiled content." file = open(filename, "rt") try: source = file.read() finally: file.close() # Python 2.6 and below did not support passing strings to exec() & # compile() functions containing line separato...
python
{ "resource": "" }
q8168
recursive_package_list
train
def recursive_package_list(*packages): """ Returns a list of all the given packages and all their subpackages. Given packages are expected to be found relative to this script's location. Subpackages are detected by scanning the given packages' subfolder hierarchy for any folders containing the '__...
python
{ "resource": "" }
q8169
SchemaObject.find
train
def find(self, qref, classes=[], ignore=None): """ Find a referenced type in self or children. Return None if not found. Qualified references for all schema objects checked in this search will be added to the set of ignored qualified references to avoid the find operation going ...
python
{ "resource": "" }
q8170
Iter.next
train
def next(self): """ Get the next item. @return: A tuple: the next (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) @raise StopIteration: A the end. """ frame = self.top() while True: result = frame.next() if resu...
python
{ "resource": "" }
q8171
ServiceDefinition.getprefixes
train
def getprefixes(self): """Add prefixes for each namespace referenced by parameter types.""" namespaces = [] for l in (self.params, self.types): for t,r in l: ns = r.namespace() if ns[1] is None: continue if ns[1] in namespaces: continue...
python
{ "resource": "" }
q8172
ServiceDefinition.description
train
def description(self): """ Get a textual description of the service for which this object represents. @return: A textual description. @rtype: str """ s = [] indent = (lambda n : '\n%*s'%(n*3,' ')) s.append('Service ( %s ) tns="%s"' % (self.service.name, s...
python
{ "resource": "" }
q8173
Document.plain
train
def plain(self): """ Get a string representation of this XML document. @return: A I{plain} string. @rtype: basestring """ s = [] s.append(self.DECL) root = self.root() if root is not None: s.append(root.plain()) return ''.join(s...
python
{ "resource": "" }
q8174
SchemaCollection.merge
train
def merge(self): """ Merge contained schemas into one. @return: The merged schema. @rtype: L{Schema} """ if self.children: schema = self.children[0] for s in self.children[1:]: schema.merge(s) return schema
python
{ "resource": "" }
q8175
Topics.create_sqs_policy
train
def create_sqs_policy(self, topic_name, topic_arn, topic_subs): """ This method creates the SQS policy needed for an SNS subscription. It also takes the ARN of the SQS queue and converts it to the URL needed for the subscription, as that takes a URL rather than the ARN. """ ...
python
{ "resource": "" }
q8176
Topics.create_topic
train
def create_topic(self, topic_name, topic_config): """ Creates the SNS topic, along with any subscriptions requested. """ topic_subs = [] t = self.template if "Subscription" in topic_config: topic_subs = topic_config["Subscription"] t.add_resource( ...
python
{ "resource": "" }
q8177
get_stream_action_type
train
def get_stream_action_type(stream_arn): """Returns the awacs Action for a stream type given an arn Args: stream_arn (str): The Arn of the stream. Returns: :class:`awacs.aws.Action`: The appropriate stream type awacs Action class Raises: ValueError: If the stream ty...
python
{ "resource": "" }
q8178
stream_reader_statements
train
def stream_reader_statements(stream_arn): """Returns statements to allow Lambda to read from a stream. Handles both DynamoDB & Kinesis streams. Automatically figures out the type of stream, and provides the correct actions from the supplied Arn. Arg: stream_arn (str): A kinesis or dynamodb str...
python
{ "resource": "" }
q8179
Function.add_policy_statements
train
def add_policy_statements(self, statements): """Adds statements to the policy. Args: statements (:class:`awacs.aws.Statement` or list): Either a single Statment, or a list of statements. """ if isinstance(statements, Statement): statements = [stat...
python
{ "resource": "" }
q8180
Function.generate_policy_statements
train
def generate_policy_statements(self): """Generates the policy statements for the role used by the function. To add additional statements you can either override the `extended_policy_statements` method to return a list of Statements to be added to the policy, or override this method itse...
python
{ "resource": "" }
q8181
GenericResourceCreator.setup_resource
train
def setup_resource(self): """ Setting Up Resource """ template = self.template variables = self.get_variables() tclass = variables['Class'] tprops = variables['Properties'] output = variables['Output'] klass = load_object_from_string('troposphere.' + tclass) ...
python
{ "resource": "" }
q8182
kms_key_policy
train
def kms_key_policy(): """ Creates a key policy for use of a KMS Key. """ statements = [] statements.extend(kms_key_root_statements()) return Policy( Version="2012-10-17", Id="root-account-access", Statement=statements )
python
{ "resource": "" }
q8183
logstream_policy
train
def logstream_policy(): """Policy needed for logspout -> kinesis log streaming.""" p = Policy( Statement=[ Statement( Effect=Allow, Resource=["*"], Action=[ kinesis.CreateStream, kinesis.DescribeStream, A...
python
{ "resource": "" }
q8184
runlogs_policy
train
def runlogs_policy(log_group_ref): """Policy needed for Empire -> Cloudwatch logs to record run output.""" p = Policy( Statement=[ Statement( Effect=Allow, Resource=[ Join('', [ 'arn:aws:logs:*:*:log-group:', ...
python
{ "resource": "" }
q8185
check_properties
train
def check_properties(properties, allowed_properties, resource): """Checks the list of properties in the properties variable against the property list provided by the allowed_properties variable. If any property does not match the properties in allowed_properties, a ValueError is raised to prevent unexpe...
python
{ "resource": "" }
q8186
merge_tags
train
def merge_tags(left, right, factory=Tags): """ Merge two sets of tags into a new troposphere object Args: left (Union[dict, troposphere.Tags]): dictionary or Tags object to be merged with lower priority right (Union[dict, troposphere.Tags]): dictionary or Tags object to be ...
python
{ "resource": "" }
q8187
get_record_set_md5
train
def get_record_set_md5(rs_name, rs_type): """Accept record_set Name and Type. Return MD5 sum of these values.""" rs_name = rs_name.lower() rs_type = rs_type.upper() # Make A and CNAME records hash to same sum to support updates. rs_type = "ACNAME" if rs_type in ["A", "CNAME"] else rs_type return...
python
{ "resource": "" }
q8188
DNSRecords.add_hosted_zone_id_for_alias_target_if_missing
train
def add_hosted_zone_id_for_alias_target_if_missing(self, rs): """Add proper hosted zone id to record set alias target if missing.""" alias_target = getattr(rs, "AliasTarget", None) if alias_target: hosted_zone_id = getattr(alias_target, "HostedZoneId", None) if not hosted...
python
{ "resource": "" }
q8189
DNSRecords.create_record_sets
train
def create_record_sets(self, record_set_dicts): """Accept list of record_set dicts. Return list of record_set objects.""" record_set_objects = [] for record_set_dict in record_set_dicts: # pop removes the 'Enabled' key and tests if True. if record_set_dict.pop('En...
python
{ "resource": "" }
q8190
DNSRecords.create_record_set_groups
train
def create_record_set_groups(self, record_set_group_dicts): """Accept list of record_set_group dicts. Return list of record_set_group objects.""" record_set_groups = [] for name, group in record_set_group_dicts.iteritems(): # pop removes the 'Enabled' key and tests if True. ...
python
{ "resource": "" }
q8191
read_only_s3_bucket_policy_statements
train
def read_only_s3_bucket_policy_statements(buckets, folder="*"): """ Read only policy an s3 bucket. """ list_buckets = [s3_arn(b) for b in buckets] object_buckets = [s3_objects_arn(b, folder) for b in buckets] bucket_resources = list_buckets + object_buckets return [ Statement( ...
python
{ "resource": "" }
q8192
lambda_vpc_execution_statements
train
def lambda_vpc_execution_statements(): """Allow Lambda to manipuate EC2 ENIs for VPC support.""" return [ Statement( Effect=Allow, Resource=['*'], Action=[ ec2.CreateNetworkInterface, ec2.DescribeNetworkInterfaces, ec2.D...
python
{ "resource": "" }
q8193
dynamodb_autoscaling_policy
train
def dynamodb_autoscaling_policy(tables): """Policy to allow AutoScaling a list of DynamoDB tables.""" return Policy( Statement=[ Statement( Effect=Allow, Resource=dynamodb_arns(tables), Action=[ dynamodb.DescribeTable, ...
python
{ "resource": "" }
q8194
HEALPix.interpolate_bilinear_skycoord
train
def interpolate_bilinear_skycoord(self, skycoord, values): """ Interpolate values at specific celestial coordinates using bilinear interpolation. If a position does not have four neighbours, this currently returns NaN. Note that this method requires that a celestial frame was specified...
python
{ "resource": "" }
q8195
HEALPix.cone_search_skycoord
train
def cone_search_skycoord(self, skycoord, radius): """ Find all the HEALPix pixels within a given radius of a celestial position. Note that this returns all pixels that overlap, including partially, with the search cone. This function can only be used for a single celestial posit...
python
{ "resource": "" }
q8196
HEALPix.boundaries_skycoord
train
def boundaries_skycoord(self, healpix_index, step): """ Return the celestial coordinates of the edges of HEALPix pixels This returns the celestial coordinates of points along the edge of each HEALPIX pixel. The number of points returned for each pixel is ``4 * step``, so setting...
python
{ "resource": "" }
q8197
level_to_nside
train
def level_to_nside(level): """ Find the pixel dimensions of the top-level HEALPix tiles. This is given by ``nside = 2**level``. Parameters ---------- level : int The resolution level Returns ------- nside : int The number of pixels on the side of one of the 12 'top...
python
{ "resource": "" }
q8198
nside_to_level
train
def nside_to_level(nside): """ Find the HEALPix level for a given nside. This is given by ``level = log2(nside)``. This function is the inverse of `level_to_nside`. Parameters ---------- nside : int The number of pixels on the side of one of the 12 'top-level' HEALPix tiles. ...
python
{ "resource": "" }
q8199
level_ipix_to_uniq
train
def level_ipix_to_uniq(level, ipix): """ Convert a level and HEALPix index into a uniq number representing the cell. This function is the inverse of `uniq_to_level_ipix`. Parameters ---------- level : int The level of the HEALPix cell ipix : int The index of the HEALPix cel...
python
{ "resource": "" }