index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
48,082
dominate.tags
h4
Represents the fourth-highest ranking heading.
class h4(html_tag): ''' Represents the fourth-highest ranking heading. ''' pass
(*args, **kwargs)
48,116
dominate.tags
h5
Represents the fifth-highest ranking heading.
class h5(html_tag): ''' Represents the fifth-highest ranking heading. ''' pass
(*args, **kwargs)
48,150
dominate.tags
h6
Represents the sixth-highest ranking heading.
class h6(html_tag): ''' Represents the sixth-highest ranking heading. ''' pass
(*args, **kwargs)
48,185
dominate.tags
head
The head element represents a collection of metadata for the document.
class head(html_tag): ''' The head element represents a collection of metadata for the document. ''' pass
(*args, **kwargs)
48,219
dominate.tags
header
The header element represents a group of introductory or navigational aids.
class header(html_tag): ''' The header element represents a group of introductory or navigational aids. ''' pass
(*args, **kwargs)
48,253
dominate.tags
hgroup
The hgroup element represents the heading of a section. The element is used to group a set of h1-h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.
class hgroup(html_tag): ''' The hgroup element represents the heading of a section. The element is used to group a set of h1-h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines. ''' pass
(*args, **kwargs)
48,287
dominate.tags
hr
The hr element represents a paragraph-level thematic break, e.g. a scene change in a story, or a transition to another topic within a section of a reference book.
class hr(html_tag): ''' The hr element represents a paragraph-level thematic break, e.g. a scene change in a story, or a transition to another topic within a section of a reference book. ''' is_single = True
(*args, **kwargs)
48,321
dominate.tags
html
The html element represents the root of an HTML document.
class html(html_tag): ''' The html element represents the root of an HTML document. ''' pass # def validate_attributes(self): # errors = [] # for invalid in self._check_attributes(_ATTR_GLOBAL, 'manifest'): # errors.append( (self, ERR_ATTRIBUTE, 'Invalid attribute: "%s"' % invalid) ) # return errors # def validate_context(self): # if self.parent is not None and not isinstance(self.parent, iframe): # return [(self, ERR_CONTEXT, 'Must be root element or child of an <iframe>')] # return [] # def validate_content(self): # if len(self) != 2 or not isinstance(self[0], head) or not isinstance(self[1], body): # return [(self, ERR_CONTENT, 'Children must be <head> and then <body>.')] # return []
(*args, **kwargs)
48,355
dominate.tags
html_tag
null
class html_tag(dom_tag, dom1core): def __init__(self, *args, **kwargs): ''' Creates a new html tag instance. ''' super(html_tag, self).__init__(*args, **kwargs) # def validate(self): # ''' # Validate the tag. This will check the attributes, context, and contents and # emit tuples in the form of: element, message. # ''' # errors = [] # errors.extend(self.validate_attributes()) # errors.extend(self.validate_context()) # errors.extend(self.validate_content()) # return errors # def validate_attributes(self): # ''' # Validate the tag attributes. # ''' # return [] # def validate_context(self): # ''' # Validate the tag context. # ''' # return [] # def validate_content(self): # ''' # Validate the content of the tag. # ''' # return [] # def _check_attributes(self, *attrs): # valid = set([]) # for attr in attrs: # if hasattr(attr, '__iter__'): # valid |= set(attr) # else: # valid.add(attr) # return set(list(self.attributes.iterkeys())) - valid
(*args, **kwargs)
48,389
dominate.tags
i
null
class i(html_tag): is_inline = True ''' The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, or a ship name in Western texts. ''' pass
(*args, **kwargs)
48,423
dominate.tags
iframe
The iframe element represents a nested browsing context.
class iframe(html_tag): ''' The iframe element represents a nested browsing context. ''' pass
(*args, **kwargs)
48,457
dominate.tags
img
An img element represents an image.
class img(html_tag): ''' An img element represents an image. ''' is_single = True
(*args, **kwargs)
48,491
dominate.tags
input_
The input element represents a typed data field, usually with a form control to allow the user to edit the data.
class input_(html_tag): ''' The input element represents a typed data field, usually with a form control to allow the user to edit the data. ''' is_single = True
(*args, **kwargs)
48,525
dominate.tags
ins
The ins element represents an addition to the document.
class ins(html_tag): ''' The ins element represents an addition to the document. ''' pass
(*args, **kwargs)
48,559
easul.util
is_successful_outcome
Determines if outcome was successful or not. Args: outcome: Returns:
def is_successful_outcome(outcome): """ Determines if outcome was successful or not. Args: outcome: Returns: """ if not outcome: return False return False if issubclass(outcome.__class__,FailedOutcome) else True
(outcome)
48,560
dominate.tags
kbd
The kbd element represents user input (typically keyboard input, although it may also be used to represent other input, such as voice commands).
class kbd(html_tag): ''' The kbd element represents user input (typically keyboard input, although it may also be used to represent other input, such as voice commands). ''' pass
(*args, **kwargs)
48,594
dominate.tags
keygen
The keygen element represents a key pair generator control. When the control's form is submitted, the private key is stored in the local keystore, and the public key is packaged and sent to the server.
class keygen(html_tag): ''' The keygen element represents a key pair generator control. When the control's form is submitted, the private key is stored in the local keystore, and the public key is packaged and sent to the server. ''' is_single = True
(*args, **kwargs)
48,628
dominate.tags
label
The label represents a caption in a user interface. The caption can be associated with a specific form control, known as the label element's labeled control, either using for attribute, or by putting the form control inside the label element itself.
class label(html_tag): ''' The label represents a caption in a user interface. The caption can be associated with a specific form control, known as the label element's labeled control, either using for attribute, or by putting the form control inside the label element itself. ''' pass
(*args, **kwargs)
48,662
dominate.tags
legend
The legend element represents a caption for the rest of the contents of the legend element's parent fieldset element, if any.
class legend(html_tag): ''' The legend element represents a caption for the rest of the contents of the legend element's parent fieldset element, if any. ''' pass
(*args, **kwargs)
48,696
dominate.tags
li
The li element represents a list item. If its parent element is an ol, ul, or menu element, then the element is an item of the parent element's list, as defined for those elements. Otherwise, the list item has no defined list-related relationship to any other li element.
class li(html_tag): ''' The li element represents a list item. If its parent element is an ol, ul, or menu element, then the element is an item of the parent element's list, as defined for those elements. Otherwise, the list item has no defined list-related relationship to any other li element. ''' pass
(*args, **kwargs)
48,730
dominate.tags
link
The link element allows authors to link their document to other resources.
class link(html_tag): ''' The link element allows authors to link their document to other resources. ''' is_single = True
(*args, **kwargs)
48,766
dominate.tags
main
The main content area of a document includes content that is unique to that document and excludes content that is repeated across a set of documents such as site navigation links, copyright information, site logos and banners and search forms (unless the document or application's main function is that of a search form).
class main(html_tag): ''' The main content area of a document includes content that is unique to that document and excludes content that is repeated across a set of documents such as site navigation links, copyright information, site logos and banners and search forms (unless the document or application's main function is that of a search form). '''
(*args, **kwargs)
48,800
dominate.tags
map_
The map element, in conjunction with any area element descendants, defines an image map. The element represents its children.
class map_(html_tag): ''' The map element, in conjunction with any area element descendants, defines an image map. The element represents its children. ''' pass
(*args, **kwargs)
48,834
dominate.tags
mark
The mark element represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. When used in a quotation or other block of text referred to from the prose, it indicates a highlight that was not originally present but which has been added to bring the reader's attention to a part of the text that might not have been considered important by the original author when the block was originally written, but which is now under previously unexpected scrutiny. When used in the main prose of a document, it indicates a part of the document that has been highlighted due to its likely relevance to the user's current activity.
class mark(html_tag): ''' The mark element represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. When used in a quotation or other block of text referred to from the prose, it indicates a highlight that was not originally present but which has been added to bring the reader's attention to a part of the text that might not have been considered important by the original author when the block was originally written, but which is now under previously unexpected scrutiny. When used in the main prose of a document, it indicates a part of the document that has been highlighted due to its likely relevance to the user's current activity. ''' pass
(*args, **kwargs)
48,869
dominate.tags
menu
The menu element represents a list of commands.
class menu(html_tag): ''' The menu element represents a list of commands. ''' pass
(*args, **kwargs)
48,903
dominate.tags
meta
The meta element represents various kinds of metadata that cannot be expressed using the title, base, link, style, and script elements.
class meta(html_tag): ''' The meta element represents various kinds of metadata that cannot be expressed using the title, base, link, style, and script elements. ''' is_single = True
(*args, **kwargs)
48,937
dominate.tags
meter
The meter element represents a scalar measurement within a known range, or a fractional value; for example disk usage, the relevance of a query result, or the fraction of a voting population to have selected a particular candidate.
class meter(html_tag): ''' The meter element represents a scalar measurement within a known range, or a fractional value; for example disk usage, the relevance of a query result, or the fraction of a voting population to have selected a particular candidate. ''' pass
(*args, **kwargs)
48,971
dominate.tags
nav
The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.
class nav(html_tag): ''' The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. ''' pass
(*args, **kwargs)
49,005
dominate.tags
noscript
The noscript element represents nothing if scripting is enabled, and represents its children if scripting is disabled. It is used to present different markup to user agents that support scripting and those that don't support scripting, by affecting how the document is parsed.
class noscript(html_tag): ''' The noscript element represents nothing if scripting is enabled, and represents its children if scripting is disabled. It is used to present different markup to user agents that support scripting and those that don't support scripting, by affecting how the document is parsed. ''' pass
(*args, **kwargs)
49,040
easul.data
np_random_splitter
Numpy-based random splitter through permutation
def np_random_splitter(data, train_size, **kwargs): """Numpy-based random splitter through permutation """ train_no = round(data.shape[0] * train_size) test_no = data.shape[0] - train_no rnd_indexes = list(np.random.permutation(data.index)) train_idx = rnd_indexes[slice(0, train_no)] test_idx = rnd_indexes[slice(train_no, test_no + train_no)] train = data.loc[train_idx, :] test = data.loc[test_idx, :] return train, test
(data, train_size, **kwargs)
49,041
dominate.tags
object_
The object element can represent an external resource, which, depending on the type of the resource, will either be treated as an image, as a nested browsing context, or as an external resource to be processed by a plugin.
class object_(html_tag): ''' The object element can represent an external resource, which, depending on the type of the resource, will either be treated as an image, as a nested browsing context, or as an external resource to be processed by a plugin. ''' pass
(*args, **kwargs)
49,075
dominate.tags
ol
The ol element represents a list of items, where the items have been intentionally ordered, such that changing the order would change the meaning of the document.
class ol(html_tag): ''' The ol element represents a list of items, where the items have been intentionally ordered, such that changing the order would change the meaning of the document. ''' pass
(*args, **kwargs)
49,109
easul.data
one_hot_encoding
null
def one_hot_encoding(field_name, dinput): return single_field_data_to_np_values(dinput.data[field_name], dinput.schema[field_name])
(field_name, dinput)
49,111
dominate.tags
optgroup
The optgroup element represents a group of option elements with a common label.
class optgroup(html_tag): ''' The optgroup element represents a group of option elements with a common label. ''' pass
(*args, **kwargs)
49,145
dominate.tags
option
The option element represents an option in a select element or as part of a list of suggestions in a datalist element.
class option(html_tag): ''' The option element represents an option in a select element or as part of a list of suggestions in a datalist element. ''' pass
(*args, **kwargs)
49,181
dominate.tags
output
The output element represents the result of a calculation.
class output(html_tag): ''' The output element represents the result of a calculation. ''' pass
(*args, **kwargs)
49,215
dominate.tags
p
The p element represents a paragraph.
class p(html_tag): ''' The p element represents a paragraph. ''' pass
(*args, **kwargs)
49,249
dominate.tags
param
The param element defines parameters for plugins invoked by object elements. It does not represent anything on its own.
class param(html_tag): ''' The param element defines parameters for plugins invoked by object elements. It does not represent anything on its own. ''' is_single = True
(*args, **kwargs)
49,286
dominate.tags
pre
The pre element represents a block of preformatted text, in which structure is represented by typographic conventions rather than by elements.
class pre(html_tag): ''' The pre element represents a block of preformatted text, in which structure is represented by typographic conventions rather than by elements. ''' is_pretty = False
(*args, **kwargs)
49,322
dominate.tags
progress
The progress element represents the completion progress of a task. The progress is either indeterminate, indicating that progress is being made but that it is not clear how much more work remains to be done before the task is complete (e.g. because the task is waiting for a remote host to respond), or the progress is a number in the range zero to a maximum, giving the fraction of work that has so far been completed.
class progress(html_tag): ''' The progress element represents the completion progress of a task. The progress is either indeterminate, indicating that progress is being made but that it is not clear how much more work remains to be done before the task is complete (e.g. because the task is waiting for a remote host to respond), or the progress is a number in the range zero to a maximum, giving the fraction of work that has so far been completed. ''' pass
(*args, **kwargs)
49,356
dominate.tags
q
The q element represents some phrasing content quoted from another source.
class q(html_tag): ''' The q element represents some phrasing content quoted from another source. ''' pass
(*args, **kwargs)
49,393
dominate.tags
rp
The rp element can be used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don't support ruby annotations.
class rp(html_tag): ''' The rp element can be used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don't support ruby annotations. ''' pass
(*args, **kwargs)
49,427
dominate.tags
rt
The rt element marks the ruby text component of a ruby annotation.
class rt(html_tag): ''' The rt element marks the ruby text component of a ruby annotation. ''' pass
(*args, **kwargs)
49,461
dominate.tags
ruby
The ruby element allows one or more spans of phrasing content to be marked with ruby annotations. Ruby annotations are short runs of text presented alongside base text, primarily used in East Asian typography as a guide for pronunciation or to include other annotations. In Japanese, this form of typography is also known as furigana.
class ruby(html_tag): ''' The ruby element allows one or more spans of phrasing content to be marked with ruby annotations. Ruby annotations are short runs of text presented alongside base text, primarily used in East Asian typography as a guide for pronunciation or to include other annotations. In Japanese, this form of typography is also known as furigana. ''' pass
(*args, **kwargs)
49,496
easul.run
run_step_chain
Run the chain of steps iterative which start at next_step. Args: next_step: driver: previous_outcome: Returns:
def run_step_chain(next_step, driver, previous_outcome=None): """ Run the chain of steps iterative which start at next_step. Args: next_step: driver: previous_outcome: Returns: """ outcome = next_step.run_all(driver, previous_outcome=previous_outcome) if not outcome: LOG.info(f"[{driver.journey.get('reference')}:END] - no outcome") return if not outcome.next_step: if is_successful_outcome(outcome) and driver.journey.get("complete") != 1: LOG.error( f"Journey '{driver.journey.get('reference')}' is not marked complete, but no next step was obtained from latest step {next_step}") return if isinstance(outcome, PauseOutcome): return run_step_chain(outcome.next_step, driver, previous_outcome = outcome)
(next_step, driver, previous_outcome=None)
49,497
easul.plan._plan
run_step_logic
Main function used by Args: step: Step to run event: ActionEvent passed in Returns:
def run_step_logic(step, event): """ Main function used by Args: step: Step to run event: ActionEvent passed in Returns: """ from easul.error import StepDataNotAvailable, InvalidStepData from easul.outcome import MissingDataOutcome, InvalidDataOutcome try: outcome = step.run_logic(event) event.outcome = outcome step._trigger_actions("after_run", event) return outcome except StepDataNotAvailable as ex: LOG.warning(f"[{ex.journey.get('reference')}:{step.name}] step data NOT available [status:WAITING]") event.driver.store_step(step.name, StepStatuses.WAITING, status_info=str(ex), timestamp=event.driver.clock.timestamp) step._trigger_actions("missing_data", event) if event.outcome: return event.outcome return MissingDataOutcome(outcome_step=step, reason=str(ex)) except InvalidStepData as ex: step._trigger_actions("invalid_data", event) if event.outcome: return event.outcome LOG.warning(f"[{ex.journey.get('reference')}:{step.name}] step data invalid [status:ERROR]") event.driver.store_step(step.name, StepStatuses.ERROR, status_info=str(ex), timestamp=event.driver.clock.timestamp) return InvalidDataOutcome(outcome_step=step, reason=str(ex))
(step, event)
49,498
dominate.tags
s
The s element represents contents that are no longer accurate or no longer relevant.
class s(html_tag): ''' The s element represents contents that are no longer accurate or no longer relevant. ''' pass
(*args, **kwargs)
49,532
dominate.tags
samp
The samp element represents (sample) output from a program or computing system.
class samp(html_tag): ''' The samp element represents (sample) output from a program or computing system. ''' pass
(*args, **kwargs)
49,566
dominate.tags
script
The script element allows authors to include dynamic script and data blocks in their documents. The element does not represent content for the user.
class script(html_tag): ''' The script element allows authors to include dynamic script and data blocks in their documents. The element does not represent content for the user. ''' is_pretty = False
(*args, **kwargs)
49,600
dominate.tags
section
The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.
class section(html_tag): ''' The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading. ''' pass
(*args, **kwargs)
49,634
dominate.tags
select
The select element represents a control for selecting amongst a set of options.
class select(html_tag): ''' The select element represents a control for selecting amongst a set of options. ''' pass
(*args, **kwargs)
49,668
easul.util
single_field_data_to_np_values
null
def single_field_data_to_np_values(field_values, field_details): allowed_values = np.array(list(field_details.get("options").keys())) cls_to_idx = {v:idx for idx, v in enumerate(allowed_values)} np_values = [cls_to_idx.get(v) for v in field_values] num_classes = len(cls_to_idx) return to_categorical(np_values, num_classes)
(field_values, field_details)
49,669
dominate.tags
small
The small element represents side comments such as small print.
class small(html_tag): ''' The small element represents side comments such as small print. ''' pass
(*args, **kwargs)
49,703
stringcase
snakecase
Convert string into snake case. Join punctuation with underscore Args: string: String to convert. Returns: string: Snake cased string.
def snakecase(string): """Convert string into snake case. Join punctuation with underscore Args: string: String to convert. Returns: string: Snake cased string. """ string = re.sub(r"[\-\.\s]", '_', str(string)) if not string: return string return lowercase(string[0]) + re.sub(r"[A-Z]", lambda matched: '_' + lowercase(matched.group(0)), string[1:])
(string)
49,704
dominate.tags
source
The source element allows authors to specify multiple alternative media resources for media elements. It does not represent anything on its own.
class source(html_tag): ''' The source element allows authors to specify multiple alternative media resources for media elements. It does not represent anything on its own. ''' is_single = True
(*args, **kwargs)
49,738
dominate.tags
span
The span element doesn't mean anything on its own, but can be useful when used together with the global attributes, e.g. class, lang, or dir. It represents its children.
class span(html_tag): ''' The span element doesn't mean anything on its own, but can be useful when used together with the global attributes, e.g. class, lang, or dir. It represents its children. ''' pass
(*args, **kwargs)
49,774
dominate.tags
strong
The strong element represents strong importance for its contents.
class strong(html_tag): ''' The strong element represents strong importance for its contents. ''' pass
(*args, **kwargs)
49,808
dominate.tags
style
The style element allows authors to embed style information in their documents. The style element is one of several inputs to the styling processing model. The element does not represent content for the user.
class style(html_tag): ''' The style element allows authors to embed style information in their documents. The style element is one of several inputs to the styling processing model. The element does not represent content for the user. ''' is_pretty = False
(*args, **kwargs)
49,842
dominate.tags
sub
The sub element represents a subscript.
class sub(html_tag): ''' The sub element represents a subscript. ''' pass
(*args, **kwargs)
49,876
easul.visual.draw.style
suggest_text_color_from_fill
null
def suggest_text_color_from_fill(fill): # Used simpler approach than W3C recommended approach. See: # https://stackoverjourney.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color r, g, b = ImageColor.getcolor(fill, "RGB") if (r * 0.299 + g * 0.587 + b * 0.114) > 186: return "black" else: return "white"
(fill)
49,877
dominate.tags
summary
The summary element represents a summary, caption, or legend for the rest of the contents of the summary element's parent details element, if any.
class summary(html_tag): ''' The summary element represents a summary, caption, or legend for the rest of the contents of the summary element's parent details element, if any. ''' pass
(*args, **kwargs)
49,911
dominate.tags
sup
The sup element represents a superscript.
class sup(html_tag): ''' The sup element represents a superscript. ''' pass
(*args, **kwargs)
49,945
dominate.tags
table
The table element represents data with more than one dimension, in the form of a table.
class table(html_tag): ''' The table element represents data with more than one dimension, in the form of a table. ''' pass
(*args, **kwargs)
49,979
dominate.tags
tbody
The tbody element represents a block of rows that consist of a body of data for the parent table element, if the tbody element has a parent and it is a table.
class tbody(html_tag): ''' The tbody element represents a block of rows that consist of a body of data for the parent table element, if the tbody element has a parent and it is a table. ''' pass
(*args, **kwargs)
50,013
dominate.tags
td
The td element represents a data cell in a table.
class td(html_tag): ''' The td element represents a data cell in a table. ''' pass
(*args, **kwargs)
50,047
dominate.tags
textarea
The textarea element represents a multiline plain text edit control for the element's raw value. The contents of the control represent the control's default value.
class textarea(html_tag): ''' The textarea element represents a multiline plain text edit control for the element's raw value. The contents of the control represent the control's default value. ''' pass
(*args, **kwargs)
50,081
dominate.tags
tfoot
The tfoot element represents the block of rows that consist of the column summaries (footers) for the parent table element, if the tfoot element has a parent and it is a table.
class tfoot(html_tag): ''' The tfoot element represents the block of rows that consist of the column summaries (footers) for the parent table element, if the tfoot element has a parent and it is a table. ''' pass
(*args, **kwargs)
50,115
dominate.tags
th
The th element represents a header cell in a table.
class th(html_tag): ''' The th element represents a header cell in a table. ''' pass
(*args, **kwargs)
50,149
dominate.tags
thead
The thead element represents the block of rows that consist of the column labels (headers) for the parent table element, if the thead element has a parent and it is a table.
class thead(html_tag): ''' The thead element represents the block of rows that consist of the column labels (headers) for the parent table element, if the thead element has a parent and it is a table. ''' pass
(*args, **kwargs)
50,184
dominate.tags
time_
The time element represents either a time on a 24 hour clock, or a precise date in the proleptic Gregorian calendar, optionally with a time and a time-zone offset.
class time_(html_tag): ''' The time element represents either a time on a 24 hour clock, or a precise date in the proleptic Gregorian calendar, optionally with a time and a time-zone offset. ''' pass
(*args, **kwargs)
50,218
dominate.tags
title
The title element represents the document's title or name. Authors should use titles that identify their documents even when they are used out of context, for example in a user's history or bookmarks, or in search results. The document's title is often different from its first heading, since the first heading does not have to stand alone when taken out of context.
class title(html_tag): ''' The title element represents the document's title or name. Authors should use titles that identify their documents even when they are used out of context, for example in a user's history or bookmarks, or in search results. The document's title is often different from its first heading, since the first heading does not have to stand alone when taken out of context. ''' def _get_text(self): return u''.join(self.get(basestring)) def _set_text(self, text): self.clear() self.add(text) text = property(_get_text, _set_text)
(*args, **kwargs)
50,238
dominate.tags
_get_text
null
def _get_text(self): return u''.join(self.get(basestring))
(self)
50,241
dominate.tags
_set_text
null
def _set_text(self, text): self.clear() self.add(text)
(self, text)
50,254
easul.data
to_boolean
Tries to convert a numeric value or string (e.g. 0 or 1) to a boolean Args: value: Input value details: Returns:
def to_boolean(value, details): """ Tries to convert a numeric value or string (e.g. 0 or 1) to a boolean Args: value: Input value details: Returns: """ if value is None: return None if type(value) is str: if value=="": return None value = np.int64(value) return bool(value)
(value, details)
50,255
easul.data
to_float
Tries to convert a value to a float Args: value: Input value details: Returns:
def to_float(value, details): """ Tries to convert a value to a float Args: value: Input value details: Returns: """ if value is None: return None if value == "": return None if type(value) is bool: value = bool(value) return float(value)
(value, details)
50,256
easul.util
to_np_values
Converts values to numpy values for provided fields and definitions. Args: field_values: fields: Returns:
def to_np_values(field_values, fields): """ Converts values to numpy values for provided fields and definitions. Args: field_values: fields: Returns: """ x_values = [] for field_name, field_details in fields.items(): field_type = field_details['type'] if field_type == "list": allowed_values = np.array(field_details.get("options"),dtype='int') allowed_values = allowed_values.ravel() num_classes = np.max(allowed_values) + 1 x_values.append(to_categorical(field_values[field_name], num_classes)) else: x_values.append([float64(field_values[field_name])]) return list(chain.from_iterable(x_values))
(field_values, fields)
50,257
dominate.tags
tr
The tr element represents a row of cells in a table.
class tr(html_tag): ''' The tr element represents a row of cells in a table. ''' pass
(*args, **kwargs)
50,291
dominate.tags
track
The track element allows authors to specify explicit external timed text tracks for media elements. It does not represent anything on its own.
class track(html_tag): ''' The track element allows authors to specify explicit external timed text tracks for media elements. It does not represent anything on its own. ''' is_single = True
(*args, **kwargs)
50,325
dominate.tags
u
The u element represents a span of text with an unarticulated, though explicitly rendered, non-textual annotation, such as labeling the text as being a proper name in Chinese text (a Chinese proper name mark), or labeling the text as being misspelt.
class u(html_tag): ''' The u element represents a span of text with an unarticulated, though explicitly rendered, non-textual annotation, such as labeling the text as being a proper name in Chinese text (a Chinese proper name mark), or labeling the text as being misspelt. ''' pass
(*args, **kwargs)
50,359
dominate.tags
ul
The ul element represents a list of items, where the order of the items is not important - that is, where changing the order would not materially change the meaning of the document.
class ul(html_tag): ''' The ul element represents a list of items, where the order of the items is not important - that is, where changing the order would not materially change the meaning of the document. ''' pass
(*args, **kwargs)
50,395
dominate.tags
var
The var element represents a variable. This could be an actual variable in a mathematical expression or programming context, an identifier representing a constant, a function parameter, or just be a term used as a placeholder in prose.
class var(html_tag): ''' The var element represents a variable. This could be an actual variable in a mathematical expression or programming context, an identifier representing a constant, a function parameter, or just be a term used as a placeholder in prose. ''' pass
(*args, **kwargs)
50,429
dominate.tags
video
A video element is used for playing videos or movies, and audio files with captions.
class video(html_tag): ''' A video element is used for playing videos or movies, and audio files with captions. ''' pass
(*args, **kwargs)
50,464
dominate.tags
wbr
The wbr element represents a line break opportunity.
class wbr(html_tag): ''' The wbr element represents a line break opportunity. ''' is_single = True is_inline = True
(*args, **kwargs)
50,498
ctypes
CFunctionType
null
def PYFUNCTYPE(restype, *argtypes): class CFunctionType(_CFuncPtr): _argtypes_ = argtypes _restype_ = restype _flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI return CFunctionType
null
50,499
capstone
Cs
null
class Cs(object): def __init__(self, arch, mode): # verify version compatibility with the core before doing anything (major, minor, _combined) = cs_version() if major != CS_API_MAJOR or minor != CS_API_MINOR: self.csh = None # our binding version is different from the core's API version raise CsError(CS_ERR_VERSION) self.arch, self._mode = arch, mode self.csh = ctypes.c_size_t() status = _cs.cs_open(arch, mode, ctypes.byref(self.csh)) if status != CS_ERR_OK: self.csh = None raise CsError(status) try: from . import ccapstone # rewire disasm to use the faster version self.disasm = ccapstone.Cs(self).disasm except: pass if arch == CS_ARCH_X86: # Intel syntax is default for X86 self._syntax = CS_OPT_SYNTAX_INTEL else: self._syntax = None self._detail = False # by default, do not produce instruction details self._imm_unsigned = False # by default, print immediate operands as signed numbers self._diet = cs_support(CS_SUPPORT_DIET) self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE) # default mnemonic for SKIPDATA self._skipdata_mnem = ".byte" self._skipdata_cb = (None, None) # store reference to option object to avoid it being freed # because C code uses it by reference self._skipdata_opt = _cs_opt_skipdata() self._skipdata = False # destructor to be called automatically when object is destroyed. def __del__(self): if self.csh: try: status = _cs.cs_close(ctypes.byref(self.csh)) if status != CS_ERR_OK: raise CsError(status) except: # _cs might be pulled from under our feet pass # def option(self, opt_type, opt_value): # return _cs.cs_option(self.csh, opt_type, opt_value) # is this a diet engine? @property def diet(self): return self._diet # is this engine compiled with X86-reduce option? @property def x86_reduce(self): return self._x86reduce # return assembly syntax. @property def syntax(self): return self._syntax # syntax setter: modify assembly syntax. @syntax.setter def syntax(self, style): status = _cs.cs_option(self.csh, CS_OPT_SYNTAX, style) if status != CS_ERR_OK: raise CsError(status) # save syntax self._syntax = style # return current skipdata status @property def skipdata(self): return self._skipdata # setter: modify skipdata status @skipdata.setter def skipdata(self, opt): if opt == False: status = _cs.cs_option(self.csh, CS_OPT_SKIPDATA, CS_OPT_OFF) else: status = _cs.cs_option(self.csh, CS_OPT_SKIPDATA, CS_OPT_ON) if status != CS_ERR_OK: raise CsError(status) # save this option self._skipdata = opt @property def skipdata_setup(self): return (self._skipdata_mnem,) + self._skipdata_cb @skipdata_setup.setter def skipdata_setup(self, opt): _mnem, _cb, _ud = opt self._skipdata_opt.mnemonic = _mnem.encode() self._skipdata_opt.callback = CS_SKIPDATA_CALLBACK(_cb or 0) self._skipdata_opt.user_data = ctypes.cast(_ud, ctypes.c_void_p) status = _cs.cs_option(self.csh, CS_OPT_SKIPDATA_SETUP, ctypes.cast(ctypes.byref(self._skipdata_opt), ctypes.c_void_p)) if status != CS_ERR_OK: raise CsError(status) self._skipdata_mnem = _mnem self._skipdata_cb = (_cb, _ud) @property def skipdata_mnem(self): return self._skipdata_mnem @skipdata_mnem.setter def skipdata_mnem(self, mnem): self.skipdata_setup = (mnem,) + self._skipdata_cb @property def skipdata_callback(self): return self._skipdata_cb @skipdata_callback.setter def skipdata_callback(self, val): if not isinstance(val, tuple): val = (val, None) func, data = val self.skipdata_setup = (self._skipdata_mnem, func, data) # customize instruction mnemonic def mnemonic_setup(self, id, mnem): _mnem_opt = _cs_opt_mnem() _mnem_opt.id = id if mnem: _mnem_opt.mnemonic = mnem.encode() else: _mnem_opt.mnemonic = mnem status = _cs.cs_option(self.csh, CS_OPT_MNEMONIC, ctypes.cast(ctypes.byref(_mnem_opt), ctypes.c_void_p)) if status != CS_ERR_OK: raise CsError(status) # check to see if this engine supports a particular arch, # or diet mode (depending on @query). def support(self, query): return cs_support(query) # is detail mode enable? @property def detail(self): return self._detail # modify detail mode. @detail.setter def detail(self, opt): # opt is boolean type, so must be either 'True' or 'False' if opt == False: status = _cs.cs_option(self.csh, CS_OPT_DETAIL, CS_OPT_OFF) else: status = _cs.cs_option(self.csh, CS_OPT_DETAIL, CS_OPT_ON) if status != CS_ERR_OK: raise CsError(status) # save detail self._detail = opt # is detail mode enable? @property def imm_unsigned(self): return self._imm_unsigned # modify detail mode. @imm_unsigned.setter def imm_unsigned(self, opt): # opt is boolean type, so must be either 'True' or 'False' if opt == False: status = _cs.cs_option(self.csh, CS_OPT_UNSIGNED, CS_OPT_OFF) else: status = _cs.cs_option(self.csh, CS_OPT_UNSIGNED, CS_OPT_ON) if status != CS_ERR_OK: raise CsError(status) # save detail self._imm_unsigned = opt # return disassembly mode of this engine. @property def mode(self): return self._mode # modify engine's mode at run-time. @mode.setter def mode(self, opt): # opt is new disasm mode, of int type status = _cs.cs_option(self.csh, CS_OPT_MODE, opt) if status != CS_ERR_OK: raise CsError(status) # save mode self._mode = opt # get the last error code def errno(self): return _cs.cs_errno(self.csh) # get the register name, given the register ID def reg_name(self, reg_id, default=None): if self._diet: # Diet engine cannot provide register name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_reg_name(self.csh, reg_id), default) # get the instruction name, given the instruction ID def insn_name(self, insn_id, default=None): if self._diet: # Diet engine cannot provide instruction name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_insn_name(self.csh, insn_id), default) # get the group name def group_name(self, group_id, default=None): if self._diet: # Diet engine cannot provide group name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_group_name(self.csh, group_id), default) # Disassemble binary & return disassembled instructions in CsInsn objects def disasm(self, code, offset, count=0): all_insn = ctypes.POINTER(_cs_insn)() '''if not _python2: print(code) code = code.encode() print(code)''' # Pass a bytearray by reference size = len(code) view = memoryview(code) if not view.readonly: code = ctypes.byref(ctypes.c_char.from_buffer(view)) elif not isinstance(code, bytes): code = view.tobytes() res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn)) if res > 0: try: for i in range(res): yield CsInsn(self, all_insn[i]) finally: _cs.cs_free(all_insn, res) else: status = _cs.cs_errno(self.csh) if status != CS_ERR_OK: raise CsError(status) return yield # Light function to disassemble binary. This is about 20% faster than disasm() because # unlike disasm(), disasm_lite() only return tuples of (address, size, mnemonic, op_str), # rather than CsInsn objects. def disasm_lite(self, code, offset, count=0): if self._diet: # Diet engine cannot provide @mnemonic & @op_str raise CsError(CS_ERR_DIET) all_insn = ctypes.POINTER(_cs_insn)() size = len(code) # Pass a bytearray by reference view = memoryview(code) if not view.readonly: code = ctypes.byref(ctypes.c_char.from_buffer(view)) elif not isinstance(code, bytes): code = view.tobytes() res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn)) if res > 0: try: for i in range(res): insn = all_insn[i] yield (insn.address, insn.size, insn.mnemonic.decode('ascii'), insn.op_str.decode('ascii')) finally: _cs.cs_free(all_insn, res) else: status = _cs.cs_errno(self.csh) if status != CS_ERR_OK: raise CsError(status) return yield
(arch, mode)
50,500
capstone
__del__
null
def __del__(self): if self.csh: try: status = _cs.cs_close(ctypes.byref(self.csh)) if status != CS_ERR_OK: raise CsError(status) except: # _cs might be pulled from under our feet pass
(self)
50,501
capstone
__init__
null
def __init__(self, arch, mode): # verify version compatibility with the core before doing anything (major, minor, _combined) = cs_version() if major != CS_API_MAJOR or minor != CS_API_MINOR: self.csh = None # our binding version is different from the core's API version raise CsError(CS_ERR_VERSION) self.arch, self._mode = arch, mode self.csh = ctypes.c_size_t() status = _cs.cs_open(arch, mode, ctypes.byref(self.csh)) if status != CS_ERR_OK: self.csh = None raise CsError(status) try: from . import ccapstone # rewire disasm to use the faster version self.disasm = ccapstone.Cs(self).disasm except: pass if arch == CS_ARCH_X86: # Intel syntax is default for X86 self._syntax = CS_OPT_SYNTAX_INTEL else: self._syntax = None self._detail = False # by default, do not produce instruction details self._imm_unsigned = False # by default, print immediate operands as signed numbers self._diet = cs_support(CS_SUPPORT_DIET) self._x86reduce = cs_support(CS_SUPPORT_X86_REDUCE) # default mnemonic for SKIPDATA self._skipdata_mnem = ".byte" self._skipdata_cb = (None, None) # store reference to option object to avoid it being freed # because C code uses it by reference self._skipdata_opt = _cs_opt_skipdata() self._skipdata = False
(self, arch, mode)
50,502
capstone
disasm
null
def disasm(self, code, offset, count=0): all_insn = ctypes.POINTER(_cs_insn)() '''if not _python2: print(code) code = code.encode() print(code)''' # Pass a bytearray by reference size = len(code) view = memoryview(code) if not view.readonly: code = ctypes.byref(ctypes.c_char.from_buffer(view)) elif not isinstance(code, bytes): code = view.tobytes() res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn)) if res > 0: try: for i in range(res): yield CsInsn(self, all_insn[i]) finally: _cs.cs_free(all_insn, res) else: status = _cs.cs_errno(self.csh) if status != CS_ERR_OK: raise CsError(status) return yield
(self, code, offset, count=0)
50,503
capstone
disasm_lite
null
def disasm_lite(self, code, offset, count=0): if self._diet: # Diet engine cannot provide @mnemonic & @op_str raise CsError(CS_ERR_DIET) all_insn = ctypes.POINTER(_cs_insn)() size = len(code) # Pass a bytearray by reference view = memoryview(code) if not view.readonly: code = ctypes.byref(ctypes.c_char.from_buffer(view)) elif not isinstance(code, bytes): code = view.tobytes() res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn)) if res > 0: try: for i in range(res): insn = all_insn[i] yield (insn.address, insn.size, insn.mnemonic.decode('ascii'), insn.op_str.decode('ascii')) finally: _cs.cs_free(all_insn, res) else: status = _cs.cs_errno(self.csh) if status != CS_ERR_OK: raise CsError(status) return yield
(self, code, offset, count=0)
50,504
capstone
errno
null
def errno(self): return _cs.cs_errno(self.csh)
(self)
50,505
capstone
group_name
null
def group_name(self, group_id, default=None): if self._diet: # Diet engine cannot provide group name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_group_name(self.csh, group_id), default)
(self, group_id, default=None)
50,506
capstone
insn_name
null
def insn_name(self, insn_id, default=None): if self._diet: # Diet engine cannot provide instruction name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_insn_name(self.csh, insn_id), default)
(self, insn_id, default=None)
50,507
capstone
mnemonic_setup
null
def mnemonic_setup(self, id, mnem): _mnem_opt = _cs_opt_mnem() _mnem_opt.id = id if mnem: _mnem_opt.mnemonic = mnem.encode() else: _mnem_opt.mnemonic = mnem status = _cs.cs_option(self.csh, CS_OPT_MNEMONIC, ctypes.cast(ctypes.byref(_mnem_opt), ctypes.c_void_p)) if status != CS_ERR_OK: raise CsError(status)
(self, id, mnem)
50,508
capstone
reg_name
null
def reg_name(self, reg_id, default=None): if self._diet: # Diet engine cannot provide register name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_reg_name(self.csh, reg_id), default)
(self, reg_id, default=None)
50,509
capstone
support
null
def support(self, query): return cs_support(query)
(self, query)
50,510
capstone
CsError
null
class CsError(Exception): def __init__(self, errno): self.errno = errno if _python2: def __str__(self): return _cs.cs_strerror(self.errno) else: def __str__(self): return _cs.cs_strerror(self.errno).decode()
(errno)
50,511
capstone
__init__
null
def __init__(self, errno): self.errno = errno
(self, errno)
50,512
capstone
__str__
null
def __str__(self): return _cs.cs_strerror(self.errno).decode()
(self)
50,513
capstone
CsInsn
null
class CsInsn(object): def __init__(self, cs, all_info): self._raw = copy_ctypes(all_info) self._cs = cs if self._cs._detail and self._raw.id != 0: # save detail self._raw.detail = ctypes.pointer(all_info.detail._type_()) ctypes.memmove(ctypes.byref(self._raw.detail[0]), ctypes.byref(all_info.detail[0]), ctypes.sizeof(type(all_info.detail[0]))) def __repr__(self): return '<CsInsn 0x%x [%s]: %s %s>' % (self.address, self.bytes.hex(), self.mnemonic, self.op_str) # return instruction's ID. @property def id(self): return self._raw.id # return instruction's address. @property def address(self): return self._raw.address # return instruction's size. @property def size(self): return self._raw.size # return instruction's machine bytes (which should have @size bytes). @property def bytes(self): return bytearray(self._raw.bytes)[:self._raw.size] # return instruction's mnemonic. @property def mnemonic(self): if self._cs._diet: # Diet engine cannot provide @mnemonic. raise CsError(CS_ERR_DIET) return self._raw.mnemonic.decode('ascii') # return instruction's operands (in string). @property def op_str(self): if self._cs._diet: # Diet engine cannot provide @op_str. raise CsError(CS_ERR_DIET) return self._raw.op_str.decode('ascii') # return list of all implicit registers being read. @property def regs_read(self): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide @regs_read. raise CsError(CS_ERR_DIET) if self._cs._detail: return self._raw.detail.contents.regs_read[:self._raw.detail.contents.regs_read_count] raise CsError(CS_ERR_DETAIL) # return list of all implicit registers being modified @property def regs_write(self): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide @regs_write raise CsError(CS_ERR_DIET) if self._cs._detail: return self._raw.detail.contents.regs_write[:self._raw.detail.contents.regs_write_count] raise CsError(CS_ERR_DETAIL) # return list of semantic groups this instruction belongs to. @property def groups(self): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide @groups raise CsError(CS_ERR_DIET) if self._cs._detail: return self._raw.detail.contents.groups[:self._raw.detail.contents.groups_count] raise CsError(CS_ERR_DETAIL) def __gen_detail(self): if self._raw.id == 0: # do nothing in skipdata mode return arch = self._cs.arch if arch == CS_ARCH_ARM: (self.usermode, self.vector_size, self.vector_data, self.cps_mode, self.cps_flag, self.cc, self.update_flags, \ self.writeback, self.post_index, self.mem_barrier, self.operands) = arm.get_arch_info(self._raw.detail.contents.arch.arm) elif arch == CS_ARCH_ARM64: (self.cc, self.update_flags, self.writeback, self.post_index, self.operands) = \ arm64.get_arch_info(self._raw.detail.contents.arch.arm64) elif arch == CS_ARCH_X86: (self.prefix, self.opcode, self.rex, self.addr_size, \ self.modrm, self.sib, self.disp, \ self.sib_index, self.sib_scale, self.sib_base, self.xop_cc, self.sse_cc, \ self.avx_cc, self.avx_sae, self.avx_rm, self.eflags, self.fpu_flags, \ self.encoding, self.modrm_offset, self.disp_offset, self.disp_size, self.imm_offset, self.imm_size, \ self.operands) = x86.get_arch_info(self._raw.detail.contents.arch.x86) elif arch == CS_ARCH_M68K: (self.operands, self.op_size) = m68k.get_arch_info(self._raw.detail.contents.arch.m68k) elif arch == CS_ARCH_MIPS: self.operands = mips.get_arch_info(self._raw.detail.contents.arch.mips) elif arch == CS_ARCH_PPC: (self.bc, self.bh, self.update_cr0, self.operands) = \ ppc.get_arch_info(self._raw.detail.contents.arch.ppc) elif arch == CS_ARCH_SPARC: (self.cc, self.hint, self.operands) = sparc.get_arch_info(self._raw.detail.contents.arch.sparc) elif arch == CS_ARCH_SYSZ: (self.cc, self.operands) = systemz.get_arch_info(self._raw.detail.contents.arch.sysz) elif arch == CS_ARCH_XCORE: (self.operands) = xcore.get_arch_info(self._raw.detail.contents.arch.xcore) elif arch == CS_ARCH_TMS320C64X: (self.condition, self.funit, self.parallel, self.operands) = tms320c64x.get_arch_info(self._raw.detail.contents.arch.tms320c64x) elif arch == CS_ARCH_M680X: (self.flags, self.operands) = m680x.get_arch_info(self._raw.detail.contents.arch.m680x) elif arch == CS_ARCH_EVM: (self.pop, self.push, self.fee) = evm.get_arch_info(self._raw.detail.contents.arch.evm) elif arch == CS_ARCH_MOS65XX: (self.am, self.modifies_flags, self.operands) = mos65xx.get_arch_info(self._raw.detail.contents.arch.mos65xx) elif arch == CS_ARCH_WASM: (self.operands) = wasm.get_arch_info(self._raw.detail.contents.arch.wasm) elif arch == CS_ARCH_BPF: (self.operands) = bpf.get_arch_info(self._raw.detail.contents.arch.bpf) elif arch == CS_ARCH_RISCV: (self.need_effective_addr, self.operands) = riscv.get_arch_info(self._raw.detail.contents.arch.riscv) elif arch == CS_ARCH_SH: (self.sh_insn, self.sh_size, self.operands) = sh.get_arch_info(self._raw.detail.contents.arch.sh) elif arch == CS_ARCH_TRICORE: (self.update_flags, self.operands) = tricore.get_arch_info(self._raw.detail.contents.arch.tricore) def __getattr__(self, name): if not self._cs._detail: raise CsError(CS_ERR_DETAIL) attr = object.__getattribute__ if not attr(self, '_cs')._detail: raise AttributeError(name) _dict = attr(self, '__dict__') if 'operands' not in _dict: self.__gen_detail() if name not in _dict: if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) raise AttributeError(name) return _dict[name] # get the last error code def errno(self): return _cs.cs_errno(self._cs.csh) # get the register name, given the register ID def reg_name(self, reg_id, default=None): if self._cs._diet: # Diet engine cannot provide register name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_reg_name(self._cs.csh, reg_id), default) # get the instruction name def insn_name(self, default=None): if self._cs._diet: # Diet engine cannot provide instruction name raise CsError(CS_ERR_DIET) if self._raw.id == 0: return default return _ascii_name_or_default(_cs.cs_insn_name(self._cs.csh, self.id), default) # get the group name def group_name(self, group_id, default=None): if self._cs._diet: # Diet engine cannot provide group name raise CsError(CS_ERR_DIET) return _ascii_name_or_default(_cs.cs_group_name(self._cs.csh, group_id), default) # verify if this insn belong to group with id as @group_id def group(self, group_id): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide group information raise CsError(CS_ERR_DIET) return group_id in self.groups # verify if this instruction implicitly read register @reg_id def reg_read(self, reg_id): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide regs_read information raise CsError(CS_ERR_DIET) return reg_id in self.regs_read # verify if this instruction implicitly modified register @reg_id def reg_write(self, reg_id): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) if self._cs._diet: # Diet engine cannot provide regs_write information raise CsError(CS_ERR_DIET) return reg_id in self.regs_write # return number of operands having same operand type @op_type def op_count(self, op_type): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) c = 0 for op in self.operands: if op.type == op_type: c += 1 return c # get the operand at position @position of all operands having the same type @op_type def op_find(self, op_type, position): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) c = 0 for op in self.operands: if op.type == op_type: c += 1 if c == position: return op # Return (list-of-registers-read, list-of-registers-modified) by this instructions. # This includes all the implicit & explicit registers. def regs_access(self): if self._raw.id == 0: raise CsError(CS_ERR_SKIPDATA) regs_read = (ctypes.c_uint16 * 64)() regs_read_count = ctypes.c_uint8() regs_write = (ctypes.c_uint16 * 64)() regs_write_count = ctypes.c_uint8() status = _cs.cs_regs_access(self._cs.csh, self._raw, ctypes.byref(regs_read), ctypes.byref(regs_read_count), ctypes.byref(regs_write), ctypes.byref(regs_write_count)) if status != CS_ERR_OK: raise CsError(status) if regs_read_count.value > 0: regs_read = regs_read[:regs_read_count.value] else: regs_read = [] if regs_write_count.value > 0: regs_write = regs_write[:regs_write_count.value] else: regs_write = [] return (regs_read, regs_write)
(cs, all_info)
50,514
capstone
__gen_detail
null
def __gen_detail(self): if self._raw.id == 0: # do nothing in skipdata mode return arch = self._cs.arch if arch == CS_ARCH_ARM: (self.usermode, self.vector_size, self.vector_data, self.cps_mode, self.cps_flag, self.cc, self.update_flags, \ self.writeback, self.post_index, self.mem_barrier, self.operands) = arm.get_arch_info(self._raw.detail.contents.arch.arm) elif arch == CS_ARCH_ARM64: (self.cc, self.update_flags, self.writeback, self.post_index, self.operands) = \ arm64.get_arch_info(self._raw.detail.contents.arch.arm64) elif arch == CS_ARCH_X86: (self.prefix, self.opcode, self.rex, self.addr_size, \ self.modrm, self.sib, self.disp, \ self.sib_index, self.sib_scale, self.sib_base, self.xop_cc, self.sse_cc, \ self.avx_cc, self.avx_sae, self.avx_rm, self.eflags, self.fpu_flags, \ self.encoding, self.modrm_offset, self.disp_offset, self.disp_size, self.imm_offset, self.imm_size, \ self.operands) = x86.get_arch_info(self._raw.detail.contents.arch.x86) elif arch == CS_ARCH_M68K: (self.operands, self.op_size) = m68k.get_arch_info(self._raw.detail.contents.arch.m68k) elif arch == CS_ARCH_MIPS: self.operands = mips.get_arch_info(self._raw.detail.contents.arch.mips) elif arch == CS_ARCH_PPC: (self.bc, self.bh, self.update_cr0, self.operands) = \ ppc.get_arch_info(self._raw.detail.contents.arch.ppc) elif arch == CS_ARCH_SPARC: (self.cc, self.hint, self.operands) = sparc.get_arch_info(self._raw.detail.contents.arch.sparc) elif arch == CS_ARCH_SYSZ: (self.cc, self.operands) = systemz.get_arch_info(self._raw.detail.contents.arch.sysz) elif arch == CS_ARCH_XCORE: (self.operands) = xcore.get_arch_info(self._raw.detail.contents.arch.xcore) elif arch == CS_ARCH_TMS320C64X: (self.condition, self.funit, self.parallel, self.operands) = tms320c64x.get_arch_info(self._raw.detail.contents.arch.tms320c64x) elif arch == CS_ARCH_M680X: (self.flags, self.operands) = m680x.get_arch_info(self._raw.detail.contents.arch.m680x) elif arch == CS_ARCH_EVM: (self.pop, self.push, self.fee) = evm.get_arch_info(self._raw.detail.contents.arch.evm) elif arch == CS_ARCH_MOS65XX: (self.am, self.modifies_flags, self.operands) = mos65xx.get_arch_info(self._raw.detail.contents.arch.mos65xx) elif arch == CS_ARCH_WASM: (self.operands) = wasm.get_arch_info(self._raw.detail.contents.arch.wasm) elif arch == CS_ARCH_BPF: (self.operands) = bpf.get_arch_info(self._raw.detail.contents.arch.bpf) elif arch == CS_ARCH_RISCV: (self.need_effective_addr, self.operands) = riscv.get_arch_info(self._raw.detail.contents.arch.riscv) elif arch == CS_ARCH_SH: (self.sh_insn, self.sh_size, self.operands) = sh.get_arch_info(self._raw.detail.contents.arch.sh) elif arch == CS_ARCH_TRICORE: (self.update_flags, self.operands) = tricore.get_arch_info(self._raw.detail.contents.arch.tricore)
(self)