_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q243900 | StepFcAggLayerOrigin.on_rbAggLayerNoAggregation_toggled | train | def on_rbAggLayerNoAggregation_toggled(self):
"""Unlock the Next button
Also, clear any previously set aggregation layer
| python | {
"resource": ""
} |
q243901 | StepFcAggLayerOrigin.set_widgets | train | def set_widgets(self):
"""Set widgets on the Aggregation Layer Origin Type tab."""
# First, list available layers in order to check if there are
# any available layers. Note This will be repeated in
# set_widgets_step_fc_agglayer_from_canvas because we need
# to list them again a... | python | {
"resource": ""
} |
q243902 | MetadataDbIO.default_metadata_db_path | train | def default_metadata_db_path():
"""Helper to get the default path for the metadata file.
:returns: The path to where the default location of the metadata
database is. Maps to which is ~/.inasafe.metadata35.db
:rtype: str
| python | {
"resource": ""
} |
q243903 | MetadataDbIO.setup_metadata_db_path | train | def setup_metadata_db_path(self):
"""Helper to set the active path for the metadata.
Called at init time, you can override this path by calling
set_metadata_db_path.setmetadataDbPath.
:returns: The path to where the metadata file is. If | python | {
"resource": ""
} |
q243904 | connect | train | def connect(receiver, signal=Any, sender=Any, weak=True):
"""Connect receiver to sender for signal
receiver -- a callable Python object which is to receive
messages/signals/events. Receivers must be hashable
objects.
if weak is True, then receiver must be weak-referencable
(mo... | python | {
"resource": ""
} |
q243905 | getReceivers | train | def getReceivers( sender = Any, signal = Any ):
"""Get list of receivers from global tables
This utility function allows you to retrieve the
raw list of receivers from the connections table
for the given sender and signal pair.
Note:
there is no guarantee that this is the actual list
| python | {
"resource": ""
} |
q243906 | liveReceivers | train | def liveReceivers(receivers):
"""Filter sequence of receivers to get resolved, live receivers
This is a generator which will iterate over
the passed sequence, checking for weak references
and resolving them, then returning all live
receivers.
"""
for receiver in receivers:
if isinst... | python | {
"resource": ""
} |
q243907 | getAllReceivers | train | def getAllReceivers( sender = Any, signal = Any ):
"""Get list of all receivers from global tables
This gets all receivers which should receive
the given signal from sender, each receiver should
be produced only once by the resulting generator
"""
receivers = {}
for set in (
# Get r... | python | {
"resource": ""
} |
q243908 | sendExact | train | def sendExact( signal=Any, sender=Anonymous, *arguments, **named ):
"""Send signal only to those receivers registered for exact message
sendExact allows for avoiding Any/Anonymous registered
handlers, sending only to those receivers explicitly
registered for a particular signal on a particular
send... | python | {
"resource": ""
} |
q243909 | _removeReceiver | train | def _removeReceiver(receiver):
"""Remove receiver from connections."""
if not sendersBack:
# During module cleanup the mapping will be replaced with None
return False
backKey = id(receiver)
try:
backSet = sendersBack.pop(backKey)
except KeyError:
return False
els... | python | {
"resource": ""
} |
q243910 | _cleanupConnections | train | def _cleanupConnections(senderkey, signal):
"""Delete any empty signals for senderkey. Delete senderkey if empty."""
try:
receivers = connections[senderkey][signal]
except:
pass
else:
if not receivers:
# No more connected receivers. Therefore, remove the signal.
... | python | {
"resource": ""
} |
q243911 | _removeBackrefs | train | def _removeBackrefs( senderkey):
"""Remove all back-references to this senderkey"""
try:
signals = connections[senderkey]
except KeyError:
signals = None
else:
items = signals.items()
def allReceivers( ):
| python | {
"resource": ""
} |
q243912 | _removeOldBackRefs | train | def _removeOldBackRefs(senderkey, signal, receiver, receivers):
"""Kill old sendersBack references from receiver
This guards against multiple registration of the same
receiver for a given signal and sender leaking memory
as old back reference records build up.
Also removes old receiver instance fr... | python | {
"resource": ""
} |
q243913 | _killBackref | train | def _killBackref( receiver, senderkey ):
"""Do the actual removal of back reference from receiver to senderkey"""
receiverkey = id(receiver)
set = sendersBack.get( receiverkey, () )
while senderkey in set:
try:
set.remove( senderkey )
| python | {
"resource": ""
} |
q243914 | StepKwPurpose.on_lstCategories_itemSelectionChanged | train | def on_lstCategories_itemSelectionChanged(self):
"""Update purpose description label.
.. note:: This is an automatic Qt slot
executed when the purpose selection changes.
"""
self.clear_further_steps()
# Set widgets
purpose = self.selected_purpose()
| python | {
"resource": ""
} |
q243915 | StepKwPurpose.selected_purpose | train | def selected_purpose(self):
"""Obtain the layer purpose selected by user.
:returns: Metadata of the selected layer purpose.
:rtype: dict, None
"""
item = self.lstCategories.currentItem()
try:
| python | {
"resource": ""
} |
q243916 | StepKwPurpose.set_widgets | train | def set_widgets(self):
"""Set widgets on the layer purpose tab."""
self.clear_further_steps()
# Set widgets
self.lstCategories.clear()
self.lblDescribeCategory.setText('')
self.lblIconCategory.setPixmap(QPixmap())
self.lblSelectCategory.setText(
catego... | python | {
"resource": ""
} |
q243917 | qgis_expressions | train | def qgis_expressions():
"""Retrieve all QGIS Expressions provided by InaSAFE.
:return: Dictionary of expression name and the expression itself.
:rtype: dict
"""
all_expressions = {
fct[0]: fct[1] for fct in getmembers(generic_expressions)
if fct[1].__class__.__name__ == 'QgsExpressi... | python | {
"resource": ""
} |
q243918 | check_nearby_preprocessor | train | def check_nearby_preprocessor(impact_function):
"""Checker for the nearby preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool
| python | {
"resource": ""
} |
q243919 | fake_nearby_preprocessor | train | def fake_nearby_preprocessor(impact_function):
"""Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer
"""
_ = impact_function # NOQA
from saf... | python | {
"resource": ""
} |
q243920 | check_earthquake_contour_preprocessor | train | def check_earthquake_contour_preprocessor(impact_function):
"""Checker for the contour preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
| python | {
"resource": ""
} |
q243921 | earthquake_contour_preprocessor | train | def earthquake_contour_preprocessor(impact_function):
"""Preprocessor to create contour from an earthquake
:param impact_function: Impact function to run.
:type impact_function: ImpactFunction
:return: The contour layer.
:rtype: QgsMapLayer
| python | {
"resource": ""
} |
q243922 | WizardDialog.set_mode_label_to_ifcw | train | def set_mode_label_to_ifcw(self):
"""Set the mode label to the IFCW."""
self.setWindowTitle(self.ifcw_name) | python | {
"resource": ""
} |
q243923 | WizardDialog.set_keywords_creation_mode | train | def set_keywords_creation_mode(self, layer=None, keywords=None):
"""Set the Wizard to the Keywords Creation mode.
:param layer: Layer to set the keywords for
:type layer: QgsMapLayer
:param keywords: Keywords for the layer.
:type keywords: dict, None
"""
self.la... | python | {
"resource": ""
} |
q243924 | WizardDialog.set_function_centric_mode | train | def set_function_centric_mode(self):
"""Set the Wizard to the Function Centric mode."""
self.set_mode_label_to_ifcw()
| python | {
"resource": ""
} |
q243925 | WizardDialog.field_keyword_for_the_layer | train | def field_keyword_for_the_layer(self):
"""Return the proper keyword for field for the current layer.
:returns: the field keyword
:rtype: str
"""
layer_purpose_key = self.step_kw_purpose.selected_purpose()['key']
if layer_purpose_key == layer_purpose_aggregation['key']:
... | python | {
"resource": ""
} |
q243926 | WizardDialog.get_parent_mode_constraints | train | def get_parent_mode_constraints(self):
"""Return the category and subcategory keys to be set in the
subordinate mode.
:returns: (the category definition, the hazard/exposure definition)
:rtype: (dict, dict)
"""
h, e, _hc, _ec = self.selected_impact_function_constraints()... | python | {
"resource": ""
} |
q243927 | WizardDialog.selected_impact_function_constraints | train | def selected_impact_function_constraints(self):
"""Obtain impact function constraints selected by user.
:returns: Tuple of metadata of hazard, exposure,
hazard layer geometry and exposure layer geometry
:rtype: tuple
"""
hazard = self.step_fc_functions1.selected_val... | python | {
"resource": ""
} |
q243928 | WizardDialog.is_layer_compatible | train | def is_layer_compatible(self, layer, layer_purpose=None, keywords=None):
"""Validate if a given layer is compatible for selected IF
as a given layer_purpose
:param layer: The layer to be validated
:type layer: QgsVectorLayer | QgsRasterLayer
:param layer_purpose: The layer_p... | python | {
"resource": ""
} |
q243929 | WizardDialog.get_compatible_canvas_layers | train | def get_compatible_canvas_layers(self, category):
"""Collect layers from map canvas, compatible for the given category
and selected impact function
.. note:: Returns layers with keywords and layermode matching
the category and compatible with the selected impact function.
... | python | {
"resource": ""
} |
q243930 | WizardDialog.get_existing_keyword | train | def get_existing_keyword(self, keyword):
"""Obtain an existing keyword's value.
:param keyword: A keyword from keywords.
:type keyword: str
:returns: The value of the keyword.
:rtype: str, QUrl
"""
if self.existing_keywords is | python | {
"resource": ""
} |
q243931 | WizardDialog.get_layer_description_from_canvas | train | def get_layer_description_from_canvas(self, layer, purpose):
"""Obtain the description of a canvas layer selected by user.
:param layer: The QGIS layer.
:type layer: QgsMapLayer
:param purpose: The layer purpose of the layer to get the description.
:type purpose: string
... | python | {
"resource": ""
} |
q243932 | WizardDialog.go_to_step | train | def go_to_step(self, step):
"""Set the stacked widget to the given step, set up the buttons,
and run all operations that should start immediately after
entering the new step.
:param step: The step widget to be moved to.
:type step: WizardStep
"""
self.stack... | python | {
"resource": ""
} |
q243933 | WizardDialog.on_pbnNext_released | train | def on_pbnNext_released(self):
"""Handle the Next button release.
.. note:: This is an automatic Qt slot
executed when the Next button is released.
"""
current_step = self.get_current_step()
if current_step == self.step_kw_fields_mapping:
try:
... | python | {
"resource": ""
} |
q243934 | WizardDialog.on_pbnBack_released | train | def on_pbnBack_released(self):
"""Handle the Back button release.
.. note:: This is an automatic Qt slot
executed when the Back button is released.
"""
current_step = self.get_current_step()
if current_step.step_type == STEP_FC:
new_step = self.impact_func... | python | {
"resource": ""
} |
q243935 | WizardDialog.save_current_keywords | train | def save_current_keywords(self):
"""Save keywords to the layer.
It will write out the keywords for the current layer.
This method is based on the KeywordsDialog class.
"""
current_keywords = self.get_keywords()
try:
self.keyword_io.write_keywords(
... | python | {
"resource": ""
} |
q243936 | StepFcFunctions1.populate_function_table_1 | train | def populate_function_table_1(self):
"""Populate the tblFunctions1 table with available functions."""
hazards = deepcopy(hazard_all)
exposures = exposure_all
self.lblAvailableFunctions1.clear()
self.tblFunctions1.clear()
self.tblFunctions1.setColumnCount(len(hazards))
... | python | {
"resource": ""
} |
q243937 | StepFcFunctions1.set_widgets | train | def set_widgets(self):
"""Set widgets on the Impact Functions Table 1 tab."""
self.tblFunctions1.horizontalHeader().setSectionResizeMode(
QHeaderView.Stretch)
| python | {
"resource": ""
} |
q243938 | dock_help | train | def dock_help():
"""Help message for Dock Widget.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message | python | {
"resource": ""
} |
q243939 | KeywordIO.write_keywords | train | def write_keywords(layer, keywords):
"""Write keywords for a datasource.
This is a wrapper method that will 'do the right thing' to store
keywords for the given datasource. In particular, if the datasource
is remote (e.g. a database connection) it will write the keywords from
th... | python | {
"resource": ""
} |
q243940 | KeywordIO.to_message | train | def to_message(self, keywords=None, show_header=True):
"""Format keywords as a message object.
.. versionadded:: 3.2
.. versionchanged:: 3.3 - default keywords to None
The message object can then be rendered to html, plain text etc.
:param keywords: Keywords to be converted t... | python | {
"resource": ""
} |
q243941 | KeywordIO._keyword_to_row | train | def _keyword_to_row(self, keyword, value, wrap_slash=False):
"""Helper to make a message row from a keyword.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object.
:param keyword: The keyword to be rendered.
:type... | python | {
"resource": ""
} |
q243942 | KeywordIO._dict_to_row | train | def _dict_to_row(keyword_value, keyword_property=None):
"""Helper to make a message row from a keyword where value is a dict.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object. This variant will unpack the dict and
pre... | python | {
"resource": ""
} |
q243943 | KeywordIO._value_maps_row | train | def _value_maps_row(value_maps_keyword):
"""Helper to make a message row from a value maps.
Expected keywords:
'value_maps': {
'structure': {
'ina_structure_flood_hazard_classification': {
'classes': {
'low': [1, 2, 3],
... | python | {
"resource": ""
} |
q243944 | intersection | train | def intersection(source, mask):
"""Intersect two layers.
Issue https://github.com/inasafe/inasafe/issues/3186
:param source: The vector layer to clip.
:type source: QgsVectorLayer
:param mask: The vector layer to use for clipping.
:type mask: QgsVectorLayer
:return: The clip vector layer... | python | {
"resource": ""
} |
q243945 | field_mapping_help | train | def field_mapping_help():
"""Help message for field mapping Dialog.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message | python | {
"resource": ""
} |
q243946 | TcExInit._print_results | train | def _print_results(file, status):
"""Print the download results.
Args:
file (str): The filename.
status (str): The file download status.
"""
file_color = c.Fore.GREEN
status_color = c.Fore.RED
if status == 'Success':
status_color = c.... | python | {
"resource": ""
} |
q243947 | TcExInit._confirm_overwrite | train | def _confirm_overwrite(filename):
"""Confirm overwrite of template files.
Make sure the user would like to continue downloading a file which will overwrite a file
in the current directory.
Args:
filename (str): The name of the file to overwrite.
Returns:
... | python | {
"resource": ""
} |
q243948 | TcExInit.check_empty_app_dir | train | def check_empty_app_dir(self):
"""Check to see if the directory in which the app is going to be created is empty."""
if not os.listdir(self.app_path):
self.handle_error(
'No app exists in this directory. Try | python | {
"resource": ""
} |
q243949 | TcExInit.download_file | train | def download_file(self, remote_filename, local_filename=None):
"""Download file from github.
Args:
remote_filename (str): The name of the file as defined in git repository.
local_filename (str, optional): Defaults to None. The name of the file as it should be
be ... | python | {
"resource": ""
} |
q243950 | TcExInit.update_install_json | train | def update_install_json():
"""Update the install.json configuration file if exists."""
if not os.path.isfile('install.json'):
return
with open('install.json', 'r') as f:
install_json = json.load(f)
if install_json.get('programMain'):
install_json['pr... | python | {
"resource": ""
} |
q243951 | TcExInit.update_tcex_json | train | def update_tcex_json(self):
"""Update the tcex.json configuration file if exists."""
if not os.path.isfile('tcex.json'):
return
# display warning on missing app_name field
if self.tcex_json.get('package', {}).get('app_name') is None:
print('{}The tcex.json file i... | python | {
"resource": ""
} |
q243952 | Signature.download | train | def download(self):
"""
Downloads the signature.
Returns:
"""
if not self.can_update():
self._tcex.handle_error(910, [self.type])
| python | {
"resource": ""
} |
q243953 | TcExDataStore._create_index | train | def _create_index(self):
"""Create index if it doesn't exist."""
if not self.index_exists:
index_settings = {}
headers = {'Content-Type': 'application/json', 'DB-Method': 'POST'}
url = '/v2/exchange/db/{}/{}'.format(self.domain, self.data_type)
| python | {
"resource": ""
} |
q243954 | TcExDataStore._update_mappings | train | def _update_mappings(self):
"""Update the mappings for the current index."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'PUT'}
url = '/v2/exchange/db/{}/{}/_mappings'.format(self.domain, self.data_type)
| python | {
"resource": ""
} |
q243955 | TcExDataStore.index_exists | train | def index_exists(self):
"""Check to see if index exists."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'GET'}
url = '/v2/exchange/db/{}/{}/_search'.format(self.domain, self.data_type)
r = self.tcex.session.post(url, headers=headers)
| python | {
"resource": ""
} |
q243956 | TcExDataStore.put | train | def put(self, rid, data, raise_on_error=True):
"""Update the data for the provided Id.
Args:
rid (str): The record identifier.
data (dict): A search query
raise_on_error (bool): If True and not r.ok this method will raise a RunTimeError.
Returns:
... | python | {
"resource": ""
} |
q243957 | TcExRun._create_tc_dirs | train | def _create_tc_dirs(self):
"""Create app directories for logs and data files."""
tc_log_path = self.profile.get('args', {}).get('tc_log_path')
if tc_log_path is not None and not os.path.isdir(tc_log_path):
os.makedirs(tc_log_path)
tc_out_path = self.profile.get('args', {}).ge... | python | {
"resource": ""
} |
q243958 | TcExRun._logger | train | def _logger(self):
"""Create logger instance.
Returns:
logger: An instance of logging
"""
log_level = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': l... | python | {
"resource": ""
} |
q243959 | TcExRun._signal_handler_init | train | def _signal_handler_init(self):
"""Catch interupt signals."""
signal.signal(signal.SIGINT, signal.SIG_IGN)
| python | {
"resource": ""
} |
q243960 | TcExRun._vars_match | train | def _vars_match(self):
"""Regular expression to match playbook variable."""
return re.compile(
r'#([A-Za-z]+)' # match literal (#App) at beginning of String
r':([\d]+)' # app id (:7979)
r':([A-Za-z0-9_\.\-\[\]]+)' # variable name (:variable_name)
r'!(St... | python | {
"resource": ""
} |
q243961 | TcExRun.autoclear | train | def autoclear(self):
"""Clear Redis and ThreatConnect data from staging data."""
for sd in self.staging_data:
data_type = sd.get('data_type', 'redis')
if data_type == 'redis':
self.clear_redis(sd.get('variable'), 'auto-clear')
elif data_type == 'redis-... | python | {
"resource": ""
} |
q243962 | TcExRun.clear | train | def clear(self):
"""Clear Redis and ThreatConnect data defined in profile.
Redis Data:
.. code-block:: javascript
{
"data_type": "redis",
"variable": "#App:4768:tc.adversary!TCEntity"
}
ThreatConnect Data:
.. code-block:: j... | python | {
"resource": ""
} |
q243963 | TcExRun.clear_redis | train | def clear_redis(self, variable, clear_type):
"""Delete Redis data for provided variable.
Args:
variable (str): The Redis variable to delete.
clear_type (str): The type of clear action.
"""
if variable is None:
return
if variable in self._clear... | python | {
"resource": ""
} |
q243964 | TcExRun.clear_tc | train | def clear_tc(self, owner, data, clear_type):
"""Delete threat intel from ThreatConnect platform.
Args:
owner (str): The ThreatConnect owner.
data (dict): The data for the threat intel to clear.
clear_type (str): The type of clear action.
"""
batch = s... | python | {
"resource": ""
} |
q243965 | TcExRun.data_in_db | train | def data_in_db(db_data, user_data):
"""Validate db data in user data.
Args:
db_data (str): The data store in Redis.
user_data (list): The user provided data.
Returns:
bool: True if the data passed validation.
| python | {
"resource": ""
} |
q243966 | TcExRun.data_it | train | def data_it(db_data, user_type):
"""Validate data is type.
Args:
db_data (dict|str|list): The data store in Redis.
user_data (str): The user provided data.
Returns:
bool: True if the data passed validation.
"""
data_type = {
'arra... | python | {
"resource": ""
} |
q243967 | TcExRun.data_not_in | train | def data_not_in(db_data, user_data):
"""Validate data not in user data.
Args:
db_data (str): The data store in Redis.
user_data (list): The user provided data.
Returns:
bool: True if the data passed validation.
| python | {
"resource": ""
} |
q243968 | TcExRun.data_string_compare | train | def data_string_compare(db_data, user_data):
"""Validate string removing all white space before comparison.
Args:
db_data (str): The data store in Redis.
user_data (str): The user provided data.
Returns:
bool: True if the data passed validation.
| python | {
"resource": ""
} |
q243969 | TcExRun.included_profiles | train | def included_profiles(self):
"""Load all profiles."""
profiles = []
for directory in | python | {
"resource": ""
} |
q243970 | TcExRun.load_tcex | train | def load_tcex(self):
"""Inject required TcEx CLI Args."""
for arg, value in self.profile.get('profile_args', {}).data.items():
if arg not in self._tcex_required_args:
continue
# add new log file name and level
sys.argv.extend(['--tc_log_file', 'tcex.l... | python | {
"resource": ""
} |
q243971 | TcExRun.operators | train | def operators(self):
"""Return dict of Validation Operators.
+ deep-diff (dd): This operator can compare any object that can be represented as JSON.
+ eq: This operator does a equal to comparison for String and StringArray variables.
+ ends-with (ew): This operator compares the end of a... | python | {
"resource": ""
} |
q243972 | TcExRun.path_data | train | def path_data(self, variable_data, path):
"""Return JMESPath data.
Args:
variable_data (str): The JSON data to run path expression.
path (str): The JMESPath expression.
Returns:
dict: The resulting data from JMESPath.
"""
# NOTE: tcex does in... | python | {
"resource": ""
} |
q243973 | TcExRun.profile | train | def profile(self, profile):
"""Set the current profile.
Args:
profile (dict): The profile data.
"""
# clear staging data
self._staging_data = None
# retrieve language from install.json or assume Python
lang = profile.get('install_json', {}).get('progr... | python | {
"resource": ""
} |
q243974 | TcExRun.profile_args | train | def profile_args(_args):
"""Return args for v1, v2, or v3 structure.
Args:
_args (dict): The args section from the profile.
Returns:
dict: A collapsed version of the args dict.
"""
# TODO: clean this up in a way that works for both py2/3
if (
... | python | {
"resource": ""
} |
q243975 | TcExRun.profiles | train | def profiles(self):
"""Return all selected profiles."""
selected_profiles = []
for config in self.included_profiles:
profile_selected = False
profile_name = config.get('profile_name')
if profile_name == self.args.profile:
profile_selected = Tr... | python | {
"resource": ""
} |
q243976 | TcExRun.report | train | def report(self):
"""Format and output report data to screen."""
print('\n{}{}{}'.format(c.Style.BRIGHT, c.Fore.CYAN, 'Report:'))
# report headers
print('{!s:<85}{!s:<20}'.format('', 'Validations'))
print(
'{!s:<60}{!s:<25}{!s:<10}{!s:<10}'.format(
'Pr... | python | {
"resource": ""
} |
q243977 | TcExRun.run | train | def run(self):
"""Run the App using the current profile.
The current profile has the install_json and args pre-loaded.
"""
install_json = self.profile.get('install_json')
program_language = self.profile.get('install_json').get('programLanguage', 'python').lower()
print(... | python | {
"resource": ""
} |
q243978 | TcExRun.run_commands | train | def run_commands(self, program_language, program_main):
"""Return the run Print Command.
Args:
program_language (str): The language of the current App/Project.
program_main (str): The executable name.
Returns:
dict: A dictionary containing the run command an... | python | {
"resource": ""
} |
q243979 | TcExRun.run_local | train | def run_local(self, commands):
"""Run the App on local system.
Args:
commands (dict): A dictionary of the CLI commands.
Returns:
int: The exit code of the subprocess command.
"""
process = subprocess.Popen(
commands.get('cli_command'),
... | python | {
"resource": ""
} |
q243980 | TcExRun.run_docker | train | def run_docker(self, commands):
"""Run App in Docker Container.
Args:
commands (dict): A dictionary of the CLI commands.
Returns:
int: The exit code of the subprocess command.
"""
try:
import docker
except ImportError:
pri... | python | {
"resource": ""
} |
q243981 | TcExRun.run_display_app_output | train | def run_display_app_output(self, out):
"""Print any App output.
Args:
out (str): One or more lines of output messages.
"""
if not self.profile.get('quiet') and not self.args.quiet:
print('App Output:')
for o in out.decode('utf-8').split('\n'):
| python | {
"resource": ""
} |
q243982 | TcExRun.run_validate_program_main | train | def run_validate_program_main(self, program_main):
"""Validate the program main file exists.
Args:
program_main (str): The executable name.
"""
program_language = self.profile.get('install_json').get('programLanguage', 'python').lower()
if program_language == 'python... | python | {
"resource": ""
} |
q243983 | TcExRun.stage | train | def stage(self):
"""Stage Redis and ThreatConnect data defined in profile.
Redis Data:
.. code-block:: javascript
{
"data": [
"This is an example Source #1",
"This is an example Source #2"
],
"... | python | {
"resource": ""
} |
q243984 | TcExRun.staging_data | train | def staging_data(self):
"""Read data files and return all staging data for current profile."""
if self._staging_data is None:
staging_data = []
for staging_file in self.profile.get('data_files') or []:
if os.path.isfile(staging_file):
print(
... | python | {
"resource": ""
} |
q243985 | TcExRun.stage_redis | train | def stage_redis(self, variable, data):
"""Stage data in Redis.
Args:
variable (str): The Redis variable name.
data (dict|list|str): The data to store in Redis.
"""
if isinstance(data, int):
data = str(data)
# handle binary
if variable.... | python | {
"resource": ""
} |
q243986 | TcExRun.stage_tc | train | def stage_tc(self, owner, staging_data, variable):
"""Stage data using ThreatConnect API.
.. code-block:: javascript
[{
"data": {
"id": 116,
"value": "adversary001-build-testing",
"type": "Adversary",
"ownerName"... | python | {
"resource": ""
} |
q243987 | TcExRun.stage_tc_create_security_label | train | def stage_tc_create_security_label(self, label, resource):
"""Add a security label to a resource.
Args:
label (str): The security label (must exit in ThreatConnect).
resource (obj): An instance of tcex resource class.
"""
sl_resource = resource.security_labels(la... | python | {
"resource": ""
} |
q243988 | TcExRun.stage_tc_create_tag | train | def stage_tc_create_tag(self, tag, resource):
"""Add a tag to a resource.
Args:
tag (str): The tag to be added to the resource.
resource (obj): An instance of tcex resource class.
"""
tag_resource = resource.tags(self.tcex.safetag(tag))
tag_resource.http_... | python | {
"resource": ""
} |
q243989 | TcExRun.stage_tc_batch | train | def stage_tc_batch(self, owner, staging_data):
"""Stage data in ThreatConnect Platform using batch API.
Args:
owner (str): The ThreatConnect owner to submit batch job.
staging_data (dict): A dict of ThreatConnect batch data.
"""
batch = self.tcex.batch(owner)
... | python | {
"resource": ""
} |
q243990 | TcExRun.stage_tc_batch_xid | train | def stage_tc_batch_xid(xid_type, xid_value, owner):
"""Create an xid for a batch job.
Args:
xid_type (str): [description]
xid_value (str): [description]
owner (str): [description]
Returns:
| python | {
"resource": ""
} |
q243991 | TcExRun.stage_tc_indicator_entity | train | def stage_tc_indicator_entity(self, indicator_data):
"""Convert JSON data to TCEntity.
Args:
indicator_data (str): [description]
Returns:
[type]: [description]
"""
path = '@.{value: summary, '
path += 'type: type, ' | python | {
"resource": ""
} |
q243992 | TcExRun.validate_log_output | train | def validate_log_output(self, passed, db_data, user_data, oper):
"""Format the validation log output to be easier to read.
Args:
passed (bool): The results of the validation test.
db_data (str): The data store in Redis.
user_data (str): The user provided data.
... | python | {
"resource": ""
} |
q243993 | ArgBuilder._add_arg_python | train | def _add_arg_python(self, key, value=None, mask=False):
"""Add CLI Arg formatted specifically for Python.
Args:
key (string): The CLI Args key (e.g., --name).
value (string): The CLI Args value (e.g., bob).
mask (boolean, default:False): Indicates whether no mask val... | python | {
"resource": ""
} |
q243994 | ArgBuilder._add_arg_java | train | def _add_arg_java(self, key, value, mask=False):
"""Add CLI Arg formatted specifically for Java.
Args:
key (string): The CLI Args key (e.g., --name).
value (string): The CLI Args value (e.g., bob).
mask (boolean, default:False): Indicates whether no mask value.
... | python | {
"resource": ""
} |
q243995 | ArgBuilder._add_arg | train | def _add_arg(self, key, value, mask=False):
"""Add CLI Arg for the correct language.
Args:
key (string): The CLI Args key (e.g., --name).
value (string): The CLI Args value (e.g., bob).
mask (boolean, default:False): Indicates whether no mask value.
"""
| python | {
"resource": ""
} |
q243996 | ArgBuilder.add | train | def add(self, key, value):
"""Add CLI Arg to lists value.
Args:
key (string): The CLI Args key (e.g., --name).
value (string): The CLI Args value (e.g., bob).
"""
if isinstance(value, list):
# TODO: support env vars in list w/masked values
... | python | {
"resource": ""
} |
q243997 | ArgBuilder.quote | train | def quote(self, data):
"""Quote any parameters that contain spaces or special character.
Returns:
(string): String containing parameters wrapped in double quotes
"""
if self.lang == 'python':
quote_char = | python | {
"resource": ""
} |
q243998 | ArgBuilder.load | train | def load(self, profile_args):
"""Load provided CLI Args.
Args:
args (dict): Dictionary of args in key/value format.
"""
| python | {
"resource": ""
} |
q243999 | Reports.add_profile | train | def add_profile(self, profile, selected):
"""Add profile to report."""
report = Report(profile)
report.selected = selected
if selected:
self.report['settings']['selected_profiles'].append(report.name)
self.report['settings']['selected_profile_count'] += 1
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.