id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
43,600
campaignmonitor/createsend-python
lib/createsend/segment.py
Segment.subscribers
def subscribers(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_information=False): """Gets the active subscribers in this segment.""" params = { "date": date, "page": page, "pagesize": page_size, "orderf...
python
def subscribers(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_information=False): """Gets the active subscribers in this segment.""" params = { "date": date, "page": page, "pagesize": page_size, "orderf...
[ "def", "subscribers", "(", "self", ",", "date", "=", "\"\"", ",", "page", "=", "1", ",", "page_size", "=", "1000", ",", "order_field", "=", "\"email\"", ",", "order_direction", "=", "\"asc\"", ",", "include_tracking_information", "=", "False", ")", ":", "p...
Gets the active subscribers in this segment.
[ "Gets", "the", "active", "subscribers", "in", "this", "segment", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/segment.py#L39-L50
43,601
campaignmonitor/createsend-python
lib/createsend/template.py
Template.create
def create(self, client_id, name, html_url, zip_url): """Creates a new email template.""" body = { "Name": name, "HtmlPageURL": html_url, "ZipFileURL": zip_url} response = self._post("/templates/%s.json" % client_id, json.dumps(bo...
python
def create(self, client_id, name, html_url, zip_url): """Creates a new email template.""" body = { "Name": name, "HtmlPageURL": html_url, "ZipFileURL": zip_url} response = self._post("/templates/%s.json" % client_id, json.dumps(bo...
[ "def", "create", "(", "self", ",", "client_id", ",", "name", ",", "html_url", ",", "zip_url", ")", ":", "body", "=", "{", "\"Name\"", ":", "name", ",", "\"HtmlPageURL\"", ":", "html_url", ",", "\"ZipFileURL\"", ":", "zip_url", "}", "response", "=", "self...
Creates a new email template.
[ "Creates", "a", "new", "email", "template", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/template.py#L16-L25
43,602
campaignmonitor/createsend-python
lib/createsend/template.py
Template.update
def update(self, name, html_url, zip_url): """Updates this email template.""" body = { "Name": name, "HtmlPageURL": html_url, "ZipFileURL": zip_url} response = self._put("/templates/%s.json" % self.template_id, json.dumps(body))
python
def update(self, name, html_url, zip_url): """Updates this email template.""" body = { "Name": name, "HtmlPageURL": html_url, "ZipFileURL": zip_url} response = self._put("/templates/%s.json" % self.template_id, json.dumps(body))
[ "def", "update", "(", "self", ",", "name", ",", "html_url", ",", "zip_url", ")", ":", "body", "=", "{", "\"Name\"", ":", "name", ",", "\"HtmlPageURL\"", ":", "html_url", ",", "\"ZipFileURL\"", ":", "zip_url", "}", "response", "=", "self", ".", "_put", ...
Updates this email template.
[ "Updates", "this", "email", "template", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/template.py#L32-L39
43,603
campaignmonitor/createsend-python
lib/createsend/administrator.py
Administrator.add
def add(self, email_address, name): """Adds an administrator to an account.""" body = { "EmailAddress": email_address, "Name": name} response = self._post("/admins.json", json.dumps(body)) return json_to_py(response)
python
def add(self, email_address, name): """Adds an administrator to an account.""" body = { "EmailAddress": email_address, "Name": name} response = self._post("/admins.json", json.dumps(body)) return json_to_py(response)
[ "def", "add", "(", "self", ",", "email_address", ",", "name", ")", ":", "body", "=", "{", "\"EmailAddress\"", ":", "email_address", ",", "\"Name\"", ":", "name", "}", "response", "=", "self", ".", "_post", "(", "\"/admins.json\"", ",", "json", ".", "dump...
Adds an administrator to an account.
[ "Adds", "an", "administrator", "to", "an", "account", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/administrator.py#L22-L28
43,604
campaignmonitor/createsend-python
lib/createsend/administrator.py
Administrator.update
def update(self, new_email_address, name): """Updates the details for an administrator.""" params = {"email": self.email_address} body = { "EmailAddress": new_email_address, "Name": name} response = self._put("/admins.json", body=json....
python
def update(self, new_email_address, name): """Updates the details for an administrator.""" params = {"email": self.email_address} body = { "EmailAddress": new_email_address, "Name": name} response = self._put("/admins.json", body=json....
[ "def", "update", "(", "self", ",", "new_email_address", ",", "name", ")", ":", "params", "=", "{", "\"email\"", ":", "self", ".", "email_address", "}", "body", "=", "{", "\"EmailAddress\"", ":", "new_email_address", ",", "\"Name\"", ":", "name", "}", "resp...
Updates the details for an administrator.
[ "Updates", "the", "details", "for", "an", "administrator", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/administrator.py#L30-L40
43,605
campaignmonitor/createsend-python
lib/createsend/administrator.py
Administrator.delete
def delete(self): """Deletes the administrator from the account.""" params = {"email": self.email_address} response = self._delete("/admins.json", params=params)
python
def delete(self): """Deletes the administrator from the account.""" params = {"email": self.email_address} response = self._delete("/admins.json", params=params)
[ "def", "delete", "(", "self", ")", ":", "params", "=", "{", "\"email\"", ":", "self", ".", "email_address", "}", "response", "=", "self", ".", "_delete", "(", "\"/admins.json\"", ",", "params", "=", "params", ")" ]
Deletes the administrator from the account.
[ "Deletes", "the", "administrator", "from", "the", "account", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/administrator.py#L42-L45
43,606
campaignmonitor/createsend-python
lib/createsend/list.py
List.create
def create(self, client_id, title, unsubscribe_page, confirmed_opt_in, confirmation_success_page, unsubscribe_setting="AllClientLists"): """Creates a new list for a client.""" body = { "Title": title, "UnsubscribePage": unsubscribe_page, "ConfirmedOptIn...
python
def create(self, client_id, title, unsubscribe_page, confirmed_opt_in, confirmation_success_page, unsubscribe_setting="AllClientLists"): """Creates a new list for a client.""" body = { "Title": title, "UnsubscribePage": unsubscribe_page, "ConfirmedOptIn...
[ "def", "create", "(", "self", ",", "client_id", ",", "title", ",", "unsubscribe_page", ",", "confirmed_opt_in", ",", "confirmation_success_page", ",", "unsubscribe_setting", "=", "\"AllClientLists\"", ")", ":", "body", "=", "{", "\"Title\"", ":", "title", ",", "...
Creates a new list for a client.
[ "Creates", "a", "new", "list", "for", "a", "client", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L17-L28
43,607
campaignmonitor/createsend-python
lib/createsend/list.py
List.create_custom_field
def create_custom_field(self, field_name, data_type, options=[], visible_in_preference_center=True): """Creates a new custom field for this list.""" body = { "FieldName": field_name, "DataType": data_type, "Options": options, "V...
python
def create_custom_field(self, field_name, data_type, options=[], visible_in_preference_center=True): """Creates a new custom field for this list.""" body = { "FieldName": field_name, "DataType": data_type, "Options": options, "V...
[ "def", "create_custom_field", "(", "self", ",", "field_name", ",", "data_type", ",", "options", "=", "[", "]", ",", "visible_in_preference_center", "=", "True", ")", ":", "body", "=", "{", "\"FieldName\"", ":", "field_name", ",", "\"DataType\"", ":", "data_typ...
Creates a new custom field for this list.
[ "Creates", "a", "new", "custom", "field", "for", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L34-L43
43,608
campaignmonitor/createsend-python
lib/createsend/list.py
List.update_custom_field
def update_custom_field(self, custom_field_key, field_name, visible_in_preference_center): """Updates a custom field belonging to this list.""" custom_field_key = quote(custom_field_key, '') body = { "FieldName": field_name, "VisibleInPreferenc...
python
def update_custom_field(self, custom_field_key, field_name, visible_in_preference_center): """Updates a custom field belonging to this list.""" custom_field_key = quote(custom_field_key, '') body = { "FieldName": field_name, "VisibleInPreferenc...
[ "def", "update_custom_field", "(", "self", ",", "custom_field_key", ",", "field_name", ",", "visible_in_preference_center", ")", ":", "custom_field_key", "=", "quote", "(", "custom_field_key", ",", "''", ")", "body", "=", "{", "\"FieldName\"", ":", "field_name", "...
Updates a custom field belonging to this list.
[ "Updates", "a", "custom", "field", "belonging", "to", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L45-L54
43,609
campaignmonitor/createsend-python
lib/createsend/list.py
List.delete_custom_field
def delete_custom_field(self, custom_field_key): """Deletes a custom field associated with this list.""" custom_field_key = quote(custom_field_key, '') response = self._delete("/lists/%s/customfields/%s.json" % (self.list_id, custom_field_key))
python
def delete_custom_field(self, custom_field_key): """Deletes a custom field associated with this list.""" custom_field_key = quote(custom_field_key, '') response = self._delete("/lists/%s/customfields/%s.json" % (self.list_id, custom_field_key))
[ "def", "delete_custom_field", "(", "self", ",", "custom_field_key", ")", ":", "custom_field_key", "=", "quote", "(", "custom_field_key", ",", "''", ")", "response", "=", "self", ".", "_delete", "(", "\"/lists/%s/customfields/%s.json\"", "%", "(", "self", ".", "l...
Deletes a custom field associated with this list.
[ "Deletes", "a", "custom", "field", "associated", "with", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L56-L60
43,610
campaignmonitor/createsend-python
lib/createsend/list.py
List.update_custom_field_options
def update_custom_field_options(self, custom_field_key, new_options, keep_existing_options): """Updates the options of a multi-optioned custom field on this list.""" custom_field_key = quote(custom_field_key, '') body = { "Options": new_options, ...
python
def update_custom_field_options(self, custom_field_key, new_options, keep_existing_options): """Updates the options of a multi-optioned custom field on this list.""" custom_field_key = quote(custom_field_key, '') body = { "Options": new_options, ...
[ "def", "update_custom_field_options", "(", "self", ",", "custom_field_key", ",", "new_options", ",", "keep_existing_options", ")", ":", "custom_field_key", "=", "quote", "(", "custom_field_key", ",", "''", ")", "body", "=", "{", "\"Options\"", ":", "new_options", ...
Updates the options of a multi-optioned custom field on this list.
[ "Updates", "the", "options", "of", "a", "multi", "-", "optioned", "custom", "field", "on", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L62-L70
43,611
campaignmonitor/createsend-python
lib/createsend/list.py
List.active
def active(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=False): """Gets the active subscribers for this list.""" params = { "date": date, "page": page, "pagesize": page_size, "orderfield": o...
python
def active(self, date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=False): """Gets the active subscribers for this list.""" params = { "date": date, "page": page, "pagesize": page_size, "orderfield": o...
[ "def", "active", "(", "self", ",", "date", "=", "\"\"", ",", "page", "=", "1", ",", "page_size", "=", "1000", ",", "order_field", "=", "\"email\"", ",", "order_direction", "=", "\"asc\"", ",", "include_tracking_preference", "=", "False", ")", ":", "params"...
Gets the active subscribers for this list.
[ "Gets", "the", "active", "subscribers", "for", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L92-L103
43,612
campaignmonitor/createsend-python
lib/createsend/list.py
List.update
def update(self, title, unsubscribe_page, confirmed_opt_in, confirmation_success_page, unsubscribe_setting="AllClientLists", add_unsubscribes_to_supp_list=False, scrub_active_with_supp_list=False): """Updates this list.""" body = { "Title": title, "U...
python
def update(self, title, unsubscribe_page, confirmed_opt_in, confirmation_success_page, unsubscribe_setting="AllClientLists", add_unsubscribes_to_supp_list=False, scrub_active_with_supp_list=False): """Updates this list.""" body = { "Title": title, "U...
[ "def", "update", "(", "self", ",", "title", ",", "unsubscribe_page", ",", "confirmed_opt_in", ",", "confirmation_success_page", ",", "unsubscribe_setting", "=", "\"AllClientLists\"", ",", "add_unsubscribes_to_supp_list", "=", "False", ",", "scrub_active_with_supp_list", "...
Updates this list.
[ "Updates", "this", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L157-L169
43,613
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.get
def get(self, list_id=None, email_address=None, include_tracking_preference=False): """Gets a subscriber by list ID and email address.""" params = { "email": email_address or self.email_address, "includetrackingpreference": include_tracking_preference, } response ...
python
def get(self, list_id=None, email_address=None, include_tracking_preference=False): """Gets a subscriber by list ID and email address.""" params = { "email": email_address or self.email_address, "includetrackingpreference": include_tracking_preference, } response ...
[ "def", "get", "(", "self", ",", "list_id", "=", "None", ",", "email_address", "=", "None", ",", "include_tracking_preference", "=", "False", ")", ":", "params", "=", "{", "\"email\"", ":", "email_address", "or", "self", ".", "email_address", ",", "\"includet...
Gets a subscriber by list ID and email address.
[ "Gets", "a", "subscriber", "by", "list", "ID", "and", "email", "address", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L17-L25
43,614
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.add
def add(self, list_id, email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False): """Adds a subscriber to a subscriber list.""" validate_consent_to_track(consent_to_track) body = { "EmailAddress": email_address, "N...
python
def add(self, list_id, email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False): """Adds a subscriber to a subscriber list.""" validate_consent_to_track(consent_to_track) body = { "EmailAddress": email_address, "N...
[ "def", "add", "(", "self", ",", "list_id", ",", "email_address", ",", "name", ",", "custom_fields", ",", "resubscribe", ",", "consent_to_track", ",", "restart_subscription_based_autoresponders", "=", "False", ")", ":", "validate_consent_to_track", "(", "consent_to_tra...
Adds a subscriber to a subscriber list.
[ "Adds", "a", "subscriber", "to", "a", "subscriber", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L27-L39
43,615
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.update
def update(self, new_email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False): """Updates any aspect of a subscriber, including email address, name, and custom field data if supplied.""" validate_consent_to_track(consent_to_track) ...
python
def update(self, new_email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False): """Updates any aspect of a subscriber, including email address, name, and custom field data if supplied.""" validate_consent_to_track(consent_to_track) ...
[ "def", "update", "(", "self", ",", "new_email_address", ",", "name", ",", "custom_fields", ",", "resubscribe", ",", "consent_to_track", ",", "restart_subscription_based_autoresponders", "=", "False", ")", ":", "validate_consent_to_track", "(", "consent_to_track", ")", ...
Updates any aspect of a subscriber, including email address, name, and custom field data if supplied.
[ "Updates", "any", "aspect", "of", "a", "subscriber", "including", "email", "address", "name", "and", "custom", "field", "data", "if", "supplied", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L41-L57
43,616
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.import_subscribers
def import_subscribers(self, list_id, subscribers, resubscribe, queue_subscription_based_autoresponders=False, restart_subscription_based_autoresponders=False): """Imports subscribers into a subscriber list.""" body = { "Subscribers": subscribers, "Resubscribe": resubscribe, ...
python
def import_subscribers(self, list_id, subscribers, resubscribe, queue_subscription_based_autoresponders=False, restart_subscription_based_autoresponders=False): """Imports subscribers into a subscriber list.""" body = { "Subscribers": subscribers, "Resubscribe": resubscribe, ...
[ "def", "import_subscribers", "(", "self", ",", "list_id", ",", "subscribers", ",", "resubscribe", ",", "queue_subscription_based_autoresponders", "=", "False", ",", "restart_subscription_based_autoresponders", "=", "False", ")", ":", "body", "=", "{", "\"Subscribers\"",...
Imports subscribers into a subscriber list.
[ "Imports", "subscribers", "into", "a", "subscriber", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L59-L78
43,617
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.unsubscribe
def unsubscribe(self): """Unsubscribes this subscriber from the associated list.""" body = { "EmailAddress": self.email_address} response = self._post("/subscribers/%s/unsubscribe.json" % self.list_id, json.dumps(body))
python
def unsubscribe(self): """Unsubscribes this subscriber from the associated list.""" body = { "EmailAddress": self.email_address} response = self._post("/subscribers/%s/unsubscribe.json" % self.list_id, json.dumps(body))
[ "def", "unsubscribe", "(", "self", ")", ":", "body", "=", "{", "\"EmailAddress\"", ":", "self", ".", "email_address", "}", "response", "=", "self", ".", "_post", "(", "\"/subscribers/%s/unsubscribe.json\"", "%", "self", ".", "list_id", ",", "json", ".", "dum...
Unsubscribes this subscriber from the associated list.
[ "Unsubscribes", "this", "subscriber", "from", "the", "associated", "list", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L80-L85
43,618
campaignmonitor/createsend-python
lib/createsend/subscriber.py
Subscriber.history
def history(self): """Gets the historical record of this subscriber's trackable actions.""" params = {"email": self.email_address} response = self._get("/subscribers/%s/history.json" % self.list_id, params=params) return json_to_py(response)
python
def history(self): """Gets the historical record of this subscriber's trackable actions.""" params = {"email": self.email_address} response = self._get("/subscribers/%s/history.json" % self.list_id, params=params) return json_to_py(response)
[ "def", "history", "(", "self", ")", ":", "params", "=", "{", "\"email\"", ":", "self", ".", "email_address", "}", "response", "=", "self", ".", "_get", "(", "\"/subscribers/%s/history.json\"", "%", "self", ".", "list_id", ",", "params", "=", "params", ")",...
Gets the historical record of this subscriber's trackable actions.
[ "Gets", "the", "historical", "record", "of", "this", "subscriber", "s", "trackable", "actions", "." ]
4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/subscriber.py#L87-L92
43,619
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_input
def set_input(self): """Returns form input field of Field. """ name = self.attrs.get("_override", self.widget.__class__.__name__) self.values["field"] = str(FIELDS.get(name, FIELDS.get(None))(self.field, self.attrs))
python
def set_input(self): """Returns form input field of Field. """ name = self.attrs.get("_override", self.widget.__class__.__name__) self.values["field"] = str(FIELDS.get(name, FIELDS.get(None))(self.field, self.attrs))
[ "def", "set_input", "(", "self", ")", ":", "name", "=", "self", ".", "attrs", ".", "get", "(", "\"_override\"", ",", "self", ".", "widget", ".", "__class__", ".", "__name__", ")", "self", ".", "values", "[", "\"field\"", "]", "=", "str", "(", "FIELDS...
Returns form input field of Field.
[ "Returns", "form", "input", "field", "of", "Field", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L36-L40
43,620
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_label
def set_label(self): """Set label markup. """ if not self.field.label or self.attrs.get("_no_label"): return self.values["label"] = format_html( LABEL_TEMPLATE, self.field.html_name, mark_safe(self.field.label) )
python
def set_label(self): """Set label markup. """ if not self.field.label or self.attrs.get("_no_label"): return self.values["label"] = format_html( LABEL_TEMPLATE, self.field.html_name, mark_safe(self.field.label) )
[ "def", "set_label", "(", "self", ")", ":", "if", "not", "self", ".", "field", ".", "label", "or", "self", ".", "attrs", ".", "get", "(", "\"_no_label\"", ")", ":", "return", "self", ".", "values", "[", "\"label\"", "]", "=", "format_html", "(", "LABE...
Set label markup.
[ "Set", "label", "markup", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L43-L51
43,621
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_help
def set_help(self): """Set help text markup. """ if not (self.field.help_text and self.attrs.get("_help")): return self.values["help"] = HELP_TEMPLATE.format(self.field.help_text)
python
def set_help(self): """Set help text markup. """ if not (self.field.help_text and self.attrs.get("_help")): return self.values["help"] = HELP_TEMPLATE.format(self.field.help_text)
[ "def", "set_help", "(", "self", ")", ":", "if", "not", "(", "self", ".", "field", ".", "help_text", "and", "self", ".", "attrs", ".", "get", "(", "\"_help\"", ")", ")", ":", "return", "self", ".", "values", "[", "\"help\"", "]", "=", "HELP_TEMPLATE",...
Set help text markup.
[ "Set", "help", "text", "markup", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L54-L60
43,622
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_errors
def set_errors(self): """Set errors markup. """ if not self.field.errors or self.attrs.get("_no_errors"): return self.values["class"].append("error") for error in self.field.errors: self.values["errors"] += ERROR_WRAPPER % {"message": error}
python
def set_errors(self): """Set errors markup. """ if not self.field.errors or self.attrs.get("_no_errors"): return self.values["class"].append("error") for error in self.field.errors: self.values["errors"] += ERROR_WRAPPER % {"message": error}
[ "def", "set_errors", "(", "self", ")", ":", "if", "not", "self", ".", "field", ".", "errors", "or", "self", ".", "attrs", ".", "get", "(", "\"_no_errors\"", ")", ":", "return", "self", ".", "values", "[", "\"class\"", "]", ".", "append", "(", "\"erro...
Set errors markup.
[ "Set", "errors", "markup", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L63-L72
43,623
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_icon
def set_icon(self): """Wrap current field with icon wrapper. This setter must be the last setter called. """ if not self.attrs.get("_icon"): return if "Date" in self.field.field.__class__.__name__: return self.values["field"] = INPUT_WRAPPER % { "field": self.values["field"], "help...
python
def set_icon(self): """Wrap current field with icon wrapper. This setter must be the last setter called. """ if not self.attrs.get("_icon"): return if "Date" in self.field.field.__class__.__name__: return self.values["field"] = INPUT_WRAPPER % { "field": self.values["field"], "help...
[ "def", "set_icon", "(", "self", ")", ":", "if", "not", "self", ".", "attrs", ".", "get", "(", "\"_icon\"", ")", ":", "return", "if", "\"Date\"", "in", "self", ".", "field", ".", "field", ".", "__class__", ".", "__name__", ":", "return", "self", ".", ...
Wrap current field with icon wrapper. This setter must be the last setter called.
[ "Wrap", "current", "field", "with", "icon", "wrapper", ".", "This", "setter", "must", "be", "the", "last", "setter", "called", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L75-L90
43,624
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.set_classes
def set_classes(self): """Set field properties and custom classes. """ # Custom field classes on field wrapper if self.attrs.get("_field_class"): self.values["class"].append(escape(self.attrs.get("_field_class"))) # Inline class if self.attrs.get("_inline"): self.values["class"].append("inli...
python
def set_classes(self): """Set field properties and custom classes. """ # Custom field classes on field wrapper if self.attrs.get("_field_class"): self.values["class"].append(escape(self.attrs.get("_field_class"))) # Inline class if self.attrs.get("_inline"): self.values["class"].append("inli...
[ "def", "set_classes", "(", "self", ")", ":", "# Custom field classes on field wrapper\r", "if", "self", ".", "attrs", ".", "get", "(", "\"_field_class\"", ")", ":", "self", ".", "values", "[", "\"class\"", "]", ".", "append", "(", "escape", "(", "self", ".",...
Set field properties and custom classes.
[ "Set", "field", "properties", "and", "custom", "classes", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L93-L112
43,625
thetarkus/django-semanticui-forms
semanticuiforms/templatetags/semanticui.py
Field.render
def render(self): """Render field as HTML. """ self.widget.attrs = { k: v for k, v in self.attrs.items() if k[0] != "_" } self.set_input() if not self.attrs.get("_no_wrapper"): self.set_label() self.set_help() self.set_errors() self.set_classes() self.set_icon() # Must be th...
python
def render(self): """Render field as HTML. """ self.widget.attrs = { k: v for k, v in self.attrs.items() if k[0] != "_" } self.set_input() if not self.attrs.get("_no_wrapper"): self.set_label() self.set_help() self.set_errors() self.set_classes() self.set_icon() # Must be th...
[ "def", "render", "(", "self", ")", ":", "self", ".", "widget", ".", "attrs", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "attrs", ".", "items", "(", ")", "if", "k", "[", "0", "]", "!=", "\"_\"", "}", "self", ".", "set_...
Render field as HTML.
[ "Render", "field", "as", "HTML", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/templatetags/semanticui.py#L115-L133
43,626
thetarkus/django-semanticui-forms
example/app/apps.py
ExampleAppConfig.ready
def ready(self): """ Create test friends for displaying. """ from .models import Friend # Requires migrations, not necessary try: Friend.objects.get_or_create(first_name="Michael", last_name="1", age=22) Friend.objects.get_or_create(first_name="Joe", last_name="2", age=21) Friend.objects.get_or_cr...
python
def ready(self): """ Create test friends for displaying. """ from .models import Friend # Requires migrations, not necessary try: Friend.objects.get_or_create(first_name="Michael", last_name="1", age=22) Friend.objects.get_or_create(first_name="Joe", last_name="2", age=21) Friend.objects.get_or_cr...
[ "def", "ready", "(", "self", ")", ":", "from", ".", "models", "import", "Friend", "# Requires migrations, not necessary", "try", ":", "Friend", ".", "objects", ".", "get_or_create", "(", "first_name", "=", "\"Michael\"", ",", "last_name", "=", "\"1\"", ",", "a...
Create test friends for displaying.
[ "Create", "test", "friends", "for", "displaying", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/example/app/apps.py#L12-L24
43,627
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_booleanfield
def render_booleanfield(field, attrs): """ Render BooleanField with label next to instead of above. """ attrs.setdefault("_no_label", True) # No normal label for booleanfields attrs.setdefault("_inline", True) # Checkbox should be inline field.field.widget.attrs["style"] = "display:hidden" # Hidden field ret...
python
def render_booleanfield(field, attrs): """ Render BooleanField with label next to instead of above. """ attrs.setdefault("_no_label", True) # No normal label for booleanfields attrs.setdefault("_inline", True) # Checkbox should be inline field.field.widget.attrs["style"] = "display:hidden" # Hidden field ret...
[ "def", "render_booleanfield", "(", "field", ",", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"_no_label\"", ",", "True", ")", "# No normal label for booleanfields", "attrs", ".", "setdefault", "(", "\"_inline\"", ",", "True", ")", "# Checkbox should be inl...
Render BooleanField with label next to instead of above.
[ "Render", "BooleanField", "with", "label", "next", "to", "instead", "of", "above", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L33-L47
43,628
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_choicefield
def render_choicefield(field, attrs, choices=None): """ Render ChoiceField as 'div' dropdown rather than select for more customization. """ # Allow custom choice list, but if no custom choice list then wrap all # choices into the `wrappers.CHOICE_TEMPLATE` if not choices: choices = format_html_join("", wrapper...
python
def render_choicefield(field, attrs, choices=None): """ Render ChoiceField as 'div' dropdown rather than select for more customization. """ # Allow custom choice list, but if no custom choice list then wrap all # choices into the `wrappers.CHOICE_TEMPLATE` if not choices: choices = format_html_join("", wrapper...
[ "def", "render_choicefield", "(", "field", ",", "attrs", ",", "choices", "=", "None", ")", ":", "# Allow custom choice list, but if no custom choice list then wrap all", "# choices into the `wrappers.CHOICE_TEMPLATE`", "if", "not", "choices", ":", "choices", "=", "format_html...
Render ChoiceField as 'div' dropdown rather than select for more customization.
[ "Render", "ChoiceField", "as", "div", "dropdown", "rather", "than", "select", "for", "more", "customization", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L50-L71
43,629
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_countryfield
def render_countryfield(field, attrs): """ Render a custom ChoiceField specific for CountryFields. """ choices = ((k, k.lower(), v) for k, v in field.field._choices[1:]) # Render a `ChoiceField` with all countries return render_choicefield( field, attrs, format_html_join("", wrappers.COUNTRY_TEMPLATE, choice...
python
def render_countryfield(field, attrs): """ Render a custom ChoiceField specific for CountryFields. """ choices = ((k, k.lower(), v) for k, v in field.field._choices[1:]) # Render a `ChoiceField` with all countries return render_choicefield( field, attrs, format_html_join("", wrappers.COUNTRY_TEMPLATE, choice...
[ "def", "render_countryfield", "(", "field", ",", "attrs", ")", ":", "choices", "=", "(", "(", "k", ",", "k", ".", "lower", "(", ")", ",", "v", ")", "for", "k", ",", "v", "in", "field", ".", "field", ".", "_choices", "[", "1", ":", "]", ")", "...
Render a custom ChoiceField specific for CountryFields.
[ "Render", "a", "custom", "ChoiceField", "specific", "for", "CountryFields", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L99-L109
43,630
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_multiplechoicefield
def render_multiplechoicefield(field, attrs, choices=None): """ MultipleChoiceField uses its own field, but also uses a queryset. """ choices = format_html_join("", wrappers.CHOICE_TEMPLATE, get_choices(field)) return wrappers.MULTIPLE_DROPDOWN_WRAPPER % { "name": field.html_name, "field": field, "choices": ...
python
def render_multiplechoicefield(field, attrs, choices=None): """ MultipleChoiceField uses its own field, but also uses a queryset. """ choices = format_html_join("", wrappers.CHOICE_TEMPLATE, get_choices(field)) return wrappers.MULTIPLE_DROPDOWN_WRAPPER % { "name": field.html_name, "field": field, "choices": ...
[ "def", "render_multiplechoicefield", "(", "field", ",", "attrs", ",", "choices", "=", "None", ")", ":", "choices", "=", "format_html_join", "(", "\"\"", ",", "wrappers", ".", "CHOICE_TEMPLATE", ",", "get_choices", "(", "field", ")", ")", "return", "wrappers", ...
MultipleChoiceField uses its own field, but also uses a queryset.
[ "MultipleChoiceField", "uses", "its", "own", "field", "but", "also", "uses", "a", "queryset", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L112-L124
43,631
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_datefield
def render_datefield(field, attrs, style="date"): """ DateField that uses wrappers.CALENDAR_WRAPPER. """ return wrappers.CALENDAR_WRAPPER % { "field": field, "style": pad(style), "align": pad(attrs.get("_align", "")), "icon": format_html(wrappers.ICON_TEMPLATE, attrs.get("_icon")), }
python
def render_datefield(field, attrs, style="date"): """ DateField that uses wrappers.CALENDAR_WRAPPER. """ return wrappers.CALENDAR_WRAPPER % { "field": field, "style": pad(style), "align": pad(attrs.get("_align", "")), "icon": format_html(wrappers.ICON_TEMPLATE, attrs.get("_icon")), }
[ "def", "render_datefield", "(", "field", ",", "attrs", ",", "style", "=", "\"date\"", ")", ":", "return", "wrappers", ".", "CALENDAR_WRAPPER", "%", "{", "\"field\"", ":", "field", ",", "\"style\"", ":", "pad", "(", "style", ")", ",", "\"align\"", ":", "p...
DateField that uses wrappers.CALENDAR_WRAPPER.
[ "DateField", "that", "uses", "wrappers", ".", "CALENDAR_WRAPPER", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L127-L136
43,632
thetarkus/django-semanticui-forms
semanticuiforms/fields.py
render_filefield
def render_filefield(field, attrs): """ Render a typical File Field. """ field.field.widget.attrs["style"] = "display:none" if not "_no_label" in attrs: attrs["_no_label"] = True return wrappers.FILE_WRAPPER % { "field": field, "id": "id_" + field.name, "style": pad(attrs.get("_style", "")), "text": e...
python
def render_filefield(field, attrs): """ Render a typical File Field. """ field.field.widget.attrs["style"] = "display:none" if not "_no_label" in attrs: attrs["_no_label"] = True return wrappers.FILE_WRAPPER % { "field": field, "id": "id_" + field.name, "style": pad(attrs.get("_style", "")), "text": e...
[ "def", "render_filefield", "(", "field", ",", "attrs", ")", ":", "field", ".", "field", ".", "widget", ".", "attrs", "[", "\"style\"", "]", "=", "\"display:none\"", "if", "not", "\"_no_label\"", "in", "attrs", ":", "attrs", "[", "\"_no_label\"", "]", "=", ...
Render a typical File Field.
[ "Render", "a", "typical", "File", "Field", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/fields.py#L153-L168
43,633
cmcqueen/simplerandom
python/python2/simplerandom/iterators/_iterators_py.py
_repeat_iter
def _repeat_iter(input_iter): """Iterate over the input iter values. Then repeat the last value indefinitely. This is useful to repeat seed values when an insufficient number of seeds are provided. E.g. KISS(1) effectively becomes KISS(1, 1, 1, 1), rather than (if we just used default values) KISS(...
python
def _repeat_iter(input_iter): """Iterate over the input iter values. Then repeat the last value indefinitely. This is useful to repeat seed values when an insufficient number of seeds are provided. E.g. KISS(1) effectively becomes KISS(1, 1, 1, 1), rather than (if we just used default values) KISS(...
[ "def", "_repeat_iter", "(", "input_iter", ")", ":", "last_value", "=", "None", "for", "value", "in", "input_iter", ":", "last_value", "=", "value", "yield", "value", "if", "last_value", "is", "not", "None", ":", "while", "True", ":", "yield", "last_value" ]
Iterate over the input iter values. Then repeat the last value indefinitely. This is useful to repeat seed values when an insufficient number of seeds are provided. E.g. KISS(1) effectively becomes KISS(1, 1, 1, 1), rather than (if we just used default values) KISS(1, default-value, default-value, defa...
[ "Iterate", "over", "the", "input", "iter", "values", ".", "Then", "repeat", "the", "last", "value", "indefinitely", ".", "This", "is", "useful", "to", "repeat", "seed", "values", "when", "an", "insufficient", "number", "of", "seeds", "are", "provided", "." ]
3f19ffdfeaa8256986adf7173f08c1c719164d01
https://github.com/cmcqueen/simplerandom/blob/3f19ffdfeaa8256986adf7173f08c1c719164d01/python/python2/simplerandom/iterators/_iterators_py.py#L40-L59
43,634
cmcqueen/simplerandom
python/python2/simplerandom/random/_random_py.py
_StandardRandomTemplate.seed
def seed(self, x=None, *args): """For consistent cross-platform seeding, provide an integer seed. """ if x is None: # Use same random seed code copied from Python's random.Random try: x = long(_hexlify(_urandom(16)), 16) except NotImplementedEr...
python
def seed(self, x=None, *args): """For consistent cross-platform seeding, provide an integer seed. """ if x is None: # Use same random seed code copied from Python's random.Random try: x = long(_hexlify(_urandom(16)), 16) except NotImplementedEr...
[ "def", "seed", "(", "self", ",", "x", "=", "None", ",", "*", "args", ")", ":", "if", "x", "is", "None", ":", "# Use same random seed code copied from Python's random.Random", "try", ":", "x", "=", "long", "(", "_hexlify", "(", "_urandom", "(", "16", ")", ...
For consistent cross-platform seeding, provide an integer seed.
[ "For", "consistent", "cross", "-", "platform", "seeding", "provide", "an", "integer", "seed", "." ]
3f19ffdfeaa8256986adf7173f08c1c719164d01
https://github.com/cmcqueen/simplerandom/blob/3f19ffdfeaa8256986adf7173f08c1c719164d01/python/python2/simplerandom/random/_random_py.py#L44-L59
43,635
cmcqueen/simplerandom
python/python2/simplerandom/random/_random_py.py
_StandardRandomTemplate.setbpf
def setbpf(self, bpf): """Set number of bits per float output""" self._bpf = min(bpf, self.BPF) self._rng_n = int((self._bpf + self.RNG_RANGE_BITS - 1) / self.RNG_RANGE_BITS)
python
def setbpf(self, bpf): """Set number of bits per float output""" self._bpf = min(bpf, self.BPF) self._rng_n = int((self._bpf + self.RNG_RANGE_BITS - 1) / self.RNG_RANGE_BITS)
[ "def", "setbpf", "(", "self", ",", "bpf", ")", ":", "self", ".", "_bpf", "=", "min", "(", "bpf", ",", "self", ".", "BPF", ")", "self", ".", "_rng_n", "=", "int", "(", "(", "self", ".", "_bpf", "+", "self", ".", "RNG_RANGE_BITS", "-", "1", ")", ...
Set number of bits per float output
[ "Set", "number", "of", "bits", "per", "float", "output" ]
3f19ffdfeaa8256986adf7173f08c1c719164d01
https://github.com/cmcqueen/simplerandom/blob/3f19ffdfeaa8256986adf7173f08c1c719164d01/python/python2/simplerandom/random/_random_py.py#L65-L68
43,636
mbr/flask-appconfig
flask_appconfig/server_backends.py
ServerBackend.get_info
def get_info(cls): """Return information about backend and its availability. :return: A BackendInfo tuple if the import worked, none otherwise. """ mod = try_import(cls.mod_name) if not mod: return None version = getattr(mod, '__version__', None) or getattr(m...
python
def get_info(cls): """Return information about backend and its availability. :return: A BackendInfo tuple if the import worked, none otherwise. """ mod = try_import(cls.mod_name) if not mod: return None version = getattr(mod, '__version__', None) or getattr(m...
[ "def", "get_info", "(", "cls", ")", ":", "mod", "=", "try_import", "(", "cls", ".", "mod_name", ")", "if", "not", "mod", ":", "return", "None", "version", "=", "getattr", "(", "mod", ",", "'__version__'", ",", "None", ")", "or", "getattr", "(", "mod"...
Return information about backend and its availability. :return: A BackendInfo tuple if the import worked, none otherwise.
[ "Return", "information", "about", "backend", "and", "its", "availability", "." ]
5264719ac9229339070b219a4358a3203ffd05b0
https://github.com/mbr/flask-appconfig/blob/5264719ac9229339070b219a4358a3203ffd05b0/flask_appconfig/server_backends.py#L42-L52
43,637
thetarkus/django-semanticui-forms
semanticuiforms/utils.py
get_choices
def get_choices(field): """ Find choices of a field, whether it has choices or has a queryset. Args: field (BoundField): Django form boundfield Returns: list: List of choices """ empty_label = getattr(field.field, "empty_label", False) needs_empty_value = False choices = [] # Data is the choices if ha...
python
def get_choices(field): """ Find choices of a field, whether it has choices or has a queryset. Args: field (BoundField): Django form boundfield Returns: list: List of choices """ empty_label = getattr(field.field, "empty_label", False) needs_empty_value = False choices = [] # Data is the choices if ha...
[ "def", "get_choices", "(", "field", ")", ":", "empty_label", "=", "getattr", "(", "field", ".", "field", ",", "\"empty_label\"", ",", "False", ")", "needs_empty_value", "=", "False", "choices", "=", "[", "]", "# Data is the choices", "if", "hasattr", "(", "f...
Find choices of a field, whether it has choices or has a queryset. Args: field (BoundField): Django form boundfield Returns: list: List of choices
[ "Find", "choices", "of", "a", "field", "whether", "it", "has", "choices", "or", "has", "a", "queryset", "." ]
9664c6f01621568c3fa39b36439178586649eafe
https://github.com/thetarkus/django-semanticui-forms/blob/9664c6f01621568c3fa39b36439178586649eafe/semanticuiforms/utils.py#L25-L66
43,638
miyakogi/wdom
wdom/web_node.py
WdomElement.get_class_list
def get_class_list(cls) -> DOMTokenList: """Get class-level class list, including all super class's.""" cl = [] cl.append(DOMTokenList(cls, cls.class_)) if cls.inherit_class: for base_cls in cls.__bases__: if issubclass(base_cls, WdomElement): ...
python
def get_class_list(cls) -> DOMTokenList: """Get class-level class list, including all super class's.""" cl = [] cl.append(DOMTokenList(cls, cls.class_)) if cls.inherit_class: for base_cls in cls.__bases__: if issubclass(base_cls, WdomElement): ...
[ "def", "get_class_list", "(", "cls", ")", "->", "DOMTokenList", ":", "cl", "=", "[", "]", "cl", ".", "append", "(", "DOMTokenList", "(", "cls", ",", "cls", ".", "class_", ")", ")", "if", "cls", ".", "inherit_class", ":", "for", "base_cls", "in", "cls...
Get class-level class list, including all super class's.
[ "Get", "class", "-", "level", "class", "list", "including", "all", "super", "class", "s", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L137-L147
43,639
miyakogi/wdom
wdom/web_node.py
WdomElement.appendChild
def appendChild(self, child: 'WdomElement') -> Node: """Append child node at the last of child nodes. If this instance is connected to the node on browser, the child node is also added to it. """ if self.connected: self._append_child_web(child) return self._a...
python
def appendChild(self, child: 'WdomElement') -> Node: """Append child node at the last of child nodes. If this instance is connected to the node on browser, the child node is also added to it. """ if self.connected: self._append_child_web(child) return self._a...
[ "def", "appendChild", "(", "self", ",", "child", ":", "'WdomElement'", ")", "->", "Node", ":", "if", "self", ".", "connected", ":", "self", ".", "_append_child_web", "(", "child", ")", "return", "self", ".", "_append_child", "(", "child", ")" ]
Append child node at the last of child nodes. If this instance is connected to the node on browser, the child node is also added to it.
[ "Append", "child", "node", "at", "the", "last", "of", "child", "nodes", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L221-L229
43,640
miyakogi/wdom
wdom/web_node.py
WdomElement.insertBefore
def insertBefore(self, child: Node, ref_node: Node) -> Node: """Insert new child node before the reference child node. If the reference node is not a child of this node, raise ValueError. If this instance is connected to the node on browser, the child node is also added to it. "...
python
def insertBefore(self, child: Node, ref_node: Node) -> Node: """Insert new child node before the reference child node. If the reference node is not a child of this node, raise ValueError. If this instance is connected to the node on browser, the child node is also added to it. "...
[ "def", "insertBefore", "(", "self", ",", "child", ":", "Node", ",", "ref_node", ":", "Node", ")", "->", "Node", ":", "if", "self", ".", "connected", ":", "self", ".", "_insert_before_web", "(", "child", ",", "ref_node", ")", "return", "self", ".", "_in...
Insert new child node before the reference child node. If the reference node is not a child of this node, raise ValueError. If this instance is connected to the node on browser, the child node is also added to it.
[ "Insert", "new", "child", "node", "before", "the", "reference", "child", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L240-L249
43,641
miyakogi/wdom
wdom/web_node.py
WdomElement.removeChild
def removeChild(self, child: Node) -> Node: """Remove the child node from this node. If the node is not a child of this node, raise ValueError. """ if self.connected: self._remove_child_web(child) return self._remove_child(child)
python
def removeChild(self, child: Node) -> Node: """Remove the child node from this node. If the node is not a child of this node, raise ValueError. """ if self.connected: self._remove_child_web(child) return self._remove_child(child)
[ "def", "removeChild", "(", "self", ",", "child", ":", "Node", ")", "->", "Node", ":", "if", "self", ".", "connected", ":", "self", ".", "_remove_child_web", "(", "child", ")", "return", "self", ".", "_remove_child", "(", "child", ")" ]
Remove the child node from this node. If the node is not a child of this node, raise ValueError.
[ "Remove", "the", "child", "node", "from", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L259-L266
43,642
miyakogi/wdom
wdom/web_node.py
WdomElement.replaceChild
def replaceChild(self, new_child: 'WdomElement', old_child: 'WdomElement' ) -> Node: """Replace child nodes.""" if self.connected: self._replace_child_web(new_child, old_child) return self._replace_child(new_child, old_child)
python
def replaceChild(self, new_child: 'WdomElement', old_child: 'WdomElement' ) -> Node: """Replace child nodes.""" if self.connected: self._replace_child_web(new_child, old_child) return self._replace_child(new_child, old_child)
[ "def", "replaceChild", "(", "self", ",", "new_child", ":", "'WdomElement'", ",", "old_child", ":", "'WdomElement'", ")", "->", "Node", ":", "if", "self", ".", "connected", ":", "self", ".", "_replace_child_web", "(", "new_child", ",", "old_child", ")", "retu...
Replace child nodes.
[ "Replace", "child", "nodes", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L279-L284
43,643
miyakogi/wdom
wdom/web_node.py
WdomElement.textContent
def textContent(self, text: str) -> None: # type: ignore """Set textContent both on this node and related browser node.""" self._set_text_content(text) if self.connected: self._set_text_content_web(text)
python
def textContent(self, text: str) -> None: # type: ignore """Set textContent both on this node and related browser node.""" self._set_text_content(text) if self.connected: self._set_text_content_web(text)
[ "def", "textContent", "(", "self", ",", "text", ":", "str", ")", "->", "None", ":", "# type: ignore", "self", ".", "_set_text_content", "(", "text", ")", "if", "self", ".", "connected", ":", "self", ".", "_set_text_content_web", "(", "text", ")" ]
Set textContent both on this node and related browser node.
[ "Set", "textContent", "both", "on", "this", "node", "and", "related", "browser", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L295-L299
43,644
miyakogi/wdom
wdom/web_node.py
WdomElement.innerHTML
def innerHTML(self, html: str) -> None: # type: ignore """Set innerHTML both on this node and related browser node.""" df = self._parse_html(html) if self.connected: self._set_inner_html_web(df.html) self._empty() self._append_child(df)
python
def innerHTML(self, html: str) -> None: # type: ignore """Set innerHTML both on this node and related browser node.""" df = self._parse_html(html) if self.connected: self._set_inner_html_web(df.html) self._empty() self._append_child(df)
[ "def", "innerHTML", "(", "self", ",", "html", ":", "str", ")", "->", "None", ":", "# type: ignore", "df", "=", "self", ".", "_parse_html", "(", "html", ")", "if", "self", ".", "connected", ":", "self", ".", "_set_inner_html_web", "(", "df", ".", "html"...
Set innerHTML both on this node and related browser node.
[ "Set", "innerHTML", "both", "on", "this", "node", "and", "related", "browser", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L305-L311
43,645
miyakogi/wdom
wdom/web_node.py
WdomElement.click
def click(self) -> None: """Send click event.""" if self.connected: self.js_exec('click') else: # Web上に表示されてれば勝手にブラウザ側からクリックイベント発生する # のでローカルのクリックイベント不要 msg = {'proto': '', 'type': 'click', 'currentTarget': {'id': self.wdom_id}, ...
python
def click(self) -> None: """Send click event.""" if self.connected: self.js_exec('click') else: # Web上に表示されてれば勝手にブラウザ側からクリックイベント発生する # のでローカルのクリックイベント不要 msg = {'proto': '', 'type': 'click', 'currentTarget': {'id': self.wdom_id}, ...
[ "def", "click", "(", "self", ")", "->", "None", ":", "if", "self", ".", "connected", ":", "self", ".", "js_exec", "(", "'click'", ")", "else", ":", "# Web上に表示されてれば勝手にブラウザ側からクリックイベント発生する", "# のでローカルのクリックイベント不要", "msg", "=", "{", "'proto'", ":", "''", ",", "...
Send click event.
[ "Send", "click", "event", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L318-L329
43,646
miyakogi/wdom
wdom/document.py
getElementById
def getElementById(id: str) -> Optional[Node]: """Get element with ``id``.""" elm = Element._elements_with_id.get(id) return elm
python
def getElementById(id: str) -> Optional[Node]: """Get element with ``id``.""" elm = Element._elements_with_id.get(id) return elm
[ "def", "getElementById", "(", "id", ":", "str", ")", "->", "Optional", "[", "Node", "]", ":", "elm", "=", "Element", ".", "_elements_with_id", ".", "get", "(", "id", ")", "return", "elm" ]
Get element with ``id``.
[ "Get", "element", "with", "id", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L31-L34
43,647
miyakogi/wdom
wdom/document.py
getElementByWdomId
def getElementByWdomId(id: str) -> Optional[WebEventTarget]: """Get element with ``wdom_id``.""" if not id: return None elif id == 'document': return get_document() elif id == 'window': return get_document().defaultView elm = WdomElement._elements_with_wdom_id.get(id) ret...
python
def getElementByWdomId(id: str) -> Optional[WebEventTarget]: """Get element with ``wdom_id``.""" if not id: return None elif id == 'document': return get_document() elif id == 'window': return get_document().defaultView elm = WdomElement._elements_with_wdom_id.get(id) ret...
[ "def", "getElementByWdomId", "(", "id", ":", "str", ")", "->", "Optional", "[", "WebEventTarget", "]", ":", "if", "not", "id", ":", "return", "None", "elif", "id", "==", "'document'", ":", "return", "get_document", "(", ")", "elif", "id", "==", "'window'...
Get element with ``wdom_id``.
[ "Get", "element", "with", "wdom_id", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L37-L46
43,648
miyakogi/wdom
wdom/document.py
_cleanup
def _cleanup(path: str) -> None: """Cleanup temporary directory.""" if os.path.isdir(path): shutil.rmtree(path)
python
def _cleanup(path: str) -> None: """Cleanup temporary directory.""" if os.path.isdir(path): shutil.rmtree(path)
[ "def", "_cleanup", "(", "path", ":", "str", ")", "->", "None", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "shutil", ".", "rmtree", "(", "path", ")" ]
Cleanup temporary directory.
[ "Cleanup", "temporary", "directory", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L49-L52
43,649
miyakogi/wdom
wdom/document.py
create_element
def create_element(tag: str, name: str = None, base: type = None, attr: dict = None) -> Node: """Create element with a tag of ``name``. :arg str name: html tag. :arg type base: Base class of the created element (defatlt: ``WdomElement``) :arg dict attr: Attribu...
python
def create_element(tag: str, name: str = None, base: type = None, attr: dict = None) -> Node: """Create element with a tag of ``name``. :arg str name: html tag. :arg type base: Base class of the created element (defatlt: ``WdomElement``) :arg dict attr: Attribu...
[ "def", "create_element", "(", "tag", ":", "str", ",", "name", ":", "str", "=", "None", ",", "base", ":", "type", "=", "None", ",", "attr", ":", "dict", "=", "None", ")", "->", "Node", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "...
Create element with a tag of ``name``. :arg str name: html tag. :arg type base: Base class of the created element (defatlt: ``WdomElement``) :arg dict attr: Attributes (key-value pairs dict) of the new element.
[ "Create", "element", "with", "a", "tag", "of", "name", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L55-L78
43,650
miyakogi/wdom
wdom/document.py
Document.characterSet
def characterSet(self, charset: str) -> None: """Set character set of this document.""" charset_node = self._find_charset_node() or Meta(parent=self.head) charset_node.setAttribute('charset', charset)
python
def characterSet(self, charset: str) -> None: """Set character set of this document.""" charset_node = self._find_charset_node() or Meta(parent=self.head) charset_node.setAttribute('charset', charset)
[ "def", "characterSet", "(", "self", ",", "charset", ":", "str", ")", "->", "None", ":", "charset_node", "=", "self", ".", "_find_charset_node", "(", ")", "or", "Meta", "(", "parent", "=", "self", ".", "head", ")", "charset_node", ".", "setAttribute", "("...
Set character set of this document.
[ "Set", "character", "set", "of", "this", "document", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L149-L152
43,651
miyakogi/wdom
wdom/document.py
Document.getElementsBy
def getElementsBy(self, cond: Callable[[Element], bool]) -> NodeList: """Get elements in this document which matches condition.""" return getElementsBy(self, cond)
python
def getElementsBy(self, cond: Callable[[Element], bool]) -> NodeList: """Get elements in this document which matches condition.""" return getElementsBy(self, cond)
[ "def", "getElementsBy", "(", "self", ",", "cond", ":", "Callable", "[", "[", "Element", "]", ",", "bool", "]", ")", "->", "NodeList", ":", "return", "getElementsBy", "(", "self", ",", "cond", ")" ]
Get elements in this document which matches condition.
[ "Get", "elements", "in", "this", "document", "which", "matches", "condition", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L173-L175
43,652
miyakogi/wdom
wdom/document.py
Document.getElementById
def getElementById(self, id: str) -> Optional[Node]: """Get element by ``id``. If this document does not have the element with the id, return None. """ elm = getElementById(id) if elm and elm.ownerDocument is self: return elm return None
python
def getElementById(self, id: str) -> Optional[Node]: """Get element by ``id``. If this document does not have the element with the id, return None. """ elm = getElementById(id) if elm and elm.ownerDocument is self: return elm return None
[ "def", "getElementById", "(", "self", ",", "id", ":", "str", ")", "->", "Optional", "[", "Node", "]", ":", "elm", "=", "getElementById", "(", "id", ")", "if", "elm", "and", "elm", ".", "ownerDocument", "is", "self", ":", "return", "elm", "return", "N...
Get element by ``id``. If this document does not have the element with the id, return None.
[ "Get", "element", "by", "id", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L185-L193
43,653
miyakogi/wdom
wdom/document.py
Document.createElement
def createElement(self, tag: str) -> Node: """Create new element whose tag name is ``tag``.""" return create_element(tag, base=self._default_class)
python
def createElement(self, tag: str) -> Node: """Create new element whose tag name is ``tag``.""" return create_element(tag, base=self._default_class)
[ "def", "createElement", "(", "self", ",", "tag", ":", "str", ")", "->", "Node", ":", "return", "create_element", "(", "tag", ",", "base", "=", "self", ".", "_default_class", ")" ]
Create new element whose tag name is ``tag``.
[ "Create", "new", "element", "whose", "tag", "name", "is", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L207-L209
43,654
miyakogi/wdom
wdom/document.py
WdomDocument.getElementByWdomId
def getElementByWdomId(self, id: Union[str]) -> Optional[WebEventTarget]: """Get an element node with ``wdom_id``. If this document does not have the element with the id, return None. """ elm = getElementByWdomId(id) if elm and elm.ownerDocument is self: return elm ...
python
def getElementByWdomId(self, id: Union[str]) -> Optional[WebEventTarget]: """Get an element node with ``wdom_id``. If this document does not have the element with the id, return None. """ elm = getElementByWdomId(id) if elm and elm.ownerDocument is self: return elm ...
[ "def", "getElementByWdomId", "(", "self", ",", "id", ":", "Union", "[", "str", "]", ")", "->", "Optional", "[", "WebEventTarget", "]", ":", "elm", "=", "getElementByWdomId", "(", "id", ")", "if", "elm", "and", "elm", ".", "ownerDocument", "is", "self", ...
Get an element node with ``wdom_id``. If this document does not have the element with the id, return None.
[ "Get", "an", "element", "node", "with", "wdom_id", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L297-L305
43,655
miyakogi/wdom
wdom/document.py
WdomDocument.add_jsfile
def add_jsfile(self, src: str) -> None: """Add JS file to load at this document's bottom of the body.""" self.body.appendChild(Script(src=src))
python
def add_jsfile(self, src: str) -> None: """Add JS file to load at this document's bottom of the body.""" self.body.appendChild(Script(src=src))
[ "def", "add_jsfile", "(", "self", ",", "src", ":", "str", ")", "->", "None", ":", "self", ".", "body", ".", "appendChild", "(", "Script", "(", "src", "=", "src", ")", ")" ]
Add JS file to load at this document's bottom of the body.
[ "Add", "JS", "file", "to", "load", "at", "this", "document", "s", "bottom", "of", "the", "body", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L307-L309
43,656
miyakogi/wdom
wdom/document.py
WdomDocument.add_jsfile_head
def add_jsfile_head(self, src: str) -> None: """Add JS file to load at this document's header.""" self.head.appendChild(Script(src=src))
python
def add_jsfile_head(self, src: str) -> None: """Add JS file to load at this document's header.""" self.head.appendChild(Script(src=src))
[ "def", "add_jsfile_head", "(", "self", ",", "src", ":", "str", ")", "->", "None", ":", "self", ".", "head", ".", "appendChild", "(", "Script", "(", "src", "=", "src", ")", ")" ]
Add JS file to load at this document's header.
[ "Add", "JS", "file", "to", "load", "at", "this", "document", "s", "header", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L311-L313
43,657
miyakogi/wdom
wdom/document.py
WdomDocument.add_cssfile
def add_cssfile(self, src: str) -> None: """Add CSS file to load at this document's header.""" self.head.appendChild(Link(rel='stylesheet', href=src))
python
def add_cssfile(self, src: str) -> None: """Add CSS file to load at this document's header.""" self.head.appendChild(Link(rel='stylesheet', href=src))
[ "def", "add_cssfile", "(", "self", ",", "src", ":", "str", ")", "->", "None", ":", "self", ".", "head", ".", "appendChild", "(", "Link", "(", "rel", "=", "'stylesheet'", ",", "href", "=", "src", ")", ")" ]
Add CSS file to load at this document's header.
[ "Add", "CSS", "file", "to", "load", "at", "this", "document", "s", "header", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L315-L317
43,658
miyakogi/wdom
wdom/document.py
WdomDocument.register_theme
def register_theme(self, theme: ModuleType) -> None: """Set theme for this docuemnt. This method sets theme's js/css files and headers on this document. :arg ModuleType theme: a module which has ``js_files``, ``css_files``, ``headers``, and ``extended_classes``. see ``wdom.themes``...
python
def register_theme(self, theme: ModuleType) -> None: """Set theme for this docuemnt. This method sets theme's js/css files and headers on this document. :arg ModuleType theme: a module which has ``js_files``, ``css_files``, ``headers``, and ``extended_classes``. see ``wdom.themes``...
[ "def", "register_theme", "(", "self", ",", "theme", ":", "ModuleType", ")", "->", "None", ":", "if", "not", "hasattr", "(", "theme", ",", "'css_files'", ")", ":", "raise", "ValueError", "(", "'theme module must include `css_files`.'", ")", "for", "css", "in", ...
Set theme for this docuemnt. This method sets theme's js/css files and headers on this document. :arg ModuleType theme: a module which has ``js_files``, ``css_files``, ``headers``, and ``extended_classes``. see ``wdom.themes`` directory actual theme module structures.
[ "Set", "theme", "for", "this", "docuemnt", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L326-L344
43,659
miyakogi/wdom
wdom/document.py
WdomDocument.build
def build(self) -> str: """Return HTML representation of this document.""" self._set_autoreload() return ''.join(child.html for child in self.childNodes)
python
def build(self) -> str: """Return HTML representation of this document.""" self._set_autoreload() return ''.join(child.html for child in self.childNodes)
[ "def", "build", "(", "self", ")", "->", "str", ":", "self", ".", "_set_autoreload", "(", ")", "return", "''", ".", "join", "(", "child", ".", "html", "for", "child", "in", "self", ".", "childNodes", ")" ]
Return HTML representation of this document.
[ "Return", "HTML", "representation", "of", "this", "document", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L346-L349
43,660
miyakogi/wdom
wdom/server/__init__.py
send_message
def send_message() -> None: """Send message via WS to all client connections.""" if not _msg_queue: return msg = json.dumps(_msg_queue) _msg_queue.clear() for conn in module.connections: conn.write_message(msg)
python
def send_message() -> None: """Send message via WS to all client connections.""" if not _msg_queue: return msg = json.dumps(_msg_queue) _msg_queue.clear() for conn in module.connections: conn.write_message(msg)
[ "def", "send_message", "(", ")", "->", "None", ":", "if", "not", "_msg_queue", ":", "return", "msg", "=", "json", ".", "dumps", "(", "_msg_queue", ")", "_msg_queue", ".", "clear", "(", ")", "for", "conn", "in", "module", ".", "connections", ":", "conn"...
Send message via WS to all client connections.
[ "Send", "message", "via", "WS", "to", "all", "client", "connections", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/__init__.py#L43-L50
43,661
miyakogi/wdom
wdom/server/__init__.py
add_static_path
def add_static_path(prefix: str, path: str, no_watch: bool = False) -> None: """Add directory to serve static files. First argument ``prefix`` is a URL prefix for the ``path``. ``path`` must be a directory. If ``no_watch`` is True, any change of the files in the path do not trigger restart if ``--autor...
python
def add_static_path(prefix: str, path: str, no_watch: bool = False) -> None: """Add directory to serve static files. First argument ``prefix`` is a URL prefix for the ``path``. ``path`` must be a directory. If ``no_watch`` is True, any change of the files in the path do not trigger restart if ``--autor...
[ "def", "add_static_path", "(", "prefix", ":", "str", ",", "path", ":", "str", ",", "no_watch", ":", "bool", "=", "False", ")", "->", "None", ":", "app", "=", "get_app", "(", ")", "app", ".", "add_static_path", "(", "prefix", ",", "path", ")", "if", ...
Add directory to serve static files. First argument ``prefix`` is a URL prefix for the ``path``. ``path`` must be a directory. If ``no_watch`` is True, any change of the files in the path do not trigger restart if ``--autoreload`` is enabled.
[ "Add", "directory", "to", "serve", "static", "files", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/__init__.py#L53-L63
43,662
miyakogi/wdom
wdom/server/__init__.py
start
def start(**kwargs: Any) -> None: """Start web server. Run until ``Ctrl-c`` pressed, or if auto-shutdown is enabled, until when all browser windows are closed. This function accepts keyword areguments same as :func:`start_server` and all arguments passed to it. """ start_server(**kwargs) ...
python
def start(**kwargs: Any) -> None: """Start web server. Run until ``Ctrl-c`` pressed, or if auto-shutdown is enabled, until when all browser windows are closed. This function accepts keyword areguments same as :func:`start_server` and all arguments passed to it. """ start_server(**kwargs) ...
[ "def", "start", "(", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "start_server", "(", "*", "*", "kwargs", ")", "try", ":", "asyncio", ".", "get_event_loop", "(", ")", ".", "run_forever", "(", ")", "except", "KeyboardInterrupt", ":", "stop_s...
Start web server. Run until ``Ctrl-c`` pressed, or if auto-shutdown is enabled, until when all browser windows are closed. This function accepts keyword areguments same as :func:`start_server` and all arguments passed to it.
[ "Start", "web", "server", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/__init__.py#L116-L129
43,663
miyakogi/wdom
wdom/window.py
CustomElementsRegistry.define
def define(self, *args: Any, **kwargs: Any) -> None: """Add new custom element.""" if isinstance(args[0], str): self._define_orig(*args, **kwargs) elif isinstance(args[0], type): self._define_class(*args, **kwargs) else: raise TypeError( ...
python
def define(self, *args: Any, **kwargs: Any) -> None: """Add new custom element.""" if isinstance(args[0], str): self._define_orig(*args, **kwargs) elif isinstance(args[0], type): self._define_class(*args, **kwargs) else: raise TypeError( ...
[ "def", "define", "(", "self", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "if", "isinstance", "(", "args", "[", "0", "]", ",", "str", ")", ":", "self", ".", "_define_orig", "(", "*", "args", ",", ...
Add new custom element.
[ "Add", "new", "custom", "element", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/window.py#L75-L83
43,664
miyakogi/wdom
wdom/server/handler.py
event_handler
def event_handler(msg: EventMsgDict) -> Event: """Handle events emitted on browser.""" e = create_event_from_msg(msg) if e.currentTarget is None: if e.type not in ['mount', 'unmount']: id = msg['currentTarget']['id'] logger.warning('No such element: wdom_id={}'.format(id)) ...
python
def event_handler(msg: EventMsgDict) -> Event: """Handle events emitted on browser.""" e = create_event_from_msg(msg) if e.currentTarget is None: if e.type not in ['mount', 'unmount']: id = msg['currentTarget']['id'] logger.warning('No such element: wdom_id={}'.format(id)) ...
[ "def", "event_handler", "(", "msg", ":", "EventMsgDict", ")", "->", "Event", ":", "e", "=", "create_event_from_msg", "(", "msg", ")", "if", "e", ".", "currentTarget", "is", "None", ":", "if", "e", ".", "type", "not", "in", "[", "'mount'", ",", "'unmoun...
Handle events emitted on browser.
[ "Handle", "events", "emitted", "on", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L49-L59
43,665
miyakogi/wdom
wdom/server/handler.py
response_handler
def response_handler(msg: Dict[str, str]) -> None: """Handle response sent by browser.""" from wdom.document import getElementByWdomId id = msg['id'] elm = getElementByWdomId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: wdom_id={}'.format(id))
python
def response_handler(msg: Dict[str, str]) -> None: """Handle response sent by browser.""" from wdom.document import getElementByWdomId id = msg['id'] elm = getElementByWdomId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: wdom_id={}'.format(id))
[ "def", "response_handler", "(", "msg", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "None", ":", "from", "wdom", ".", "document", "import", "getElementByWdomId", "id", "=", "msg", "[", "'id'", "]", "elm", "=", "getElementByWdomId", "(", "id", "...
Handle response sent by browser.
[ "Handle", "response", "sent", "by", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L62-L70
43,666
miyakogi/wdom
wdom/server/handler.py
on_websocket_message
def on_websocket_message(message: str) -> None: """Handle messages from browser.""" msgs = json.loads(message) for msg in msgs: if not isinstance(msg, dict): logger.error('Invalid WS message format: {}'.format(message)) continue _type = msg.get('type') if _typ...
python
def on_websocket_message(message: str) -> None: """Handle messages from browser.""" msgs = json.loads(message) for msg in msgs: if not isinstance(msg, dict): logger.error('Invalid WS message format: {}'.format(message)) continue _type = msg.get('type') if _typ...
[ "def", "on_websocket_message", "(", "message", ":", "str", ")", "->", "None", ":", "msgs", "=", "json", ".", "loads", "(", "message", ")", "for", "msg", "in", "msgs", ":", "if", "not", "isinstance", "(", "msg", ",", "dict", ")", ":", "logger", ".", ...
Handle messages from browser.
[ "Handle", "messages", "from", "browser", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/handler.py#L73-L88
43,667
miyakogi/wdom
wdom/parser.py
parse_html
def parse_html(html: str, parser: FragmentParser = None) -> Node: """Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes. """ parser = parser or FragmentParser() parser.feed(html) return parser.root
python
def parse_html(html: str, parser: FragmentParser = None) -> Node: """Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes. """ parser = parser or FragmentParser() parser.feed(html) return parser.root
[ "def", "parse_html", "(", "html", ":", "str", ",", "parser", ":", "FragmentParser", "=", "None", ")", "->", "Node", ":", "parser", "=", "parser", "or", "FragmentParser", "(", ")", "parser", ".", "feed", "(", "html", ")", "return", "parser", ".", "root"...
Parse HTML fragment and return DocumentFragment object. DocumentFragment object has parsed Node objects as its child nodes.
[ "Parse", "HTML", "fragment", "and", "return", "DocumentFragment", "object", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/parser.py#L68-L75
43,668
miyakogi/wdom
wdom/element.py
getElementsBy
def getElementsBy(start_node: ParentNode, cond: Callable[['Element'], bool]) -> NodeList: """Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested conditi...
python
def getElementsBy(start_node: ParentNode, cond: Callable[['Element'], bool]) -> NodeList: """Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested conditi...
[ "def", "getElementsBy", "(", "start_node", ":", "ParentNode", ",", "cond", ":", "Callable", "[", "[", "'Element'", "]", ",", "bool", "]", ")", "->", "NodeList", ":", "elements", "=", "[", "]", "for", "child", "in", "start_node", ".", "children", ":", "...
Return list of child elements of start_node which matches ``cond``. ``cond`` must be a function which gets a single argument ``Element``, and returns boolean. If the node matches requested condition, ``cond`` should return True. This searches all child elements recursively. :arg ParentNode start_n...
[ "Return", "list", "of", "child", "elements", "of", "start_node", "which", "matches", "cond", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L375-L393
43,669
miyakogi/wdom
wdom/element.py
getElementsByTagName
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList: """Get child nodes which tag name is ``tag``.""" _tag = tag.upper() return getElementsBy(start_node, lambda node: node.tagName == _tag)
python
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList: """Get child nodes which tag name is ``tag``.""" _tag = tag.upper() return getElementsBy(start_node, lambda node: node.tagName == _tag)
[ "def", "getElementsByTagName", "(", "start_node", ":", "ParentNode", ",", "tag", ":", "str", ")", "->", "NodeList", ":", "_tag", "=", "tag", ".", "upper", "(", ")", "return", "getElementsBy", "(", "start_node", ",", "lambda", "node", ":", "node", ".", "t...
Get child nodes which tag name is ``tag``.
[ "Get", "child", "nodes", "which", "tag", "name", "is", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L396-L399
43,670
miyakogi/wdom
wdom/element.py
getElementsByClassName
def getElementsByClassName(start_node: ParentNode, class_name: str ) -> NodeList: """Get child nodes which has ``class_name`` class attribute.""" classes = set(class_name.split(' ')) return getElementsBy( start_node, lambda node: classes.issubset(set(node.classList...
python
def getElementsByClassName(start_node: ParentNode, class_name: str ) -> NodeList: """Get child nodes which has ``class_name`` class attribute.""" classes = set(class_name.split(' ')) return getElementsBy( start_node, lambda node: classes.issubset(set(node.classList...
[ "def", "getElementsByClassName", "(", "start_node", ":", "ParentNode", ",", "class_name", ":", "str", ")", "->", "NodeList", ":", "classes", "=", "set", "(", "class_name", ".", "split", "(", "' '", ")", ")", "return", "getElementsBy", "(", "start_node", ",",...
Get child nodes which has ``class_name`` class attribute.
[ "Get", "child", "nodes", "which", "has", "class_name", "class", "attribute", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L402-L409
43,671
miyakogi/wdom
wdom/element.py
DOMTokenList.add
def add(self, *tokens: str) -> None: """Add new tokens to list.""" from wdom.web_node import WdomElement _new_tokens = [] for token in tokens: self._validate_token(token) if token and token not in self: self._list.append(token) _new...
python
def add(self, *tokens: str) -> None: """Add new tokens to list.""" from wdom.web_node import WdomElement _new_tokens = [] for token in tokens: self._validate_token(token) if token and token not in self: self._list.append(token) _new...
[ "def", "add", "(", "self", ",", "*", "tokens", ":", "str", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "_new_tokens", "=", "[", "]", "for", "token", "in", "tokens", ":", "self", ".", "_validate_token", "(", "token"...
Add new tokens to list.
[ "Add", "new", "tokens", "to", "list", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L93-L103
43,672
miyakogi/wdom
wdom/element.py
DOMTokenList.remove
def remove(self, *tokens: str) -> None: """Remove tokens from list.""" from wdom.web_node import WdomElement _removed_tokens = [] for token in tokens: self._validate_token(token) if token in self: self._list.remove(token) _removed_t...
python
def remove(self, *tokens: str) -> None: """Remove tokens from list.""" from wdom.web_node import WdomElement _removed_tokens = [] for token in tokens: self._validate_token(token) if token in self: self._list.remove(token) _removed_t...
[ "def", "remove", "(", "self", ",", "*", "tokens", ":", "str", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "_removed_tokens", "=", "[", "]", "for", "token", "in", "tokens", ":", "self", ".", "_validate_token", "(", ...
Remove tokens from list.
[ "Remove", "tokens", "from", "list", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L105-L115
43,673
miyakogi/wdom
wdom/element.py
DOMTokenList.contains
def contains(self, token: str) -> bool: """Return if the token is in the list or not.""" self._validate_token(token) return token in self
python
def contains(self, token: str) -> bool: """Return if the token is in the list or not.""" self._validate_token(token) return token in self
[ "def", "contains", "(", "self", ",", "token", ":", "str", ")", "->", "bool", ":", "self", ".", "_validate_token", "(", "token", ")", "return", "token", "in", "self" ]
Return if the token is in the list or not.
[ "Return", "if", "the", "token", "is", "in", "the", "list", "or", "not", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L141-L144
43,674
miyakogi/wdom
wdom/element.py
Attr.html
def html(self) -> str: """Return string representation of this. Used in start tag of HTML representation of the Element node. """ if self._owner and self.name in self._owner._special_attr_boolean: return self.name else: value = self.value if i...
python
def html(self) -> str: """Return string representation of this. Used in start tag of HTML representation of the Element node. """ if self._owner and self.name in self._owner._special_attr_boolean: return self.name else: value = self.value if i...
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_owner", "and", "self", ".", "name", "in", "self", ".", "_owner", ".", "_special_attr_boolean", ":", "return", "self", ".", "name", "else", ":", "value", "=", "self", ".", "value"...
Return string representation of this. Used in start tag of HTML representation of the Element node.
[ "Return", "string", "representation", "of", "this", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L175-L186
43,675
miyakogi/wdom
wdom/element.py
DraggableAttr.html
def html(self) -> str: """Return html representation.""" if isinstance(self.value, bool): val = 'true' if self.value else 'false' else: val = str(self.value) return 'draggable="{}"'.format(val)
python
def html(self) -> str: """Return html representation.""" if isinstance(self.value, bool): val = 'true' if self.value else 'false' else: val = str(self.value) return 'draggable="{}"'.format(val)
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "isinstance", "(", "self", ".", "value", ",", "bool", ")", ":", "val", "=", "'true'", "if", "self", ".", "value", "else", "'false'", "else", ":", "val", "=", "str", "(", "self", ".", "value...
Return html representation.
[ "Return", "html", "representation", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L212-L218
43,676
miyakogi/wdom
wdom/element.py
NamedNodeMap.getNamedItem
def getNamedItem(self, name: str) -> Optional[Attr]: """Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None. """ return self._dict.get(name, None)
python
def getNamedItem(self, name: str) -> Optional[Attr]: """Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None. """ return self._dict.get(name, None)
[ "def", "getNamedItem", "(", "self", ",", "name", ":", "str", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "_dict", ".", "get", "(", "name", ",", "None", ")" ]
Get ``Attr`` object which has ``name``. If does not have ``name`` attr, return None.
[ "Get", "Attr", "object", "which", "has", "name", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L258-L263
43,677
miyakogi/wdom
wdom/element.py
NamedNodeMap.setNamedItem
def setNamedItem(self, item: Attr) -> None: """Set ``Attr`` object in this collection.""" from wdom.web_node import WdomElement if not isinstance(item, Attr): raise TypeError('item must be an instance of Attr') if isinstance(self._owner, WdomElement): self._owner....
python
def setNamedItem(self, item: Attr) -> None: """Set ``Attr`` object in this collection.""" from wdom.web_node import WdomElement if not isinstance(item, Attr): raise TypeError('item must be an instance of Attr') if isinstance(self._owner, WdomElement): self._owner....
[ "def", "setNamedItem", "(", "self", ",", "item", ":", "Attr", ")", "->", "None", ":", "from", "wdom", ".", "web_node", "import", "WdomElement", "if", "not", "isinstance", "(", "item", ",", "Attr", ")", ":", "raise", "TypeError", "(", "'item must be an inst...
Set ``Attr`` object in this collection.
[ "Set", "Attr", "object", "in", "this", "collection", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L265-L274
43,678
miyakogi/wdom
wdom/element.py
NamedNodeMap.item
def item(self, index: int) -> Optional[Attr]: """Return ``index``-th attr node.""" if 0 <= index < len(self): return self._dict[tuple(self._dict.keys())[index]] return None
python
def item(self, index: int) -> Optional[Attr]: """Return ``index``-th attr node.""" if 0 <= index < len(self): return self._dict[tuple(self._dict.keys())[index]] return None
[ "def", "item", "(", "self", ",", "index", ":", "int", ")", "->", "Optional", "[", "Attr", "]", ":", "if", "0", "<=", "index", "<", "len", "(", "self", ")", ":", "return", "self", ".", "_dict", "[", "tuple", "(", "self", ".", "_dict", ".", "keys...
Return ``index``-th attr node.
[ "Return", "index", "-", "th", "attr", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L288-L292
43,679
miyakogi/wdom
wdom/element.py
NamedNodeMap.toString
def toString(self) -> str: """Return string representation of collections.""" return ' '.join(attr.html for attr in self._dict.values())
python
def toString(self) -> str: """Return string representation of collections.""" return ' '.join(attr.html for attr in self._dict.values())
[ "def", "toString", "(", "self", ")", "->", "str", ":", "return", "' '", ".", "join", "(", "attr", ".", "html", "for", "attr", "in", "self", ".", "_dict", ".", "values", "(", ")", ")" ]
Return string representation of collections.
[ "Return", "string", "representation", "of", "collections", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L294-L296
43,680
miyakogi/wdom
wdom/element.py
Element.start_tag
def start_tag(self) -> str: """Return HTML start tag.""" tag = '<' + self.tag attrs = self._get_attrs_by_string() if attrs: tag = ' '.join((tag, attrs)) return tag + '>'
python
def start_tag(self) -> str: """Return HTML start tag.""" tag = '<' + self.tag attrs = self._get_attrs_by_string() if attrs: tag = ' '.join((tag, attrs)) return tag + '>'
[ "def", "start_tag", "(", "self", ")", "->", "str", ":", "tag", "=", "'<'", "+", "self", ".", "tag", "attrs", "=", "self", ".", "_get_attrs_by_string", "(", ")", "if", "attrs", ":", "tag", "=", "' '", ".", "join", "(", "(", "tag", ",", "attrs", ")...
Return HTML start tag.
[ "Return", "HTML", "start", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L480-L486
43,681
miyakogi/wdom
wdom/element.py
Element.insertAdjacentHTML
def insertAdjacentHTML(self, position: str, html: str) -> None: """Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd". """ df = self._parse_html(html) pos =...
python
def insertAdjacentHTML(self, position: str, html: str) -> None: """Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd". """ df = self._parse_html(html) pos =...
[ "def", "insertAdjacentHTML", "(", "self", ",", "position", ":", "str", ",", "html", ":", "str", ")", "->", "None", ":", "df", "=", "self", ".", "_parse_html", "(", "html", ")", "pos", "=", "position", ".", "lower", "(", ")", "if", "pos", "==", "'be...
Parse ``html`` to DOM and insert to ``position``. ``position`` is a case-insensive string, and must be one of "beforeBegin", "afterBegin", "beforeEnd", or "afterEnd".
[ "Parse", "html", "to", "DOM", "and", "insert", "to", "position", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L523-L543
43,682
miyakogi/wdom
wdom/element.py
Element.getAttribute
def getAttribute(self, attr: str) -> _AttrValueType: """Get attribute of this node as string format. If this node does not have ``attr``, return None. """ if attr == 'class': if self.classList: return self.classList.toString() return None ...
python
def getAttribute(self, attr: str) -> _AttrValueType: """Get attribute of this node as string format. If this node does not have ``attr``, return None. """ if attr == 'class': if self.classList: return self.classList.toString() return None ...
[ "def", "getAttribute", "(", "self", ",", "attr", ":", "str", ")", "->", "_AttrValueType", ":", "if", "attr", "==", "'class'", ":", "if", "self", ".", "classList", ":", "return", "self", ".", "classList", ".", "toString", "(", ")", "return", "None", "at...
Get attribute of this node as string format. If this node does not have ``attr``, return None.
[ "Get", "attribute", "of", "this", "node", "as", "string", "format", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L579-L591
43,683
miyakogi/wdom
wdom/element.py
Element.getAttributeNode
def getAttributeNode(self, attr: str) -> Optional[Attr]: """Get attribute of this node as Attr format. If this node does not have ``attr``, return None. """ return self.attributes.getNamedItem(attr)
python
def getAttributeNode(self, attr: str) -> Optional[Attr]: """Get attribute of this node as Attr format. If this node does not have ``attr``, return None. """ return self.attributes.getNamedItem(attr)
[ "def", "getAttributeNode", "(", "self", ",", "attr", ":", "str", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "attributes", ".", "getNamedItem", "(", "attr", ")" ]
Get attribute of this node as Attr format. If this node does not have ``attr``, return None.
[ "Get", "attribute", "of", "this", "node", "as", "Attr", "format", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L593-L598
43,684
miyakogi/wdom
wdom/element.py
Element.hasAttribute
def hasAttribute(self, attr: str) -> bool: """Return True if this node has ``attr``.""" if attr == 'class': return bool(self.classList) return attr in self.attributes
python
def hasAttribute(self, attr: str) -> bool: """Return True if this node has ``attr``.""" if attr == 'class': return bool(self.classList) return attr in self.attributes
[ "def", "hasAttribute", "(", "self", ",", "attr", ":", "str", ")", "->", "bool", ":", "if", "attr", "==", "'class'", ":", "return", "bool", "(", "self", ".", "classList", ")", "return", "attr", "in", "self", ".", "attributes" ]
Return True if this node has ``attr``.
[ "Return", "True", "if", "this", "node", "has", "attr", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L600-L604
43,685
miyakogi/wdom
wdom/element.py
Element.setAttribute
def setAttribute(self, attr: str, value: _AttrValueType) -> None: """Set ``attr`` and ``value`` in this node.""" self._set_attribute(attr, value)
python
def setAttribute(self, attr: str, value: _AttrValueType) -> None: """Set ``attr`` and ``value`` in this node.""" self._set_attribute(attr, value)
[ "def", "setAttribute", "(", "self", ",", "attr", ":", "str", ",", "value", ":", "_AttrValueType", ")", "->", "None", ":", "self", ".", "_set_attribute", "(", "attr", ",", "value", ")" ]
Set ``attr`` and ``value`` in this node.
[ "Set", "attr", "and", "value", "in", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L646-L648
43,686
miyakogi/wdom
wdom/element.py
Element.removeAttributeNode
def removeAttributeNode(self, attr: Attr) -> Optional[Attr]: """Remove ``Attr`` node from this node.""" return self.attributes.removeNamedItem(attr)
python
def removeAttributeNode(self, attr: Attr) -> Optional[Attr]: """Remove ``Attr`` node from this node.""" return self.attributes.removeNamedItem(attr)
[ "def", "removeAttributeNode", "(", "self", ",", "attr", ":", "Attr", ")", "->", "Optional", "[", "Attr", "]", ":", "return", "self", ".", "attributes", ".", "removeNamedItem", "(", "attr", ")" ]
Remove ``Attr`` node from this node.
[ "Remove", "Attr", "node", "from", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L668-L670
43,687
miyakogi/wdom
wdom/element.py
HTMLElement.style
def style(self, style: _AttrValueType) -> None: """Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``. """ if isinstance(style, str): self.__style._parse_str(style) elif style is None: s...
python
def style(self, style: _AttrValueType) -> None: """Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``. """ if isinstance(style, str): self.__style._parse_str(style) elif style is None: s...
[ "def", "style", "(", "self", ",", "style", ":", "_AttrValueType", ")", "->", "None", ":", "if", "isinstance", "(", "style", ",", "str", ")", ":", "self", ".", "__style", ".", "_parse_str", "(", "style", ")", "elif", "style", "is", "None", ":", "self"...
Set style attribute of this node. If argument ``style`` is string, it will be parsed to ``CSSStyleDeclaration``.
[ "Set", "style", "attribute", "of", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L735-L756
43,688
miyakogi/wdom
wdom/element.py
HTMLElement.draggable
def draggable(self) -> Union[bool, str]: """Get ``draggable`` property.""" if not self.hasAttribute('draggable'): return False return self.getAttribute('draggable')
python
def draggable(self) -> Union[bool, str]: """Get ``draggable`` property.""" if not self.hasAttribute('draggable'): return False return self.getAttribute('draggable')
[ "def", "draggable", "(", "self", ")", "->", "Union", "[", "bool", ",", "str", "]", ":", "if", "not", "self", ".", "hasAttribute", "(", "'draggable'", ")", ":", "return", "False", "return", "self", ".", "getAttribute", "(", "'draggable'", ")" ]
Get ``draggable`` property.
[ "Get", "draggable", "property", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L759-L763
43,689
miyakogi/wdom
wdom/element.py
HTMLElement.draggable
def draggable(self, value: Union[bool, str]) -> None: """Set ``draggable`` property. ``value`` is boolean or string. """ if value is False: self.removeAttribute('draggable') else: self.setAttribute('draggable', value)
python
def draggable(self, value: Union[bool, str]) -> None: """Set ``draggable`` property. ``value`` is boolean or string. """ if value is False: self.removeAttribute('draggable') else: self.setAttribute('draggable', value)
[ "def", "draggable", "(", "self", ",", "value", ":", "Union", "[", "bool", ",", "str", "]", ")", "->", "None", ":", "if", "value", "is", "False", ":", "self", ".", "removeAttribute", "(", "'draggable'", ")", "else", ":", "self", ".", "setAttribute", "...
Set ``draggable`` property. ``value`` is boolean or string.
[ "Set", "draggable", "property", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L766-L774
43,690
miyakogi/wdom
wdom/element.py
FormControlMixin.form
def form(self) -> Optional['HTMLFormElement']: """Get ``HTMLFormElement`` object related to this node.""" if self.__form: return self.__form parent = self.parentNode while parent: if isinstance(parent, HTMLFormElement): return parent el...
python
def form(self) -> Optional['HTMLFormElement']: """Get ``HTMLFormElement`` object related to this node.""" if self.__form: return self.__form parent = self.parentNode while parent: if isinstance(parent, HTMLFormElement): return parent el...
[ "def", "form", "(", "self", ")", "->", "Optional", "[", "'HTMLFormElement'", "]", ":", "if", "self", ".", "__form", ":", "return", "self", ".", "__form", "parent", "=", "self", ".", "parentNode", "while", "parent", ":", "if", "isinstance", "(", "parent",...
Get ``HTMLFormElement`` object related to this node.
[ "Get", "HTMLFormElement", "object", "related", "to", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L818-L828
43,691
miyakogi/wdom
wdom/element.py
HTMLLabelElement.control
def control(self) -> Optional[HTMLElement]: """Return related HTMLElement object.""" id = self.getAttribute('for') if id: if self.ownerDocument: return self.ownerDocument.getElementById(id) elif isinstance(id, str): from wdom.document impor...
python
def control(self) -> Optional[HTMLElement]: """Return related HTMLElement object.""" id = self.getAttribute('for') if id: if self.ownerDocument: return self.ownerDocument.getElementById(id) elif isinstance(id, str): from wdom.document impor...
[ "def", "control", "(", "self", ")", "->", "Optional", "[", "HTMLElement", "]", ":", "id", "=", "self", ".", "getAttribute", "(", "'for'", ")", "if", "id", ":", "if", "self", ".", "ownerDocument", ":", "return", "self", ".", "ownerDocument", ".", "getEl...
Return related HTMLElement object.
[ "Return", "related", "HTMLElement", "object", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L933-L944
43,692
miyakogi/wdom
wdom/element.py
HTMLSelectElement.selectedOptions
def selectedOptions(self) -> NodeList: """Return all selected option nodes.""" return NodeList(list(opt for opt in self.options if opt.selected))
python
def selectedOptions(self) -> NodeList: """Return all selected option nodes.""" return NodeList(list(opt for opt in self.options if opt.selected))
[ "def", "selectedOptions", "(", "self", ")", "->", "NodeList", ":", "return", "NodeList", "(", "list", "(", "opt", "for", "opt", "in", "self", ".", "options", "if", "opt", ".", "selected", ")", ")" ]
Return all selected option nodes.
[ "Return", "all", "selected", "option", "nodes", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/element.py#L1005-L1007
43,693
miyakogi/wdom
wdom/tag.py
NewTagClass
def NewTagClass(class_name: str, tag: str = None, bases: Union[type, Iterable] = (Tag, ), **kwargs: Any) -> type: """Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple ...
python
def NewTagClass(class_name: str, tag: str = None, bases: Union[type, Iterable] = (Tag, ), **kwargs: Any) -> type: """Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple ...
[ "def", "NewTagClass", "(", "class_name", ":", "str", ",", "tag", ":", "str", "=", "None", ",", "bases", ":", "Union", "[", "type", ",", "Iterable", "]", "=", "(", "Tag", ",", ")", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "type", ":", "if...
Generate and return new ``Tag`` class. If ``tag`` is empty, lower case of ``class_name`` is used for a tag name of the new class. ``bases`` should be a tuple of base classes. If it is empty, use ``Tag`` class for a base class. Other keyword arguments are used for class variables of the new class. ...
[ "Generate", "and", "return", "new", "Tag", "class", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L170-L203
43,694
miyakogi/wdom
wdom/tag.py
Tag._clone_node
def _clone_node(self) -> 'Tag': """Need to copy class, not tag. So need to re-implement copy. """ clone = type(self)() for attr in self.attributes: clone.setAttribute(attr, self.getAttribute(attr)) for c in self.classList: clone.addClass(c) ...
python
def _clone_node(self) -> 'Tag': """Need to copy class, not tag. So need to re-implement copy. """ clone = type(self)() for attr in self.attributes: clone.setAttribute(attr, self.getAttribute(attr)) for c in self.classList: clone.addClass(c) ...
[ "def", "_clone_node", "(", "self", ")", "->", "'Tag'", ":", "clone", "=", "type", "(", "self", ")", "(", ")", "for", "attr", "in", "self", ".", "attributes", ":", "clone", ".", "setAttribute", "(", "attr", ",", "self", ".", "getAttribute", "(", "attr...
Need to copy class, not tag. So need to re-implement copy.
[ "Need", "to", "copy", "class", "not", "tag", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L63-L75
43,695
miyakogi/wdom
wdom/tag.py
NestedTag.textContent
def textContent(self, text: str) -> None: # type: ignore """Set text content to inner node.""" if self._inner_element: self._inner_element.textContent = text else: # Need a trick to call property of super-class super().textContent = text
python
def textContent(self, text: str) -> None: # type: ignore """Set text content to inner node.""" if self._inner_element: self._inner_element.textContent = text else: # Need a trick to call property of super-class super().textContent = text
[ "def", "textContent", "(", "self", ",", "text", ":", "str", ")", "->", "None", ":", "# type: ignore", "if", "self", ".", "_inner_element", ":", "self", ".", "_inner_element", ".", "textContent", "=", "text", "else", ":", "# Need a trick to call property of super...
Set text content to inner node.
[ "Set", "text", "content", "to", "inner", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L139-L145
43,696
miyakogi/wdom
wdom/tag.py
NestedTag.html
def html(self) -> str: """Get whole html representation of this node.""" if self._inner_element: return self.start_tag + self._inner_element.html + self.end_tag return super().html
python
def html(self) -> str: """Get whole html representation of this node.""" if self._inner_element: return self.start_tag + self._inner_element.html + self.end_tag return super().html
[ "def", "html", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_inner_element", ":", "return", "self", ".", "start_tag", "+", "self", ".", "_inner_element", ".", "html", "+", "self", ".", "end_tag", "return", "super", "(", ")", ".", "html" ]
Get whole html representation of this node.
[ "Get", "whole", "html", "representation", "of", "this", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L148-L152
43,697
miyakogi/wdom
wdom/tag.py
NestedTag.innerHTML
def innerHTML(self) -> str: """Get innerHTML of the inner node.""" if self._inner_element: return self._inner_element.innerHTML return super().innerHTML
python
def innerHTML(self) -> str: """Get innerHTML of the inner node.""" if self._inner_element: return self._inner_element.innerHTML return super().innerHTML
[ "def", "innerHTML", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_inner_element", ":", "return", "self", ".", "_inner_element", ".", "innerHTML", "return", "super", "(", ")", ".", "innerHTML" ]
Get innerHTML of the inner node.
[ "Get", "innerHTML", "of", "the", "inner", "node", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/tag.py#L155-L159
43,698
miyakogi/wdom
wdom/server/_tornado.py
MainHandler.get
def get(self) -> None: """Return whole html representation of the root document.""" from wdom.document import get_document logger.info('connected') self.write(get_document().build())
python
def get(self) -> None: """Return whole html representation of the root document.""" from wdom.document import get_document logger.info('connected') self.write(get_document().build())
[ "def", "get", "(", "self", ")", "->", "None", ":", "from", "wdom", ".", "document", "import", "get_document", "logger", ".", "info", "(", "'connected'", ")", "self", ".", "write", "(", "get_document", "(", ")", ".", "build", "(", ")", ")" ]
Return whole html representation of the root document.
[ "Return", "whole", "html", "representation", "of", "the", "root", "document", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L35-L39
43,699
miyakogi/wdom
wdom/server/_tornado.py
WSHandler.terminate
async def terminate(self) -> None: """Terminate server if no more connection exists.""" await asyncio.sleep(config.shutdown_wait) # stop server and close loop if no more connection exists if not is_connected(): stop_server(self.application.server) self.application...
python
async def terminate(self) -> None: """Terminate server if no more connection exists.""" await asyncio.sleep(config.shutdown_wait) # stop server and close loop if no more connection exists if not is_connected(): stop_server(self.application.server) self.application...
[ "async", "def", "terminate", "(", "self", ")", "->", "None", ":", "await", "asyncio", ".", "sleep", "(", "config", ".", "shutdown_wait", ")", "# stop server and close loop if no more connection exists", "if", "not", "is_connected", "(", ")", ":", "stop_server", "(...
Terminate server if no more connection exists.
[ "Terminate", "server", "if", "no", "more", "connection", "exists", "." ]
a21bcd23e94baceee71161829f6897bee3fd39c1
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/_tornado.py#L54-L60