partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Modules.status_server
Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, a warning will be displayed to the user, but...
src/binwalk/core/module.py
def status_server(self, port): ''' Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, ...
def status_server(self, port): ''' Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, ...
[ "Starts", "the", "progress", "bar", "TCP", "service", "on", "the", "specified", "port", ".", "This", "service", "will", "only", "be", "started", "once", "per", "instance", "regardless", "of", "the", "number", "of", "times", "this", "method", "is", "invoked",...
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L979-L993
[ "def", "status_server", "(", "self", ",", "port", ")", ":", "if", "self", ".", "status_server_started", "==", "False", ":", "self", ".", "status_server_started", "=", "True", "try", ":", "self", ".", "status_service", "=", "binwalk", ".", "core", ".", "sta...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
PFSCommon._make_short
Returns a 2 byte integer.
src/binwalk/plugins/unpfs.py
def _make_short(self, data, endianness): """Returns a 2 byte integer.""" data = binwalk.core.compat.str2bytes(data) return struct.unpack('%sH' % endianness, data)[0]
def _make_short(self, data, endianness): """Returns a 2 byte integer.""" data = binwalk.core.compat.str2bytes(data) return struct.unpack('%sH' % endianness, data)[0]
[ "Returns", "a", "2", "byte", "integer", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L10-L13
[ "def", "_make_short", "(", "self", ",", "data", ",", "endianness", ")", ":", "data", "=", "binwalk", ".", "core", ".", "compat", ".", "str2bytes", "(", "data", ")", "return", "struct", ".", "unpack", "(", "'%sH'", "%", "endianness", ",", "data", ")", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
PFS._get_fname_len
Returns the number of bytes designated for the filename.
src/binwalk/plugins/unpfs.py
def _get_fname_len(self, bufflen=128): """Returns the number of bytes designated for the filename.""" buff = self.meta.peek(bufflen) strlen = buff.find('\0') for i, b in enumerate(buff[strlen:]): if b != '\0': return strlen+i return bufflen
def _get_fname_len(self, bufflen=128): """Returns the number of bytes designated for the filename.""" buff = self.meta.peek(bufflen) strlen = buff.find('\0') for i, b in enumerate(buff[strlen:]): if b != '\0': return strlen+i return bufflen
[ "Returns", "the", "number", "of", "bytes", "designated", "for", "the", "filename", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L33-L40
[ "def", "_get_fname_len", "(", "self", ",", "bufflen", "=", "128", ")", ":", "buff", "=", "self", ".", "meta", ".", "peek", "(", "bufflen", ")", "strlen", "=", "buff", ".", "find", "(", "'\\0'", ")", "for", "i", ",", "b", "in", "enumerate", "(", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
PFS._get_node
Reads a chunk of meta data from file and returns a PFSNode.
src/binwalk/plugins/unpfs.py
def _get_node(self): """Reads a chunk of meta data from file and returns a PFSNode.""" data = self.meta.read(self.node_size) return PFSNode(data, self.endianness)
def _get_node(self): """Reads a chunk of meta data from file and returns a PFSNode.""" data = self.meta.read(self.node_size) return PFSNode(data, self.endianness)
[ "Reads", "a", "chunk", "of", "meta", "data", "from", "file", "and", "returns", "a", "PFSNode", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L42-L45
[ "def", "_get_node", "(", "self", ")", ":", "data", "=", "self", ".", "meta", ".", "read", "(", "self", ".", "node_size", ")", "return", "PFSNode", "(", "data", ",", "self", ".", "endianness", ")" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
PFS.entries
Returns file meta-data entries one by one.
src/binwalk/plugins/unpfs.py
def entries(self): """Returns file meta-data entries one by one.""" self.meta.seek(self.file_list_start) for i in range(0, self.num_files): yield self._get_node()
def entries(self): """Returns file meta-data entries one by one.""" self.meta.seek(self.file_list_start) for i in range(0, self.num_files): yield self._get_node()
[ "Returns", "file", "meta", "-", "data", "entries", "one", "by", "one", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L51-L55
[ "def", "entries", "(", "self", ")", ":", "self", ".", "meta", ".", "seek", "(", "self", ".", "file_list_start", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "num_files", ")", ":", "yield", "self", ".", "_get_node", "(", ")" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
PFSNode._decode_fname
Extracts the actual string from the available bytes.
src/binwalk/plugins/unpfs.py
def _decode_fname(self): """Extracts the actual string from the available bytes.""" self.fname = self.fname[:self.fname.find('\0')] self.fname = self.fname.replace('\\', '/')
def _decode_fname(self): """Extracts the actual string from the available bytes.""" self.fname = self.fname[:self.fname.find('\0')] self.fname = self.fname.replace('\\', '/')
[ "Extracts", "the", "actual", "string", "from", "the", "available", "bytes", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L73-L76
[ "def", "_decode_fname", "(", "self", ")", ":", "self", ".", "fname", "=", "self", ".", "fname", "[", ":", "self", ".", "fname", ".", "find", "(", "'\\0'", ")", "]", "self", ".", "fname", "=", "self", ".", "fname", ".", "replace", "(", "'\\\\'", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Signature._generate_regex
Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression.
src/binwalk/core/magic.py
def _generate_regex(self, line): ''' Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression. ''' restr = "" #...
def _generate_regex(self, line): ''' Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression. ''' restr = "" #...
[ "Generates", "a", "regular", "expression", "from", "the", "magic", "bytes", "of", "a", "signature", ".", "The", "regex", "is", "used", "by", "Magic", ".", "_analyze", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L302-L375
[ "def", "_generate_regex", "(", "self", ",", "line", ")", ":", "restr", "=", "\"\"", "# Strings and single byte signatures are taken at face value;", "# multi-byte integer values are turned into regex strings based", "# on their data type size and endianness.", "if", "line", ".", "t...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic._filtered
Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed.
src/binwalk/core/magic.py
def _filtered(self, text): ''' Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed. ''' filtere...
def _filtered(self, text): ''' Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed. ''' filtere...
[ "Tests", "if", "a", "string", "should", "be", "filtered", "out", "or", "not", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L436-L471
[ "def", "_filtered", "(", "self", ",", "text", ")", ":", "filtered", "=", "None", "# Text is converted to lower case first, partially for historical", "# purposes, but also because it simplifies writing filter rules", "# (e.g., don't have to worry about case sensitivity).", "text", "=",...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic._do_math
Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is the result of the evaluated expression.
src/binwalk/core/magic.py
def _do_math(self, offset, expression): ''' Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is th...
def _do_math(self, offset, expression): ''' Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is th...
[ "Parses", "and", "evaluates", "complex", "expressions", "e", ".", "g", ".", "(", "4", ".", "l", "+", "12", ")", "(", "6", "*", "32", ")", "etc", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L473-L546
[ "def", "_do_math", "(", "self", ",", "offset", ",", "expression", ")", ":", "# Does the expression contain an offset (e.g., \"(4.l+12)\")?", "if", "'.'", "in", "expression", "and", "'('", "in", "expression", ":", "replacements", "=", "{", "}", "for", "period", "in...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic._analyze
Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the data.
src/binwalk/core/magic.py
def _analyze(self, signature, offset): ''' Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the...
def _analyze(self, signature, offset): ''' Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the...
[ "Analyzes", "self", ".", "data", "for", "the", "specified", "signature", "data", "at", "the", "specified", "offset", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L548-L771
[ "def", "_analyze", "(", "self", ",", "signature", ",", "offset", ")", ":", "description", "=", "[", "]", "max_line_level", "=", "0", "previous_line_end", "=", "0", "tags", "=", "{", "'id'", ":", "signature", ".", "id", ",", "'offset'", ":", "offset", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic.scan
Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects.
src/binwalk/core/magic.py
def scan(self, data, dlen=None): ''' Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects. ''' results = [] ma...
def scan(self, data, dlen=None): ''' Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects. ''' results = [] ma...
[ "Scan", "a", "data", "block", "for", "matching", "signatures", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L783-L841
[ "def", "scan", "(", "self", ",", "data", ",", "dlen", "=", "None", ")", ":", "results", "=", "[", "]", "matched_offsets", "=", "set", "(", ")", "# Since data can potentially be quite a large string, make it available to other", "# methods via a class attribute so that it ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic.load
Load signatures from a file. @fname - Path to signature file. Returns None.
src/binwalk/core/magic.py
def load(self, fname): ''' Load signatures from a file. @fname - Path to signature file. Returns None. ''' # Magic files must be ASCII, else encoding issues can arise. fp = open(fname, "r") lines = fp.readlines() self.parse(lines) fp.clos...
def load(self, fname): ''' Load signatures from a file. @fname - Path to signature file. Returns None. ''' # Magic files must be ASCII, else encoding issues can arise. fp = open(fname, "r") lines = fp.readlines() self.parse(lines) fp.clos...
[ "Load", "signatures", "from", "a", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L843-L855
[ "def", "load", "(", "self", ",", "fname", ")", ":", "# Magic files must be ASCII, else encoding issues can arise.", "fp", "=", "open", "(", "fname", ",", "\"r\"", ")", "lines", "=", "fp", ".", "readlines", "(", ")", "self", ".", "parse", "(", "lines", ")", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Magic.parse
Parse signature file lines. @lines - A list of lines from a signature file. Returns None.
src/binwalk/core/magic.py
def parse(self, lines): ''' Parse signature file lines. @lines - A list of lines from a signature file. Returns None. ''' signature = None for line in lines: # Split at the first comment delimiter (if any) and strip the # result ...
def parse(self, lines): ''' Parse signature file lines. @lines - A list of lines from a signature file. Returns None. ''' signature = None for line in lines: # Split at the first comment delimiter (if any) and strip the # result ...
[ "Parse", "signature", "file", "lines", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L857-L904
[ "def", "parse", "(", "self", ",", "lines", ")", ":", "signature", "=", "None", "for", "line", "in", "lines", ":", "# Split at the first comment delimiter (if any) and strip the", "# result", "line", "=", "line", ".", "split", "(", "'#'", ")", "[", "0", "]", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
General._set_verbosity
Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set.
src/binwalk/modules/general.py
def _set_verbosity(self): ''' Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set. ''' # If more than one target file was specified, enable verbose mode; else, there is # nothing in some outputs to indicat...
def _set_verbosity(self): ''' Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set. ''' # If more than one target file was specified, enable verbose mode; else, there is # nothing in some outputs to indicat...
[ "Sets", "the", "appropriate", "verbosity", ".", "Must", "be", "called", "after", "self", ".", "_test_target_files", "so", "that", "self", ".", "target_files", "is", "properly", "set", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L159-L168
[ "def", "_set_verbosity", "(", "self", ")", ":", "# If more than one target file was specified, enable verbose mode; else, there is", "# nothing in some outputs to indicate which scan corresponds to which", "# file.", "if", "len", "(", "self", ".", "target_files", ")", ">", "1", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
General.file_name_filter
Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be scanned, False if not.
src/binwalk/modules/general.py
def file_name_filter(self, fp): ''' Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be sca...
def file_name_filter(self, fp): ''' Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be sca...
[ "Checks", "to", "see", "if", "a", "file", "should", "be", "scanned", "based", "on", "file", "name", "include", "/", "exclude", "filters", ".", "Most", "useful", "for", "matryoshka", "scans", "where", "only", "certian", "files", "are", "desired", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L170-L184
[ "def", "file_name_filter", "(", "self", ",", "fp", ")", ":", "if", "self", ".", "file_name_include_regex", "and", "not", "self", ".", "file_name_include_regex", ".", "search", "(", "fp", ".", "name", ")", ":", "return", "False", "if", "self", ".", "file_na...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
General.open_file
Opens the specified file with all pertinent configuration settings.
src/binwalk/modules/general.py
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None): ''' Opens the specified file with all pertinent configuration settings. ''' if length is None: length = self.length if offset is None: offset = self.offset if s...
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None): ''' Opens the specified file with all pertinent configuration settings. ''' if length is None: length = self.length if offset is None: offset = self.offset if s...
[ "Opens", "the", "specified", "file", "with", "all", "pertinent", "configuration", "settings", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L186-L203
[ "def", "open_file", "(", "self", ",", "fname", ",", "length", "=", "None", ",", "offset", "=", "None", ",", "swap", "=", "None", ",", "block", "=", "None", ",", "peek", "=", "None", ")", ":", "if", "length", "is", "None", ":", "length", "=", "sel...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
General._open_target_files
Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list.
src/binwalk/modules/general.py
def _open_target_files(self): ''' Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list. ''' # Validate the target files listed in target_files for tfile in self.files: # Ignore directories. ...
def _open_target_files(self): ''' Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list. ''' # Validate the target files listed in target_files for tfile in self.files: # Ignore directories. ...
[ "Checks", "if", "the", "target", "files", "can", "be", "opened", ".", "Any", "files", "that", "cannot", "be", "opened", "are", "removed", "from", "the", "self", ".", "target_files", "list", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L205-L222
[ "def", "_open_target_files", "(", "self", ")", ":", "# Validate the target files listed in target_files", "for", "tfile", "in", "self", ".", "files", ":", "# Ignore directories.", "if", "not", "self", ".", "subclass", "==", "io", ".", "FileIO", "or", "not", "os", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Signature.validate
Called automatically by self.result.
src/binwalk/modules/signature.py
def validate(self, r): ''' Called automatically by self.result. ''' if self.show_invalid: r.valid = True elif r.valid: if not r.description: r.valid = False if r.size and (r.size + r.offset) > r.file.size: r.val...
def validate(self, r): ''' Called automatically by self.result. ''' if self.show_invalid: r.valid = True elif r.valid: if not r.description: r.valid = False if r.size and (r.size + r.offset) > r.file.size: r.val...
[ "Called", "automatically", "by", "self", ".", "result", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/signature.py#L107-L134
[ "def", "validate", "(", "self", ",", "r", ")", ":", "if", "self", ".", "show_invalid", ":", "r", ".", "valid", "=", "True", "elif", "r", ".", "valid", ":", "if", "not", "r", ".", "description", ":", "r", ".", "valid", "=", "False", "if", "r", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Plugins.list_plugins
Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'module pydoc string'}, ...
src/binwalk/core/plugin.py
def list_plugins(self): ''' Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'modul...
def list_plugins(self): ''' Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'modul...
[ "Obtain", "a", "list", "of", "all", "user", "and", "system", "plugin", "modules", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/plugin.py#L132-L206
[ "def", "list_plugins", "(", "self", ")", ":", "plugins", "=", "{", "'user'", ":", "{", "'modules'", ":", "[", "]", ",", "'descriptions'", ":", "{", "}", ",", "'enabled'", ":", "{", "}", ",", "'path'", ":", "None", ",", "}", ",", "'system'", ":", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Entropy.shannon
Performs a Shannon entropy analysis on a given block of data.
src/binwalk/modules/entropy.py
def shannon(self, data): ''' Performs a Shannon entropy analysis on a given block of data. ''' entropy = 0 if data: length = len(data) seen = dict(((chr(x), 0) for x in range(0, 256))) for byte in data: seen[byte] += 1 ...
def shannon(self, data): ''' Performs a Shannon entropy analysis on a given block of data. ''' entropy = 0 if data: length = len(data) seen = dict(((chr(x), 0) for x in range(0, 256))) for byte in data: seen[byte] += 1 ...
[ "Performs", "a", "Shannon", "entropy", "analysis", "on", "a", "given", "block", "of", "data", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/entropy.py#L221-L239
[ "def", "shannon", "(", "self", ",", "data", ")", ":", "entropy", "=", "0", "if", "data", ":", "length", "=", "len", "(", "data", ")", "seen", "=", "dict", "(", "(", "(", "chr", "(", "x", ")", ",", "0", ")", "for", "x", "in", "range", "(", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Entropy.gzip
Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate.
src/binwalk/modules/entropy.py
def gzip(self, data, truncate=True): ''' Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate. ''' # Entropy is a simple ratio of: <zlib compressed size> / <original # size> e = float(f...
def gzip(self, data, truncate=True): ''' Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate. ''' # Entropy is a simple ratio of: <zlib compressed size> / <original # size> e = float(f...
[ "Performs", "an", "entropy", "analysis", "based", "on", "zlib", "compression", "ratio", ".", "This", "is", "faster", "than", "the", "shannon", "entropy", "analysis", "but", "not", "as", "accurate", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/entropy.py#L241-L253
[ "def", "gzip", "(", "self", ",", "data", ",", "truncate", "=", "True", ")", ":", "# Entropy is a simple ratio of: <zlib compressed size> / <original", "# size>", "e", "=", "float", "(", "float", "(", "len", "(", "zlib", ".", "compress", "(", "str2bytes", "(", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
TarPlugin.nts
Convert a null-terminated string field to a python string.
src/binwalk/plugins/tar.py
def nts(self, s): """ Convert a null-terminated string field to a python string. """ # Use the string up to the first null char. p = s.find("\0") if p == -1: return s return s[:p]
def nts(self, s): """ Convert a null-terminated string field to a python string. """ # Use the string up to the first null char. p = s.find("\0") if p == -1: return s return s[:p]
[ "Convert", "a", "null", "-", "terminated", "string", "field", "to", "a", "python", "string", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/tar.py#L13-L21
[ "def", "nts", "(", "self", ",", "s", ")", ":", "# Use the string up to the first null char.", "p", "=", "s", ".", "find", "(", "\"\\0\"", ")", "if", "p", "==", "-", "1", ":", "return", "s", "return", "s", "[", ":", "p", "]" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
TarPlugin.nti
Convert a number field to a python number.
src/binwalk/plugins/tar.py
def nti(self, s): """ Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0x80): try: n = int(self.nts(s) or "0", 8) except ValueError: ...
def nti(self, s): """ Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0x80): try: n = int(self.nts(s) or "0", 8) except ValueError: ...
[ "Convert", "a", "number", "field", "to", "a", "python", "number", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/tar.py#L23-L39
[ "def", "nti", "(", "self", ",", "s", ")", ":", "# There are two possible encodings for a number field, see", "# itn() below.", "if", "s", "[", "0", "]", "!=", "chr", "(", "0x80", ")", ":", "try", ":", "n", "=", "int", "(", "self", ".", "nts", "(", "s", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
debug
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
src/binwalk/core/common.py
def debug(msg): ''' Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. ''' if DEBUG: sys.stderr.write("DEBUG: " + msg + "\n") sys.stderr.flush()
def debug(msg): ''' Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. ''' if DEBUG: sys.stderr.write("DEBUG: " + msg + "\n") sys.stderr.flush()
[ "Displays", "debug", "messages", "to", "stderr", "only", "if", "the", "Python", "interpreter", "was", "invoked", "with", "the", "-", "O", "flag", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L30-L36
[ "def", "debug", "(", "msg", ")", ":", "if", "DEBUG", ":", "sys", ".", "stderr", ".", "write", "(", "\"DEBUG: \"", "+", "msg", "+", "\"\\n\"", ")", "sys", ".", "stderr", ".", "flush", "(", ")" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
file_md5
Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string.
src/binwalk/core/common.py
def file_md5(file_name): ''' Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string. ''' md5 = hashlib.md5() with open(file_name, 'rb') as f: for chunk in iter(lambda: f.read(128 * md5.block_size), b''): md5.update(c...
def file_md5(file_name): ''' Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string. ''' md5 = hashlib.md5() with open(file_name, 'rb') as f: for chunk in iter(lambda: f.read(128 * md5.block_size), b''): md5.update(c...
[ "Generate", "an", "MD5", "hash", "of", "the", "specified", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L71-L85
[ "def", "file_md5", "(", "file_name", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "file_name", ",", "'rb'", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(", "128", "*", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
file_size
Obtains the size of a given file. @filename - Path to the file. Returns the size of the file.
src/binwalk/core/common.py
def file_size(filename): ''' Obtains the size of a given file. @filename - Path to the file. Returns the size of the file. ''' # Using open/lseek works on both regular files and block devices fd = os.open(filename, os.O_RDONLY) try: return os.lseek(fd, 0, os.SEEK_END) excep...
def file_size(filename): ''' Obtains the size of a given file. @filename - Path to the file. Returns the size of the file. ''' # Using open/lseek works on both regular files and block devices fd = os.open(filename, os.O_RDONLY) try: return os.lseek(fd, 0, os.SEEK_END) excep...
[ "Obtains", "the", "size", "of", "a", "given", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L88-L106
[ "def", "file_size", "(", "filename", ")", ":", "# Using open/lseek works on both regular files and block devices", "fd", "=", "os", ".", "open", "(", "filename", ",", "os", ".", "O_RDONLY", ")", "try", ":", "return", "os", ".", "lseek", "(", "fd", ",", "0", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
get_quoted_strings
Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present.
src/binwalk/core/common.py
def get_quoted_strings(quoted_string): ''' Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present. ''' try: # This regex grabs ...
def get_quoted_strings(quoted_string): ''' Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present. ''' try: # This regex grabs ...
[ "Returns", "a", "string", "comprised", "of", "all", "data", "in", "between", "double", "quotes", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L126-L146
[ "def", "get_quoted_strings", "(", "quoted_string", ")", ":", "try", ":", "# This regex grabs all quoted data from string.", "# Note that this gets everything in between the first and last double quote.", "# This is intentional, as printed (and quoted) strings from a target file may contain", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
unique_file_name
Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string.
src/binwalk/core/common.py
def unique_file_name(base_name, extension=''): ''' Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string. ''' idcount = 0 if...
def unique_file_name(base_name, extension=''): ''' Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string. ''' idcount = 0 if...
[ "Creates", "a", "unique", "file", "name", "based", "on", "the", "specified", "base", "name", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L149-L169
[ "def", "unique_file_name", "(", "base_name", ",", "extension", "=", "''", ")", ":", "idcount", "=", "0", "if", "extension", "and", "not", "extension", ".", "startswith", "(", "'.'", ")", ":", "extension", "=", "'.%s'", "%", "extension", "fname", "=", "ba...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
strings
A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename.
src/binwalk/core/common.py
def strings(filename, minimum=4): ''' A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename. ''' result = "" with BlockFile(filename) as...
def strings(filename, minimum=4): ''' A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename. ''' result = "" with BlockFile(filename) as...
[ "A", "strings", "generator", "similar", "to", "the", "Unix", "strings", "utility", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L172-L197
[ "def", "strings", "(", "filename", ",", "minimum", "=", "4", ")", ":", "result", "=", "\"\"", "with", "BlockFile", "(", "filename", ")", "as", "f", ":", "while", "True", ":", "(", "data", ",", "dlen", ")", "=", "f", ".", "read_block", "(", ")", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
bytes2str
For cross compatibility between Python 2 and Python 3 strings.
src/binwalk/core/compat.py
def bytes2str(bs): ''' For cross compatibility between Python 2 and Python 3 strings. ''' if isinstance(bs, type(b'')) and PY_MAJOR_VERSION > 2: return bs.decode('latin1') else: return bs
def bytes2str(bs): ''' For cross compatibility between Python 2 and Python 3 strings. ''' if isinstance(bs, type(b'')) and PY_MAJOR_VERSION > 2: return bs.decode('latin1') else: return bs
[ "For", "cross", "compatibility", "between", "Python", "2", "and", "Python", "3", "strings", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/compat.py#L60-L67
[ "def", "bytes2str", "(", "bs", ")", ":", "if", "isinstance", "(", "bs", ",", "type", "(", "b''", ")", ")", "and", "PY_MAJOR_VERSION", ">", "2", ":", "return", "bs", ".", "decode", "(", "'latin1'", ")", "else", ":", "return", "bs" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.create_rule
Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex - If rule string is not specified, this is the regular expression string to use. @extension - If rule string is n...
src/binwalk/modules/extractor.py
def create_rule(self, txtrule=None, regex=None, extension=None, cmd=None, codes=[0, None], recurse=True): ''' Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex...
def create_rule(self, txtrule=None, regex=None, extension=None, cmd=None, codes=[0, None], recurse=True): ''' Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex...
[ "Adds", "a", "set", "of", "rules", "to", "the", "extraction", "rule", "list", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L301-L362
[ "def", "create_rule", "(", "self", ",", "txtrule", "=", "None", ",", "regex", "=", "None", ",", "extension", "=", "None", ",", "cmd", "=", "None", ",", "codes", "=", "[", "0", ",", "None", "]", ",", "recurse", "=", "True", ")", ":", "rules", "=",...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.remove_rules
Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed.
src/binwalk/modules/extractor.py
def remove_rules(self, description): ''' Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed. ''' rm = [] description = description.lower() for i in range(0, len(self....
def remove_rules(self, description): ''' Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed. ''' rm = [] description = description.lower() for i in range(0, len(self....
[ "Remove", "all", "rules", "that", "match", "a", "specified", "description", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L364-L382
[ "def", "remove_rules", "(", "self", ",", "description", ")", ":", "rm", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "extract_rules", ")", ")", ":", "if...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.edit_rules
Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Returns the number of rules modified.
src/binwalk/modules/extractor.py
def edit_rules(self, description, key, value): ''' Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Retur...
def edit_rules(self, description, key, value): ''' Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Retur...
[ "Edit", "all", "rules", "that", "match", "a", "specified", "description", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L384-L403
[ "def", "edit_rules", "(", "self", ",", "description", ",", "key", ",", "value", ")", ":", "count", "=", "0", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "extract_rules"...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.get_rules
Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules are returned.
src/binwalk/modules/extractor.py
def get_rules(self, description=None): ''' Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules...
def get_rules(self, description=None): ''' Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules...
[ "Returns", "a", "list", "of", "extraction", "rules", "that", "match", "a", "given", "description", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L413-L431
[ "def", "get_rules", "(", "self", ",", "description", "=", "None", ")", ":", "if", "description", ":", "rules", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.load_from_file
Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None.
src/binwalk/modules/extractor.py
def load_from_file(self, fname): ''' Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None. ''' try: # Process each line from the extract file, ignoring comments with open(fname, 'r') as f: ...
def load_from_file(self, fname): ''' Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None. ''' try: # Process each line from the extract file, ignoring comments with open(fname, 'r') as f: ...
[ "Loads", "extraction", "rules", "from", "the", "specified", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L433-L449
[ "def", "load_from_file", "(", "self", ",", "fname", ")", ":", "try", ":", "# Process each line from the extract file, ignoring comments", "with", "open", "(", "fname", ",", "'r'", ")", "as", "f", ":", "for", "rule", "in", "f", ".", "readlines", "(", ")", ":"...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.load_defaults
Loads default extraction rules from the user and system extract.conf files. Returns None.
src/binwalk/modules/extractor.py
def load_defaults(self): ''' Loads default extraction rules from the user and system extract.conf files. Returns None. ''' # Load the user extract file first to ensure its rules take precedence. extract_files = [ self.config.settings.user.extract, ...
def load_defaults(self): ''' Loads default extraction rules from the user and system extract.conf files. Returns None. ''' # Load the user extract file first to ensure its rules take precedence. extract_files = [ self.config.settings.user.extract, ...
[ "Loads", "default", "extraction", "rules", "from", "the", "user", "and", "system", "extract", ".", "conf", "files", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L451-L471
[ "def", "load_defaults", "(", "self", ")", ":", "# Load the user extract file first to ensure its rules take precedence.", "extract_files", "=", "[", "self", ".", "config", ".", "settings", ".", "user", ".", "extract", ",", "self", ".", "config", ".", "settings", "."...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.build_output_directory
Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None.
src/binwalk/modules/extractor.py
def build_output_directory(self, path): ''' Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None. ''' # If we have not already created an output directory for this target # file, create one now...
def build_output_directory(self, path): ''' Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None. ''' # If we have not already created an output directory for this target # file, create one now...
[ "Set", "the", "output", "directory", "for", "extracted", "files", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L490-L536
[ "def", "build_output_directory", "(", "self", ",", "path", ")", ":", "# If we have not already created an output directory for this target", "# file, create one now", "if", "not", "has_key", "(", "self", ".", "extraction_directories", ",", "path", ")", ":", "basedir", "="...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.extract
Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Description of the embedded file to extract, as returned by libmagic. @file_name -...
src/binwalk/modules/extractor.py
def extract(self, offset, description, file_name, size, name=None): ''' Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Desc...
def extract(self, offset, description, file_name, size, name=None): ''' Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Desc...
[ "Extract", "an", "embedded", "file", "from", "the", "target", "file", "if", "it", "matches", "an", "extract", "rule", ".", "Called", "automatically", "by", "Binwalk", ".", "scan", "()", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L553-L676
[ "def", "extract", "(", "self", ",", "offset", ",", "description", ",", "file_name", ",", "size", ",", "name", "=", "None", ")", ":", "fname", "=", "''", "rule", "=", "None", "recurse", "=", "False", "command_line", "=", "''", "original_dir", "=", "os",...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor._entry_offset
Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. Returns the offset, if a matching description is found. Retu...
src/binwalk/modules/extractor.py
def _entry_offset(self, index, entries, description): ''' Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. ...
def _entry_offset(self, index, entries, description): ''' Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. ...
[ "Gets", "the", "offset", "of", "the", "first", "entry", "that", "matches", "the", "description", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L687-L704
[ "def", "_entry_offset", "(", "self", ",", "index", ",", "entries", ",", "description", ")", ":", "description", "=", "description", ".", "lower", "(", ")", "for", "(", "offset", ",", "infos", ")", "in", "entries", "[", "index", ":", "]", ":", "for", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.match
Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no match is found.
src/binwalk/modules/extractor.py
def match(self, description): ''' Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no mat...
def match(self, description): ''' Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no mat...
[ "Check", "to", "see", "if", "the", "provided", "description", "string", "matches", "an", "extract", "rule", ".", "Called", "internally", "by", "self", ".", "extract", "()", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L706-L732
[ "def", "match", "(", "self", ",", "description", ")", ":", "rules", "=", "[", "]", "ordered_rules", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "rule", "in", "self", ".", "extract_rules", ":", "if", "rule", "[", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor._parse_rule
Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>].
src/binwalk/modules/extractor.py
def _parse_rule(self, rule): ''' Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>]. ''' v...
def _parse_rule(self, rule): ''' Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>]. ''' v...
[ "Parses", "an", "extraction", "rule", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L734-L756
[ "def", "_parse_rule", "(", "self", ",", "rule", ")", ":", "values", "=", "rule", ".", "strip", "(", ")", ".", "split", "(", "self", ".", "RULE_DELIM", ",", "4", ")", "if", "len", "(", "values", ")", ">=", "4", ":", "codes", "=", "values", "[", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor._dd
Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Number of bytes to extract. @extension - The file exension to assign to the extracte...
src/binwalk/modules/extractor.py
def _dd(self, file_name, offset, size, extension, output_file_name=None): ''' Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Numbe...
def _dd(self, file_name, offset, size, extension, output_file_name=None): ''' Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Numbe...
[ "Extracts", "a", "file", "embedded", "inside", "the", "target", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L758-L835
[ "def", "_dd", "(", "self", ",", "file_name", ",", "offset", ",", "size", ",", "extension", ",", "output_file_name", "=", "None", ")", ":", "total_size", "=", "0", "# Default extracted file name is <displayed hex offset>.<extension>", "default_bname", "=", "\"%X\"", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Extractor.execute
Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None if the external extraction utility could not be found.
src/binwalk/modules/extractor.py
def execute(self, cmd, fname, codes=[0, None]): ''' Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None ...
def execute(self, cmd, fname, codes=[0, None]): ''' Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None ...
[ "Execute", "a", "command", "against", "the", "specified", "file", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L837-L912
[ "def", "execute", "(", "self", ",", "cmd", ",", "fname", ",", "codes", "=", "[", "0", ",", "None", "]", ")", ":", "tmp", "=", "None", "rval", "=", "0", "retval", "=", "True", "command_list", "=", "[", "]", "binwalk", ".", "core", ".", "common", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Display._fix_unicode_list
Convenience wrapper for self.log which is passed a list of format arguments.
src/binwalk/core/display.py
def _fix_unicode_list(self, columns): ''' Convenience wrapper for self.log which is passed a list of format arguments. ''' if type(columns) in [list, tuple]: for i in range(0, len(columns)): try: columns[i] = self._fix_unicode(columns[i]) ...
def _fix_unicode_list(self, columns): ''' Convenience wrapper for self.log which is passed a list of format arguments. ''' if type(columns) in [list, tuple]: for i in range(0, len(columns)): try: columns[i] = self._fix_unicode(columns[i]) ...
[ "Convenience", "wrapper", "for", "self", ".", "log", "which", "is", "passed", "a", "list", "of", "format", "arguments", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L51-L61
[ "def", "_fix_unicode_list", "(", "self", ",", "columns", ")", ":", "if", "type", "(", "columns", ")", "in", "[", "list", ",", "tuple", "]", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "columns", ")", ")", ":", "try", ":", "columns"...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Display._append_to_data_parts
Intelligently appends data to self.string_parts. For use by self._format.
src/binwalk/core/display.py
def _append_to_data_parts(self, data, start, end): ''' Intelligently appends data to self.string_parts. For use by self._format. ''' try: while data[start] == ' ': start += 1 if start == end: end = len(data[start:]) ...
def _append_to_data_parts(self, data, start, end): ''' Intelligently appends data to self.string_parts. For use by self._format. ''' try: while data[start] == ' ': start += 1 if start == end: end = len(data[start:]) ...
[ "Intelligently", "appends", "data", "to", "self", ".", "string_parts", ".", "For", "use", "by", "self", ".", "_format", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L155-L178
[ "def", "_append_to_data_parts", "(", "self", ",", "data", ",", "start", ",", "end", ")", ":", "try", ":", "while", "data", "[", "start", "]", "==", "' '", ":", "start", "+=", "1", "if", "start", "==", "end", ":", "end", "=", "len", "(", "data", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Display._format_line
Formats a line of text to fit in the terminal window. For Tim.
src/binwalk/core/display.py
def _format_line(self, line): ''' Formats a line of text to fit in the terminal window. For Tim. ''' delim = '\n' offset = 0 self.string_parts = [] # Split the line into an array of columns, e.g., ['0', '0x00000000', # 'Some description here'] ...
def _format_line(self, line): ''' Formats a line of text to fit in the terminal window. For Tim. ''' delim = '\n' offset = 0 self.string_parts = [] # Split the line into an array of columns, e.g., ['0', '0x00000000', # 'Some description here'] ...
[ "Formats", "a", "line", "of", "text", "to", "fit", "in", "the", "terminal", "window", ".", "For", "Tim", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L180-L230
[ "def", "_format_line", "(", "self", ",", "line", ")", ":", "delim", "=", "'\\n'", "offset", "=", "0", "self", ".", "string_parts", "=", "[", "]", "# Split the line into an array of columns, e.g., ['0', '0x00000000',", "# 'Some description here']", "line_columns", "=", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Display._configure_formatting
Configures output formatting, and fitting output to the current terminal width. Returns None.
src/binwalk/core/display.py
def _configure_formatting(self): ''' Configures output formatting, and fitting output to the current terminal width. Returns None. ''' self.format_strings(self.DEFAULT_FORMAT, self.DEFAULT_FORMAT) if self.fit_to_screen: try: import fcntl ...
def _configure_formatting(self): ''' Configures output formatting, and fitting output to the current terminal width. Returns None. ''' self.format_strings(self.DEFAULT_FORMAT, self.DEFAULT_FORMAT) if self.fit_to_screen: try: import fcntl ...
[ "Configures", "output", "formatting", "and", "fitting", "output", "to", "the", "current", "terminal", "width", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L232-L252
[ "def", "_configure_formatting", "(", "self", ")", ":", "self", ".", "format_strings", "(", "self", ".", "DEFAULT_FORMAT", ",", "self", ".", "DEFAULT_FORMAT", ")", "if", "self", ".", "fit_to_screen", ":", "try", ":", "import", "fcntl", "import", "struct", "im...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings._magic_signature_files
Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Returns a list of user/system magic signature files.
src/binwalk/core/settings.py
def _magic_signature_files(self, system_only=False, user_only=False): ''' Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Retu...
def _magic_signature_files(self, system_only=False, user_only=False): ''' Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Retu...
[ "Find", "all", "user", "/", "system", "magic", "signature", "files", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L56-L87
[ "def", "_magic_signature_files", "(", "self", ",", "system_only", "=", "False", ",", "user_only", "=", "False", ")", ":", "files", "=", "[", "]", "user_binarch", "=", "self", ".", "_user_path", "(", "self", ".", "BINWALK_MAGIC_DIR", ",", "self", ".", "BINA...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings.find_magic_file
Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. If sys...
src/binwalk/core/settings.py
def find_magic_file(self, fname, system_only=False, user_only=False): ''' Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @u...
def find_magic_file(self, fname, system_only=False, user_only=False): ''' Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @u...
[ "Finds", "the", "specified", "magic", "file", "name", "in", "the", "system", "/", "user", "magic", "file", "directories", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L89-L113
[ "def", "find_magic_file", "(", "self", ",", "fname", ",", "system_only", "=", "False", ",", "user_only", "=", "False", ")", ":", "loc", "=", "None", "if", "not", "system_only", ":", "fpath", "=", "self", ".", "_user_path", "(", "self", ".", "BINWALK_MAGI...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings._get_user_dir
Get the user's home directory.
src/binwalk/core/settings.py
def _get_user_dir(self): ''' Get the user's home directory. ''' try: # This should work in both Windows and Unix environments for envname in ['USERPROFILE', 'HOME']: user_dir = os.getenv(envname) if user_dir is not None: ...
def _get_user_dir(self): ''' Get the user's home directory. ''' try: # This should work in both Windows and Unix environments for envname in ['USERPROFILE', 'HOME']: user_dir = os.getenv(envname) if user_dir is not None: ...
[ "Get", "the", "user", "s", "home", "directory", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L125-L140
[ "def", "_get_user_dir", "(", "self", ")", ":", "try", ":", "# This should work in both Windows and Unix environments", "for", "envname", "in", "[", "'USERPROFILE'", ",", "'HOME'", "]", ":", "user_dir", "=", "os", ".", "getenv", "(", "envname", ")", "if", "user_d...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings._file_path
Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'.
src/binwalk/core/settings.py
def _file_path(self, dirname, filename): ''' Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'. ''' if not os.path.exists(dirname):...
def _file_path(self, dirname, filename): ''' Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'. ''' if not os.path.exists(dirname):...
[ "Builds", "an", "absolute", "path", "and", "creates", "the", "directory", "and", "file", "if", "they", "don", "t", "already", "exist", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L142-L169
[ "def", "_file_path", "(", "self", ",", "dirname", ",", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dirname", ")", ":", "try", ":", "os", ".", "makedirs", "(", "dirname", ")", "except", "KeyboardInterrupt", "as", "e", ":...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings._user_path
Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basename' file.
src/binwalk/core/settings.py
def _user_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basenam...
def _user_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basenam...
[ "Gets", "the", "full", "path", "to", "the", "subdir", "/", "basename", "file", "in", "the", "user", "binwalk", "directory", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L171-L185
[ "def", "_user_path", "(", "self", ",", "subdir", ",", "basename", "=", "''", ")", ":", "try", ":", "return", "self", ".", "_file_path", "(", "os", ".", "path", ".", "join", "(", "self", ".", "user_dir", ",", "self", ".", "BINWALK_USER_DIR", ",", "sub...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Settings._system_path
Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basename' file.
src/binwalk/core/settings.py
def _system_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/b...
def _system_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/b...
[ "Gets", "the", "full", "path", "to", "the", "subdir", "/", "basename", "file", "in", "the", "system", "binwalk", "directory", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L187-L201
[ "def", "_system_path", "(", "self", ",", "subdir", ",", "basename", "=", "''", ")", ":", "try", ":", "return", "self", ".", "_file_path", "(", "os", ".", "path", ".", "join", "(", "self", ".", "system_dir", ",", "subdir", ")", ",", "basename", ")", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
HilinkDecryptor._decrypt_and_extract
This does the extraction (e.g., it decrypts the image and writes it to a new file on disk).
src/binwalk/plugins/hilink.py
def _decrypt_and_extract(self, fname): ''' This does the extraction (e.g., it decrypts the image and writes it to a new file on disk). ''' with open(fname, "r") as fp_in: encrypted_data = fp_in.read() decrypted_data = self._hilink_decrypt(encrypted_data) ...
def _decrypt_and_extract(self, fname): ''' This does the extraction (e.g., it decrypts the image and writes it to a new file on disk). ''' with open(fname, "r") as fp_in: encrypted_data = fp_in.read() decrypted_data = self._hilink_decrypt(encrypted_data) ...
[ "This", "does", "the", "extraction", "(", "e", ".", "g", ".", "it", "decrypts", "the", "image", "and", "writes", "it", "to", "a", "new", "file", "on", "disk", ")", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L38-L48
[ "def", "_decrypt_and_extract", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "\"r\"", ")", "as", "fp_in", ":", "encrypted_data", "=", "fp_in", ".", "read", "(", ")", "decrypted_data", "=", "self", ".", "_hilink_decrypt", "(", "e...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
HilinkDecryptor._hilink_decrypt
This does the actual decryption.
src/binwalk/plugins/hilink.py
def _hilink_decrypt(self, encrypted_firmware): ''' This does the actual decryption. ''' cipher = DES.new(self.DES_KEY, DES.MODE_ECB) p1 = encrypted_firmware[0:3] p2 = encrypted_firmware[3:] p2 += b"\x00" * (8 - (len(p2) % 8)) d1 = p1 + cipher.decrypt(p2)...
def _hilink_decrypt(self, encrypted_firmware): ''' This does the actual decryption. ''' cipher = DES.new(self.DES_KEY, DES.MODE_ECB) p1 = encrypted_firmware[0:3] p2 = encrypted_firmware[3:] p2 += b"\x00" * (8 - (len(p2) % 8)) d1 = p1 + cipher.decrypt(p2)...
[ "This", "does", "the", "actual", "decryption", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L50-L63
[ "def", "_hilink_decrypt", "(", "self", ",", "encrypted_firmware", ")", ":", "cipher", "=", "DES", ".", "new", "(", "self", ".", "DES_KEY", ",", "DES", ".", "MODE_ECB", ")", "p1", "=", "encrypted_firmware", "[", "0", ":", "3", "]", "p2", "=", "encrypted...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
HilinkDecryptor.scan
Validate signature results.
src/binwalk/plugins/hilink.py
def scan(self, result): ''' Validate signature results. ''' if self.enabled is True: if result.valid is True: if result.description.lower().startswith(self.SIGNATURE_DESCRIPTION) is True: # Read in the first 64 bytes of the suspected encryp...
def scan(self, result): ''' Validate signature results. ''' if self.enabled is True: if result.valid is True: if result.description.lower().startswith(self.SIGNATURE_DESCRIPTION) is True: # Read in the first 64 bytes of the suspected encryp...
[ "Validate", "signature", "results", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L65-L94
[ "def", "scan", "(", "self", ",", "result", ")", ":", "if", "self", ".", "enabled", "is", "True", ":", "if", "result", ".", "valid", "is", "True", ":", "if", "result", ".", "description", ".", "lower", "(", ")", ".", "startswith", "(", "self", ".", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
run
Locks the main thread while the subscription in running
sample/new_messages_observer.py
def run(): print("Environment", os.environ) try: os.environ["SELENIUM"] except KeyError: print("Please set the environment variable SELENIUM to Selenium URL") sys.exit(1) driver = WhatsAPIDriver(client='remote', command_executor=os.environ["SELENIUM"]) print("Waiting for QR"...
def run(): print("Environment", os.environ) try: os.environ["SELENIUM"] except KeyError: print("Please set the environment variable SELENIUM to Selenium URL") sys.exit(1) driver = WhatsAPIDriver(client='remote', command_executor=os.environ["SELENIUM"]) print("Waiting for QR"...
[ "Locks", "the", "main", "thread", "while", "the", "subscription", "in", "running" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/new_messages_observer.py#L8-L26
[ "def", "run", "(", ")", ":", "print", "(", "\"Environment\"", ",", "os", ".", "environ", ")", "try", ":", "os", ".", "environ", "[", "\"SELENIUM\"", "]", "except", "KeyError", ":", "print", "(", "\"Please set the environment variable SELENIUM to Selenium URL\"", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.save_firefox_profile
Function to save the firefox profile to the permanant one
webwhatsapi/__init__.py
def save_firefox_profile(self, remove_old=False): """Function to save the firefox profile to the permanant one""" self.logger.info("Saving profile from %s to %s" % (self._profile.path, self._profile_path)) if remove_old: if os.path.exists(self._profile_path): try: ...
def save_firefox_profile(self, remove_old=False): """Function to save the firefox profile to the permanant one""" self.logger.info("Saving profile from %s to %s" % (self._profile.path, self._profile_path)) if remove_old: if os.path.exists(self._profile_path): try: ...
[ "Function", "to", "save", "the", "firefox", "profile", "to", "the", "permanant", "one" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L111-L137
[ "def", "save_firefox_profile", "(", "self", ",", "remove_old", "=", "False", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Saving profile from %s to %s\"", "%", "(", "self", ".", "_profile", ".", "path", ",", "self", ".", "_profile_path", ")", ")", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.wait_for_login
Waits for the QR to go away
webwhatsapi/__init__.py
def wait_for_login(self, timeout=90): """Waits for the QR to go away""" WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, self._SELECTORS['mainPage'])) )
def wait_for_login(self, timeout=90): """Waits for the QR to go away""" WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, self._SELECTORS['mainPage'])) )
[ "Waits", "for", "the", "QR", "to", "go", "away" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L258-L262
[ "def", "wait_for_login", "(", "self", ",", "timeout", "=", "90", ")", ":", "WebDriverWait", "(", "self", ".", "driver", ",", "timeout", ")", ".", "until", "(", "EC", ".", "visibility_of_element_located", "(", "(", "By", ".", "CSS_SELECTOR", ",", "self", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_qr
Get pairing QR code from client
webwhatsapi/__init__.py
def get_qr(self, filename=None): """Get pairing QR code from client""" if "Click to reload QR code" in self.driver.page_source: self.reload_qr() qr = self.driver.find_element_by_css_selector(self._SELECTORS['qrCode']) if filename is None: fd, fn_png = tempfile.mks...
def get_qr(self, filename=None): """Get pairing QR code from client""" if "Click to reload QR code" in self.driver.page_source: self.reload_qr() qr = self.driver.find_element_by_css_selector(self._SELECTORS['qrCode']) if filename is None: fd, fn_png = tempfile.mks...
[ "Get", "pairing", "QR", "code", "from", "client" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L267-L280
[ "def", "get_qr", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "\"Click to reload QR code\"", "in", "self", ".", "driver", ".", "page_source", ":", "self", ".", "reload_qr", "(", ")", "qr", "=", "self", ".", "driver", ".", "find_element_by_css...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_contacts
Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact]
webwhatsapi/__init__.py
def get_contacts(self): """ Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact] """ all_contacts = self.wapi_functions.getAllContacts() ...
def get_contacts(self): """ Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact] """ all_contacts = self.wapi_functions.getAllContacts() ...
[ "Fetches", "list", "of", "all", "contacts", "This", "will", "return", "chats", "with", "people", "from", "the", "address", "book", "only", "Use", "get_all_chats", "for", "all", "chats" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L292-L302
[ "def", "get_contacts", "(", "self", ")", ":", "all_contacts", "=", "self", ".", "wapi_functions", ".", "getAllContacts", "(", ")", "return", "[", "Contact", "(", "contact", ",", "self", ")", "for", "contact", "in", "all_contacts", "]" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_my_contacts
Fetches list of added contacts :return: List of contacts :rtype: list[Contact]
webwhatsapi/__init__.py
def get_my_contacts(self): """ Fetches list of added contacts :return: List of contacts :rtype: list[Contact] """ my_contacts = self.wapi_functions.getMyContacts() return [Contact(contact, self) for contact in my_contacts]
def get_my_contacts(self): """ Fetches list of added contacts :return: List of contacts :rtype: list[Contact] """ my_contacts = self.wapi_functions.getMyContacts() return [Contact(contact, self) for contact in my_contacts]
[ "Fetches", "list", "of", "added", "contacts" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L304-L312
[ "def", "get_my_contacts", "(", "self", ")", ":", "my_contacts", "=", "self", ".", "wapi_functions", ".", "getMyContacts", "(", ")", "return", "[", "Contact", "(", "contact", ",", "self", ")", "for", "contact", "in", "my_contacts", "]" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_all_chats
Fetches all chats :return: List of chats :rtype: list[Chat]
webwhatsapi/__init__.py
def get_all_chats(self): """ Fetches all chats :return: List of chats :rtype: list[Chat] """ chats = self.wapi_functions.getAllChats() if chats: return [factory_chat(chat, self) for chat in chats] else: return []
def get_all_chats(self): """ Fetches all chats :return: List of chats :rtype: list[Chat] """ chats = self.wapi_functions.getAllChats() if chats: return [factory_chat(chat, self) for chat in chats] else: return []
[ "Fetches", "all", "chats" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L314-L325
[ "def", "get_all_chats", "(", "self", ")", ":", "chats", "=", "self", ".", "wapi_functions", ".", "getAllChats", "(", ")", "if", "chats", ":", "return", "[", "factory_chat", "(", "chat", ",", "self", ")", "for", "chat", "in", "chats", "]", "else", ":", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_unread
Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :param use_unread_count: If set uses chat's 'unreadCount' attribute to fetch ...
webwhatsapi/__init__.py
def get_unread(self, include_me=False, include_notifications=False, use_unread_count=False): """ Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_...
def get_unread(self, include_me=False, include_notifications=False, use_unread_count=False): """ Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_...
[ "Fetches", "unread", "messages", ":", "param", "include_me", ":", "Include", "user", "s", "messages", ":", "type", "include_me", ":", "bool", "or", "None", ":", "param", "include_notifications", ":", "Include", "events", "happening", "on", "chat", ":", "type",...
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L336-L357
[ "def", "get_unread", "(", "self", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ",", "use_unread_count", "=", "False", ")", ":", "raw_message_groups", "=", "self", ".", "wapi_functions", ".", "getUnreadMessages", "(", "include_me", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_unread_messages_in_chat
I fetch unread messages from an asked chat. :param id: chat id :type id: str :param include_me: if user's messages are to be included :type include_me: bool :param include_notifications: if events happening on chat are to be included :type include_notifications: bool ...
webwhatsapi/__init__.py
def get_unread_messages_in_chat(self, id, include_me=False, include_notifications=False): """ I fetch unread messages from an asked chat. :param id: chat id :type id: str ...
def get_unread_messages_in_chat(self, id, include_me=False, include_notifications=False): """ I fetch unread messages from an asked chat. :param id: chat id :type id: str ...
[ "I", "fetch", "unread", "messages", "from", "an", "asked", "chat", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L359-L386
[ "def", "get_unread_messages_in_chat", "(", "self", ",", "id", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "# get unread messages", "messages", "=", "self", ".", "wapi_functions", ".", "getUnreadMessagesInChat", "(", "id", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_all_messages_in_chat
Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :return: List of messages in chat :rtype: list[Message]
webwhatsapi/__init__.py
def get_all_messages_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_no...
def get_all_messages_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_no...
[ "Fetches", "messages", "in", "chat" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L390-L405
[ "def", "get_all_messages_in_chat", "(", "self", ",", "chat", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "message_objs", "=", "self", ".", "wapi_functions", ".", "getAllMessagesInChat", "(", "chat", ".", "id", ",", "i...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_all_message_ids_in_chat
Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :return: List of message ids in chat :rtype: list[str]
webwhatsapi/__init__.py
def get_all_message_ids_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type incl...
def get_all_message_ids_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type incl...
[ "Fetches", "message", "ids", "in", "chat" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L407-L418
[ "def", "get_all_message_ids_in_chat", "(", "self", ",", "chat", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "return", "self", ".", "wapi_functions", ".", "getAllMessageIdsInChat", "(", "chat", ".", "id", ",", "include_m...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_message_by_id
Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message
webwhatsapi/__init__.py
def get_message_by_id(self, message_id): """ Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message """ result = self.wapi_functions.getMessageById(message_id) if result: result =...
def get_message_by_id(self, message_id): """ Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message """ result = self.wapi_functions.getMessageById(message_id) if result: result =...
[ "Fetch", "a", "message" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L420-L434
[ "def", "get_message_by_id", "(", "self", ",", "message_id", ")", ":", "result", "=", "self", ".", "wapi_functions", ".", "getMessageById", "(", "message_id", ")", "if", "result", ":", "result", "=", "factory_message", "(", "result", ",", "self", ")", "return...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_contact_from_id
Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact
webwhatsapi/__init__.py
def get_contact_from_id(self, contact_id): """ Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact """ contact = self.wapi_functions.getContact(contact_id) if contact is Non...
def get_contact_from_id(self, contact_id): """ Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact """ contact = self.wapi_functions.getContact(contact_id) if contact is Non...
[ "Fetches", "a", "contact", "given", "its", "ID" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L436-L450
[ "def", "get_contact_from_id", "(", "self", ",", "contact_id", ")", ":", "contact", "=", "self", ".", "wapi_functions", ".", "getContact", "(", "contact_id", ")", "if", "contact", "is", "None", ":", "raise", "ContactNotFoundError", "(", "\"Contact {0} not found\"",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_chat_from_id
Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat
webwhatsapi/__init__.py
def get_chat_from_id(self, chat_id): """ Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat """ chat = self.wapi_functions.getChatById(chat_id) if chat: return factory_chat(chat, ...
def get_chat_from_id(self, chat_id): """ Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat """ chat = self.wapi_functions.getChatById(chat_id) if chat: return factory_chat(chat, ...
[ "Fetches", "a", "chat", "given", "its", "ID" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L452-L465
[ "def", "get_chat_from_id", "(", "self", ",", "chat_id", ")", ":", "chat", "=", "self", ".", "wapi_functions", ".", "getChatById", "(", "chat_id", ")", "if", "chat", ":", "return", "factory_chat", "(", "chat", ",", "self", ")", "raise", "ChatNotFoundError", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_chat_from_phone_number
Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param number: Phone number :return: Chat :rtype: Chat
webwhatsapi/__init__.py
def get_chat_from_phone_number(self, number, createIfNotFound = False): """ Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param numbe...
def get_chat_from_phone_number(self, number, createIfNotFound = False): """ Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param numbe...
[ "Gets", "chat", "by", "phone", "number", "Number", "format", "should", "be", "as", "it", "appears", "in", "Whatsapp", "ID", "For", "example", "for", "the", "number", ":", "+", "972", "-", "51", "-", "234", "-", "5678", "This", "function", "would", "rec...
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L467-L492
[ "def", "get_chat_from_phone_number", "(", "self", ",", "number", ",", "createIfNotFound", "=", "False", ")", ":", "for", "chat", "in", "self", ".", "get_all_chats", "(", ")", ":", "if", "not", "isinstance", "(", "chat", ",", "UserChat", ")", "or", "number"...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_status
Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus
webwhatsapi/__init__.py
def get_status(self): """ Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus """ if self.driver is None: return WhatsAPIDriverStatus.NotConnected if self.driver.session_id is None: return WhatsAPIDriverStatus.NotConn...
def get_status(self): """ Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus """ if self.driver is None: return WhatsAPIDriverStatus.NotConnected if self.driver.session_id is None: return WhatsAPIDriverStatus.NotConn...
[ "Returns", "status", "of", "the", "driver" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L497-L518
[ "def", "get_status", "(", "self", ")", ":", "if", "self", ".", "driver", "is", "None", ":", "return", "WhatsAPIDriverStatus", ".", "NotConnected", "if", "self", ".", "driver", ".", "session_id", "is", "None", ":", "return", "WhatsAPIDriverStatus", ".", "NotC...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.contact_get_common_groups
Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact
webwhatsapi/__init__.py
def contact_get_common_groups(self, contact_id): """ Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact """ for group in self.wapi_functions.getCommonGroups(contact_id): yield factory_chat(group, self...
def contact_get_common_groups(self, contact_id): """ Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact """ for group in self.wapi_functions.getCommonGroups(contact_id): yield factory_chat(group, self...
[ "Returns", "groups", "common", "between", "a", "user", "and", "the", "contact", "with", "given", "id", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L520-L528
[ "def", "contact_get_common_groups", "(", "self", ",", "contact_id", ")", ":", "for", "group", "in", "self", ".", "wapi_functions", ".", "getCommonGroups", "(", "contact_id", ")", ":", "yield", "factory_chat", "(", "group", ",", "self", ")" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.convert_to_base64
:param path: file path :return: returns the converted string and formatted for the send media function send_media
webwhatsapi/__init__.py
def convert_to_base64(self, path): """ :param path: file path :return: returns the converted string and formatted for the send media function send_media """ mime = magic.Magic(mime=True) content_type = mime.from_file(path) archive = '' with open(path, "rb...
def convert_to_base64(self, path): """ :param path: file path :return: returns the converted string and formatted for the send media function send_media """ mime = magic.Magic(mime=True) content_type = mime.from_file(path) archive = '' with open(path, "rb...
[ ":", "param", "path", ":", "file", "path", ":", "return", ":", "returns", "the", "converted", "string", "and", "formatted", "for", "the", "send", "media", "function", "send_media" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L555-L567
[ "def", "convert_to_base64", "(", "self", ",", "path", ")", ":", "mime", "=", "magic", ".", "Magic", "(", "mime", "=", "True", ")", "content_type", "=", "mime", ".", "from_file", "(", "path", ")", "archive", "=", "''", "with", "open", "(", "path", ","...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.send_media
converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return:
webwhatsapi/__init__.py
def send_media(self, path, chatid, caption): """ converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return: """ imgBase64 = self.convert_to_base64(pa...
def send_media(self, path, chatid, caption): """ converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return: """ imgBase64 = self.convert_to_base64(pa...
[ "converts", "the", "file", "to", "base64", "and", "sends", "it", "using", "the", "sendImage", "function", "of", "wapi", ".", "js", ":", "param", "path", ":", "file", "path", ":", "param", "chatid", ":", "chatId", "to", "be", "sent", ":", "param", "capt...
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L570-L580
[ "def", "send_media", "(", "self", ",", "path", ",", "chatid", ",", "caption", ")", ":", "imgBase64", "=", "self", ".", "convert_to_base64", "(", "path", ")", "filename", "=", "os", ".", "path", ".", "split", "(", "path", ")", "[", "-", "1", "]", "r...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_profile_pic_from_id
Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str
webwhatsapi/__init__.py
def get_profile_pic_from_id(self, id): """ Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic = self.wapi_functions.getProfilePicFromId(id) if ...
def get_profile_pic_from_id(self, id): """ Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic = self.wapi_functions.getProfilePicFromId(id) if ...
[ "Get", "full", "profile", "pic", "from", "an", "id", "The", "ID", "must", "be", "on", "your", "contact", "book", "to", "successfully", "get", "their", "profile", "picture", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L623-L636
[ "def", "get_profile_pic_from_id", "(", "self", ",", "id", ")", ":", "profile_pic", "=", "self", ".", "wapi_functions", ".", "getProfilePicFromId", "(", "id", ")", "if", "profile_pic", ":", "return", "b64decode", "(", "profile_pic", ")", "else", ":", "return", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.get_profile_pic_small_from_id
Get small profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str
webwhatsapi/__init__.py
def get_profile_pic_small_from_id(self, id): """ Get small profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic_small = self.wapi_functions.getProfilePicSmallFrom...
def get_profile_pic_small_from_id(self, id): """ Get small profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic_small = self.wapi_functions.getProfilePicSmallFrom...
[ "Get", "small", "profile", "pic", "from", "an", "id", "The", "ID", "must", "be", "on", "your", "contact", "book", "to", "successfully", "get", "their", "profile", "picture", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L638-L651
[ "def", "get_profile_pic_small_from_id", "(", "self", ",", "id", ")", ":", "profile_pic_small", "=", "self", ".", "wapi_functions", ".", "getProfilePicSmallFromId", "(", "id", ")", "if", "profile_pic", ":", "return", "b64decode", "(", "profile_pic_small", ")", "els...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.delete_message
Delete a chat :param chat_id: id of chat :param message_array: one or more message(s) id :param revoke: Set to true so the message will be deleted for everyone, not only you :return:
webwhatsapi/__init__.py
def delete_message(self, chat_id, message_array, revoke=False): """ Delete a chat :param chat_id: id of chat :param message_array: one or more message(s) id :param revoke: Set to true so the message will be deleted for everyone, not only you :return: """ ...
def delete_message(self, chat_id, message_array, revoke=False): """ Delete a chat :param chat_id: id of chat :param message_array: one or more message(s) id :param revoke: Set to true so the message will be deleted for everyone, not only you :return: """ ...
[ "Delete", "a", "chat" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L719-L728
[ "def", "delete_message", "(", "self", ",", "chat_id", ",", "message_array", ",", "revoke", "=", "False", ")", ":", "return", "self", ".", "wapi_functions", ".", "deleteMessage", "(", "chat_id", ",", "message_array", ",", "revoke", "=", "False", ")" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
WhatsAPIDriver.check_number_status
Check if a number is valid/registered in the whatsapp service :param number_id: number id :return:
webwhatsapi/__init__.py
def check_number_status(self, number_id): """ Check if a number is valid/registered in the whatsapp service :param number_id: number id :return: """ number_status = self.wapi_functions.checkNumberStatus(number_id) return NumberStatus(number_status, self)
def check_number_status(self, number_id): """ Check if a number is valid/registered in the whatsapp service :param number_id: number id :return: """ number_status = self.wapi_functions.checkNumberStatus(number_id) return NumberStatus(number_status, self)
[ "Check", "if", "a", "number", "is", "valid", "/", "registered", "in", "the", "whatsapp", "service" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L730-L738
[ "def", "check_number_status", "(", "self", ",", "number_id", ")", ":", "number_status", "=", "self", ".", "wapi_functions", ".", "checkNumberStatus", "(", "number_id", ")", "return", "NumberStatus", "(", "number_status", ",", "self", ")" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
factory_chat
Factory function for creating appropriate object given selenium JS object
webwhatsapi/objects/chat.py
def factory_chat(js_obj, driver=None): """Factory function for creating appropriate object given selenium JS object""" if js_obj["kind"] not in ["chat", "group", "broadcast"]: raise AssertionError("Expected chat, group or broadcast object, got {0}".format(js_obj["kind"])) if js_obj["isGroup"]: ...
def factory_chat(js_obj, driver=None): """Factory function for creating appropriate object given selenium JS object""" if js_obj["kind"] not in ["chat", "group", "broadcast"]: raise AssertionError("Expected chat, group or broadcast object, got {0}".format(js_obj["kind"])) if js_obj["isGroup"]: ...
[ "Factory", "function", "for", "creating", "appropriate", "object", "given", "selenium", "JS", "object" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/objects/chat.py#L7-L18
[ "def", "factory_chat", "(", "js_obj", ",", "driver", "=", "None", ")", ":", "if", "js_obj", "[", "\"kind\"", "]", "not", "in", "[", "\"chat\"", ",", "\"group\"", ",", "\"broadcast\"", "]", ":", "raise", "AssertionError", "(", "\"Expected chat, group or broadca...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
Chat.get_unread_messages
I fetch unread messages. :param include_me: if user's messages are to be included :type include_me: bool :param include_notifications: if events happening on chat are to be included :type include_notifications: bool :return: list of unread messages :rtype: list
webwhatsapi/objects/chat.py
def get_unread_messages(self, include_me=False, include_notifications=False): """ I fetch unread messages. :param include_me: if user's messages are to be included :type include_me: bool :param include_notifications: if e...
def get_unread_messages(self, include_me=False, include_notifications=False): """ I fetch unread messages. :param include_me: if user's messages are to be included :type include_me: bool :param include_notifications: if e...
[ "I", "fetch", "unread", "messages", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/objects/chat.py#L42-L61
[ "def", "get_unread_messages", "(", "self", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "return", "list", "(", "self", ".", "driver", ".", "get_unread_messages_in_chat", "(", "self", ".", "id", ",", "include_me", ",", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
Chat.load_earlier_messages_till
Triggers loading of messages till a specific point in time :param last: Datetime object for the last message to be loaded :type last: datetime :return: Nothing :rtype: None
webwhatsapi/objects/chat.py
def load_earlier_messages_till(self, last): """ Triggers loading of messages till a specific point in time :param last: Datetime object for the last message to be loaded :type last: datetime :return: Nothing :rtype: None """ timestamp = time.mktime(last.t...
def load_earlier_messages_till(self, last): """ Triggers loading of messages till a specific point in time :param last: Datetime object for the last message to be loaded :type last: datetime :return: Nothing :rtype: None """ timestamp = time.mktime(last.t...
[ "Triggers", "loading", "of", "messages", "till", "a", "specific", "point", "in", "time" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/objects/chat.py#L71-L81
[ "def", "load_earlier_messages_till", "(", "self", ",", "last", ")", ":", "timestamp", "=", "time", ".", "mktime", "(", "last", ".", "timetuple", "(", ")", ")", "self", ".", "driver", ".", "wapi_functions", ".", "loadEarlierMessagesTillDate", "(", "self", "."...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
factory_message
Factory function for creating appropriate object given selenium JS object
webwhatsapi/objects/message.py
def factory_message(js_obj, driver): """Factory function for creating appropriate object given selenium JS object""" if js_obj is None: return if "lat" in js_obj and "lng" in js_obj and js_obj["lat"] and js_obj["lng"]: return GeoMessage(js_obj, driver) if js_obj["isMedia"]: ret...
def factory_message(js_obj, driver): """Factory function for creating appropriate object given selenium JS object""" if js_obj is None: return if "lat" in js_obj and "lng" in js_obj and js_obj["lat"] and js_obj["lng"]: return GeoMessage(js_obj, driver) if js_obj["isMedia"]: ret...
[ "Factory", "function", "for", "creating", "appropriate", "object", "given", "selenium", "JS", "object" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/objects/message.py#L21-L41
[ "def", "factory_message", "(", "js_obj", ",", "driver", ")", ":", "if", "js_obj", "is", "None", ":", "return", "if", "\"lat\"", "in", "js_obj", "and", "\"lng\"", "in", "js_obj", "and", "js_obj", "[", "\"lat\"", "]", "and", "js_obj", "[", "\"lng\"", "]", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
create_logger
Initial the global logger variable
sample/flask/webapi.py
def create_logger(): """Initial the global logger variable""" global logger formatter = logging.Formatter('%(asctime)s|%(levelname)s|%(message)s') handler = TimedRotatingFileHandler(log_file, when="midnight", interval=1) handler.setFormatter(formatter) handler.setLevel(log_level) handler.su...
def create_logger(): """Initial the global logger variable""" global logger formatter = logging.Formatter('%(asctime)s|%(levelname)s|%(message)s') handler = TimedRotatingFileHandler(log_file, when="midnight", interval=1) handler.setFormatter(formatter) handler.setLevel(log_level) handler.su...
[ "Initial", "the", "global", "logger", "variable" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L156-L167
[ "def", "create_logger", "(", ")", ":", "global", "logger", "formatter", "=", "logging", ".", "Formatter", "(", "'%(asctime)s|%(levelname)s|%(message)s'", ")", "handler", "=", "TimedRotatingFileHandler", "(", "log_file", ",", "when", "=", "\"midnight\"", ",", "interv...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
init_driver
Initialises a new driver via webwhatsapi module @param client_id: ID of user client @return webwhatsapi object
sample/flask/webapi.py
def init_driver(client_id): """Initialises a new driver via webwhatsapi module @param client_id: ID of user client @return webwhatsapi object """ # Create profile directory if it does not exist profile_path = CHROME_CACHE_PATH + str(client_id) if not os.path.exists(profile_path): ...
def init_driver(client_id): """Initialises a new driver via webwhatsapi module @param client_id: ID of user client @return webwhatsapi object """ # Create profile directory if it does not exist profile_path = CHROME_CACHE_PATH + str(client_id) if not os.path.exists(profile_path): ...
[ "Initialises", "a", "new", "driver", "via", "webwhatsapi", "module" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L170-L199
[ "def", "init_driver", "(", "client_id", ")", ":", "# Create profile directory if it does not exist", "profile_path", "=", "CHROME_CACHE_PATH", "+", "str", "(", "client_id", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "profile_path", ")", ":", "os", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
init_client
Initialse a driver for client and store for future reference @param client_id: ID of client user @return whebwhatsapi object
sample/flask/webapi.py
def init_client(client_id): """Initialse a driver for client and store for future reference @param client_id: ID of client user @return whebwhatsapi object """ if client_id not in drivers: drivers[client_id] = init_driver(client_id) return drivers[client_id]
def init_client(client_id): """Initialse a driver for client and store for future reference @param client_id: ID of client user @return whebwhatsapi object """ if client_id not in drivers: drivers[client_id] = init_driver(client_id) return drivers[client_id]
[ "Initialse", "a", "driver", "for", "client", "and", "store", "for", "future", "reference" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L202-L210
[ "def", "init_client", "(", "client_id", ")", ":", "if", "client_id", "not", "in", "drivers", ":", "drivers", "[", "client_id", "]", "=", "init_driver", "(", "client_id", ")", "return", "drivers", "[", "client_id", "]" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
delete_client
Delete all objects related to client @param client_id: ID of client user @param preserve_cache: Boolean, whether to delete the chrome profile folder or not
sample/flask/webapi.py
def delete_client(client_id, preserve_cache): """Delete all objects related to client @param client_id: ID of client user @param preserve_cache: Boolean, whether to delete the chrome profile folder or not """ if client_id in drivers: drivers.pop(client_id).quit() try: ...
def delete_client(client_id, preserve_cache): """Delete all objects related to client @param client_id: ID of client user @param preserve_cache: Boolean, whether to delete the chrome profile folder or not """ if client_id in drivers: drivers.pop(client_id).quit() try: ...
[ "Delete", "all", "objects", "related", "to", "client" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L213-L231
[ "def", "delete_client", "(", "client_id", ",", "preserve_cache", ")", ":", "if", "client_id", "in", "drivers", ":", "drivers", ".", "pop", "(", "client_id", ")", ".", "quit", "(", ")", "try", ":", "timers", "[", "client_id", "]", ".", "stop", "(", ")",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
init_timer
Create a timer for the client driver to watch for events @param client_id: ID of clinet user
sample/flask/webapi.py
def init_timer(client_id): """Create a timer for the client driver to watch for events @param client_id: ID of clinet user """ if client_id in timers and timers[client_id]: timers[client_id].start() return # Create a timer to call check_new_message function after every 2 seconds...
def init_timer(client_id): """Create a timer for the client driver to watch for events @param client_id: ID of clinet user """ if client_id in timers and timers[client_id]: timers[client_id].start() return # Create a timer to call check_new_message function after every 2 seconds...
[ "Create", "a", "timer", "for", "the", "client", "driver", "to", "watch", "for", "events" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L234-L244
[ "def", "init_timer", "(", "client_id", ")", ":", "if", "client_id", "in", "timers", "and", "timers", "[", "client_id", "]", ":", "timers", "[", "client_id", "]", ".", "start", "(", ")", "return", "# Create a timer to call check_new_message function after every 2 sec...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
check_new_messages
Check for new unread messages and send them to the custom api @param client_id: ID of client user
sample/flask/webapi.py
def check_new_messages(client_id): """Check for new unread messages and send them to the custom api @param client_id: ID of client user """ # Return if driver is not defined or if whatsapp is not logged in. # Stop the timer as well if client_id not in drivers or not drivers[client_id] or not dr...
def check_new_messages(client_id): """Check for new unread messages and send them to the custom api @param client_id: ID of client user """ # Return if driver is not defined or if whatsapp is not logged in. # Stop the timer as well if client_id not in drivers or not drivers[client_id] or not dr...
[ "Check", "for", "new", "unread", "messages", "and", "send", "them", "to", "the", "custom", "api" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L247-L277
[ "def", "check_new_messages", "(", "client_id", ")", ":", "# Return if driver is not defined or if whatsapp is not logged in.", "# Stop the timer as well", "if", "client_id", "not", "in", "drivers", "or", "not", "drivers", "[", "client_id", "]", "or", "not", "drivers", "["...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
get_client_info
Get the status of a perticular client, as to he/she is connected or not @param client_id: ID of client user @return JSON object { "driver_status": webdriver status "is_alive": if driver is active or not "is_logged_in": if user is logged in or not "is_timer": if timer is runn...
sample/flask/webapi.py
def get_client_info(client_id): """Get the status of a perticular client, as to he/she is connected or not @param client_id: ID of client user @return JSON object { "driver_status": webdriver status "is_alive": if driver is active or not "is_logged_in": if user is logged in or n...
def get_client_info(client_id): """Get the status of a perticular client, as to he/she is connected or not @param client_id: ID of client user @return JSON object { "driver_status": webdriver status "is_alive": if driver is active or not "is_logged_in": if user is logged in or n...
[ "Get", "the", "status", "of", "a", "perticular", "client", "as", "to", "he", "/", "she", "is", "connected", "or", "not" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L280-L307
[ "def", "get_client_info", "(", "client_id", ")", ":", "if", "client_id", "not", "in", "drivers", ":", "return", "None", "driver_status", "=", "drivers", "[", "client_id", "]", ".", "get_status", "(", ")", "is_alive", "=", "False", "is_logged_in", "=", "False...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
create_static_profile_path
Create a profile path folder if not exist @param client_id: ID of client user @return string profile path
sample/flask/webapi.py
def create_static_profile_path(client_id): """Create a profile path folder if not exist @param client_id: ID of client user @return string profile path """ profile_path = os.path.join(STATIC_FILES_PATH, str(client_id)) if not os.path.exists(profile_path): os.makedirs(profile_path) ...
def create_static_profile_path(client_id): """Create a profile path folder if not exist @param client_id: ID of client user @return string profile path """ profile_path = os.path.join(STATIC_FILES_PATH, str(client_id)) if not os.path.exists(profile_path): os.makedirs(profile_path) ...
[ "Create", "a", "profile", "path", "folder", "if", "not", "exist" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L354-L363
[ "def", "create_static_profile_path", "(", "client_id", ")", ":", "profile_path", "=", "os", ".", "path", ".", "join", "(", "STATIC_FILES_PATH", ",", "str", "(", "client_id", ")", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "profile_path", ")",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
before_request
This runs before every API request. The function take cares of creating driver object is not already created. Also it checks for few prerequisits parameters and set global variables for other functions to use Required paramters for an API hit are: auth-key: key string to identify valid request ...
sample/flask/webapi.py
def before_request(): """This runs before every API request. The function take cares of creating driver object is not already created. Also it checks for few prerequisits parameters and set global variables for other functions to use Required paramters for an API hit are: auth-key: key string t...
def before_request(): """This runs before every API request. The function take cares of creating driver object is not already created. Also it checks for few prerequisits parameters and set global variables for other functions to use Required paramters for an API hit are: auth-key: key string t...
[ "This", "runs", "before", "every", "API", "request", ".", "The", "function", "take", "cares", "of", "creating", "driver", "object", "is", "not", "already", "created", ".", "Also", "it", "checks", "for", "few", "prerequisits", "parameters", "and", "set", "glo...
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L390-L438
[ "def", "before_request", "(", ")", ":", "global", "logger", "if", "not", "request", ".", "url_rule", ":", "abort", "(", "404", ")", "if", "logger", "==", "None", ":", "create_logger", "(", ")", "logger", ".", "info", "(", "\"API call \"", "+", "request",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
create_client
Create a new client driver. The driver is automatically created in before_request function.
sample/flask/webapi.py
def create_client(): """Create a new client driver. The driver is automatically created in before_request function.""" result = False if g.client_id in drivers: result = True return jsonify({'Success': result})
def create_client(): """Create a new client driver. The driver is automatically created in before_request function.""" result = False if g.client_id in drivers: result = True return jsonify({'Success': result})
[ "Create", "a", "new", "client", "driver", ".", "The", "driver", "is", "automatically", "created", "in", "before_request", "function", "." ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L473-L479
[ "def", "create_client", "(", ")", ":", "result", "=", "False", "if", "g", ".", "client_id", "in", "drivers", ":", "result", "=", "True", "return", "jsonify", "(", "{", "'Success'", ":", "result", "}", ")" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
delete_client
Delete all objects related to client
sample/flask/webapi.py
def delete_client(): """Delete all objects related to client""" preserve_cache = request.args.get('preserve_cache', False) delete_client(g.client_id, preserve_cache) return jsonify({'Success': True})
def delete_client(): """Delete all objects related to client""" preserve_cache = request.args.get('preserve_cache', False) delete_client(g.client_id, preserve_cache) return jsonify({'Success': True})
[ "Delete", "all", "objects", "related", "to", "client" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L483-L487
[ "def", "delete_client", "(", ")", ":", "preserve_cache", "=", "request", ".", "args", ".", "get", "(", "'preserve_cache'", ",", "False", ")", "delete_client", "(", "g", ".", "client_id", ",", "preserve_cache", ")", "return", "jsonify", "(", "{", "'Success'",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
get_screen
Capture chrome screen image and send it back. If the screen is currently at qr scanning phase, return the image of qr only, else return image of full screen
sample/flask/webapi.py
def get_screen(): """Capture chrome screen image and send it back. If the screen is currently at qr scanning phase, return the image of qr only, else return image of full screen""" img_title = 'screen_' + g.client_id + '.png' image_path = STATIC_FILES_PATH + img_title if g.driver_status != What...
def get_screen(): """Capture chrome screen image and send it back. If the screen is currently at qr scanning phase, return the image of qr only, else return image of full screen""" img_title = 'screen_' + g.client_id + '.png' image_path = STATIC_FILES_PATH + img_title if g.driver_status != What...
[ "Capture", "chrome", "screen", "image", "and", "send", "it", "back", ".", "If", "the", "screen", "is", "currently", "at", "qr", "scanning", "phase", "return", "the", "image", "of", "qr", "only", "else", "return", "image", "of", "full", "screen" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L493-L506
[ "def", "get_screen", "(", ")", ":", "img_title", "=", "'screen_'", "+", "g", ".", "client_id", "+", "'.png'", "image_path", "=", "STATIC_FILES_PATH", "+", "img_title", "if", "g", ".", "driver_status", "!=", "WhatsAPIDriverStatus", ".", "LoggedIn", ":", "try", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
get_unread_messages
Get all unread messages
sample/flask/webapi.py
def get_unread_messages(): """Get all unread messages""" mark_seen = request.args.get('mark_seen', True) unread_msg = g.driver.get_unread() if mark_seen: for msg in unread_msg: msg.chat.send_seen() return jsonify(unread_msg)
def get_unread_messages(): """Get all unread messages""" mark_seen = request.args.get('mark_seen', True) unread_msg = g.driver.get_unread() if mark_seen: for msg in unread_msg: msg.chat.send_seen() return jsonify(unread_msg)
[ "Get", "all", "unread", "messages" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L518-L527
[ "def", "get_unread_messages", "(", ")", ":", "mark_seen", "=", "request", ".", "args", ".", "get", "(", "'mark_seen'", ",", "True", ")", "unread_msg", "=", "g", ".", "driver", ".", "get_unread", "(", ")", "if", "mark_seen", ":", "for", "msg", "in", "un...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
get_messages
Return all of the chat messages
sample/flask/webapi.py
def get_messages(chat_id): """Return all of the chat messages""" mark_seen = request.args.get('mark_seen', True) chat = g.driver.get_chat_from_id(chat_id) msgs = list(g.driver.get_all_messages_in_chat(chat)) for msg in msgs: print(msg.id) if mark_seen: for msg in msgs: ...
def get_messages(chat_id): """Return all of the chat messages""" mark_seen = request.args.get('mark_seen', True) chat = g.driver.get_chat_from_id(chat_id) msgs = list(g.driver.get_all_messages_in_chat(chat)) for msg in msgs: print(msg.id) if mark_seen: for msg in msgs: ...
[ "Return", "all", "of", "the", "chat", "messages" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L549-L567
[ "def", "get_messages", "(", "chat_id", ")", ":", "mark_seen", "=", "request", ".", "args", ".", "get", "(", "'mark_seen'", ",", "True", ")", "chat", "=", "g", ".", "driver", ".", "get_chat_from_id", "(", "chat_id", ")", "msgs", "=", "list", "(", "g", ...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
send_message
Send a message to a chat If a media file is found, send_media is called, else a simple text message is sent
sample/flask/webapi.py
def send_message(chat_id): """Send a message to a chat If a media file is found, send_media is called, else a simple text message is sent """ files = request.files if files: res = send_media(chat_id, request) else: message = request.form.get('message') res = g.drive...
def send_message(chat_id): """Send a message to a chat If a media file is found, send_media is called, else a simple text message is sent """ files = request.files if files: res = send_media(chat_id, request) else: message = request.form.get('message') res = g.drive...
[ "Send", "a", "message", "to", "a", "chat", "If", "a", "media", "file", "is", "found", "send_media", "is", "called", "else", "a", "simple", "text", "message", "is", "sent" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L572-L589
[ "def", "send_message", "(", "chat_id", ")", ":", "files", "=", "request", ".", "files", "if", "files", ":", "res", "=", "send_media", "(", "chat_id", ",", "request", ")", "else", ":", "message", "=", "request", ".", "form", ".", "get", "(", "'message'"...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
download_message_media
Download a media file
sample/flask/webapi.py
def download_message_media(msg_id): """Download a media file""" message = g.driver.get_message_by_id(msg_id) if not message or not message.mime: abort(404) profile_path = create_static_profile_path(g.client_id) filename = message.save_media(profile_path, True) if os.path.exists(filena...
def download_message_media(msg_id): """Download a media file""" message = g.driver.get_message_by_id(msg_id) if not message or not message.mime: abort(404) profile_path = create_static_profile_path(g.client_id) filename = message.save_media(profile_path, True) if os.path.exists(filena...
[ "Download", "a", "media", "file" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L594-L607
[ "def", "download_message_media", "(", "msg_id", ")", ":", "message", "=", "g", ".", "driver", ".", "get_message_by_id", "(", "msg_id", ")", "if", "not", "message", "or", "not", "message", ".", "mime", ":", "abort", "(", "404", ")", "profile_path", "=", "...
81b918ee4e0cd0cb563807a72baa167f670d70cb
train
get_active_clients
Get a list of all active clients and their status
sample/flask/webapi.py
def get_active_clients(): """Get a list of all active clients and their status""" global drivers if not drivers: return jsonify([]) result = {client: get_client_info(client) for client in drivers} return jsonify(result)
def get_active_clients(): """Get a list of all active clients and their status""" global drivers if not drivers: return jsonify([]) result = {client: get_client_info(client) for client in drivers} return jsonify(result)
[ "Get", "a", "list", "of", "all", "active", "clients", "and", "their", "status" ]
mukulhase/WebWhatsapp-Wrapper
python
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/flask/webapi.py#L613-L621
[ "def", "get_active_clients", "(", ")", ":", "global", "drivers", "if", "not", "drivers", ":", "return", "jsonify", "(", "[", "]", ")", "result", "=", "{", "client", ":", "get_client_info", "(", "client", ")", "for", "client", "in", "drivers", "}", "retur...
81b918ee4e0cd0cb563807a72baa167f670d70cb