repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.error_codes
def error_codes(self): """ThreatConnect error codes.""" if self._error_codes is None: from .tcex_error_codes import TcExErrorCodes self._error_codes = TcExErrorCodes() return self._error_codes
python
def error_codes(self): """ThreatConnect error codes.""" if self._error_codes is None: from .tcex_error_codes import TcExErrorCodes self._error_codes = TcExErrorCodes() return self._error_codes
[ "def", "error_codes", "(", "self", ")", ":", "if", "self", ".", "_error_codes", "is", "None", ":", "from", ".", "tcex_error_codes", "import", "TcExErrorCodes", "self", ".", "_error_codes", "=", "TcExErrorCodes", "(", ")", "return", "self", ".", "_error_codes" ...
ThreatConnect error codes.
[ "ThreatConnect", "error", "codes", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L427-L433
train
27,700
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.exit
def exit(self, code=None, msg=None): """Application exit method with proper exit code The method will run the Python standard sys.exit() with the exit code previously defined via :py:meth:`~tcex.tcex.TcEx.exit_code` or provided during the call of this method. Args: ...
python
def exit(self, code=None, msg=None): """Application exit method with proper exit code The method will run the Python standard sys.exit() with the exit code previously defined via :py:meth:`~tcex.tcex.TcEx.exit_code` or provided during the call of this method. Args: ...
[ "def", "exit", "(", "self", ",", "code", "=", "None", ",", "msg", "=", "None", ")", ":", "# add exit message to message.tc file and log", "if", "msg", "is", "not", "None", ":", "if", "code", "in", "[", "0", ",", "3", "]", "or", "(", "code", "is", "No...
Application exit method with proper exit code The method will run the Python standard sys.exit() with the exit code previously defined via :py:meth:`~tcex.tcex.TcEx.exit_code` or provided during the call of this method. Args: code (Optional [integer]): The exit code value f...
[ "Application", "exit", "method", "with", "proper", "exit", "code" ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L435-L467
train
27,701
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.exit_code
def exit_code(self, code): """Set the App exit code. For TC Exchange Apps there are 3 supported exit codes. * 0 indicates a normal exit * 1 indicates a failure during execution * 3 indicates a partial failure Args: code (integer): The exit code value for the...
python
def exit_code(self, code): """Set the App exit code. For TC Exchange Apps there are 3 supported exit codes. * 0 indicates a normal exit * 1 indicates a failure during execution * 3 indicates a partial failure Args: code (integer): The exit code value for the...
[ "def", "exit_code", "(", "self", ",", "code", ")", ":", "if", "code", "is", "not", "None", "and", "code", "in", "[", "0", ",", "1", ",", "3", "]", ":", "self", ".", "_exit_code", "=", "code", "else", ":", "self", ".", "log", ".", "warning", "("...
Set the App exit code. For TC Exchange Apps there are 3 supported exit codes. * 0 indicates a normal exit * 1 indicates a failure during execution * 3 indicates a partial failure Args: code (integer): The exit code value for the app.
[ "Set", "the", "App", "exit", "code", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L475-L489
train
27,702
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.get_type_from_api_entity
def get_type_from_api_entity(self, api_entity): """ Returns the object type as a string given a api entity. Args: api_entity: Returns: """ merged = self.group_types_data.copy() merged.update(self.indicator_types_data) print(merged) f...
python
def get_type_from_api_entity(self, api_entity): """ Returns the object type as a string given a api entity. Args: api_entity: Returns: """ merged = self.group_types_data.copy() merged.update(self.indicator_types_data) print(merged) f...
[ "def", "get_type_from_api_entity", "(", "self", ",", "api_entity", ")", ":", "merged", "=", "self", ".", "group_types_data", ".", "copy", "(", ")", "merged", ".", "update", "(", "self", ".", "indicator_types_data", ")", "print", "(", "merged", ")", "for", ...
Returns the object type as a string given a api entity. Args: api_entity: Returns:
[ "Returns", "the", "object", "type", "as", "a", "string", "given", "a", "api", "entity", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L628-L644
train
27,703
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.install_json
def install_json(self): """Return contents of install.json configuration file, loading from disk if required.""" if self._install_json is None: try: install_json_filename = os.path.join(os.getcwd(), 'install.json') with open(install_json_filename, 'r') as fh: ...
python
def install_json(self): """Return contents of install.json configuration file, loading from disk if required.""" if self._install_json is None: try: install_json_filename = os.path.join(os.getcwd(), 'install.json') with open(install_json_filename, 'r') as fh: ...
[ "def", "install_json", "(", "self", ")", ":", "if", "self", ".", "_install_json", "is", "None", ":", "try", ":", "install_json_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'install.json'", ")", "with", "open...
Return contents of install.json configuration file, loading from disk if required.
[ "Return", "contents", "of", "install", ".", "json", "configuration", "file", "loading", "from", "disk", "if", "required", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L647-L657
train
27,704
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.install_json_params
def install_json_params(self): """Parse params from install.json into a dict by name.""" if not self._install_json_params: for param in self.install_json.get('params') or []: self._install_json_params[param.get('name')] = param return self._install_json_params
python
def install_json_params(self): """Parse params from install.json into a dict by name.""" if not self._install_json_params: for param in self.install_json.get('params') or []: self._install_json_params[param.get('name')] = param return self._install_json_params
[ "def", "install_json_params", "(", "self", ")", ":", "if", "not", "self", ".", "_install_json_params", ":", "for", "param", "in", "self", ".", "install_json", ".", "get", "(", "'params'", ")", "or", "[", "]", ":", "self", ".", "_install_json_params", "[", ...
Parse params from install.json into a dict by name.
[ "Parse", "params", "from", "install", ".", "json", "into", "a", "dict", "by", "name", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L660-L665
train
27,705
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.metric
def metric(self, name, description, data_type, interval, keyed=False): """Get instance of the Metrics module. Args: name (string): The name for the metric. description (string): The description of the metric. data_type (string): The type of metric: Sum, Count, Min, M...
python
def metric(self, name, description, data_type, interval, keyed=False): """Get instance of the Metrics module. Args: name (string): The name for the metric. description (string): The description of the metric. data_type (string): The type of metric: Sum, Count, Min, M...
[ "def", "metric", "(", "self", ",", "name", ",", "description", ",", "data_type", ",", "interval", ",", "keyed", "=", "False", ")", ":", "from", ".", "tcex_metrics_v2", "import", "TcExMetricsV2", "return", "TcExMetricsV2", "(", "self", ",", "name", ",", "de...
Get instance of the Metrics module. Args: name (string): The name for the metric. description (string): The description of the metric. data_type (string): The type of metric: Sum, Count, Min, Max, First, Last, and Average. interval (string): The metric interval: ...
[ "Get", "instance", "of", "the", "Metrics", "module", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L667-L682
train
27,706
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.message_tc
def message_tc(self, message, max_length=255): """Write data to message_tc file in TcEX specified directory. This method is used to set and exit message in the ThreatConnect Platform. ThreatConnect only supports files of max_message_length. Any data exceeding this limit will be truncat...
python
def message_tc(self, message, max_length=255): """Write data to message_tc file in TcEX specified directory. This method is used to set and exit message in the ThreatConnect Platform. ThreatConnect only supports files of max_message_length. Any data exceeding this limit will be truncat...
[ "def", "message_tc", "(", "self", ",", "message", ",", "max_length", "=", "255", ")", ":", "if", "os", ".", "access", "(", "self", ".", "default_args", ".", "tc_out_path", ",", "os", ".", "W_OK", ")", ":", "message_file", "=", "'{}/message.tc'", ".", "...
Write data to message_tc file in TcEX specified directory. This method is used to set and exit message in the ThreatConnect Platform. ThreatConnect only supports files of max_message_length. Any data exceeding this limit will be truncated by this method. Args: message (str...
[ "Write", "data", "to", "message_tc", "file", "in", "TcEX", "specified", "directory", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L694-L716
train
27,707
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.playbook
def playbook(self): """Include the Playbook Module. .. Note:: Playbook methods can be accessed using ``tcex.playbook.<method>``. """ if self._playbook is None: from .tcex_playbook import TcExPlaybook self._playbook = TcExPlaybook(self) return self._playb...
python
def playbook(self): """Include the Playbook Module. .. Note:: Playbook methods can be accessed using ``tcex.playbook.<method>``. """ if self._playbook is None: from .tcex_playbook import TcExPlaybook self._playbook = TcExPlaybook(self) return self._playb...
[ "def", "playbook", "(", "self", ")", ":", "if", "self", ".", "_playbook", "is", "None", ":", "from", ".", "tcex_playbook", "import", "TcExPlaybook", "self", ".", "_playbook", "=", "TcExPlaybook", "(", "self", ")", "return", "self", ".", "_playbook" ]
Include the Playbook Module. .. Note:: Playbook methods can be accessed using ``tcex.playbook.<method>``.
[ "Include", "the", "Playbook", "Module", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L724-L733
train
27,708
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.proxies
def proxies(self): """Formats proxy configuration into required format for Python Requests module. Generates a dictionary for use with the Python Requests module format when proxy is required for remote connections. **Example Response** :: {"http": "http://user:pas...
python
def proxies(self): """Formats proxy configuration into required format for Python Requests module. Generates a dictionary for use with the Python Requests module format when proxy is required for remote connections. **Example Response** :: {"http": "http://user:pas...
[ "def", "proxies", "(", "self", ")", ":", "proxies", "=", "{", "}", "if", "(", "self", ".", "default_args", ".", "tc_proxy_host", "is", "not", "None", "and", "self", ".", "default_args", ".", "tc_proxy_port", "is", "not", "None", ")", ":", "if", "(", ...
Formats proxy configuration into required format for Python Requests module. Generates a dictionary for use with the Python Requests module format when proxy is required for remote connections. **Example Response** :: {"http": "http://user:pass@10.10.1.10:3128/"} ...
[ "Formats", "proxy", "configuration", "into", "required", "format", "for", "Python", "Requests", "module", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L736-L779
train
27,709
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.request
def request(self, session=None): """Return an instance of the Request Class. A wrapper on the Python Requests module that provides a different interface for creating requests. The session property of this instance has built-in logging, session level retries, and preconfigured proxy conf...
python
def request(self, session=None): """Return an instance of the Request Class. A wrapper on the Python Requests module that provides a different interface for creating requests. The session property of this instance has built-in logging, session level retries, and preconfigured proxy conf...
[ "def", "request", "(", "self", ",", "session", "=", "None", ")", ":", "try", ":", "from", ".", "tcex_request", "import", "TcExRequest", "r", "=", "TcExRequest", "(", "self", ",", "session", ")", "if", "session", "is", "None", "and", "self", ".", "defau...
Return an instance of the Request Class. A wrapper on the Python Requests module that provides a different interface for creating requests. The session property of this instance has built-in logging, session level retries, and preconfigured proxy configuration. Returns: (ob...
[ "Return", "an", "instance", "of", "the", "Request", "Class", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L781-L804
train
27,710
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.resource
def resource(self, resource_type): """Get instance of Resource Class with dynamic type. Args: resource_type: The resource type name (e.g Adversary, User Agent, etc). Returns: (object): Instance of Resource Object child class. """ try: resourc...
python
def resource(self, resource_type): """Get instance of Resource Class with dynamic type. Args: resource_type: The resource type name (e.g Adversary, User Agent, etc). Returns: (object): Instance of Resource Object child class. """ try: resourc...
[ "def", "resource", "(", "self", ",", "resource_type", ")", ":", "try", ":", "resource", "=", "getattr", "(", "self", ".", "resources", ",", "self", ".", "safe_rt", "(", "resource_type", ")", ")", "(", "self", ")", "except", "AttributeError", ":", "self",...
Get instance of Resource Class with dynamic type. Args: resource_type: The resource type name (e.g Adversary, User Agent, etc). Returns: (object): Instance of Resource Object child class.
[ "Get", "instance", "of", "Resource", "Class", "with", "dynamic", "type", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L806-L820
train
27,711
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.results_tc
def results_tc(self, key, value): """Write data to results_tc file in TcEX specified directory. The TcEx platform support persistent values between executions of the App. This method will store the values for TC to read and put into the Database. Args: key (string): The da...
python
def results_tc(self, key, value): """Write data to results_tc file in TcEX specified directory. The TcEx platform support persistent values between executions of the App. This method will store the values for TC to read and put into the Database. Args: key (string): The da...
[ "def", "results_tc", "(", "self", ",", "key", ",", "value", ")", ":", "if", "os", ".", "access", "(", "self", ".", "default_args", ".", "tc_out_path", ",", "os", ".", "W_OK", ")", ":", "results_file", "=", "'{}/results.tc'", ".", "format", "(", "self",...
Write data to results_tc file in TcEX specified directory. The TcEx platform support persistent values between executions of the App. This method will store the values for TC to read and put into the Database. Args: key (string): The data key to be stored. value (strin...
[ "Write", "data", "to", "results_tc", "file", "in", "TcEX", "specified", "directory", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L822-L858
train
27,712
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.safe_indicator
def safe_indicator(self, indicator, errors='strict'): """Indicator encode value for safe HTTP request. Args: indicator (string): Indicator to URL Encode errors (string): The error handler type. Returns: (string): The urlencoded string """ if ...
python
def safe_indicator(self, indicator, errors='strict'): """Indicator encode value for safe HTTP request. Args: indicator (string): Indicator to URL Encode errors (string): The error handler type. Returns: (string): The urlencoded string """ if ...
[ "def", "safe_indicator", "(", "self", ",", "indicator", ",", "errors", "=", "'strict'", ")", ":", "if", "indicator", "is", "not", "None", ":", "try", ":", "indicator", "=", "quote", "(", "self", ".", "s", "(", "str", "(", "indicator", ")", ",", "erro...
Indicator encode value for safe HTTP request. Args: indicator (string): Indicator to URL Encode errors (string): The error handler type. Returns: (string): The urlencoded string
[ "Indicator", "encode", "value", "for", "safe", "HTTP", "request", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L891-L906
train
27,713
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.safe_rt
def safe_rt(resource_type, lower=False): """Format the Resource Type. Takes Custom Indicator types with a space character and return a *safe* string. (e.g. *User Agent* is converted to User_Agent or user_agent.) Args: resource_type (string): The resource type to format. ...
python
def safe_rt(resource_type, lower=False): """Format the Resource Type. Takes Custom Indicator types with a space character and return a *safe* string. (e.g. *User Agent* is converted to User_Agent or user_agent.) Args: resource_type (string): The resource type to format. ...
[ "def", "safe_rt", "(", "resource_type", ",", "lower", "=", "False", ")", ":", "if", "resource_type", "is", "not", "None", ":", "resource_type", "=", "resource_type", ".", "replace", "(", "' '", ",", "'_'", ")", "if", "lower", ":", "resource_type", "=", "...
Format the Resource Type. Takes Custom Indicator types with a space character and return a *safe* string. (e.g. *User Agent* is converted to User_Agent or user_agent.) Args: resource_type (string): The resource type to format. lower (boolean): Return type in all lower ca...
[ "Format", "the", "Resource", "Type", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L909-L927
train
27,714
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.safe_group_name
def safe_group_name(group_name, group_max_length=100, ellipsis=True): """Truncate group name to match limit breaking on space and optionally add an ellipsis. .. note:: Currently the ThreatConnect group name limit is 100 characters. Args: group_name (string): The raw group name to be...
python
def safe_group_name(group_name, group_max_length=100, ellipsis=True): """Truncate group name to match limit breaking on space and optionally add an ellipsis. .. note:: Currently the ThreatConnect group name limit is 100 characters. Args: group_name (string): The raw group name to be...
[ "def", "safe_group_name", "(", "group_name", ",", "group_max_length", "=", "100", ",", "ellipsis", "=", "True", ")", ":", "ellipsis_value", "=", "''", "if", "ellipsis", ":", "ellipsis_value", "=", "' ...'", "if", "group_name", "is", "not", "None", "and", "le...
Truncate group name to match limit breaking on space and optionally add an ellipsis. .. note:: Currently the ThreatConnect group name limit is 100 characters. Args: group_name (string): The raw group name to be truncated. group_max_length (int): The max length of the group name. ...
[ "Truncate", "group", "name", "to", "match", "limit", "breaking", "on", "space", "and", "optionally", "add", "an", "ellipsis", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L930-L958
train
27,715
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.safe_url
def safe_url(self, url, errors='strict'): """URL encode value for safe HTTP request. Args: url (string): The string to URL Encode. Returns: (string): The urlencoded string. """ if url is not None: url = quote(self.s(url, errors=errors), safe=...
python
def safe_url(self, url, errors='strict'): """URL encode value for safe HTTP request. Args: url (string): The string to URL Encode. Returns: (string): The urlencoded string. """ if url is not None: url = quote(self.s(url, errors=errors), safe=...
[ "def", "safe_url", "(", "self", ",", "url", ",", "errors", "=", "'strict'", ")", ":", "if", "url", "is", "not", "None", ":", "url", "=", "quote", "(", "self", ".", "s", "(", "url", ",", "errors", "=", "errors", ")", ",", "safe", "=", "'~'", ")"...
URL encode value for safe HTTP request. Args: url (string): The string to URL Encode. Returns: (string): The urlencoded string.
[ "URL", "encode", "value", "for", "safe", "HTTP", "request", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L986-L997
train
27,716
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.session
def session(self): """Return an instance of Requests Session configured for the ThreatConnect API.""" if self._session is None: from .tcex_session import TcExSession self._session = TcExSession(self) return self._session
python
def session(self): """Return an instance of Requests Session configured for the ThreatConnect API.""" if self._session is None: from .tcex_session import TcExSession self._session = TcExSession(self) return self._session
[ "def", "session", "(", "self", ")", ":", "if", "self", ".", "_session", "is", "None", ":", "from", ".", "tcex_session", "import", "TcExSession", "self", ".", "_session", "=", "TcExSession", "(", "self", ")", "return", "self", ".", "_session" ]
Return an instance of Requests Session configured for the ThreatConnect API.
[ "Return", "an", "instance", "of", "Requests", "Session", "configured", "for", "the", "ThreatConnect", "API", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L1000-L1006
train
27,717
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx.ti
def ti(self): """Include the Threat Intel Module. .. Note:: Threat Intell methods can be accessed using ``tcex.ti.<method>``. """ if self._ti is None: from .tcex_ti import TcExTi self._ti = TcExTi(self) return self._ti
python
def ti(self): """Include the Threat Intel Module. .. Note:: Threat Intell methods can be accessed using ``tcex.ti.<method>``. """ if self._ti is None: from .tcex_ti import TcExTi self._ti = TcExTi(self) return self._ti
[ "def", "ti", "(", "self", ")", ":", "if", "self", ".", "_ti", "is", "None", ":", "from", ".", "tcex_ti", "import", "TcExTi", "self", ".", "_ti", "=", "TcExTi", "(", "self", ")", "return", "self", ".", "_ti" ]
Include the Threat Intel Module. .. Note:: Threat Intell methods can be accessed using ``tcex.ti.<method>``.
[ "Include", "the", "Threat", "Intel", "Module", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L1009-L1018
train
27,718
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/task.py
Task.assignees
def assignees(self): """ Gets the task assignees """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) for a in self.tc_requests.assignees(self.api_type, self.api_sub_type, self.unique_id): yield a
python
def assignees(self): """ Gets the task assignees """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) for a in self.tc_requests.assignees(self.api_type, self.api_sub_type, self.unique_id): yield a
[ "def", "assignees", "(", "self", ")", ":", "if", "not", "self", ".", "can_update", "(", ")", ":", "self", ".", "_tcex", ".", "handle_error", "(", "910", ",", "[", "self", ".", "type", "]", ")", "for", "a", "in", "self", ".", "tc_requests", ".", "...
Gets the task assignees
[ "Gets", "the", "task", "assignees" ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/task.py#L144-L152
train
27,719
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/task.py
Task.escalatees
def escalatees(self): """ Gets the task escalatees """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) for e in self.tc_requests.escalatees(self.api_type, self.api_sub_type, self.unique_id): yield e
python
def escalatees(self): """ Gets the task escalatees """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) for e in self.tc_requests.escalatees(self.api_type, self.api_sub_type, self.unique_id): yield e
[ "def", "escalatees", "(", "self", ")", ":", "if", "not", "self", ".", "can_update", "(", ")", ":", "self", ".", "_tcex", ".", "handle_error", "(", "910", ",", "[", "self", ".", "type", "]", ")", "for", "e", "in", "self", ".", "tc_requests", ".", ...
Gets the task escalatees
[ "Gets", "the", "task", "escalatees" ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/task.py#L200-L208
train
27,720
ThreatConnect-Inc/tcex
tcex/tcex_key_value.py
TcExKeyValue.read
def read(self, key): """Read data from remote KV store for the provided key. Args: key (string): The key to read in remote KV store. Returns: (any): The response data from the remote KV store. """ key = quote(key, safe='~') url = '/internal/playb...
python
def read(self, key): """Read data from remote KV store for the provided key. Args: key (string): The key to read in remote KV store. Returns: (any): The response data from the remote KV store. """ key = quote(key, safe='~') url = '/internal/playb...
[ "def", "read", "(", "self", ",", "key", ")", ":", "key", "=", "quote", "(", "key", ",", "safe", "=", "'~'", ")", "url", "=", "'/internal/playbooks/keyValue/{}'", ".", "format", "(", "key", ")", "r", "=", "self", ".", "tcex", ".", "session", ".", "g...
Read data from remote KV store for the provided key. Args: key (string): The key to read in remote KV store. Returns: (any): The response data from the remote KV store.
[ "Read", "data", "from", "remote", "KV", "store", "for", "the", "provided", "key", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_key_value.py#L43-L58
train
27,721
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/indicator/indicator_types/registry_key.py
RegistryKey.can_create
def can_create(self): """ If the key_name, value_name, and value_type has been provided returns that the Registry Key can be created, otherwise returns that the Registry Key cannot be created. Returns: """ if ( self.data.get('key_name') and s...
python
def can_create(self): """ If the key_name, value_name, and value_type has been provided returns that the Registry Key can be created, otherwise returns that the Registry Key cannot be created. Returns: """ if ( self.data.get('key_name') and s...
[ "def", "can_create", "(", "self", ")", ":", "if", "(", "self", ".", "data", ".", "get", "(", "'key_name'", ")", "and", "self", ".", "data", ".", "get", "(", "'value_name'", ")", "and", "self", ".", "data", ".", "get", "(", "'value_type'", ")", ")",...
If the key_name, value_name, and value_type has been provided returns that the Registry Key can be created, otherwise returns that the Registry Key cannot be created. Returns:
[ "If", "the", "key_name", "value_name", "and", "value_type", "has", "been", "provided", "returns", "that", "the", "Registry", "Key", "can", "be", "created", "otherwise", "returns", "that", "the", "Registry", "Key", "cannot", "be", "created", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/indicator/indicator_types/registry_key.py#L29-L43
train
27,722
ThreatConnect-Inc/tcex
tcex/tcex_metrics_v2.py
TcExMetricsV2.metric_create
def metric_create(self): """Create the defined metric. .. code-block:: javascript { "status": "Success", "data": { "customMetricConfig": { "id": 12, "name": "Added Reports", ...
python
def metric_create(self): """Create the defined metric. .. code-block:: javascript { "status": "Success", "data": { "customMetricConfig": { "id": 12, "name": "Added Reports", ...
[ "def", "metric_create", "(", "self", ")", ":", "body", "=", "{", "'dataType'", ":", "self", ".", "_metric_data_type", ",", "'description'", ":", "self", ".", "_metric_description", ",", "'interval'", ":", "self", ".", "_metric_interval", ",", "'name'", ":", ...
Create the defined metric. .. code-block:: javascript { "status": "Success", "data": { "customMetricConfig": { "id": 12, "name": "Added Reports", "dataType": "Sum", ...
[ "Create", "the", "defined", "metric", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_metrics_v2.py#L29-L63
train
27,723
ThreatConnect-Inc/tcex
tcex/tcex_metrics_v2.py
TcExMetricsV2.metric_find
def metric_find(self): """Find the Metric by name. .. code-block:: javascript { "status": "Success", "data": { "resultCount": 1, "customMetricConfig": [ { "id": 9, ...
python
def metric_find(self): """Find the Metric by name. .. code-block:: javascript { "status": "Success", "data": { "resultCount": 1, "customMetricConfig": [ { "id": 9, ...
[ "def", "metric_find", "(", "self", ")", ":", "params", "=", "{", "'resultLimit'", ":", "50", ",", "'resultStart'", ":", "0", "}", "while", "True", ":", "if", "params", ".", "get", "(", "'resultStart'", ")", ">=", "params", ".", "get", "(", "'resultLimi...
Find the Metric by name. .. code-block:: javascript { "status": "Success", "data": { "resultCount": 1, "customMetricConfig": [ { "id": 9, "name": ...
[ "Find", "the", "Metric", "by", "name", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_metrics_v2.py#L65-L102
train
27,724
ThreatConnect-Inc/tcex
tcex/tcex_metrics_v2.py
TcExMetricsV2.add
def add(self, value, date=None, return_value=False, key=None): """Add metrics data to collection. Args: value (str): The value of the metric. date (str, optional): The optional date of the metric. return_value (bool, default:False): Tell the API to return the updates...
python
def add(self, value, date=None, return_value=False, key=None): """Add metrics data to collection. Args: value (str): The value of the metric. date (str, optional): The optional date of the metric. return_value (bool, default:False): Tell the API to return the updates...
[ "def", "add", "(", "self", ",", "value", ",", "date", "=", "None", ",", "return_value", "=", "False", ",", "key", "=", "None", ")", ":", "data", "=", "{", "}", "if", "self", ".", "_metric_id", "is", "None", ":", "self", ".", "tcex", ".", "handle_...
Add metrics data to collection. Args: value (str): The value of the metric. date (str, optional): The optional date of the metric. return_value (bool, default:False): Tell the API to return the updates metric value. key (str, optional): The key value for keyed me...
[ "Add", "metrics", "data", "to", "collection", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_metrics_v2.py#L104-L139
train
27,725
ThreatConnect-Inc/tcex
tcex/tcex_metrics_v2.py
TcExMetricsV2.add_keyed
def add_keyed(self, value, key, date=None, return_value=False): """Add keyed metrics data to collection. Args: value (str): The value of the metric. key (str): The key value for keyed metrics. date (str, optional): The optional date of the metric. return_...
python
def add_keyed(self, value, key, date=None, return_value=False): """Add keyed metrics data to collection. Args: value (str): The value of the metric. key (str): The key value for keyed metrics. date (str, optional): The optional date of the metric. return_...
[ "def", "add_keyed", "(", "self", ",", "value", ",", "key", ",", "date", "=", "None", ",", "return_value", "=", "False", ")", ":", "return", "self", ".", "add", "(", "value", ",", "date", ",", "return_value", ",", "key", ")" ]
Add keyed metrics data to collection. Args: value (str): The value of the metric. key (str): The key value for keyed metrics. date (str, optional): The optional date of the metric. return_value (bool, default:False): Tell the API to return the updates metric valu...
[ "Add", "keyed", "metrics", "data", "to", "collection", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_metrics_v2.py#L141-L154
train
27,726
ThreatConnect-Inc/tcex
tcex/tcex_redis.py
TcExRedis.hget
def hget(self, key): """Read data from Redis for the provided key. Args: key (string): The key to read in Redis. Returns: (any): The response data from Redis. """ data = self.r.hget(self.hash, key) if data is not None and not isinstance(data, str...
python
def hget(self, key): """Read data from Redis for the provided key. Args: key (string): The key to read in Redis. Returns: (any): The response data from Redis. """ data = self.r.hget(self.hash, key) if data is not None and not isinstance(data, str...
[ "def", "hget", "(", "self", ",", "key", ")", ":", "data", "=", "self", ".", "r", ".", "hget", "(", "self", ".", "hash", ",", "key", ")", "if", "data", "is", "not", "None", "and", "not", "isinstance", "(", "data", ",", "str", ")", ":", "data", ...
Read data from Redis for the provided key. Args: key (string): The key to read in Redis. Returns: (any): The response data from Redis.
[ "Read", "data", "from", "Redis", "for", "the", "provided", "key", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_redis.py#L63-L75
train
27,727
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs._load_secure_params
def _load_secure_params(self): """Load secure params from the API. # API Response: .. code-block:: javascript :linenos: :lineno-start: 1 { "inputs": { "tc_playbook_db_type": "Redis", ...
python
def _load_secure_params(self): """Load secure params from the API. # API Response: .. code-block:: javascript :linenos: :lineno-start: 1 { "inputs": { "tc_playbook_db_type": "Redis", ...
[ "def", "_load_secure_params", "(", "self", ")", ":", "self", ".", "tcex", ".", "log", ".", "info", "(", "'Loading secure params.'", ")", "# Retrieve secure params and inject them into sys.argv", "r", "=", "self", ".", "tcex", ".", "session", ".", "get", "(", "'/...
Load secure params from the API. # API Response: .. code-block:: javascript :linenos: :lineno-start: 1 { "inputs": { "tc_playbook_db_type": "Redis", "fail_on_error": true, ...
[ "Load", "secure", "params", "from", "the", "API", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L35-L66
train
27,728
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs._results_tc_args
def _results_tc_args(self): """Read data from results_tc file from previous run of app. This method is only required when not running from the with the TcEX platform and is only intended for testing apps locally. Returns: (dictionary): A dictionary of values written to resu...
python
def _results_tc_args(self): """Read data from results_tc file from previous run of app. This method is only required when not running from the with the TcEX platform and is only intended for testing apps locally. Returns: (dictionary): A dictionary of values written to resu...
[ "def", "_results_tc_args", "(", "self", ")", ":", "results", "=", "[", "]", "if", "os", ".", "access", "(", "self", ".", "default_args", ".", "tc_out_path", ",", "os", ".", "W_OK", ")", ":", "result_file", "=", "'{}/results.tc'", ".", "format", "(", "s...
Read data from results_tc file from previous run of app. This method is only required when not running from the with the TcEX platform and is only intended for testing apps locally. Returns: (dictionary): A dictionary of values written to results_tc.
[ "Read", "data", "from", "results_tc", "file", "from", "previous", "run", "of", "app", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L68-L96
train
27,729
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs._unknown_args
def _unknown_args(self, args): """Log argparser unknown arguments. Args: args (list): List of unknown arguments """ for u in args: self.tcex.log.warning(u'Unsupported arg found ({}).'.format(u))
python
def _unknown_args(self, args): """Log argparser unknown arguments. Args: args (list): List of unknown arguments """ for u in args: self.tcex.log.warning(u'Unsupported arg found ({}).'.format(u))
[ "def", "_unknown_args", "(", "self", ",", "args", ")", ":", "for", "u", "in", "args", ":", "self", ".", "tcex", ".", "log", ".", "warning", "(", "u'Unsupported arg found ({}).'", ".", "format", "(", "u", ")", ")" ]
Log argparser unknown arguments. Args: args (list): List of unknown arguments
[ "Log", "argparser", "unknown", "arguments", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L98-L105
train
27,730
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs.args_update
def args_update(self): """Update the argparser namespace with any data from configuration file.""" for key, value in self._config_data.items(): setattr(self._default_args, key, value)
python
def args_update(self): """Update the argparser namespace with any data from configuration file.""" for key, value in self._config_data.items(): setattr(self._default_args, key, value)
[ "def", "args_update", "(", "self", ")", ":", "for", "key", ",", "value", "in", "self", ".", "_config_data", ".", "items", "(", ")", ":", "setattr", "(", "self", ".", "_default_args", ",", "key", ",", "value", ")" ]
Update the argparser namespace with any data from configuration file.
[ "Update", "the", "argparser", "namespace", "with", "any", "data", "from", "configuration", "file", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L133-L136
train
27,731
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs.config_file
def config_file(self, filename): """Load configuration data from provided file and inject values into sys.argv. Args: config (str): The configuration file name. """ if os.path.isfile(filename): with open(filename, 'r') as fh: self._config_data = j...
python
def config_file(self, filename): """Load configuration data from provided file and inject values into sys.argv. Args: config (str): The configuration file name. """ if os.path.isfile(filename): with open(filename, 'r') as fh: self._config_data = j...
[ "def", "config_file", "(", "self", ",", "filename", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fh", ":", "self", ".", "_config_data", "=", "json", ".", "load...
Load configuration data from provided file and inject values into sys.argv. Args: config (str): The configuration file name.
[ "Load", "configuration", "data", "from", "provided", "file", "and", "inject", "values", "into", "sys", ".", "argv", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L166-L176
train
27,732
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs.default_args
def default_args(self): """Parse args and return default args.""" if self._default_args is None: self._default_args, unknown = self.parser.parse_known_args() # pylint: disable=W0612 # reinitialize logger with new log level and api settings self.tcex._logger() ...
python
def default_args(self): """Parse args and return default args.""" if self._default_args is None: self._default_args, unknown = self.parser.parse_known_args() # pylint: disable=W0612 # reinitialize logger with new log level and api settings self.tcex._logger() ...
[ "def", "default_args", "(", "self", ")", ":", "if", "self", ".", "_default_args", "is", "None", ":", "self", ".", "_default_args", ",", "unknown", "=", "self", ".", "parser", ".", "parse_known_args", "(", ")", "# pylint: disable=W0612", "# reinitialize logger wi...
Parse args and return default args.
[ "Parse", "args", "and", "return", "default", "args", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L179-L193
train
27,733
ThreatConnect-Inc/tcex
tcex/tcex_args.py
TcExArgs.inject_params
def inject_params(self, params): """Inject params into sys.argv from secureParams API, AOT, or user provided. Args: params (dict): A dictionary containing all parameters that need to be injected as args. """ for arg, value in params.items(): cli_arg = '--{}'.for...
python
def inject_params(self, params): """Inject params into sys.argv from secureParams API, AOT, or user provided. Args: params (dict): A dictionary containing all parameters that need to be injected as args. """ for arg, value in params.items(): cli_arg = '--{}'.for...
[ "def", "inject_params", "(", "self", ",", "params", ")", ":", "for", "arg", ",", "value", "in", "params", ".", "items", "(", ")", ":", "cli_arg", "=", "'--{}'", ".", "format", "(", "arg", ")", "if", "cli_arg", "in", "sys", ".", "argv", ":", "# arg ...
Inject params into sys.argv from secureParams API, AOT, or user provided. Args: params (dict): A dictionary containing all parameters that need to be injected as args.
[ "Inject", "params", "into", "sys", ".", "argv", "from", "secureParams", "API", "AOT", "or", "user", "provided", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_args.py#L195-L237
train
27,734
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/tcex_ti_owner.py
Owner.many
def many(self): """ Gets all of the owners available. Args: """ for i in self.tc_requests.many(self.api_type, None, self.api_entity): yield i
python
def many(self): """ Gets all of the owners available. Args: """ for i in self.tc_requests.many(self.api_type, None, self.api_entity): yield i
[ "def", "many", "(", "self", ")", ":", "for", "i", "in", "self", ".", "tc_requests", ".", "many", "(", "self", ".", "api_type", ",", "None", ",", "self", ".", "api_entity", ")", ":", "yield", "i" ]
Gets all of the owners available. Args:
[ "Gets", "all", "of", "the", "owners", "available", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tcex_ti_owner.py#L82-L89
train
27,735
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/indicator/indicator_types/host.py
Host.dns_resolution
def dns_resolution(self): """ Updates the Host DNS resolution Returns: """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) return self.tc_requests.dns_resolution( self.api_type, self.api_sub_type, self.unique_id, owner=self.o...
python
def dns_resolution(self): """ Updates the Host DNS resolution Returns: """ if not self.can_update(): self._tcex.handle_error(910, [self.type]) return self.tc_requests.dns_resolution( self.api_type, self.api_sub_type, self.unique_id, owner=self.o...
[ "def", "dns_resolution", "(", "self", ")", ":", "if", "not", "self", ".", "can_update", "(", ")", ":", "self", ".", "_tcex", ".", "handle_error", "(", "910", ",", "[", "self", ".", "type", "]", ")", "return", "self", ".", "tc_requests", ".", "dns_res...
Updates the Host DNS resolution Returns:
[ "Updates", "the", "Host", "DNS", "resolution" ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/indicator/indicator_types/host.py#L49-L61
train
27,736
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile._create_tcex_dirs
def _create_tcex_dirs(): """Create tcex.d directory and sub directories.""" dirs = ['tcex.d', 'tcex.d/data', 'tcex.d/profiles'] for d in dirs: if not os.path.isdir(d): os.makedirs(d)
python
def _create_tcex_dirs(): """Create tcex.d directory and sub directories.""" dirs = ['tcex.d', 'tcex.d/data', 'tcex.d/profiles'] for d in dirs: if not os.path.isdir(d): os.makedirs(d)
[ "def", "_create_tcex_dirs", "(", ")", ":", "dirs", "=", "[", "'tcex.d'", ",", "'tcex.d/data'", ",", "'tcex.d/profiles'", "]", "for", "d", "in", "dirs", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "d", ")", ":", "os", ".", "makedirs", "(",...
Create tcex.d directory and sub directories.
[ "Create", "tcex", ".", "d", "directory", "and", "sub", "directories", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L46-L52
train
27,737
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.expand_valid_values
def expand_valid_values(valid_values): """Expand supported playbook variables to their full list. Args: valid_values (list): The list of valid values for Choice or MultiChoice inputs. Returns: List: An expanded list of valid values for Choice or MultiChoice inputs. ...
python
def expand_valid_values(valid_values): """Expand supported playbook variables to their full list. Args: valid_values (list): The list of valid values for Choice or MultiChoice inputs. Returns: List: An expanded list of valid values for Choice or MultiChoice inputs. ...
[ "def", "expand_valid_values", "(", "valid_values", ")", ":", "if", "'${GROUP_TYPES}'", "in", "valid_values", ":", "valid_values", ".", "remove", "(", "'${GROUP_TYPES}'", ")", "valid_values", ".", "extend", "(", "[", "'Adversary'", ",", "'Campaign'", ",", "'Documen...
Expand supported playbook variables to their full list. Args: valid_values (list): The list of valid values for Choice or MultiChoice inputs. Returns: List: An expanded list of valid values for Choice or MultiChoice inputs.
[ "Expand", "supported", "playbook", "variables", "to", "their", "full", "list", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L63-L95
train
27,738
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.gen_permutations
def gen_permutations(self, index=0, args=None): """Iterate recursively over layout.json parameter names. TODO: Add indicator values. Args: index (int, optional): The current index position in the layout names list. args (list, optional): Defaults to None. The current li...
python
def gen_permutations(self, index=0, args=None): """Iterate recursively over layout.json parameter names. TODO: Add indicator values. Args: index (int, optional): The current index position in the layout names list. args (list, optional): Defaults to None. The current li...
[ "def", "gen_permutations", "(", "self", ",", "index", "=", "0", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "[", "]", "try", ":", "name", "=", "self", ".", "layout_json_names", "[", "index", "]", "display", "="...
Iterate recursively over layout.json parameter names. TODO: Add indicator values. Args: index (int, optional): The current index position in the layout names list. args (list, optional): Defaults to None. The current list of args.
[ "Iterate", "recursively", "over", "layout", ".", "json", "parameter", "names", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L97-L149
train
27,739
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.load_profiles
def load_profiles(self): """Return configuration data. Load on first access, otherwise return existing data. .. code-block:: python self.profiles = { <profile name>: { 'data': {}, 'ij_filename': <filename>, ...
python
def load_profiles(self): """Return configuration data. Load on first access, otherwise return existing data. .. code-block:: python self.profiles = { <profile name>: { 'data': {}, 'ij_filename': <filename>, ...
[ "def", "load_profiles", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "'tcex.json'", ")", ":", "msg", "=", "'The tcex.json config file is required.'", "sys", ".", "exit", "(", "msg", ")", "# create default directories", "self", "."...
Return configuration data. Load on first access, otherwise return existing data. .. code-block:: python self.profiles = { <profile name>: { 'data': {}, 'ij_filename': <filename>, 'fqfn': 'tcex.json' ...
[ "Return", "configuration", "data", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L151-L200
train
27,740
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.load_profiles_from_file
def load_profiles_from_file(self, fqfn): """Load profiles from file. Args: fqfn (str): Fully qualified file name. """ if self.args.verbose: print('Loading profiles from File: {}{}{}'.format(c.Style.BRIGHT, c.Fore.MAGENTA, fqfn)) with open(fqfn, 'r+') as f...
python
def load_profiles_from_file(self, fqfn): """Load profiles from file. Args: fqfn (str): Fully qualified file name. """ if self.args.verbose: print('Loading profiles from File: {}{}{}'.format(c.Style.BRIGHT, c.Fore.MAGENTA, fqfn)) with open(fqfn, 'r+') as f...
[ "def", "load_profiles_from_file", "(", "self", ",", "fqfn", ")", ":", "if", "self", ".", "args", ".", "verbose", ":", "print", "(", "'Loading profiles from File: {}{}{}'", ".", "format", "(", "c", ".", "Style", ".", "BRIGHT", ",", "c", ".", "Fore", ".", ...
Load profiles from file. Args: fqfn (str): Fully qualified file name.
[ "Load", "profiles", "from", "file", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L202-L229
train
27,741
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.print_permutations
def print_permutations(self): """Print all valid permutations.""" index = 0 permutations = [] for p in self._input_permutations: permutations.append({'index': index, 'args': p}) index += 1 with open('permutations.json', 'w') as fh: json.dump(pe...
python
def print_permutations(self): """Print all valid permutations.""" index = 0 permutations = [] for p in self._input_permutations: permutations.append({'index': index, 'args': p}) index += 1 with open('permutations.json', 'w') as fh: json.dump(pe...
[ "def", "print_permutations", "(", "self", ")", ":", "index", "=", "0", "permutations", "=", "[", "]", "for", "p", "in", "self", ".", "_input_permutations", ":", "permutations", ".", "append", "(", "{", "'index'", ":", "index", ",", "'args'", ":", "p", ...
Print all valid permutations.
[ "Print", "all", "valid", "permutations", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L259-L268
train
27,742
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_create
def profile_create(self): """Create a profile.""" if self.args.profile_name in self.profiles: self.handle_error('Profile "{}" already exists.'.format(self.args.profile_name)) # load the install.json file defined as a arg (default: install.json) ij = self.load_install_json(se...
python
def profile_create(self): """Create a profile.""" if self.args.profile_name in self.profiles: self.handle_error('Profile "{}" already exists.'.format(self.args.profile_name)) # load the install.json file defined as a arg (default: install.json) ij = self.load_install_json(se...
[ "def", "profile_create", "(", "self", ")", ":", "if", "self", ".", "args", ".", "profile_name", "in", "self", ".", "profiles", ":", "self", ".", "handle_error", "(", "'Profile \"{}\" already exists.'", ".", "format", "(", "self", ".", "args", ".", "profile_n...
Create a profile.
[ "Create", "a", "profile", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L270-L303
train
27,743
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_delete
def profile_delete(self): """Delete an existing profile.""" self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) fqfn = profile_data.get('fqfn') with open(fqfn, 'r+') as fh: data = json.load(fh) for profile in data: ...
python
def profile_delete(self): """Delete an existing profile.""" self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) fqfn = profile_data.get('fqfn') with open(fqfn, 'r+') as fh: data = json.load(fh) for profile in data: ...
[ "def", "profile_delete", "(", "self", ")", ":", "self", ".", "validate_profile_exists", "(", ")", "profile_data", "=", "self", ".", "profiles", ".", "get", "(", "self", ".", "args", ".", "profile_name", ")", "fqfn", "=", "profile_data", ".", "get", "(", ...
Delete an existing profile.
[ "Delete", "an", "existing", "profile", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L305-L322
train
27,744
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_settings_args
def profile_settings_args(self, ij, required): """Return args based on install.json or layout.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or opti...
python
def profile_settings_args(self, ij, required): """Return args based on install.json or layout.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or opti...
[ "def", "profile_settings_args", "(", "self", ",", "ij", ",", "required", ")", ":", "if", "self", ".", "args", ".", "permutation_id", "is", "not", "None", ":", "if", "'sqlite3'", "not", "in", "sys", ".", "modules", ":", "print", "(", "'The sqlite3 module ne...
Return args based on install.json or layout.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args.
[ "Return", "args", "based", "on", "install", ".", "json", "or", "layout", ".", "json", "params", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L324-L341
train
27,745
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_settings_args_install_json
def profile_settings_args_install_json(self, ij, required): """Return args based on install.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or option...
python
def profile_settings_args_install_json(self, ij, required): """Return args based on install.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or option...
[ "def", "profile_settings_args_install_json", "(", "self", ",", "ij", ",", "required", ")", ":", "profile_args", "=", "{", "}", "# add App specific args", "for", "p", "in", "ij", ".", "get", "(", "'params'", ")", "or", "[", "]", ":", "# TODO: fix this required ...
Return args based on install.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args.
[ "Return", "args", "based", "on", "install", ".", "json", "params", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L343-L376
train
27,746
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_settings_args_layout_json
def profile_settings_args_layout_json(self, required): """Return args based on layout.json and conditional rendering. Args: required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args. """ pro...
python
def profile_settings_args_layout_json(self, required): """Return args based on layout.json and conditional rendering. Args: required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args. """ pro...
[ "def", "profile_settings_args_layout_json", "(", "self", ",", "required", ")", ":", "profile_args", "=", "{", "}", "self", ".", "db_create_table", "(", "self", ".", "input_table", ",", "self", ".", "install_json_params", "(", ")", ".", "keys", "(", ")", ")",...
Return args based on layout.json and conditional rendering. Args: required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args.
[ "Return", "args", "based", "on", "layout", ".", "json", "and", "conditional", "rendering", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L378-L415
train
27,747
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_setting_default_args
def profile_setting_default_args(ij): """Build the default args for this profile. Args: ij (dict): The install.json contents. Returns: dict: The default args for a Job or Playbook App. """ # build default args profile_default_args = OrderedDict(...
python
def profile_setting_default_args(ij): """Build the default args for this profile. Args: ij (dict): The install.json contents. Returns: dict: The default args for a Job or Playbook App. """ # build default args profile_default_args = OrderedDict(...
[ "def", "profile_setting_default_args", "(", "ij", ")", ":", "# build default args", "profile_default_args", "=", "OrderedDict", "(", ")", "profile_default_args", "[", "'api_default_org'", "]", "=", "'$env.API_DEFAULT_ORG'", "profile_default_args", "[", "'api_access_id'", "]...
Build the default args for this profile. Args: ij (dict): The install.json contents. Returns: dict: The default args for a Job or Playbook App.
[ "Build", "the", "default", "args", "for", "this", "profile", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L418-L453
train
27,748
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_settings_validations
def profile_settings_validations(self): """Create 2 default validations rules for each output variable. * One validation rule to check that the output variable is not null. * One validation rule to ensure the output value is of the correct type. """ ij = self.load_install_json(...
python
def profile_settings_validations(self): """Create 2 default validations rules for each output variable. * One validation rule to check that the output variable is not null. * One validation rule to ensure the output value is of the correct type. """ ij = self.load_install_json(...
[ "def", "profile_settings_validations", "(", "self", ")", ":", "ij", "=", "self", ".", "load_install_json", "(", "self", ".", "args", ".", "ij", ")", "validations", "=", "{", "'rules'", ":", "[", "]", ",", "'outputs'", ":", "[", "]", "}", "job_id", "=",...
Create 2 default validations rules for each output variable. * One validation rule to check that the output variable is not null. * One validation rule to ensure the output value is of the correct type.
[ "Create", "2", "default", "validations", "rules", "for", "each", "output", "variable", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L456-L508
train
27,749
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_update
def profile_update(self, profile): """Update an existing profile with new parameters or remove deprecated parameters. Args: profile (dict): The dictionary containting the profile settings. """ # warn about missing install_json parameter if profile.get('install_json')...
python
def profile_update(self, profile): """Update an existing profile with new parameters or remove deprecated parameters. Args: profile (dict): The dictionary containting the profile settings. """ # warn about missing install_json parameter if profile.get('install_json')...
[ "def", "profile_update", "(", "self", ",", "profile", ")", ":", "# warn about missing install_json parameter", "if", "profile", ".", "get", "(", "'install_json'", ")", "is", "None", ":", "print", "(", "'{}{}Missing install_json parameter for profile {}.'", ".", "format"...
Update an existing profile with new parameters or remove deprecated parameters. Args: profile (dict): The dictionary containting the profile settings.
[ "Update", "an", "existing", "profile", "with", "new", "parameters", "or", "remove", "deprecated", "parameters", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L510-L531
train
27,750
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_update_args_v2
def profile_update_args_v2(self, profile): """Update v1 profile args to v2 schema for args. .. code-block:: javascript "args": { "app": { "input_strings": "capitalize", "tc_action": "Capitalize" } }, ...
python
def profile_update_args_v2(self, profile): """Update v1 profile args to v2 schema for args. .. code-block:: javascript "args": { "app": { "input_strings": "capitalize", "tc_action": "Capitalize" } }, ...
[ "def", "profile_update_args_v2", "(", "self", ",", "profile", ")", ":", "ij", "=", "self", ".", "load_install_json", "(", "profile", ".", "get", "(", "'install_json'", ",", "'install.json'", ")", ")", "if", "(", "profile", ".", "get", "(", "'args'", ",", ...
Update v1 profile args to v2 schema for args. .. code-block:: javascript "args": { "app": { "input_strings": "capitalize", "tc_action": "Capitalize" } }, "default": { "api_access_id": "$...
[ "Update", "v1", "profile", "args", "to", "v2", "schema", "for", "args", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L533-L580
train
27,751
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_update_args_v3
def profile_update_args_v3(self, profile): """Update v1 profile args to v3 schema for args. .. code-block:: javascript "args": { "app": { "required": { "input_strings": "capitalize", "tc_action": "Capitaliz...
python
def profile_update_args_v3(self, profile): """Update v1 profile args to v3 schema for args. .. code-block:: javascript "args": { "app": { "required": { "input_strings": "capitalize", "tc_action": "Capitaliz...
[ "def", "profile_update_args_v3", "(", "self", ",", "profile", ")", ":", "ij", "=", "self", ".", "load_install_json", "(", "profile", ".", "get", "(", "'install_json'", ",", "'install.json'", ")", ")", "ijp", "=", "self", ".", "install_json_params", "(", "ij"...
Update v1 profile args to v3 schema for args. .. code-block:: javascript "args": { "app": { "required": { "input_strings": "capitalize", "tc_action": "Capitalize" }, "optiona...
[ "Update", "v1", "profile", "args", "to", "v3", "schema", "for", "args", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L582-L636
train
27,752
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_update_schema
def profile_update_schema(profile): """Update profile to latest schema. Args: profile (dict): The dictionary containting the profile settings. """ # add new "autoclear" field if profile.get('autoclear') is None: print( '{}{}Profile Update...
python
def profile_update_schema(profile): """Update profile to latest schema. Args: profile (dict): The dictionary containting the profile settings. """ # add new "autoclear" field if profile.get('autoclear') is None: print( '{}{}Profile Update...
[ "def", "profile_update_schema", "(", "profile", ")", ":", "# add new \"autoclear\" field", "if", "profile", ".", "get", "(", "'autoclear'", ")", "is", "None", ":", "print", "(", "'{}{}Profile Update: Adding new \"autoclear\" parameter.'", ".", "format", "(", "c", ".",...
Update profile to latest schema. Args: profile (dict): The dictionary containting the profile settings.
[ "Update", "profile", "to", "latest", "schema", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L639-L670
train
27,753
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.profile_write
def profile_write(self, profile, outfile=None): """Write the profile to the output directory. Args: profile (dict): The dictionary containting the profile settings. outfile (str, optional): Defaults to None. The filename for the profile. """ # fully qualified ou...
python
def profile_write(self, profile, outfile=None): """Write the profile to the output directory. Args: profile (dict): The dictionary containting the profile settings. outfile (str, optional): Defaults to None. The filename for the profile. """ # fully qualified ou...
[ "def", "profile_write", "(", "self", ",", "profile", ",", "outfile", "=", "None", ")", ":", "# fully qualified output file", "if", "outfile", "is", "None", ":", "outfile", "=", "'{}.json'", ".", "format", "(", "profile", ".", "get", "(", "'profile_name'", ")...
Write the profile to the output directory. Args: profile (dict): The dictionary containting the profile settings. outfile (str, optional): Defaults to None. The filename for the profile.
[ "Write", "the", "profile", "to", "the", "output", "directory", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L672-L702
train
27,754
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.replace_validation
def replace_validation(self): """Replace the validation configuration in the selected profile. TODO: Update this method. """ self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) # check redis # if redis is None: # ...
python
def replace_validation(self): """Replace the validation configuration in the selected profile. TODO: Update this method. """ self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) # check redis # if redis is None: # ...
[ "def", "replace_validation", "(", "self", ")", ":", "self", ".", "validate_profile_exists", "(", ")", "profile_data", "=", "self", ".", "profiles", ".", "get", "(", "self", ".", "args", ".", "profile_name", ")", "# check redis", "# if redis is None:", "# sel...
Replace the validation configuration in the selected profile. TODO: Update this method.
[ "Replace", "the", "validation", "configuration", "in", "the", "selected", "profile", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L704-L771
train
27,755
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.validate
def validate(self, profile): """Check to see if any args are "missing" from profile. Validate all args from install.json are in the profile. This can be helpful to validate that any new args added to App are included in the profiles. .. Note:: This method does not work with layout.jso...
python
def validate(self, profile): """Check to see if any args are "missing" from profile. Validate all args from install.json are in the profile. This can be helpful to validate that any new args added to App are included in the profiles. .. Note:: This method does not work with layout.jso...
[ "def", "validate", "(", "self", ",", "profile", ")", ":", "ij", "=", "self", ".", "load_install_json", "(", "profile", ".", "get", "(", "'install_json'", ")", ")", "print", "(", "'{}{}Profile: \"{}\".'", ".", "format", "(", "c", ".", "Style", ".", "BRIGH...
Check to see if any args are "missing" from profile. Validate all args from install.json are in the profile. This can be helpful to validate that any new args added to App are included in the profiles. .. Note:: This method does not work with layout.json Apps. Args: profi...
[ "Check", "to", "see", "if", "any", "args", "are", "missing", "from", "profile", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L773-L789
train
27,756
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.validate_layout_display
def validate_layout_display(self, table, display_condition): """Check to see if the display condition passes. Args: table (str): The name of the DB table which hold the App data. display_condition (str): The "where" clause of the DB SQL statement. Returns: b...
python
def validate_layout_display(self, table, display_condition): """Check to see if the display condition passes. Args: table (str): The name of the DB table which hold the App data. display_condition (str): The "where" clause of the DB SQL statement. Returns: b...
[ "def", "validate_layout_display", "(", "self", ",", "table", ",", "display_condition", ")", ":", "display", "=", "False", "if", "display_condition", "is", "None", ":", "display", "=", "True", "else", ":", "display_query", "=", "'select count(*) from {} where {}'", ...
Check to see if the display condition passes. Args: table (str): The name of the DB table which hold the App data. display_condition (str): The "where" clause of the DB SQL statement. Returns: bool: True if the row count is greater than 0.
[ "Check", "to", "see", "if", "the", "display", "condition", "passes", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L791-L815
train
27,757
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
TcExProfile.validate_profile_exists
def validate_profile_exists(self): """Validate the provided profiles name exists.""" if self.args.profile_name not in self.profiles: self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
python
def validate_profile_exists(self): """Validate the provided profiles name exists.""" if self.args.profile_name not in self.profiles: self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
[ "def", "validate_profile_exists", "(", "self", ")", ":", "if", "self", ".", "args", ".", "profile_name", "not", "in", "self", ".", "profiles", ":", "self", ".", "handle_error", "(", "'Could not find profile \"{}\"'", ".", "format", "(", "self", ".", "args", ...
Validate the provided profiles name exists.
[ "Validate", "the", "provided", "profiles", "name", "exists", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L817-L821
train
27,758
ThreatConnect-Inc/tcex
tcex/tcex_data_filter.py
DataFilter._build_indexes
def _build_indexes(self): """Build indexes from data for fast filtering of data. Building indexes of data when possible. This is only supported when dealing with a List of Dictionaries with String values. """ if isinstance(self._data, list): for d in self._data: ...
python
def _build_indexes(self): """Build indexes from data for fast filtering of data. Building indexes of data when possible. This is only supported when dealing with a List of Dictionaries with String values. """ if isinstance(self._data, list): for d in self._data: ...
[ "def", "_build_indexes", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_data", ",", "list", ")", ":", "for", "d", "in", "self", ".", "_data", ":", "if", "not", "isinstance", "(", "d", ",", "dict", ")", ":", "err", "=", "u'Cannot bui...
Build indexes from data for fast filtering of data. Building indexes of data when possible. This is only supported when dealing with a List of Dictionaries with String values.
[ "Build", "indexes", "from", "data", "for", "fast", "filtering", "of", "data", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_data_filter.py#L28-L57
train
27,759
ThreatConnect-Inc/tcex
tcex/tcex_data_filter.py
DataFilter._starts_with
def _starts_with(field, filter_value): """Validate field starts with provided value. Args: filter_value (string): A string or list of values. Returns: (boolean): Results of validation """ valid = False if field.startswith(filter_value): ...
python
def _starts_with(field, filter_value): """Validate field starts with provided value. Args: filter_value (string): A string or list of values. Returns: (boolean): Results of validation """ valid = False if field.startswith(filter_value): ...
[ "def", "_starts_with", "(", "field", ",", "filter_value", ")", ":", "valid", "=", "False", "if", "field", ".", "startswith", "(", "filter_value", ")", ":", "valid", "=", "True", "return", "valid" ]
Validate field starts with provided value. Args: filter_value (string): A string or list of values. Returns: (boolean): Results of validation
[ "Validate", "field", "starts", "with", "provided", "value", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_data_filter.py#L155-L167
train
27,760
ThreatConnect-Inc/tcex
tcex/tcex_data_filter.py
DataFilter.filter_data
def filter_data(self, field, filter_value, filter_operator, field_converter=None): """Filter the data given the provided. Args: field (string): The field to filter on. filter_value (string | list): The value to match. filter_operator (string): The operator for compar...
python
def filter_data(self, field, filter_value, filter_operator, field_converter=None): """Filter the data given the provided. Args: field (string): The field to filter on. filter_value (string | list): The value to match. filter_operator (string): The operator for compar...
[ "def", "filter_data", "(", "self", ",", "field", ",", "filter_value", ",", "filter_operator", ",", "field_converter", "=", "None", ")", ":", "data", "=", "[", "]", "if", "self", ".", "_indexes", ".", "get", "(", "field", ")", "is", "not", "None", ":", ...
Filter the data given the provided. Args: field (string): The field to filter on. filter_value (string | list): The value to match. filter_operator (string): The operator for comparison. field_converter (method): A method used to convert the field before comparis...
[ "Filter", "the", "data", "given", "the", "provided", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_data_filter.py#L169-L193
train
27,761
ThreatConnect-Inc/tcex
tcex/tcex_data_filter.py
DataFilter.operator
def operator(self): """Supported Filter Operators + EQ - Equal To + NE - Not Equal To + GT - Greater Than + GE - Greater Than or Equal To + LT - Less Than + LE - Less Than or Equal To + SW - Starts With + IN - In String or Array + NI - Not...
python
def operator(self): """Supported Filter Operators + EQ - Equal To + NE - Not Equal To + GT - Greater Than + GE - Greater Than or Equal To + LT - Less Than + LE - Less Than or Equal To + SW - Starts With + IN - In String or Array + NI - Not...
[ "def", "operator", "(", "self", ")", ":", "return", "{", "'EQ'", ":", "operator", ".", "eq", ",", "'NE'", ":", "operator", ".", "ne", ",", "'GT'", ":", "operator", ".", "gt", ",", "'GE'", ":", "operator", ".", "ge", ",", "'LT'", ":", "operator", ...
Supported Filter Operators + EQ - Equal To + NE - Not Equal To + GT - Greater Than + GE - Greater Than or Equal To + LT - Less Than + LE - Less Than or Equal To + SW - Starts With + IN - In String or Array + NI - Not in String or Array
[ "Supported", "Filter", "Operators" ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_data_filter.py#L214-L238
train
27,762
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/tag.py
Tag.groups
def groups(self, group_type=None, filters=None, params=None): """ Gets all groups from a tag. Args: filters: params: group_type: """ group = self._tcex.ti.group(group_type) for g in self.tc_requests.groups_from_tag(group, self.name, fi...
python
def groups(self, group_type=None, filters=None, params=None): """ Gets all groups from a tag. Args: filters: params: group_type: """ group = self._tcex.ti.group(group_type) for g in self.tc_requests.groups_from_tag(group, self.name, fi...
[ "def", "groups", "(", "self", ",", "group_type", "=", "None", ",", "filters", "=", "None", ",", "params", "=", "None", ")", ":", "group", "=", "self", ".", "_tcex", ".", "ti", ".", "group", "(", "group_type", ")", "for", "g", "in", "self", ".", "...
Gets all groups from a tag. Args: filters: params: group_type:
[ "Gets", "all", "groups", "from", "a", "tag", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tag.py#L39-L50
train
27,763
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/tag.py
Tag.indicators
def indicators(self, indicator_type=None, filters=None, params=None): """ Gets all indicators from a tag. Args: params: filters: indicator_type: """ indicator = self._tcex.ti.indicator(indicator_type) for i in self.tc_requests.indicato...
python
def indicators(self, indicator_type=None, filters=None, params=None): """ Gets all indicators from a tag. Args: params: filters: indicator_type: """ indicator = self._tcex.ti.indicator(indicator_type) for i in self.tc_requests.indicato...
[ "def", "indicators", "(", "self", ",", "indicator_type", "=", "None", ",", "filters", "=", "None", ",", "params", "=", "None", ")", ":", "indicator", "=", "self", ".", "_tcex", ".", "ti", ".", "indicator", "(", "indicator_type", ")", "for", "i", "in", ...
Gets all indicators from a tag. Args: params: filters: indicator_type:
[ "Gets", "all", "indicators", "from", "a", "tag", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tag.py#L52-L65
train
27,764
ThreatConnect-Inc/tcex
tcex/tcex_ti/mappings/tag.py
Tag.victims
def victims(self, filters=None, params=None): """ Gets all victims from a tag. """ victim = self._tcex.ti.victim(None) for v in self.tc_requests.victims_from_tag( victim, self.name, filters=filters, params=params ): yield v
python
def victims(self, filters=None, params=None): """ Gets all victims from a tag. """ victim = self._tcex.ti.victim(None) for v in self.tc_requests.victims_from_tag( victim, self.name, filters=filters, params=params ): yield v
[ "def", "victims", "(", "self", ",", "filters", "=", "None", ",", "params", "=", "None", ")", ":", "victim", "=", "self", ".", "_tcex", ".", "ti", ".", "victim", "(", "None", ")", "for", "v", "in", "self", ".", "tc_requests", ".", "victims_from_tag", ...
Gets all victims from a tag.
[ "Gets", "all", "victims", "from", "a", "tag", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tag.py#L67-L75
train
27,765
ThreatConnect-Inc/tcex
tcex/tcex_auth.py
TcExAuth._logger
def _logger(): """Initialize basic stream logger.""" logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.DEBUG) logger.addHandler(ch) return logger
python
def _logger(): """Initialize basic stream logger.""" logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.DEBUG) logger.addHandler(ch) return logger
[ "def", "_logger", "(", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "ch", "=", "logging", ".", "StreamHandler", "(", "sys", ".", "stdout", ")", "ch", ".", "s...
Initialize basic stream logger.
[ "Initialize", "basic", "stream", "logger", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_auth.py#L25-L32
train
27,766
ThreatConnect-Inc/tcex
tcex/tcex_auth.py
TcExTokenAuth._renew_token
def _renew_token(self, retry=True): """Renew expired ThreatConnect Token.""" self.renewing = True self.log.info('Renewing ThreatConnect Token') self.log.info('Current Token Expiration: {}'.format(self._token_expiration)) try: params = {'expiredToken': self._token} ...
python
def _renew_token(self, retry=True): """Renew expired ThreatConnect Token.""" self.renewing = True self.log.info('Renewing ThreatConnect Token') self.log.info('Current Token Expiration: {}'.format(self._token_expiration)) try: params = {'expiredToken': self._token} ...
[ "def", "_renew_token", "(", "self", ",", "retry", "=", "True", ")", ":", "self", ".", "renewing", "=", "True", "self", ".", "log", ".", "info", "(", "'Renewing ThreatConnect Token'", ")", "self", ".", "log", ".", "info", "(", "'Current Token Expiration: {}'"...
Renew expired ThreatConnect Token.
[ "Renew", "expired", "ThreatConnect", "Token", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_auth.py#L74-L120
train
27,767
ThreatConnect-Inc/tcex
tcex/tcex_argparser.py
TcExArgParser._api_arguments
def _api_arguments(self): """Argument specific to working with TC API. --tc_token token Token provided by ThreatConnect for app Authorization. --tc_token_expires token_expires Expiration time for the passed Token. --api_access_id access_id Access ID used for HM...
python
def _api_arguments(self): """Argument specific to working with TC API. --tc_token token Token provided by ThreatConnect for app Authorization. --tc_token_expires token_expires Expiration time for the passed Token. --api_access_id access_id Access ID used for HM...
[ "def", "_api_arguments", "(", "self", ")", ":", "# TC main >= 4.4 token will be passed to jobs.", "self", ".", "add_argument", "(", "'--tc_token'", ",", "default", "=", "None", ",", "help", "=", "'ThreatConnect API Token'", ")", "self", ".", "add_argument", "(", "'-...
Argument specific to working with TC API. --tc_token token Token provided by ThreatConnect for app Authorization. --tc_token_expires token_expires Expiration time for the passed Token. --api_access_id access_id Access ID used for HMAC Authorization. --api_secre...
[ "Argument", "specific", "to", "working", "with", "TC", "API", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_argparser.py#L47-L76
train
27,768
ThreatConnect-Inc/tcex
tcex/tcex_argparser.py
TcExArgParser._batch_arguments
def _batch_arguments(self): """Arguments specific to Batch API writes. --batch_action action Action for the batch job ['Create', 'Delete']. --batch_chunk number The maximum number of indicator per batch job. --batch_halt_on_error Flag to indicate that the bat...
python
def _batch_arguments(self): """Arguments specific to Batch API writes. --batch_action action Action for the batch job ['Create', 'Delete']. --batch_chunk number The maximum number of indicator per batch job. --batch_halt_on_error Flag to indicate that the bat...
[ "def", "_batch_arguments", "(", "self", ")", ":", "self", ".", "add_argument", "(", "'--batch_action'", ",", "choices", "=", "[", "'Create'", ",", "'Delete'", "]", ",", "default", "=", "self", ".", "_batch_action", ",", "help", "=", "'Action for the batch job'...
Arguments specific to Batch API writes. --batch_action action Action for the batch job ['Create', 'Delete']. --batch_chunk number The maximum number of indicator per batch job. --batch_halt_on_error Flag to indicate that the batch job should halt on error. --...
[ "Arguments", "specific", "to", "Batch", "API", "writes", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_argparser.py#L78-L125
train
27,769
ThreatConnect-Inc/tcex
tcex/tcex_argparser.py
TcExArgParser._playbook_arguments
def _playbook_arguments(self): """Argument specific to playbook apps. These arguments will be passed to every playbook app by default. --tc_playbook_db_type type The DB type (currently on Redis is supported). --tc_playbook_db_context context The playbook context provided by TC....
python
def _playbook_arguments(self): """Argument specific to playbook apps. These arguments will be passed to every playbook app by default. --tc_playbook_db_type type The DB type (currently on Redis is supported). --tc_playbook_db_context context The playbook context provided by TC....
[ "def", "_playbook_arguments", "(", "self", ")", ":", "self", ".", "add_argument", "(", "'--tc_playbook_db_type'", ",", "default", "=", "self", ".", "_tc_playbook_db_type", ",", "help", "=", "'Playbook DB type'", ")", "self", ".", "add_argument", "(", "'--tc_playbo...
Argument specific to playbook apps. These arguments will be passed to every playbook app by default. --tc_playbook_db_type type The DB type (currently on Redis is supported). --tc_playbook_db_context context The playbook context provided by TC. --tc_playbook_db_path path ...
[ "Argument", "specific", "to", "playbook", "apps", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_argparser.py#L127-L155
train
27,770
ThreatConnect-Inc/tcex
tcex/tcex_argparser.py
TcExArgParser._standard_arguments
def _standard_arguments(self): """These are the standard args passed to every TcEx App. --api_default_org org The TC API user default organization. --tc_api_path path The TC API path (e.g https://api.threatconnect.com). --tc_in_path path The app in path. ...
python
def _standard_arguments(self): """These are the standard args passed to every TcEx App. --api_default_org org The TC API user default organization. --tc_api_path path The TC API path (e.g https://api.threatconnect.com). --tc_in_path path The app in path. ...
[ "def", "_standard_arguments", "(", "self", ")", ":", "self", ".", "add_argument", "(", "'--api_default_org'", ",", "default", "=", "None", ",", "help", "=", "'ThreatConnect api default Org'", ")", "self", ".", "add_argument", "(", "'--tc_action_channel'", ",", "de...
These are the standard args passed to every TcEx App. --api_default_org org The TC API user default organization. --tc_api_path path The TC API path (e.g https://api.threatconnect.com). --tc_in_path path The app in path. --tc_log_file filename The app l...
[ "These", "are", "the", "standard", "args", "passed", "to", "every", "TcEx", "App", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_argparser.py#L157-L265
train
27,771
ThreatConnect-Inc/tcex
app_init/job_batch/app.py
App.run
def run(self): """Run main App logic.""" self.batch = self.tcex.batch(self.args.tc_owner) # using tcex requests to get built-in features (e.g., proxy, logging, retries) request = self.tcex.request() with request.session as s: r = s.get(self.url) if r.ok...
python
def run(self): """Run main App logic.""" self.batch = self.tcex.batch(self.args.tc_owner) # using tcex requests to get built-in features (e.g., proxy, logging, retries) request = self.tcex.request() with request.session as s: r = s.get(self.url) if r.ok...
[ "def", "run", "(", "self", ")", ":", "self", ".", "batch", "=", "self", ".", "tcex", ".", "batch", "(", "self", ".", "args", ".", "tc_owner", ")", "# using tcex requests to get built-in features (e.g., proxy, logging, retries)", "request", "=", "self", ".", "tce...
Run main App logic.
[ "Run", "main", "App", "logic", "." ]
dd4d7a1ef723af1561687120191886b9a2fd4b47
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/app_init/job_batch/app.py#L18-L53
train
27,772
jssimporter/python-jss
jss/jamf_software_server.py
JSS.get
def get(self, url_path): """GET a url, handle errors, and return an etree. In general, it is better to use a higher level interface for API requests, like the search methods on this class, or the JSSObjects themselves. Args: url_path: String API endpoint path to GET...
python
def get(self, url_path): """GET a url, handle errors, and return an etree. In general, it is better to use a higher level interface for API requests, like the search methods on this class, or the JSSObjects themselves. Args: url_path: String API endpoint path to GET...
[ "def", "get", "(", "self", ",", "url_path", ")", ":", "request_url", "=", "\"%s%s\"", "%", "(", "self", ".", "_url", ",", "quote", "(", "url_path", ".", "encode", "(", "\"utf_8\"", ")", ")", ")", "response", "=", "self", ".", "session", ".", "get", ...
GET a url, handle errors, and return an etree. In general, it is better to use a higher level interface for API requests, like the search methods on this class, or the JSSObjects themselves. Args: url_path: String API endpoint path to GET (e.g. "/packages") Returns...
[ "GET", "a", "url", "handle", "errors", "and", "return", "an", "etree", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L178-L215
train
27,773
jssimporter/python-jss
jss/jamf_software_server.py
JSS.post
def post(self, obj_class, url_path, data): """POST an object to the JSS. For creating new objects only. The data argument is POSTed to the JSS, which, upon success, returns the complete XML for the new object. This data is used to get the ID of the new object, and, via the JSSOb...
python
def post(self, obj_class, url_path, data): """POST an object to the JSS. For creating new objects only. The data argument is POSTed to the JSS, which, upon success, returns the complete XML for the new object. This data is used to get the ID of the new object, and, via the JSSOb...
[ "def", "post", "(", "self", ",", "obj_class", ",", "url_path", ",", "data", ")", ":", "# The JSS expects a post to ID 0 to create an object", "request_url", "=", "\"%s%s\"", "%", "(", "self", ".", "_url", ",", "url_path", ")", "data", "=", "ElementTree", ".", ...
POST an object to the JSS. For creating new objects only. The data argument is POSTed to the JSS, which, upon success, returns the complete XML for the new object. This data is used to get the ID of the new object, and, via the JSSObjectFactory, GET that ID to instantiate a new JSSObjec...
[ "POST", "an", "object", "to", "the", "JSS", ".", "For", "creating", "new", "objects", "only", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L217-L266
train
27,774
jssimporter/python-jss
jss/jamf_software_server.py
JSS.put
def put(self, url_path, data): """Update an existing object on the JSS. In general, it is better to use a higher level interface for updating objects, namely, making changes to a JSSObject subclass and then using its save method. Args: url_path: String API endpoint ...
python
def put(self, url_path, data): """Update an existing object on the JSS. In general, it is better to use a higher level interface for updating objects, namely, making changes to a JSSObject subclass and then using its save method. Args: url_path: String API endpoint ...
[ "def", "put", "(", "self", ",", "url_path", ",", "data", ")", ":", "request_url", "=", "\"%s%s\"", "%", "(", "self", ".", "_url", ",", "url_path", ")", "data", "=", "ElementTree", ".", "tostring", "(", "data", ")", "response", "=", "self", ".", "sess...
Update an existing object on the JSS. In general, it is better to use a higher level interface for updating objects, namely, making changes to a JSSObject subclass and then using its save method. Args: url_path: String API endpoint path to PUT, with ID (e.g. ...
[ "Update", "an", "existing", "object", "on", "the", "JSS", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L268-L290
train
27,775
jssimporter/python-jss
jss/jamf_software_server.py
JSS.delete
def delete(self, url_path, data=None): """Delete an object from the JSS. In general, it is better to use a higher level interface for deleting objects, namely, using a JSSObject's delete method. Args: url_path: String API endpoint path to DEL, with ID (e.g. ...
python
def delete(self, url_path, data=None): """Delete an object from the JSS. In general, it is better to use a higher level interface for deleting objects, namely, using a JSSObject's delete method. Args: url_path: String API endpoint path to DEL, with ID (e.g. ...
[ "def", "delete", "(", "self", ",", "url_path", ",", "data", "=", "None", ")", ":", "request_url", "=", "\"%s%s\"", "%", "(", "self", ".", "_url", ",", "url_path", ")", "if", "data", ":", "response", "=", "self", ".", "session", ".", "delete", "(", ...
Delete an object from the JSS. In general, it is better to use a higher level interface for deleting objects, namely, using a JSSObject's delete method. Args: url_path: String API endpoint path to DEL, with ID (e.g. "/packages/id/<object ID>") Raises: ...
[ "Delete", "an", "object", "from", "the", "JSS", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L292-L314
train
27,776
jssimporter/python-jss
jss/jamf_software_server.py
JSS._docstring_parameter
def _docstring_parameter(obj_type, subset=False): # pylint: disable=no-self-argument """Decorator for adding _docstring to repetitive methods.""" docstring = ( "Flexibly search the JSS for objects of type {}.\n\n\tArgs:\n\t\t" "Data: Allows different types to conduct different ...
python
def _docstring_parameter(obj_type, subset=False): # pylint: disable=no-self-argument """Decorator for adding _docstring to repetitive methods.""" docstring = ( "Flexibly search the JSS for objects of type {}.\n\n\tArgs:\n\t\t" "Data: Allows different types to conduct different ...
[ "def", "_docstring_parameter", "(", "obj_type", ",", "subset", "=", "False", ")", ":", "# pylint: disable=no-self-argument", "docstring", "=", "(", "\"Flexibly search the JSS for objects of type {}.\\n\\n\\tArgs:\\n\\t\\t\"", "\"Data: Allows different types to conduct different types o...
Decorator for adding _docstring to repetitive methods.
[ "Decorator", "for", "adding", "_docstring", "to", "repetitive", "methods", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L321-L352
train
27,777
jssimporter/python-jss
jss/jamf_software_server.py
JSS.pickle_all
def pickle_all(self, path): """Back up entire JSS to a Python Pickle. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python object...
python
def pickle_all(self, path): """Back up entire JSS to a Python Pickle. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python object...
[ "def", "pickle_all", "(", "self", ",", "path", ")", ":", "all_search_methods", "=", "[", "(", "name", ",", "self", ".", "__getattribute__", "(", "name", ")", ")", "for", "name", "in", "dir", "(", "self", ")", "if", "name", "[", "0", "]", ".", "isup...
Back up entire JSS to a Python Pickle. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully func...
[ "Back", "up", "entire", "JSS", "to", "a", "Python", "Pickle", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L356-L391
train
27,778
jssimporter/python-jss
jss/jamf_software_server.py
JSS.from_pickle
def from_pickle(cls, path): """Load all objects from pickle file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
python
def from_pickle(cls, path): """Load all objects from pickle file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
[ "def", "from_pickle", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "os", ".", "path", ".", "expanduser", "(", "path", ")", ",", "\"rb\"", ")", "as", "pickle", ":", "return", "cPickle", ".", "Unpickler", "(", "pickle", ")", ".", "load", "...
Load all objects from pickle file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss.Computer().retrieve_all()). T...
[ "Load", "all", "objects", "from", "pickle", "file", "and", "return", "as", "dict", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L393-L413
train
27,779
jssimporter/python-jss
jss/jamf_software_server.py
JSS.write_all
def write_all(self, path): """Back up entire JSS to XML file. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python objects. This ...
python
def write_all(self, path): """Back up entire JSS to XML file. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python objects. This ...
[ "def", "write_all", "(", "self", ",", "path", ")", ":", "all_search_methods", "=", "[", "(", "name", ",", "self", ".", "__getattribute__", "(", "name", ")", ")", "for", "name", "in", "dir", "(", "self", ")", "if", "name", "[", "0", "]", ".", "isupp...
Back up entire JSS to XML file. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully functional ...
[ "Back", "up", "entire", "JSS", "to", "XML", "file", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L415-L457
train
27,780
jssimporter/python-jss
jss/jamf_software_server.py
JSS.load_from_xml
def load_from_xml(self, path): """Load all objects from XML file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
python
def load_from_xml(self, path): """Load all objects from XML file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
[ "def", "load_from_xml", "(", "self", ",", "path", ")", ":", "with", "open", "(", "os", ".", "path", ".", "expanduser", "(", "path", ")", ",", "\"r\"", ")", "as", "ifile", ":", "et", "=", "ElementTree", ".", "parse", "(", "ifile", ")", "root", "=", ...
Load all objects from XML file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss.Computer().retrieve_all()). This...
[ "Load", "all", "objects", "from", "XML", "file", "and", "return", "as", "dict", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L459-L484
train
27,781
jssimporter/python-jss
jss/jamf_software_server.py
JSSObjectFactory.get_object
def get_object(self, obj_class, data=None, subset=None): """Return a subclassed JSSObject instance by querying for existing objects or posting a new object. Args: obj_class: The JSSObject subclass type to search for or create. data: The data parameter per...
python
def get_object(self, obj_class, data=None, subset=None): """Return a subclassed JSSObject instance by querying for existing objects or posting a new object. Args: obj_class: The JSSObject subclass type to search for or create. data: The data parameter per...
[ "def", "get_object", "(", "self", ",", "obj_class", ",", "data", "=", "None", ",", "subset", "=", "None", ")", ":", "if", "subset", ":", "if", "not", "isinstance", "(", "subset", ",", "list", ")", ":", "if", "isinstance", "(", "subset", ",", "basestr...
Return a subclassed JSSObject instance by querying for existing objects or posting a new object. Args: obj_class: The JSSObject subclass type to search for or create. data: The data parameter performs different operations depending on the type pas...
[ "Return", "a", "subclassed", "JSSObject", "instance", "by", "querying", "for", "existing", "objects", "or", "posting", "a", "new", "object", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L830-L881
train
27,782
jssimporter/python-jss
jss/jamf_software_server.py
JSSObjectFactory.get_list
def get_list(self, obj_class, data, subset): """Get a list of objects as JSSObjectList. Args: obj_class: The JSSObject subclass type to search for. data: None subset: Some objects support a subset for listing; namely Computer, with subset="basic". ...
python
def get_list(self, obj_class, data, subset): """Get a list of objects as JSSObjectList. Args: obj_class: The JSSObject subclass type to search for. data: None subset: Some objects support a subset for listing; namely Computer, with subset="basic". ...
[ "def", "get_list", "(", "self", ",", "obj_class", ",", "data", ",", "subset", ")", ":", "url", "=", "obj_class", ".", "get_url", "(", "data", ")", "if", "obj_class", ".", "can_list", "and", "obj_class", ".", "can_get", ":", "if", "(", "subset", "and", ...
Get a list of objects as JSSObjectList. Args: obj_class: The JSSObject subclass type to search for. data: None subset: Some objects support a subset for listing; namely Computer, with subset="basic". Returns: JSSObjectList
[ "Get", "a", "list", "of", "objects", "as", "JSSObjectList", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L883-L915
train
27,783
jssimporter/python-jss
jss/jamf_software_server.py
JSSObjectFactory.get_individual_object
def get_individual_object(self, obj_class, data, subset): """Return a JSSObject of type obj_class searched for by data. Args: obj_class: The JSSObject subclass type to search for. data: The data parameter performs different operations depending on the type passed...
python
def get_individual_object(self, obj_class, data, subset): """Return a JSSObject of type obj_class searched for by data. Args: obj_class: The JSSObject subclass type to search for. data: The data parameter performs different operations depending on the type passed...
[ "def", "get_individual_object", "(", "self", ",", "obj_class", ",", "data", ",", "subset", ")", ":", "if", "obj_class", ".", "can_get", ":", "url", "=", "obj_class", ".", "get_url", "(", "data", ")", "if", "subset", ":", "if", "not", "\"general\"", "in",...
Return a JSSObject of type obj_class searched for by data. Args: obj_class: The JSSObject subclass type to search for. data: The data parameter performs different operations depending on the type passed. int: Retrieve an object with ID of <data>. ...
[ "Return", "a", "JSSObject", "of", "type", "obj_class", "searched", "for", "by", "data", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L917-L963
train
27,784
jssimporter/python-jss
jss/jamf_software_server.py
JSSObjectFactory._build_jss_object_list
def _build_jss_object_list(self, response, obj_class): """Build a JSSListData object from response.""" response_objects = [item for item in response if item is not None and item.tag != "size"] objects = [ JSSListData(obj_class, ...
python
def _build_jss_object_list(self, response, obj_class): """Build a JSSListData object from response.""" response_objects = [item for item in response if item is not None and item.tag != "size"] objects = [ JSSListData(obj_class, ...
[ "def", "_build_jss_object_list", "(", "self", ",", "response", ",", "obj_class", ")", ":", "response_objects", "=", "[", "item", "for", "item", "in", "response", "if", "item", "is", "not", "None", "and", "item", ".", "tag", "!=", "\"size\"", "]", "objects"...
Build a JSSListData object from response.
[ "Build", "a", "JSSListData", "object", "from", "response", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L988-L997
train
27,785
jssimporter/python-jss
jss/tools.py
convert_response_to_text
def convert_response_to_text(response): """Convert a JSS HTML response to plaintext.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. errorlines = response.text.encode("utf-8").split("\n") error = [] pattern = re.compile(r"<p.*>(.*)</p>") for line in er...
python
def convert_response_to_text(response): """Convert a JSS HTML response to plaintext.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. errorlines = response.text.encode("utf-8").split("\n") error = [] pattern = re.compile(r"<p.*>(.*)</p>") for line in er...
[ "def", "convert_response_to_text", "(", "response", ")", ":", "# Responses are sent as html. Split on the newlines and give us", "# the <p> text back.", "errorlines", "=", "response", ".", "text", ".", "encode", "(", "\"utf-8\"", ")", ".", "split", "(", "\"\\n\"", ")", ...
Convert a JSS HTML response to plaintext.
[ "Convert", "a", "JSS", "HTML", "response", "to", "plaintext", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/tools.py#L66-L78
train
27,786
jssimporter/python-jss
jss/tools.py
error_handler
def error_handler(exception_cls, response): """Handle HTTP errors by formatting into strings.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. error = convert_response_to_text(response) exception = exception_cls("Response Code: %s\tResponse: %s" % ...
python
def error_handler(exception_cls, response): """Handle HTTP errors by formatting into strings.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. error = convert_response_to_text(response) exception = exception_cls("Response Code: %s\tResponse: %s" % ...
[ "def", "error_handler", "(", "exception_cls", ",", "response", ")", ":", "# Responses are sent as html. Split on the newlines and give us", "# the <p> text back.", "error", "=", "convert_response_to_text", "(", "response", ")", "exception", "=", "exception_cls", "(", "\"Respo...
Handle HTTP errors by formatting into strings.
[ "Handle", "HTTP", "errors", "by", "formatting", "into", "strings", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/tools.py#L81-L89
train
27,787
jssimporter/python-jss
jss/tools.py
loop_until_valid_response
def loop_until_valid_response(prompt): """Loop over entering input until it is a valid bool-ish response. Args: prompt: Text presented to user. Returns: The bool value equivalent of what was entered. """ responses = {"Y": True, "YES": True, "TRUE": True, "N": False...
python
def loop_until_valid_response(prompt): """Loop over entering input until it is a valid bool-ish response. Args: prompt: Text presented to user. Returns: The bool value equivalent of what was entered. """ responses = {"Y": True, "YES": True, "TRUE": True, "N": False...
[ "def", "loop_until_valid_response", "(", "prompt", ")", ":", "responses", "=", "{", "\"Y\"", ":", "True", ",", "\"YES\"", ":", "True", ",", "\"TRUE\"", ":", "True", ",", "\"N\"", ":", "False", ",", "\"NO\"", ":", "False", ",", "\"FALSE\"", ":", "False", ...
Loop over entering input until it is a valid bool-ish response. Args: prompt: Text presented to user. Returns: The bool value equivalent of what was entered.
[ "Loop", "over", "entering", "input", "until", "it", "is", "a", "valid", "bool", "-", "ish", "response", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/tools.py#L92-L107
train
27,788
jssimporter/python-jss
jss/tools.py
indent_xml
def indent_xml(elem, level=0, more_sibs=False): """Indent an xml element object to prepare for pretty printing. To avoid changing the contents of the original Element, it is recommended that a copy is made to send to this function. Args: elem: Element to indent. level: Int indent level...
python
def indent_xml(elem, level=0, more_sibs=False): """Indent an xml element object to prepare for pretty printing. To avoid changing the contents of the original Element, it is recommended that a copy is made to send to this function. Args: elem: Element to indent. level: Int indent level...
[ "def", "indent_xml", "(", "elem", ",", "level", "=", "0", ",", "more_sibs", "=", "False", ")", ":", "i", "=", "\"\\n\"", "pad", "=", "\" \"", "if", "level", ":", "i", "+=", "(", "level", "-", "1", ")", "*", "pad", "num_kids", "=", "len", "(", ...
Indent an xml element object to prepare for pretty printing. To avoid changing the contents of the original Element, it is recommended that a copy is made to send to this function. Args: elem: Element to indent. level: Int indent level (default is 0) more_sibs: Bool, whether to ant...
[ "Indent", "an", "xml", "element", "object", "to", "prepare", "for", "pretty", "printing", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/tools.py#L110-L145
train
27,789
jssimporter/python-jss
jss/tools.py
element_repr
def element_repr(self): """Return a string with indented XML data. Used to replace the __repr__ method of Element. """ # deepcopy so we don't mess with the valid XML. pretty_data = copy.deepcopy(self) indent_xml(pretty_data) return ElementTree.tostring(pretty_data).encode("utf-8")
python
def element_repr(self): """Return a string with indented XML data. Used to replace the __repr__ method of Element. """ # deepcopy so we don't mess with the valid XML. pretty_data = copy.deepcopy(self) indent_xml(pretty_data) return ElementTree.tostring(pretty_data).encode("utf-8")
[ "def", "element_repr", "(", "self", ")", ":", "# deepcopy so we don't mess with the valid XML.", "pretty_data", "=", "copy", ".", "deepcopy", "(", "self", ")", "indent_xml", "(", "pretty_data", ")", "return", "ElementTree", ".", "tostring", "(", "pretty_data", ")", ...
Return a string with indented XML data. Used to replace the __repr__ method of Element.
[ "Return", "a", "string", "with", "indented", "XML", "data", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/tools.py#L148-L156
train
27,790
jssimporter/python-jss
jss/jssobjectlist.py
JSSObjectList.sort
def sort(self): """Sort list elements by ID.""" super(JSSObjectList, self).sort(key=lambda k: k.id)
python
def sort(self): """Sort list elements by ID.""" super(JSSObjectList, self).sort(key=lambda k: k.id)
[ "def", "sort", "(", "self", ")", ":", "super", "(", "JSSObjectList", ",", "self", ")", ".", "sort", "(", "key", "=", "lambda", "k", ":", "k", ".", "id", ")" ]
Sort list elements by ID.
[ "Sort", "list", "elements", "by", "ID", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjectlist.py#L143-L145
train
27,791
jssimporter/python-jss
jss/jssobjectlist.py
JSSObjectList.sort_by_name
def sort_by_name(self): """Sort list elements by name.""" super(JSSObjectList, self).sort(key=lambda k: k.name)
python
def sort_by_name(self): """Sort list elements by name.""" super(JSSObjectList, self).sort(key=lambda k: k.name)
[ "def", "sort_by_name", "(", "self", ")", ":", "super", "(", "JSSObjectList", ",", "self", ")", ".", "sort", "(", "key", "=", "lambda", "k", ":", "k", ".", "name", ")" ]
Sort list elements by name.
[ "Sort", "list", "elements", "by", "name", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjectlist.py#L147-L149
train
27,792
jssimporter/python-jss
jss/jssobjectlist.py
JSSObjectList.retrieve_by_id
def retrieve_by_id(self, id_): """Return a JSSObject for the element with ID id_""" items_with_id = [item for item in self if item.id == int(id_)] if len(items_with_id) == 1: return items_with_id[0].retrieve()
python
def retrieve_by_id(self, id_): """Return a JSSObject for the element with ID id_""" items_with_id = [item for item in self if item.id == int(id_)] if len(items_with_id) == 1: return items_with_id[0].retrieve()
[ "def", "retrieve_by_id", "(", "self", ",", "id_", ")", ":", "items_with_id", "=", "[", "item", "for", "item", "in", "self", "if", "item", ".", "id", "==", "int", "(", "id_", ")", "]", "if", "len", "(", "items_with_id", ")", "==", "1", ":", "return"...
Return a JSSObject for the element with ID id_
[ "Return", "a", "JSSObject", "for", "the", "element", "with", "ID", "id_" ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjectlist.py#L155-L159
train
27,793
jssimporter/python-jss
jss/jssobjectlist.py
JSSObjectList.retrieve_all
def retrieve_all(self, subset=None): """Return a list of all JSSListData elements as full JSSObjects. This can take a long time given a large number of objects, and depending on the size of each object. Subsetting to only include the data you need can improve performance. Args:...
python
def retrieve_all(self, subset=None): """Return a list of all JSSListData elements as full JSSObjects. This can take a long time given a large number of objects, and depending on the size of each object. Subsetting to only include the data you need can improve performance. Args:...
[ "def", "retrieve_all", "(", "self", ",", "subset", "=", "None", ")", ":", "# Attempt to speed this procedure up as much as can be done.", "get_object", "=", "self", ".", "factory", ".", "get_object", "obj_class", "=", "self", ".", "obj_class", "full_objects", "=", "...
Return a list of all JSSListData elements as full JSSObjects. This can take a long time given a large number of objects, and depending on the size of each object. Subsetting to only include the data you need can improve performance. Args: subset: For objects which support i...
[ "Return", "a", "list", "of", "all", "JSSListData", "elements", "as", "full", "JSSObjects", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjectlist.py#L161-L180
train
27,794
jssimporter/python-jss
jss/jssobjectlist.py
JSSObjectList.pickle
def pickle(self, path): """Write objects to python pickle. Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully functional JSSObject to disk, and then load it later, without having to retrieve it from the JSS. This me...
python
def pickle(self, path): """Write objects to python pickle. Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully functional JSSObject to disk, and then load it later, without having to retrieve it from the JSS. This me...
[ "def", "pickle", "(", "self", ",", "path", ")", ":", "with", "open", "(", "os", ".", "path", ".", "expanduser", "(", "path", ")", ",", "\"wb\"", ")", "as", "pickle", ":", "cPickle", ".", "Pickler", "(", "pickle", ",", "cPickle", ".", "HIGHEST_PROTOCO...
Write objects to python pickle. Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully functional JSSObject to disk, and then load it later, without having to retrieve it from the JSS. This method will pickle each item as it's ...
[ "Write", "objects", "to", "python", "pickle", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjectlist.py#L182-L200
train
27,795
jssimporter/python-jss
jss/contrib/FoundationPlist.py
readPlistFromString
def readPlistFromString(data): '''Read a plist data from a string. Return the root object.''' try: plistData = buffer(data) except TypeError, err: raise NSPropertyListSerializationException(err) dataObject, dummy_plistFormat, error = ( NSPropertyListSerialization. propert...
python
def readPlistFromString(data): '''Read a plist data from a string. Return the root object.''' try: plistData = buffer(data) except TypeError, err: raise NSPropertyListSerializationException(err) dataObject, dummy_plistFormat, error = ( NSPropertyListSerialization. propert...
[ "def", "readPlistFromString", "(", "data", ")", ":", "try", ":", "plistData", "=", "buffer", "(", "data", ")", "except", "TypeError", ",", "err", ":", "raise", "NSPropertyListSerializationException", "(", "err", ")", "dataObject", ",", "dummy_plistFormat", ",", ...
Read a plist data from a string. Return the root object.
[ "Read", "a", "plist", "data", "from", "a", "string", ".", "Return", "the", "root", "object", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/contrib/FoundationPlist.py#L90-L107
train
27,796
jssimporter/python-jss
jss/contrib/FoundationPlist.py
writePlist
def writePlist(dataObject, filepath): ''' Write 'rootObject' as a plist to filepath. ''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( dataObject, NSPropertyListXMLFormat_v1_0, None)) if plistData is None: if erro...
python
def writePlist(dataObject, filepath): ''' Write 'rootObject' as a plist to filepath. ''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( dataObject, NSPropertyListXMLFormat_v1_0, None)) if plistData is None: if erro...
[ "def", "writePlist", "(", "dataObject", ",", "filepath", ")", ":", "plistData", ",", "error", "=", "(", "NSPropertyListSerialization", ".", "dataFromPropertyList_format_errorDescription_", "(", "dataObject", ",", "NSPropertyListXMLFormat_v1_0", ",", "None", ")", ")", ...
Write 'rootObject' as a plist to filepath.
[ "Write", "rootObject", "as", "a", "plist", "to", "filepath", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/contrib/FoundationPlist.py#L110-L129
train
27,797
jssimporter/python-jss
jss/contrib/FoundationPlist.py
writePlistToString
def writePlistToString(rootObject): '''Return 'rootObject' as a plist-formatted string.''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( rootObject, NSPropertyListXMLFormat_v1_0, None)) if plistData is None: if error: ...
python
def writePlistToString(rootObject): '''Return 'rootObject' as a plist-formatted string.''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( rootObject, NSPropertyListXMLFormat_v1_0, None)) if plistData is None: if error: ...
[ "def", "writePlistToString", "(", "rootObject", ")", ":", "plistData", ",", "error", "=", "(", "NSPropertyListSerialization", ".", "dataFromPropertyList_format_errorDescription_", "(", "rootObject", ",", "NSPropertyListXMLFormat_v1_0", ",", "None", ")", ")", "if", "plis...
Return 'rootObject' as a plist-formatted string.
[ "Return", "rootObject", "as", "a", "plist", "-", "formatted", "string", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/contrib/FoundationPlist.py#L132-L145
train
27,798
jssimporter/python-jss
jss/jssobject.py
JSSObject._new
def _new(self, name, **kwargs): """Create a new JSSObject with name and "keys". Generate a default XML template for this object, based on the class attribute "keys". Args: name: String name of the object to use as the object's name property. kwar...
python
def _new(self, name, **kwargs): """Create a new JSSObject with name and "keys". Generate a default XML template for this object, based on the class attribute "keys". Args: name: String name of the object to use as the object's name property. kwar...
[ "def", "_new", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# Name is required, so set it outside of the helper func.", "if", "self", ".", "_name_path", ":", "parent", "=", "self", "for", "path_element", "in", "self", ".", "_name_path", ".", "...
Create a new JSSObject with name and "keys". Generate a default XML template for this object, based on the class attribute "keys". Args: name: String name of the object to use as the object's name property. kwargs: Accepted keyword args c...
[ "Create", "a", "new", "JSSObject", "with", "name", "and", "keys", "." ]
b95185d74e0c0531b0b563f280d4129e21d5fe5d
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobject.py#L157-L188
train
27,799