_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q30100
_parse_snapshot_share
train
def _parse_snapshot_share(response, name): ''' Extracts snapshot return header. '''
python
{ "resource": "" }
q30101
purge_blob_containers
train
def purge_blob_containers(account, account_key): """ Delete all blob containers in the given storage account. USE AT OWN RISK. NOT SUPPORTED BY STORAGE TEAM. """ bs = BlockBlobService(account, account_key) with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor: #...
python
{ "resource": "" }
q30102
_generate_encryption_data_dict
train
def _generate_encryption_data_dict(kek, cek, iv): ''' Generates and returns the encryption metadata as a dict. :param object kek: The key encryption key. See calling functions for more information. :param bytes cek: The content encryption key. :param bytes iv: The initialization vector. :return...
python
{ "resource": "" }
q30103
_generate_AES_CBC_cipher
train
def _generate_AES_CBC_cipher(cek, iv): ''' Generates and returns an encryption cipher for AES CBC using the given cek and iv. :param bytes[] cek: The content encryption key for the cipher. :param bytes[] iv: The initialization vector for the cipher. :return: A
python
{ "resource": "" }
q30104
CloudStorageAccount.create_file_service
train
def create_file_service(self): ''' Creates a FileService object with the settings specified in the CloudStorageAccount. :return: A service object. :rtype: :class:`~azure.storage.file.fileservice.FileService` ''' try: from azure.storage.file.fileservi...
python
{ "resource": "" }
q30105
_get_request_body
train
def _get_request_body(request_body): '''Converts an object into a request body. If it's None we'll return an empty string, if it's one of our objects it'll convert it to XML and return it. Otherwise we just use the object directly''' if request_body is None: return b'' if isinstance(r...
python
{ "resource": "" }
q30106
AutoUpdatedTokenCredential.stop_refreshing_token
train
def stop_refreshing_token(self): """ The timer needs to be canceled if the application is terminating, if not the timer will keep going. """
python
{ "resource": "" }
q30107
QueueService.delete_message
train
def delete_message(self, queue_name, message_id, pop_receipt, timeout=None): ''' Deletes the specified message. Normally after a client retrieves a message with the get_messages operation, the client is expected to process and delete the message. To delete the message, you mus...
python
{ "resource": "" }
q30108
FileService.make_file_url
train
def make_file_url(self, share_name, directory_name, file_name, protocol=None, sas_token=None): ''' Creates the url to access a file. :param str share_name: Name of share. :param str directory_name: The path to the directory. :param s...
python
{ "resource": "" }
q30109
FileService.generate_share_shared_access_signature
train
def generate_share_shared_access_signature(self, share_name, permission=None, expiry=None, start=None, id=None, ...
python
{ "resource": "" }
q30110
FileService.get_file_service_properties
train
def get_file_service_properties(self, timeout=None): ''' Gets the properties of a storage account's File service, including Azure Storage Analytics. :param int timeout: The timeout parameter is expressed in seconds. :return: The file service properties. :rtyp...
python
{ "resource": "" }
q30111
FileService._list_shares
train
def _list_shares(self, prefix=None, marker=None, max_results=None, include=None, timeout=None, _context=None): ''' Returns a list of the shares under the specified account. :param str prefix: Filters the results to return only shares whose names begi...
python
{ "resource": "" }
q30112
FileService.snapshot_share
train
def snapshot_share(self, share_name, metadata=None, quota=None, timeout=None): ''' Creates a snapshot of an existing share under the specified account. :param str share_name: The name of the share to create a snapshot of. :param metadata: A dict with name_value p...
python
{ "resource": "" }
q30113
FileService.get_share_acl
train
def get_share_acl(self, share_name, timeout=None): ''' Gets the permissions for the specified share. :param str share_name: Name of existing share. :param int timeout: The timeout parameter is expressed in seconds. :return: A dictionary of access policies...
python
{ "resource": "" }
q30114
FileService.delete_share
train
def delete_share(self, share_name, fail_not_exist=False, timeout=None, snapshot=None, delete_snapshots=None): ''' Marks the specified share for deletion. If the share does not exist, the operation fails on the service. By default, the exception is swallowed by the client. To exp...
python
{ "resource": "" }
q30115
FileService.create_directory
train
def create_directory(self, share_name, directory_name, metadata=None, fail_on_exist=False, timeout=None): ''' Creates a new directory under the specified share or parent directory. If the directory with the same name already exists, the operation fails on the se...
python
{ "resource": "" }
q30116
FileService.get_directory_properties
train
def get_directory_properties(self, share_name, directory_name, timeout=None, snapshot=None): ''' Returns all user-defined metadata and system properties for the specified directory. The data returned does not include the directory's list of files. :param str share_name: ...
python
{ "resource": "" }
q30117
FileService.copy_file
train
def copy_file(self, share_name, directory_name, file_name, copy_source, metadata=None, timeout=None): ''' Copies a file asynchronously. This operation returns a copy operation properties object, including a copy ID you can use to check or abort the copy operation. The...
python
{ "resource": "" }
q30118
FileService.abort_copy_file
train
def abort_copy_file(self, share_name, directory_name, file_name, copy_id, timeout=None): ''' Aborts a pending copy_file operation, and leaves a destination file with zero length and full metadata. :param str share_name: Name of destination share. :param str direct...
python
{ "resource": "" }
q30119
FileService.create_file_from_path
train
def create_file_from_path(self, share_name, directory_name, file_name, local_file_path, content_settings=None, metadata=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None): ''' Cr...
python
{ "resource": "" }
q30120
_HTTPClient.set_proxy
train
def set_proxy(self, host, port, user, password): ''' Sets the proxy server host and port for the HTTP CONNECT Tunnelling. Note that we set the proxies directly on the request later on rather than using the session object as requests has a bug where session proxy is ignored in fa...
python
{ "resource": "" }
q30121
_Retry._should_retry
train
def _should_retry(self, context): ''' A function which determines whether or not to retry. :param ~azure.storage.models.RetryContext context: The retry context. This contains the request, response, and other data which can be used to determine whether or not to retry. ...
python
{ "resource": "" }
q30122
_get_path
train
def _get_path(queue_name=None, include_messages=None, message_id=None): ''' Creates the path to access a queue resource. queue_name: Name of queue. include_messages: Whether or not to include messages. message_id: Message id. ''' if queue_name and include_messages an...
python
{ "resource": "" }
q30123
_parse_metadata
train
def _parse_metadata(response): ''' Extracts out resource metadata information. ''' if response is None or response.headers is None:
python
{ "resource": "" }
q30124
render_icon
train
def render_icon(icon, **kwargs): """ Render a Bootstrap glyphicon icon """ attrs = { "class": add_css_class( "glyphicon glyphicon-{icon}".format(icon=icon),
python
{ "resource": "" }
q30125
render_alert
train
def render_alert(content, alert_type=None, dismissable=True): """ Render a Bootstrap alert """ button = "" if not alert_type: alert_type = "info" css_classes = ["alert", "alert-" + text_value(alert_type)] if dismissable: css_classes.append("alert-dismissable") button ...
python
{ "resource": "" }
q30126
text_concat
train
def text_concat(*args, **kwargs): """ Concatenate several values as a text string with an optional separator
python
{ "resource": "" }
q30127
bootstrap_message_classes
train
def bootstrap_message_classes(message): """ Return the message classes for a message """ extra_tags = None try: extra_tags = message.extra_tags except AttributeError: pass if not extra_tags:
python
{ "resource": "" }
q30128
bootstrap_css
train
def bootstrap_css(): """ Return HTML for Bootstrap CSS. Adjust url in settings. If no url is returned, we don't want this statement to return any HTML. This is intended behavior. Default value: ``None`` This value is configurable, see Settings section
python
{ "resource": "" }
q30129
bootstrap_javascript
train
def bootstrap_javascript(jquery=None): """ Return HTML for Bootstrap JavaScript. Adjust url in settings. If no url is returned, we don't want this statement to return any HTML. This is intended behavior. Default value: ``None`` This value is configurable, see Settings section **Tag n...
python
{ "resource": "" }
q30130
bootstrap_buttons
train
def bootstrap_buttons(parser, token): """ Render buttons for form **Tag name**:: buttons **Parameters**: submit Text for a submit button reset Text for a reset button **Usage**:: {% buttons %}{% endbuttons %} **Example**::
python
{ "resource": "" }
q30131
bootstrap_messages
train
def bootstrap_messages(context, *args, **kwargs): """ Show django.contrib.messages Messages in Bootstrap alert containers. In order to make the alerts dismissable (with the close button), we have to set the jquery parameter too when using the bootstrap_javascript tag. Uses the template ``boots...
python
{ "resource": "" }
q30132
get_pagination_context
train
def get_pagination_context( page, pages_to_show=11, url=None, size=None, extra=None, parameter_name="page" ): """ Generate Bootstrap pagination context from a page object """ pages_to_show = int(pages_to_show) if pages_to_show < 1: raise ValueError( "Pagination pages_to_show ...
python
{ "resource": "" }
q30133
handle_var
train
def handle_var(value, context): """ Handle template tag variable """ # Resolve FilterExpression and Variable immediately if isinstance(value, FilterExpression) or isinstance(value, Variable): return value.resolve(context) # Return quoted strings unquoted # http://djangosnippets.org/s...
python
{ "resource": "" }
q30134
parse_token_contents
train
def parse_token_contents(parser, token): """ Parse template tag contents """ bits = token.split_contents() tag = bits.pop(0) args = [] kwargs = {} asvar = None if len(bits) >= 2 and bits[-2] == "as": asvar = bits[-1] bits = bits[:-2]
python
{ "resource": "" }
q30135
split_css_classes
train
def split_css_classes(css_classes): """ Turn string into a list of CSS classes """
python
{ "resource": "" }
q30136
add_css_class
train
def add_css_class(css_classes, css_class, prepend=False): """ Add a CSS class to a string of CSS classes """ classes_list = split_css_classes(css_classes) classes_to_add = [c for c in split_css_classes(css_class) if c not in classes_list]
python
{ "resource": "" }
q30137
remove_css_class
train
def remove_css_class(css_classes, css_class): """ Remove a CSS class from a string of CSS classes """
python
{ "resource": "" }
q30138
render_link_tag
train
def render_link_tag(url, rel="stylesheet", media=None): """ Build a link tag """ url_dict = url_to_attrs_dict(url, url_attr="href") url_dict.setdefault("href", url_dict.pop("url", None)) url_dict["rel"] = rel
python
{ "resource": "" }
q30139
render_template_file
train
def render_template_file(template, context=None): """ Render a Template to unicode
python
{ "resource": "" }
q30140
url_replace_param
train
def url_replace_param(url, name, value): """ Replace a GET parameter in an URL """ url_components = urlparse(force_str(url)) query_params = parse_qs(url_components.query) query_params[name] = value query = urlencode(query_params, doseq=True)
python
{ "resource": "" }
q30141
url_to_attrs_dict
train
def url_to_attrs_dict(url, url_attr): """ Sanitize url dict as used in django-bootstrap3 settings. """ result = dict() # If url is not a string, it should be a dict if isinstance(url, six.string_types): url_value = url else: try: url_value = url["url"] exc...
python
{ "resource": "" }
q30142
render_formset
train
def render_formset(formset, **kwargs): """ Render a formset to a Bootstrap layout """
python
{ "resource": "" }
q30143
render_formset_errors
train
def render_formset_errors(formset, **kwargs): """ Render formset errors to a Bootstrap layout """
python
{ "resource": "" }
q30144
render_form
train
def render_form(form, **kwargs): """ Render a form to a Bootstrap layout """
python
{ "resource": "" }
q30145
render_form_errors
train
def render_form_errors(form, error_types="non_field_errors", **kwargs): """ Render form errors to
python
{ "resource": "" }
q30146
render_field
train
def render_field(field, **kwargs): """ Render a field to a Bootstrap layout """
python
{ "resource": "" }
q30147
render_label
train
def render_label(content, label_for=None, label_class=None, label_title=""): """ Render a label with content """ attrs = {} if label_for:
python
{ "resource": "" }
q30148
render_button
train
def render_button( content, button_type=None, icon=None, button_class="btn-default", size="", href="", name=None, value=None, title=None, extra_classes="", id="", ): """ Render a button with content """ attrs = {} classes = add_css_class("btn", button_clas...
python
{ "resource": "" }
q30149
render_field_and_label
train
def render_field_and_label( field, label, field_class="", label_for=None, label_class="", layout="", **kwargs ): """ Render a field with its label """ if layout == "horizontal": if not label_class: label_class = get_bootstrap_setting("horizontal_label_class") if not field...
python
{ "resource": "" }
q30150
is_widget_required_attribute
train
def is_widget_required_attribute(widget): """ Is this widget required? """ if not widget.is_required: return False
python
{ "resource": "" }
q30151
is_widget_with_placeholder
train
def is_widget_with_placeholder(widget): """ Is this a widget that should have a placeholder? Only text, search, url, tel, e-mail, password, number have placeholders """ return isinstance(
python
{ "resource": "" }
q30152
ArtifactStatistics._PrintDictAsTable
train
def _PrintDictAsTable(self, src_dict): """Prints a table of artifact definitions. Args: src_dict (dict[str, ArtifactDefinition]): artifact definitions by name. """ key_list = list(src_dict.keys()) key_list.sort() print('|', end='') for key in key_list: print(' {0:s} |'.format(k...
python
{ "resource": "" }
q30153
ArtifactStatistics.BuildStats
train
def BuildStats(self): """Builds the statistics.""" artifact_reader = reader.YamlArtifactsReader() self.label_counts = {} self.os_counts = {} self.path_count = 0 self.reg_key_count = 0 self.source_type_counts = {} self.total_count = 0 for artifact_definition in artifact_reader.ReadDi...
python
{ "resource": "" }
q30154
ArtifactStatistics.PrintStats
train
def PrintStats(self): """Build stats and print in MarkDown format.""" self.BuildStats() self.PrintSummaryTable()
python
{ "resource": "" }
q30155
WindowsRegistryKeySourceType.ValidateKey
train
def ValidateKey(cls, key_path): """Validates this key against supported key names. Args: key_path (str): path of a Windows Registry key. Raises: FormatError: when key is not supported. """ for prefix in cls.VALID_PREFIXES: if key_path.startswith(prefix): return # TOD...
python
{ "resource": "" }
q30156
SourceTypeFactory.CreateSourceType
train
def CreateSourceType(cls, type_indicator, attributes): """Creates a source type. Args: type_indicator (str): source type indicator. attributes (dict[str, object]): source type attributes. Returns: SourceType: a source type. Raises: FormatError: if the type indicator is not set...
python
{ "resource": "" }
q30157
SourceTypeFactory.DeregisterSourceType
train
def DeregisterSourceType(cls, source_type_class): """Deregisters a source type. Source types are identified based on their type indicator. Args: source_type_class (type): source type. Raises: KeyError: if a source type is not set for the corresponding type indicator. """ ...
python
{ "resource": "" }
q30158
SourceTypeFactory.RegisterSourceType
train
def RegisterSourceType(cls, source_type_class): """Registers a source type. Source types are identified based on their type indicator. Args: source_type_class (type): source type. Raises: KeyError: if source types is already set for the corresponding type indicator. """ ...
python
{ "resource": "" }
q30159
ArtifactDefinitionsValidator._CheckMacOSPaths
train
def _CheckMacOSPaths(self, filename, artifact_definition, source, paths): """Checks if the paths are valid MacOS paths. Args: filename (str): name of the artifacts definition file. artifact_definition (ArtifactDefinition): artifact definition. source (SourceType): source definition. pat...
python
{ "resource": "" }
q30160
ArtifactDefinitionsValidator._CheckWindowsRegistryKeyPath
train
def _CheckWindowsRegistryKeyPath( self, filename, artifact_definition, key_path): """Checks if a path is a valid Windows Registry key path. Args: filename (str): name of the artifacts definition file. artifact_definition (ArtifactDefinition): artifact definition. key_path (str): Windows...
python
{ "resource": "" }
q30161
ArtifactDefinitionsValidator._HasDuplicateRegistryKeyPaths
train
def _HasDuplicateRegistryKeyPaths( self, filename, artifact_definition, source): """Checks if Registry key paths are not already defined by other artifacts. Note that at the moment this function will only find exact duplicate Registry key paths. Args: filename (str): name of the artifacts ...
python
{ "resource": "" }
q30162
ArtifactDefinitionsValidator.CheckFile
train
def CheckFile(self, filename): """Validates the artifacts definition in a specific file. Args: filename (str): name of the artifacts definition file. Returns: bool: True if the file contains valid artifacts definitions. """ result = True artifact_reader = reader.YamlArtifactsReader...
python
{ "resource": "" }
q30163
ArtifactDefinitionsRegistry.DeregisterDefinition
train
def DeregisterDefinition(self, artifact_definition): """Deregisters an artifact definition. Artifact definitions are identified based on their lower case name. Args: artifact_definition (ArtifactDefinition): an artifact definition. Raises: KeyError:
python
{ "resource": "" }
q30164
ArtifactDefinitionsRegistry.RegisterDefinition
train
def RegisterDefinition(self, artifact_definition): """Registers an artifact definition. Artifact definitions are identified based on their lower case name. Args: artifact_definition (ArtifactDefinition): an artifact definition. Raises: KeyError: if artifact definition is already set for t...
python
{ "resource": "" }
q30165
ArtifactDefinitionsRegistry.ReadFromDirectory
train
def ReadFromDirectory(self, artifacts_reader, path, extension='yaml'): """Reads artifact definitions into the registry from files in a directory. This function does not recurse sub directories. Args: artifacts_reader (ArtifactsReader): an artifacts reader. path (str): path of the directory to ...
python
{ "resource": "" }
q30166
ArtifactDefinitionsRegistry.ReadFromFile
train
def ReadFromFile(self, artifacts_reader, filename): """Reads artifact definitions into the registry from a file. Args: artifacts_reader (ArtifactsReader): an artifacts reader. filename (str): name of the file to read
python
{ "resource": "" }
q30167
ArtifactDefinitionsRegistry.ReadFileObject
train
def ReadFileObject(self, artifacts_reader, file_object): """Reads artifact definitions into the registry from a file-like object. Args: artifacts_reader (ArtifactsReader): an artifacts reader. file_object (file): file-like object to read from.
python
{ "resource": "" }
q30168
DependencyDefinitionReader._GetConfigValue
train
def _GetConfigValue(self, config_parser, section_name, value_name): """Retrieves a value from the config parser. Args: config_parser (ConfigParser): configuration parser. section_name (str): name of the section that contains the value. value_name (str): name of the value. Returns: ...
python
{ "resource": "" }
q30169
DependencyDefinitionReader.Read
train
def Read(self, file_object): """Reads dependency definitions. Args: file_object (file): file-like object to read from. Yields: DependencyDefinition: dependency definition. """ config_parser = configparser.RawConfigParser() # pylint: disable=deprecated-method # TODO: replace rea...
python
{ "resource": "" }
q30170
DependencyHelper._CheckPythonModuleVersion
train
def _CheckPythonModuleVersion( self, module_name, module_object, version_property, minimum_version, maximum_version): """Checks the version of a Python module. Args: module_object (module): Python module. module_name (str): name of the Python module. version_property (str): versio...
python
{ "resource": "" }
q30171
DependencyHelper._PrintCheckDependencyStatus
train
def _PrintCheckDependencyStatus( self, dependency, result, status_message, verbose_output=True): """Prints the check dependency status. Args: dependency (DependencyDefinition): dependency definition. result (bool): True if the Python module is available and conforms to the minimum...
python
{ "resource": "" }
q30172
ArtifactsReader._ReadLabels
train
def _ReadLabels(self, artifact_definition_values, artifact_definition, name): """Reads the optional artifact definition labels. Args: artifact_definition_values (dict[str, object]): artifact definition values. artifact_definition (ArtifactDefinition): an artifact definition. name (s...
python
{ "resource": "" }
q30173
ArtifactsReader._ReadSupportedOS
train
def _ReadSupportedOS(self, definition_values, definition_object, name): """Reads the optional artifact or source type supported OS. Args: definition_values (dict[str, object]): artifact definition values. definition_object (ArtifactDefinition|SourceType): the definition object. name (str): na...
python
{ "resource": "" }
q30174
ArtifactsReader._ReadSources
train
def _ReadSources(self, artifact_definition_values, artifact_definition, name): """Reads the artifact definition sources. Args: artifact_definition_values (dict[str, object]): artifact definition values. artifact_definition (ArtifactDefinition): an artifact definition. name (str): na...
python
{ "resource": "" }
q30175
ArtifactsReader.ReadArtifactDefinitionValues
train
def ReadArtifactDefinitionValues(self, artifact_definition_values): """Reads an artifact definition from a dictionary. Args: artifact_definition_values (dict[str, object]): artifact definition values. Returns: ArtifactDefinition: an artifact definition. Raises: FormatError...
python
{ "resource": "" }
q30176
ArtifactsReader.ReadDirectory
train
def ReadDirectory(self, path, extension='yaml'): """Reads artifact definitions from a directory. This function does not recurse sub directories. Args: path (str): path of the directory to read from. extension (Optional[str]): extension of the filenames to read. Yields: ArtifactDefin...
python
{ "resource": "" }
q30177
ArtifactsReader.ReadFile
train
def ReadFile(self, filename): """Reads artifact definitions from a file. Args: filename (str): name of the file to read from. Yields: ArtifactDefinition: an artifact definition. """
python
{ "resource": "" }
q30178
ArtifactWriter.WriteArtifactsFile
train
def WriteArtifactsFile(self, artifacts, filename): """Writes artifact definitions to a file. Args: artifacts (list[ArtifactDefinition]): artifact definitions to be written. filename (str): name of the file to
python
{ "resource": "" }
q30179
ArtifactDefinition.AppendSource
train
def AppendSource(self, type_indicator, attributes): """Appends a source. If you want to implement your own source type you should create a subclass in source_type.py and change the AppendSource method to handle the new subclass. This function raises FormatError if an unsupported source type indicat...
python
{ "resource": "" }
q30180
ArtifactDefinition.AsDict
train
def AsDict(self): """Represents an artifact as a dictionary. Returns: dict[str, object]: artifact attributes. """ sources = [] for source in self.sources: source_definition = { 'type': source.type_indicator, 'attributes': source.AsDict() } if source.suppo...
python
{ "resource": "" }
q30181
Cognito.renew_access_token
train
def renew_access_token(self): """ Sets a new access token on the User using the refresh token. """ auth_params = {'REFRESH_TOKEN': self.refresh_token} self._add_secret_hash(auth_params, 'SECRET_HASH') refresh_response = self.client.initiate_auth( ClientId=self...
python
{ "resource": "" }
q30182
Cognito.initiate_forgot_password
train
def initiate_forgot_password(self): """ Sends a verification code to the user to use to change their password. """ params = { 'ClientId': self.client_id,
python
{ "resource": "" }
q30183
Cognito.change_password
train
def change_password(self, previous_password, proposed_password): """ Change the User password """ self.check_token() response = self.client.change_password( PreviousPassword=previous_password,
python
{ "resource": "" }
q30184
Cognito._add_secret_hash
train
def _add_secret_hash(self, parameters, key): """ Helper function that computes SecretHash and adds it to a parameters dictionary at a specified key """ if self.client_secret is not None: secret_hash
python
{ "resource": "" }
q30185
hash_sha256
train
def hash_sha256(buf): """AuthenticationHelper.hash"""
python
{ "resource": "" }
q30186
Wallet.create_new_address_for_user
train
def create_new_address_for_user(self, user_id): """Create a new bitcoin address to accept payments for a User. This is a convenience wrapper around `get_child` that helps you do the right thing. This method always creates a public, non-prime address that can be generated from a BIP32 pu...
python
{ "resource": "" }
q30187
Wallet.get_child_for_path
train
def get_child_for_path(self, path): """Get a child for a given path. Rather than repeated calls to get_child, children can be found by a derivation path. Paths look like: m/0/1'/10 Which is the same as self.get_child(0).get_child(-1).get_child(10) Or,...
python
{ "resource": "" }
q30188
Wallet.public_copy
train
def public_copy(self): """Clone this wallet and strip it of its private information.""" return self.__class__( chain_code=self.chain_code, depth=self.depth, parent_fingerprint=self.parent_fingerprint,
python
{ "resource": "" }
q30189
Wallet.serialize
train
def serialize(self, private=True): """Serialize this key. :param private: Whether or not the serialized key should contain private information. Set to False for a public-only representation that cannot spend funds but can create children. You want private=False if yo...
python
{ "resource": "" }
q30190
Wallet.serialize_b58
train
def serialize_b58(self, private=True): """Encode the serialized node in base58.""" return ensure_str(
python
{ "resource": "" }
q30191
Wallet.to_address
train
def to_address(self): """Create a public address from this Wallet. Public addresses can accept payments. https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses """ key = unhexlify(self.get_public_key_hex())
python
{ "resource": "" }
q30192
Wallet.deserialize
train
def deserialize(cls, key, network="bitcoin_testnet"): """Load the ExtendedBip32Key from a hex key. The key consists of * 4 byte version bytes (network key) * 1 byte depth: - 0x00 for master nodes, - 0x01 for level-1 descendants, .... ...
python
{ "resource": "" }
q30193
Wallet.from_master_secret
train
def from_master_secret(cls, seed, network="bitcoin_testnet"): """Generate a new PrivateKey from a secret key. :param seed: The key to use to generate this wallet. It may be a long string. Do not use a phrase from a book or song, as that will be guessed and is not secure. My advi...
python
{ "resource": "" }
q30194
Wallet.from_master_secret_slow
train
def from_master_secret_slow(cls, password, network=BitcoinMainNet): """ Generate a new key from a password using 50,000 rounds of HMAC-SHA256. This should generate the same result as bip32.org. WARNING: The security of this method has not been evaluated. """ # Make sure...
python
{ "resource": "" }
q30195
Wallet.new_random_wallet
train
def new_random_wallet(cls, user_entropy=None, network=BitcoinMainNet): """ Generate a new wallet using a randomly generated 512 bit seed. Args: user_entropy: Optional user-supplied entropy which is combined combined with the random seed, to help counteract compromise...
python
{ "resource": "" }
q30196
get_bytes
train
def get_bytes(s): """Returns the byte representation of a hex- or byte-string.""" if isinstance(s, bytes):
python
{ "resource": "" }
q30197
PrivateKey.from_b58check
train
def from_b58check(private_key): """ Decodes a Base58Check encoded private-key. Args: private_key (str): A Base58Check encoded private key. Returns: PrivateKey: A PrivateKey object """ b58dec = base58.b58decode_check(private_key) version = b58dec[...
python
{ "resource": "" }
q30198
PrivateKey.to_b58check
train
def to_b58check(self, testnet=False): """ Generates a Base58Check encoding of this private key. Returns: str: A Base58Check encoded string representing the key. """
python
{ "resource": "" }
q30199
PublicKey.from_int
train
def from_int(i): """ Generates a public key object from an integer. Note: This assumes that the upper 32 bytes of the integer are the x component of the public key point and the lower
python
{ "resource": "" }