_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q23700
gradient
train
def gradient(f, **kwargs): """Calculate the gradient of a grid of values. Works for both regularly-spaced data, and grids with varying spacing. Either `coordinates` or `deltas` must be specified, or `f` must be given as an `xarray.DataArray` with attached coordinate and projection information. If `f`...
python
{ "resource": "" }
q23701
laplacian
train
def laplacian(f, **kwargs): """Calculate the laplacian of a grid of values. Works for both regularly-spaced data, and grids with varying spacing. Either `coordinates` or `deltas` must be specified, or `f` must be given as an `xarray.DataArray` with attached coordinate and projection information. If `...
python
{ "resource": "" }
q23702
_broadcast_to_axis
train
def _broadcast_to_axis(arr, axis, ndim): """Handle reshaping coordinate array to have proper dimensionality. This puts the values along the specified axis. """ if arr.ndim == 1 and
python
{ "resource": "" }
q23703
_process_gradient_args
train
def _process_gradient_args(f, kwargs): """Handle common processing of arguments for gradient and gradient-like functions.""" axes = kwargs.get('axes', range(f.ndim)) def _check_length(positions): if 'axes' in kwargs and len(positions) < len(axes): raise ValueError('Length of "coordinate...
python
{ "resource": "" }
q23704
_process_deriv_args
train
def _process_deriv_args(f, kwargs): """Handle common processing of arguments for derivative functions.""" n = f.ndim axis = normalize_axis_index(kwargs.get('axis', 0), n) if f.shape[axis] < 3: raise ValueError('f must have at least 3 point along the desired axis.') if 'delta' in kwargs: ...
python
{ "resource": "" }
q23705
parse_angle
train
def parse_angle(input_dir): """Calculate the meteorological angle from directional text. Works for abbrieviations or whole words (E -> 90 | South -> 180) and also is able to parse 22.5 degreee angles such as ESE/East South East Parameters ---------- input_dir : string or array-like strings ...
python
{ "resource": "" }
q23706
Text.to_dict
train
def to_dict(self): """ Returns the underlying data as a Python dict. """ return {
python
{ "resource": "" }
q23707
Text.generate_corpus
train
def generate_corpus(self, text): """ Given a text string, returns a list of lists; that is, a list of "sentences," each of which is a list of words. Before splitting into words, the sentences are filtered through `self.test_sentence_input` """ if isinstance(text, str): ...
python
{ "resource": "" }
q23708
Text.from_chain
train
def from_chain(cls, chain_json, corpus=None, parsed_sentences=None): """ Init a Text class based on an existing chain JSON string or object
python
{ "resource": "" }
q23709
Chain.build
train
def build(self, corpus, state_size): """ Build a Python representation of the Markov model. Returns a dict of dicts where the keys of the outer dict represent all possible states, and point to the inner dicts. The inner dicts represent all possibilities for the "next" item in the...
python
{ "resource": "" }
q23710
Chain.move
train
def move(self, state): """ Given a state, choose the next item at random. """ if state == tuple([ BEGIN ] * self.state_size): choices = self.begin_choices cumdist = self.begin_cumdist else:
python
{ "resource": "" }
q23711
Chain.from_json
train
def from_json(cls, json_thing): """ Given a JSON object or JSON string that was created by `self.to_json`, return the corresponding markovify.Chain. """ if isinstance(json_thing, basestring): obj = json.loads(json_thing) else: obj = json_thing ...
python
{ "resource": "" }
q23712
PyJWS.register_algorithm
train
def register_algorithm(self, alg_id, alg_obj): """ Registers a new Algorithm for use when creating and verifying tokens. """ if alg_id in self._algorithms: raise ValueError('Algorithm already has a handler.') if not isinstance(alg_obj, Algorithm):
python
{ "resource": "" }
q23713
PyJWS.unregister_algorithm
train
def unregister_algorithm(self, alg_id): """ Unregisters an Algorithm for use when creating and verifying tokens Throws KeyError if algorithm is not registered. """ if alg_id not in self._algorithms: raise KeyError('The
python
{ "resource": "" }
q23714
get_default_algorithms
train
def get_default_algorithms(): """ Returns the algorithms that are implemented by the library. """ default_algorithms = { 'none': NoneAlgorithm(), 'HS256': HMACAlgorithm(HMACAlgorithm.SHA256), 'HS384': HMACAlgorithm(HMACAlgorithm.SHA384), 'HS512': HMACAlgorithm(HMACAlgorit...
python
{ "resource": "" }
q23715
info
train
def info(): """ Generate information for a bug report. Based on the requests package help utility module. """ try: platform_info = {"system": platform.system(), "release": platform.release()} except IOError: platform_info = {"system": "Unknown", "release": "Unknown"} impleme...
python
{ "resource": "" }
q23716
Provider._authenticate
train
def _authenticate(self): """Authenticate with netcup server. Must be called first.""" login_info = self._apicall('login') self.api_session_id = login_info['apisessionid'] if not self.api_session_id: raise Exception('Login failed') # query
python
{ "resource": "" }
q23717
Provider._create_record
train
def _create_record(self, rtype, name, content): """Create record. If it already exists, do nothing.""" if not self._list_records(rtype, name, content): self._update_records([{}], { 'type': rtype, 'hostname':
python
{ "resource": "" }
q23718
Provider._list_records
train
def _list_records(self, rtype=None, name=None, content=None): """List all records. Return an empty list if no records found. ``rtype``, ``name`` and ``content`` are used to filter records.""" records = [ { 'id': record['id'], 'type': record['type'], ...
python
{ "resource": "" }
q23719
Provider._delete_record
train
def _delete_record(self, identifier=None, rtype=None, name=None, content=None): """Delete an existing record. If record does not exist, do nothing.""" records = self._raw_records(identifier, rtype, name, content) LOGGER.debug('delete_records: %s', [rec['id'] for rec in records]) self._up...
python
{ "resource": "" }
q23720
Provider._raw_records
train
def _raw_records(self, identifier=None, rtype=None, name=None, content=None): """Return list of record dicts in the netcup API convention.""" record_fields = { 'id': identifier, 'type': rtype, 'hostname': name and self._relative_name(name), 'destination': ...
python
{ "resource": "" }
q23721
Provider._update_records
train
def _update_records(self, records, data): """Insert or update a list of DNS records, specified in the netcup API convention. The fields ``hostname``, ``type``, and ``destination`` are mandatory and must be provided either in the record dict or through ``data``! """ data ...
python
{ "resource": "" }
q23722
provider_parser
train
def provider_parser(subparser): """Configure provider parser for Rackspace""" subparser.add_argument( "--auth-account", help="specify account number for authentication") subparser.add_argument( "--auth-username", help="specify username for authentication. Only used if --auth-token is...
python
{ "resource": "" }
q23723
provider_parser
train
def provider_parser(subparser): """Specify arguments for AWS Route 53 Lexicon Provider.""" subparser.add_argument("--auth-access-key", help="specify ACCESS_KEY for authentication") subparser.add_argument("--auth-access-secret", help="specify ACCESS_SECRE...
python
{ "resource": "" }
q23724
RecordSetPaginator.get_base_kwargs
train
def get_base_kwargs(self): """Get base kwargs for API call.""" kwargs = { 'HostedZoneId': self.hosted_zone_id
python
{ "resource": "" }
q23725
RecordSetPaginator.all_record_sets
train
def all_record_sets(self): """Generator to loop through current record set. Call next page if it exists. """ is_truncated = True start_record_name = None start_record_type = None kwargs = self.get_base_kwargs() while is_truncated: if start_rec...
python
{ "resource": "" }
q23726
Provider.filter_zone
train
def filter_zone(self, data): """Check if a zone is private""" if self.private_zone is not None: if data['Config']['PrivateZone'] != self.str2bool(self.private_zone):
python
{ "resource": "" }
q23727
Provider._authenticate
train
def _authenticate(self): """Determine the hosted zone id for the domain.""" try: hosted_zones = self.r53_client.list_hosted_zones_by_name()[ 'HostedZones'
python
{ "resource": "" }
q23728
Provider._create_record
train
def _create_record(self, rtype, name, content): """Create a record in the hosted zone."""
python
{ "resource": "" }
q23729
Provider._update_record
train
def _update_record(self, identifier=None, rtype=None, name=None, content=None): """Update a record from the hosted zone."""
python
{ "resource": "" }
q23730
Provider._delete_record
train
def _delete_record(self, identifier=None, rtype=None, name=None, content=None): """Delete a record from the hosted zone."""
python
{ "resource": "" }
q23731
Provider._list_records
train
def _list_records(self, rtype=None, name=None, content=None): """List all records for the hosted zone.""" records = [] paginator = RecordSetPaginator(self.r53_client, self.domain_id) for record in paginator.all_record_sets(): if rtype is not None and record['Type'] != rtype: ...
python
{ "resource": "" }
q23732
Provider._authenticate
train
def _authenticate(self): """ Authenticates against Easyname website and try to find out the domain id. Easyname uses a CSRF token in its login form, so two requests are neccessary to actually login. Returns: bool: True if domain id was found. Raises: ...
python
{ "resource": "" }
q23733
Provider._create_record_internal
train
def _create_record_internal(self, rtype, name, content, identifier=None): """ Create a new DNS entry in the domain zone if it does not already exist. Args: rtype (str): The DNS type (e.g. A, TXT, MX, etc) of the new entry. name (str): The name of the new DNS entry, e.g the d...
python
{ "resource": "" }
q23734
Provider._delete_record
train
def _delete_record(self, identifier=None, rtype=None, name=None, content=None): """ Delete one or more DNS entries in the domain zone that match the given criteria. Args: [identifier] (str): An ID to match against DNS entry easyname IDs. [rtype] (str): A DNS rtype (e...
python
{ "resource": "" }
q23735
Provider._update_record
train
def _update_record(self, identifier, rtype=None, name=None, content=None): """ Update a DNS entry identified by identifier or name in the domain zone. Any non given argument will leave the current value of the DNS entry. Args: identifier (str): The easyname id of the DNS entry...
python
{ "resource": "" }
q23736
Provider._list_records_internal
train
def _list_records_internal(self, rtype=None, name=None, content=None, identifier=None): """ Filter and list DNS entries of domain zone on Easyname. Easyname shows each entry in a HTML table row and each attribute on a table column. Args: [rtype] (str): Filter by DNS rt...
python
{ "resource": "" }
q23737
Provider._get_post_data_to_create_dns_entry
train
def _get_post_data_to_create_dns_entry(self, rtype, name, content, identifier=None): """ Build and return the post date that is needed to create a DNS entry. """ is_update = identifier is not None if is_update: records = self._list_records_internal(identifier=identifi...
python
{ "resource": "" }
q23738
Provider._is_duplicate_record
train
def _is_duplicate_record(self, rtype, name, content): """Check if DNS entry already exists.""" records = self._list_records(rtype, name, content)
python
{ "resource": "" }
q23739
Provider._get_matching_dns_entry_ids
train
def _get_matching_dns_entry_ids(self, identifier=None, rtype=None, name=None, content=None): """Return a list of DNS entries that match the given criteria.""" record_ids = [] if not identifier: records
python
{ "resource": "" }
q23740
Provider._get_dns_entry_trs
train
def _get_dns_entry_trs(self): """ Return the TR elements holding the DNS entries. """ from bs4 import BeautifulSoup dns_list_response = self.session.get( self.URLS['dns'].format(self.domain_id)) self._log('DNS list', dns_list_response) assert dns_list_...
python
{ "resource": "" }
q23741
Provider._filter_records
train
def _filter_records(self, records, rtype=None, name=None, content=None, identifier=None): # pylint: disable=too-many-arguments,no-self-use """ Filter dns entries based on type, name or content. """ if not records: return [] if identifier is not None: LOGG...
python
{ "resource": "" }
q23742
Provider._get_csrf_token
train
def _get_csrf_token(self): """Return the CSRF Token of easyname login form.""" from bs4 import BeautifulSoup home_response = self.session.get(self.URLS['login']) self._log('Home', home_response) assert home_response.status_code == 200, \ 'Could not load Easyname login...
python
{ "resource": "" }
q23743
Provider._login
train
def _login(self, csrf_token): """Attempt to login session on easyname.""" login_response = self.session.post( self.URLS['login'], data={ 'username': self._get_provider_option('auth_username') or '', 'password': self._get_provider_option('auth_passw...
python
{ "resource": "" }
q23744
Provider._get_domain_text_of_authoritative_zone
train
def _get_domain_text_of_authoritative_zone(self): """Get the authoritative name zone.""" # We are logged in, so get the domain list from bs4 import BeautifulSoup zones_response = self.session.get(self.URLS['domain_list']) self._log('Zone', zones_response) assert zones_res...
python
{ "resource": "" }
q23745
Provider._get_domain_id
train
def _get_domain_id(self, domain_text_element): # pylint: disable=no-self-use """Return the easyname id of the domain.""" try: # Hierarchy: TR > TD > SPAN > Domain Text tr_anchor = domain_text_element.parent.parent.parent td_anchor = tr_anchor.find('td', {'class': 'td...
python
{ "resource": "" }
q23746
Provider._log
train
def _log(self, name, element): # pylint: disable=no-self-use """ Log Response and Tag elements. Do nothing if elements is none of them. """ from bs4 import BeautifulSoup, Tag if isinstance(element, Response):
python
{ "resource": "" }
q23747
find_providers
train
def find_providers(): """Find all providers registered in Lexicon, and their availability""" providers_list = sorted({modname for (_, modname, _) in pkgutil.iter_modules(providers.__path__) if modname != 'base'}) try: distribution
python
{ "resource": "" }
q23748
provider_parser
train
def provider_parser(subparser): """Configure a provider parser for Hetzner""" subparser.add_argument('--auth-account', help='specify type of Hetzner account: by default Hetzner Robot ' '(robot) or Hetzner konsoleH (konsoleh)') subparser.add_argument('--a...
python
{ "resource": "" }
q23749
Provider._create_record
train
def _create_record(self, rtype, name, content): """ Connects to Hetzner account, adds a new record to the zone and returns a boolean, if creation was successful or not. Needed record rtype, name and content for record to create. """ with self._session(self.domain, self.do...
python
{ "resource": "" }
q23750
Provider._list_records
train
def _list_records(self, rtype=None, name=None, content=None): """ Connects to Hetzner account and returns a list of records filtered by record rtype, name and content. The list is empty if no records found. """ with self._session(self.domain, self.domain_id) as ddata:
python
{ "resource": "" }
q23751
Provider._delete_record
train
def _delete_record(self, identifier=None, rtype=None, name=None, content=None): """ Connects to Hetzner account, removes an existing record from the zone and returns a boolean, if deletion was successful or not. Uses identifier or rtype, name & content to lookup over all records of the z...
python
{ "resource": "" }
q23752
Provider._create_identifier
train
def _create_identifier(rdtype, name, content): """ Creates hashed identifier based on full qualified record type, name & content and returns hash. """ sha256 = hashlib.sha256() sha256.update((rdtype + '/').encode('UTF-8'))
python
{ "resource": "" }
q23753
Provider._parse_identifier
train
def _parse_identifier(self, identifier, zone=None): """ Parses the record identifier and returns type, name & content of the associated record as tuple. The tuple is empty if no associated record found. """ rdtype, name, content = None, None, None
python
{ "resource": "" }
q23754
Provider._convert_content
train
def _convert_content(self, rdtype, content): """ Converts type dependent record content into well formed and fully qualified content for domain zone and returns content. """ if rdtype == 'TXT': if content[0] != '"': content = '"' + content ...
python
{ "resource": "" }
q23755
Provider._list_records_in_zone
train
def _list_records_in_zone(self, zone, rdtype=None, name=None, content=None): """ Iterates over all records of the zone and returns a list of records filtered by record type, name and content. The list is empty if no records found. """ records = [] rrsets = zone.iterate_rd...
python
{ "resource": "" }
q23756
Provider._request
train
def _request(self, action='GET', url='/', data=None, query_params=None): """ Requests to Hetzner by current session and returns the response. """ if data is None: data = {} if query_params is None: query_params = {}
python
{ "resource": "" }
q23757
Provider._dns_lookup
train
def _dns_lookup(name, rdtype, nameservers=None): """ Looks on specified or default system domain nameservers to resolve record type & name and returns record set. The record set is empty if no propagated record found. """ rrset = dns.rrset.from_text(name, 0, 1, rdtype) ...
python
{ "resource": "" }
q23758
Provider._get_nameservers
train
def _get_nameservers(domain): """ Looks for domain nameservers and returns the IPs of the nameservers as a list. The list is empty, if no nameservers were found. Needed associated domain zone name for lookup. """ nameservers = [] rdtypes_ns = ['SOA', 'NS'] ...
python
{ "resource": "" }
q23759
Provider._get_dns_cname
train
def _get_dns_cname(name, link=False): """ Looks for associated domain zone, nameservers and linked record name until no more linked record name was found for the given fully qualified record name or the CNAME lookup was disabled, and then returns the parameters as a tuple. """ ...
python
{ "resource": "" }
q23760
Provider._link_record
train
def _link_record(self): """ Checks restrictions for use of CNAME lookup and returns a tuple of the fully qualified record name to lookup and a boolean, if a CNAME lookup should be done or not. The fully qualified record name is empty if no record name is specified by this provide...
python
{ "resource": "" }
q23761
Provider._propagated_record
train
def _propagated_record(self, rdtype, name, content, nameservers=None): """ If the publicly propagation check should be done, waits until the domain nameservers responses with the propagated record type, name & content and returns a boolean, if the publicly propagation was successful or n...
python
{ "resource": "" }
q23762
Provider._filter_dom
train
def _filter_dom(dom, filters, last_find_all=False): """ If not exists, creates an DOM from a given session response, then filters the DOM via given API filters and returns the filtered DOM. The DOM is empty if the filters have no match. """ if isinstance(dom, string_types...
python
{ "resource": "" }
q23763
Provider._extract_hidden_data
train
def _extract_hidden_data(dom): """ Extracts hidden input data from DOM and returns the data as dictionary. """
python
{ "resource": "" }
q23764
Provider._extract_domain_id
train
def _extract_domain_id(string, regex): """ Extracts domain ID from given string and returns the domain ID.
python
{ "resource": "" }
q23765
Provider._auth_session
train
def _auth_session(self, username, password): """ Creates session to Hetzner account, authenticates with given credentials and returns the session, if authentication was successful. Otherwise raises error. """ api = self.api[self.account]['auth'] endpoint = api.get('endpoi...
python
{ "resource": "" }
q23766
Provider._exit_session
train
def _exit_session(self): """ Exits session to Hetzner account and returns. """ api = self.api[self.account] response = self._get(api['exit']['GET']['url']) if not Provider._filter_dom(response.text, api['filter']):
python
{ "resource": "" }
q23767
Provider._get_domain_id
train
def _get_domain_id(self, domain): """ Pulls all domains managed by authenticated Hetzner account, extracts their IDs and returns the ID for the current domain, if exists. Otherwise raises error. """ api = self.api[self.account]['domain_id'] qdomain = dns.name.from_text(do...
python
{ "resource": "" }
q23768
Provider._get_zone
train
def _get_zone(self, domain, domain_id): """ Pulls the zone for the current domain from authenticated Hetzner account and returns it as an zone object. """ api = self.api[self.account] for request in api['zone']['GET']: url = (request.copy()).get('url', '/').re...
python
{ "resource": "" }
q23769
Provider._post_zone
train
def _post_zone(self, zone): """ Pushes updated zone for current domain to authenticated Hetzner account and returns a boolean, if update was successful or not. Furthermore, waits until the zone has been taken over, if it is a Hetzner Robot account. """ api = self.api[self...
python
{ "resource": "" }
q23770
Provider._validate_response
train
def _validate_response(self, response, message, exclude_code=None): # pylint: disable=no-self-use """ validate an api server response :param dict response: server response to check :param str message: error message to raise :param int exclude_code: error codes
python
{ "resource": "" }
q23771
Provider._authenticate
train
def _authenticate(self): """ run any request against the API just to make sure the credentials are valid :return bool: success status :raises Exception: on error """ opts = {'domain': self._domain} opts.update(self._auth) response = self._api.doma...
python
{ "resource": "" }
q23772
Provider._create_record
train
def _create_record(self, rtype, name, content): """ create a record does nothing if the record already exists :param str rtype: type of record :param str name: name of record :param mixed content: value of record :return bool: success status :raises Excep...
python
{ "resource": "" }
q23773
Provider._list_records
train
def _list_records(self, rtype=None, name=None, content=None): """ list all records :param str rtype: type of record :param str name: name of record :param mixed content: value of record :return list: list of found records :raises Exception: on error """ ...
python
{ "resource": "" }
q23774
Provider._update_record
train
def _update_record(self, identifier, rtype=None, name=None, content=None): """ update a record :param int identifier: identifier of record to update :param str rtype: type of record :param str name: name of record :param mixed content: value of record :return boo...
python
{ "resource": "" }
q23775
Provider.create_record
train
def create_record(self, rtype=None, name=None, content=None, **kwargs): """ Create record. If record already exists with the same content, do nothing. """ if not rtype and kwargs.get('type'): warnings.warn('Parameter "type" is deprecated, use "rtype" instead.',
python
{ "resource": "" }
q23776
Provider.list_records
train
def list_records(self, rtype=None, name=None, content=None, **kwargs): """ List all records. Return an empty list if no records found type, name and content are used to filter records. If possible filter during the query, otherwise filter after response is received. """ ...
python
{ "resource": "" }
q23777
Provider.update_record
train
def update_record(self, identifier, rtype=None, name=None, content=None, **kwargs): """ Update a record. Identifier must be specified. """ if not rtype and kwargs.get('type'): warnings.warn('Parameter "type" is deprecated, use "rtype" instead.',
python
{ "resource": "" }
q23778
Provider.delete_record
train
def delete_record(self, identifier=None, rtype=None, name=None, content=None, **kwargs): """ Delete an existing record. If record does not exist, do nothing. If an identifier is specified, use it, otherwise do a lookup using type, name and content. """ if not rtype and kw...
python
{ "resource": "" }
q23779
Provider.notify_slaves
train
def notify_slaves(self): """Checks to see if slaves should be notified, and notifies them if needed""" if self.disable_slave_notify is not None: LOGGER.debug('Slave notifications disabled') return False if self.zone_data()['kind'] == 'Master':
python
{ "resource": "" }
q23780
Provider.zone_data
train
def zone_data(self): """Get zone data""" if self._zone_data is
python
{ "resource": "" }
q23781
Provider._update_record
train
def _update_record(self, identifier, rtype=None, name=None, content=None): """Updates the specified record in a new Gandi zone 'content' should be a string or a list of strings """ if self.protocol == 'rpc': return self.rpc_helper.update_record(identifier, rtype, name, conte...
python
{ "resource": "" }
q23782
GandiRPCSubProvider.authenticate
train
def authenticate(self): """Determine the current domain and zone IDs for the domain.""" try: payload = self._api.domain.info(self._api_key, self._domain) self._zone_id = payload['zone_id']
python
{ "resource": "" }
q23783
GandiRPCSubProvider.create_record
train
def create_record(self, rtype, name, content, ttl): """Creates a record for the domain in a new Gandi zone.""" version = None ret = False # This isn't quite "do nothing" if the record already exists. # In this case, no new record will be created, but a new zone version #...
python
{ "resource": "" }
q23784
GandiRPCSubProvider.update_record
train
def update_record(self, identifier, rtype=None, name=None, content=None): # pylint: disable=too-many-branches """Updates the specified record in a new Gandi zone.""" if not identifier: records = self.list_records(rtype, name) if len(records) == 1: identifier = re...
python
{ "resource": "" }
q23785
GandiRPCSubProvider.delete_record
train
def delete_record(self, identifier=None, rtype=None, name=None, content=None): """Removes the specified records in a new Gandi zone.""" version = None ret = False opts = {} if identifier is not None: opts['id'] = identifier else: if not rtype and ...
python
{ "resource": "" }
q23786
ConfigResolver.add_config_source
train
def add_config_source(self, config_source, position=None): """ Add a config source to the current ConfigResolver instance. If position is
python
{ "resource": "" }
q23787
ConfigResolver.with_legacy_dict
train
def with_legacy_dict(self, legacy_dict_object): """Configure a source that consumes the dict that where used on Lexicon 2.x""" warnings.warn(DeprecationWarning('Legacy configuration object has been used '
python
{ "resource": "" }
q23788
provider_parser
train
def provider_parser(subparser): """Configure provider parser for CloudNS""" identity_group = subparser.add_mutually_exclusive_group() identity_group.add_argument( "--auth-id", help="specify user id for authentication") identity_group.add_argument( "--auth-subid", help="specify subuser id...
python
{ "resource": "" }
q23789
Provider._find_record
train
def _find_record(self, domain, _type=None): """search for a record on NS1 across zones. returns None if not found.""" def _is_matching(record): """filter function for records""" if domain and record.get('domain', None) != domain: return False if _typ...
python
{ "resource": "" }
q23790
generate_list_table_result
train
def generate_list_table_result(lexicon_logger, output=None, without_header=None): """Convert returned data from list actions into a nice table for command line usage""" if not isinstance(output, list): lexicon_logger.debug('Command output is not a list, and then cannot ' 'be...
python
{ "resource": "" }
q23791
generate_table_results
train
def generate_table_results(output=None, without_header=None): """Convert returned data from non-list actions into a nice table for command line usage"""
python
{ "resource": "" }
q23792
handle_output
train
def handle_output(results, output_type, action): """Print the relevant output for given output_type""" if output_type == 'QUIET': return if not output_type == 'JSON': if action == 'list': table = generate_list_table_result( logger, results, output_type == 'TABLE-...
python
{ "resource": "" }
q23793
main
train
def main(): """Main function of Lexicon.""" # Dynamically determine all the providers available and gather command line arguments. parsed_args = generate_cli_main_parser().parse_args() log_level = logging.getLevelName(parsed_args.log_level) logging.basicConfig(stream=sys.stdout, level=log_level, ...
python
{ "resource": "" }
q23794
Client.execute
train
def execute(self): """Execute provided configuration in class constructor to the DNS records""" self.provider.authenticate() identifier = self.config.resolve('lexicon:identifier') record_type = self.config.resolve('lexicon:type') name = self.config.resolve('lexicon:name') ...
python
{ "resource": "" }
q23795
Provider._authenticate
train
def _authenticate(self): """Logs-in the user and checks the domain name""" if not self._get_provider_option( 'auth_username') or not self._get_provider_option('auth_password'): raise Exception( 'No valid authentication data passed, expected: auth-username and ...
python
{ "resource": "" }
q23796
Provider._create_record
train
def _create_record(self, rtype, name, content): """Creates a new unique record""" found = self._list_records(rtype=rtype, name=name, content=content) if found: return True record = self._create_request_record(None, rtype, name, content,
python
{ "resource": "" }
q23797
Provider._update_record
train
def _update_record(self, identifier, rtype=None, name=None, content=None): """Updates a record. Name changes are allowed, but the record identifier will change""" if identifier is not None: if name is not None: records = self._list_records_internal(identifier=identifier) ...
python
{ "resource": "" }
q23798
Provider._update_record_with_id
train
def _update_record_with_id(self, identifier, rtype, content): """Updates existing record with no sub-domain name changes""" record = self._create_request_record(identifier, rtype, None, content,
python
{ "resource": "" }
q23799
Provider._update_record_with_name
train
def _update_record_with_name(self, old_record, rtype, new_name, content): """Updates existing record and changes it's sub-domain name""" new_type = rtype if rtype else old_record['type'] new_ttl = self._get_lexicon_option('ttl') if new_ttl is None and 'ttl' in old_record: ne...
python
{ "resource": "" }