repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.createx
def createx(self, object_type, under=None, attributes=None, **kwattrs): """Create a new automation object. Arguments: object_type -- Type of object to create. under -- Handle of the parent of the new object. attributes -- Dictionary of attributes (name-value pairs). ...
python
def createx(self, object_type, under=None, attributes=None, **kwattrs): """Create a new automation object. Arguments: object_type -- Type of object to create. under -- Handle of the parent of the new object. attributes -- Dictionary of attributes (name-value pairs). ...
[ "def", "createx", "(", "self", ",", "object_type", ",", "under", "=", "None", ",", "attributes", "=", "None", ",", "*", "*", "kwattrs", ")", ":", "self", ".", "_check_session", "(", ")", "params", "=", "{", "'object_type'", ":", "object_type", "}", "if...
Create a new automation object. Arguments: object_type -- Type of object to create. under -- Handle of the parent of the new object. attributes -- Dictionary of attributes (name-value pairs). kwattrs -- Optional keyword attributes (name=value pairs). Return: ...
[ "Create", "a", "new", "automation", "object", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L378-L401
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.delete
def delete(self, handle): """Delete the specified object. Arguments: handle -- Handle of object to delete. """ self._check_session() self._rest.delete_request('objects', str(handle))
python
def delete(self, handle): """Delete the specified object. Arguments: handle -- Handle of object to delete. """ self._check_session() self._rest.delete_request('objects', str(handle))
[ "def", "delete", "(", "self", ",", "handle", ")", ":", "self", ".", "_check_session", "(", ")", "self", ".", "_rest", ".", "delete_request", "(", "'objects'", ",", "str", "(", "handle", ")", ")" ]
Delete the specified object. Arguments: handle -- Handle of object to delete.
[ "Delete", "the", "specified", "object", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L403-L411
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.perform
def perform(self, command, params=None, **kwargs): """Execute a command. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.perform('LoadFromXml', {'filename':'config.xml'}) stc.perform('LoadFromXml', filename='config.xml') ...
python
def perform(self, command, params=None, **kwargs): """Execute a command. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.perform('LoadFromXml', {'filename':'config.xml'}) stc.perform('LoadFromXml', filename='config.xml') ...
[ "def", "perform", "(", "self", ",", "command", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_session", "(", ")", "if", "not", "params", ":", "params", "=", "{", "}", "if", "kwargs", ":", "params", ".", "update"...
Execute a command. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.perform('LoadFromXml', {'filename':'config.xml'}) stc.perform('LoadFromXml', filename='config.xml') Arguments: command -- Command to execute. para...
[ "Execute", "a", "command", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L413-L437
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.config
def config(self, handle, attributes=None, **kwattrs): """Sets or modifies one or more object attributes or relations. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.config('port1', location='//10.1.2.3/1/1') stc.config('port2', {...
python
def config(self, handle, attributes=None, **kwattrs): """Sets or modifies one or more object attributes or relations. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.config('port1', location='//10.1.2.3/1/1') stc.config('port2', {...
[ "def", "config", "(", "self", ",", "handle", ",", "attributes", "=", "None", ",", "*", "*", "kwattrs", ")", ":", "self", ".", "_check_session", "(", ")", "if", "kwattrs", ":", "if", "attributes", ":", "attributes", ".", "update", "(", "kwattrs", ")", ...
Sets or modifies one or more object attributes or relations. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.config('port1', location='//10.1.2.3/1/1') stc.config('port2', {'location': '//10.1.2.3/1/2'}) Arguments: handle...
[ "Sets", "or", "modifies", "one", "or", "more", "object", "attributes", "or", "relations", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L439-L459
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.chassis
def chassis(self): """Get list of chassis known to test session.""" self._check_session() status, data = self._rest.get_request('chassis') return data
python
def chassis(self): """Get list of chassis known to test session.""" self._check_session() status, data = self._rest.get_request('chassis') return data
[ "def", "chassis", "(", "self", ")", ":", "self", ".", "_check_session", "(", ")", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'chassis'", ")", "return", "data" ]
Get list of chassis known to test session.
[ "Get", "list", "of", "chassis", "known", "to", "test", "session", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L461-L465
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.chassis_info
def chassis_info(self, chassis): """Get information about the specified chassis.""" if not chassis or not isinstance(chassis, str): raise RuntimeError('missing chassis address') self._check_session() status, data = self._rest.get_request('chassis', chassis) return dat...
python
def chassis_info(self, chassis): """Get information about the specified chassis.""" if not chassis or not isinstance(chassis, str): raise RuntimeError('missing chassis address') self._check_session() status, data = self._rest.get_request('chassis', chassis) return dat...
[ "def", "chassis_info", "(", "self", ",", "chassis", ")", ":", "if", "not", "chassis", "or", "not", "isinstance", "(", "chassis", ",", "str", ")", ":", "raise", "RuntimeError", "(", "'missing chassis address'", ")", "self", ".", "_check_session", "(", ")", ...
Get information about the specified chassis.
[ "Get", "information", "about", "the", "specified", "chassis", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L467-L473
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.connections
def connections(self): """Get list of connections.""" self._check_session() status, data = self._rest.get_request('connections') return data
python
def connections(self): """Get list of connections.""" self._check_session() status, data = self._rest.get_request('connections') return data
[ "def", "connections", "(", "self", ")", ":", "self", ".", "_check_session", "(", ")", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'connections'", ")", "return", "data" ]
Get list of connections.
[ "Get", "list", "of", "connections", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L475-L479
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.is_connected
def is_connected(self, chassis): """Get Boolean connected status of the specified chassis.""" self._check_session() try: status, data = self._rest.get_request('connections', chassis) except resthttp.RestHttpError as e: if int(e) == 404: # 404 NOT F...
python
def is_connected(self, chassis): """Get Boolean connected status of the specified chassis.""" self._check_session() try: status, data = self._rest.get_request('connections', chassis) except resthttp.RestHttpError as e: if int(e) == 404: # 404 NOT F...
[ "def", "is_connected", "(", "self", ",", "chassis", ")", ":", "self", ".", "_check_session", "(", ")", "try", ":", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'connections'", ",", "chassis", ")", "except", "resthttp", ".",...
Get Boolean connected status of the specified chassis.
[ "Get", "Boolean", "connected", "status", "of", "the", "specified", "chassis", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L481-L490
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.connect
def connect(self, chassis_list): """Establish connection to one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) Return: List of chassis addresses. """ self._check_session() if not isinstance(chassis_list, (list, t...
python
def connect(self, chassis_list): """Establish connection to one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) Return: List of chassis addresses. """ self._check_session() if not isinstance(chassis_list, (list, t...
[ "def", "connect", "(", "self", ",", "chassis_list", ")", ":", "self", ".", "_check_session", "(", ")", "if", "not", "isinstance", "(", "chassis_list", ",", "(", "list", ",", "tuple", ",", "set", ",", "dict", ",", "frozenset", ")", ")", ":", "chassis_li...
Establish connection to one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) Return: List of chassis addresses.
[ "Establish", "connection", "to", "one", "or", "more", "chassis", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L492-L514
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.disconnect
def disconnect(self, chassis_list): """Remove connection with one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) """ self._check_session() if not isinstance(chassis_list, (list, tuple, set, dict, frozenset)): chassis_...
python
def disconnect(self, chassis_list): """Remove connection with one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) """ self._check_session() if not isinstance(chassis_list, (list, tuple, set, dict, frozenset)): chassis_...
[ "def", "disconnect", "(", "self", ",", "chassis_list", ")", ":", "self", ".", "_check_session", "(", ")", "if", "not", "isinstance", "(", "chassis_list", ",", "(", "list", ",", "tuple", ",", "set", ",", "dict", ",", "frozenset", ")", ")", ":", "chassis...
Remove connection with one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names)
[ "Remove", "connection", "with", "one", "or", "more", "chassis", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L516-L532
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.help
def help(self, subject=None, args=None): """Get help information about Automation API. The following values can be specified for the subject: None -- gets an overview of help. 'commands' -- gets a list of API functions command name -- get info about the specified com...
python
def help(self, subject=None, args=None): """Get help information about Automation API. The following values can be specified for the subject: None -- gets an overview of help. 'commands' -- gets a list of API functions command name -- get info about the specified com...
[ "def", "help", "(", "self", ",", "subject", "=", "None", ",", "args", "=", "None", ")", ":", "if", "subject", ":", "if", "subject", "not", "in", "(", "'commands'", ",", "'create'", ",", "'config'", ",", "'get'", ",", "'delete'", ",", "'perform'", ","...
Get help information about Automation API. The following values can be specified for the subject: None -- gets an overview of help. 'commands' -- gets a list of API functions command name -- get info about the specified command. object type -- get info about the...
[ "Get", "help", "information", "about", "Automation", "API", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L549-L580
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.log
def log(self, level, msg): """Write a diagnostic message to a log file or to standard output. Arguments: level -- Severity level of entry. One of: INFO, WARN, ERROR, FATAL. msg -- Message to write to log. """ self._check_session() level = level.upper() ...
python
def log(self, level, msg): """Write a diagnostic message to a log file or to standard output. Arguments: level -- Severity level of entry. One of: INFO, WARN, ERROR, FATAL. msg -- Message to write to log. """ self._check_session() level = level.upper() ...
[ "def", "log", "(", "self", ",", "level", ",", "msg", ")", ":", "self", ".", "_check_session", "(", ")", "level", "=", "level", ".", "upper", "(", ")", "allowed_levels", "=", "(", "'INFO'", ",", "'WARN'", ",", "'ERROR'", ",", "'FATAL'", ")", "if", "...
Write a diagnostic message to a log file or to standard output. Arguments: level -- Severity level of entry. One of: INFO, WARN, ERROR, FATAL. msg -- Message to write to log.
[ "Write", "a", "diagnostic", "message", "to", "a", "log", "file", "or", "to", "standard", "output", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L582-L597
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.download
def download(self, file_name, save_as=None): """Download the specified file from the server. Arguments: file_name -- Name of file resource to save. save_as -- Optional path name to write file to. If not specified, then file named by the last part of the resource ...
python
def download(self, file_name, save_as=None): """Download the specified file from the server. Arguments: file_name -- Name of file resource to save. save_as -- Optional path name to write file to. If not specified, then file named by the last part of the resource ...
[ "def", "download", "(", "self", ",", "file_name", ",", "save_as", "=", "None", ")", ":", "self", ".", "_check_session", "(", ")", "try", ":", "if", "save_as", ":", "save_as", "=", "os", ".", "path", ".", "normpath", "(", "save_as", ")", "save_dir", "...
Download the specified file from the server. Arguments: file_name -- Name of file resource to save. save_as -- Optional path name to write file to. If not specified, then file named by the last part of the resource path is downloaded to current direc...
[ "Download", "the", "specified", "file", "from", "the", "server", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L599-L627
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.download_all
def download_all(self, dst_dir=None): """Download all available files. Arguments: dst_dir -- Optional destination directory to write files to. If not specified, then files are downloaded current directory. Return: Dictionary of {file_name: file_size, ..}...
python
def download_all(self, dst_dir=None): """Download all available files. Arguments: dst_dir -- Optional destination directory to write files to. If not specified, then files are downloaded current directory. Return: Dictionary of {file_name: file_size, ..}...
[ "def", "download_all", "(", "self", ",", "dst_dir", "=", "None", ")", ":", "saved", "=", "{", "}", "save_as", "=", "None", "for", "f", "in", "self", ".", "files", "(", ")", ":", "if", "dst_dir", ":", "save_as", "=", "os", ".", "path", ".", "join"...
Download all available files. Arguments: dst_dir -- Optional destination directory to write files to. If not specified, then files are downloaded current directory. Return: Dictionary of {file_name: file_size, ..}
[ "Download", "all", "available", "files", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L629-L647
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.upload
def upload(self, src_file_path, dst_file_name=None): """Upload the specified file to the server.""" self._check_session() status, data = self._rest.upload_file( 'files', src_file_path, dst_file_name) return data
python
def upload(self, src_file_path, dst_file_name=None): """Upload the specified file to the server.""" self._check_session() status, data = self._rest.upload_file( 'files', src_file_path, dst_file_name) return data
[ "def", "upload", "(", "self", ",", "src_file_path", ",", "dst_file_name", "=", "None", ")", ":", "self", ".", "_check_session", "(", ")", "status", ",", "data", "=", "self", ".", "_rest", ".", "upload_file", "(", "'files'", ",", "src_file_path", ",", "ds...
Upload the specified file to the server.
[ "Upload", "the", "specified", "file", "to", "the", "server", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L649-L654
train
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.wait_until_complete
def wait_until_complete(self, timeout=None): """Wait until sequencer is finished. This method blocks your application until the sequencer has completed its operation. It returns once the sequencer has finished. Arguments: timeout -- Optional. Seconds to wait for sequencer to ...
python
def wait_until_complete(self, timeout=None): """Wait until sequencer is finished. This method blocks your application until the sequencer has completed its operation. It returns once the sequencer has finished. Arguments: timeout -- Optional. Seconds to wait for sequencer to ...
[ "def", "wait_until_complete", "(", "self", ",", "timeout", "=", "None", ")", ":", "timeout_at", "=", "None", "if", "timeout", ":", "timeout_at", "=", "time", ".", "time", "(", ")", "+", "int", "(", "timeout", ")", "sequencer", "=", "self", ".", "get", ...
Wait until sequencer is finished. This method blocks your application until the sequencer has completed its operation. It returns once the sequencer has finished. Arguments: timeout -- Optional. Seconds to wait for sequencer to finish. If this time is exceeded, th...
[ "Wait", "until", "sequencer", "is", "finished", "." ]
80ee82bddf2fb2808f3da8ff2c80b7d588e165e8
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L656-L684
train
dcramer/mock-django
mock_django/managers.py
ManagerMock
def ManagerMock(manager, *return_value): """ Set the results to two items: >>> objects = ManagerMock(Post.objects, 'queryset', 'result') >>> assert objects.filter() == objects.all() Force an exception: >>> objects = ManagerMock(Post.objects, Exception()) See QuerySetMock for more about h...
python
def ManagerMock(manager, *return_value): """ Set the results to two items: >>> objects = ManagerMock(Post.objects, 'queryset', 'result') >>> assert objects.filter() == objects.all() Force an exception: >>> objects = ManagerMock(Post.objects, Exception()) See QuerySetMock for more about h...
[ "def", "ManagerMock", "(", "manager", ",", "*", "return_value", ")", ":", "def", "make_get_query_set", "(", "self", ",", "model", ")", ":", "def", "_get", "(", "*", "a", ",", "*", "*", "k", ")", ":", "return", "QuerySetMock", "(", "model", ",", "*", ...
Set the results to two items: >>> objects = ManagerMock(Post.objects, 'queryset', 'result') >>> assert objects.filter() == objects.all() Force an exception: >>> objects = ManagerMock(Post.objects, Exception()) See QuerySetMock for more about how this works.
[ "Set", "the", "results", "to", "two", "items", ":" ]
1168d3255e0d67fbf74a9c71feaccbdafef59d21
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/managers.py#L17-L50
train
dcramer/mock-django
mock_django/shared.py
SharedMock.assert_chain_calls
def assert_chain_calls(self, *calls): """ Asserts that a chained method was called (parents in the chain do not matter, nor are they tracked). Use with `mock.call`. >>> obj.filter(foo='bar').select_related('baz') >>> obj.assert_chain_calls(mock.call.filter(foo='bar')) >...
python
def assert_chain_calls(self, *calls): """ Asserts that a chained method was called (parents in the chain do not matter, nor are they tracked). Use with `mock.call`. >>> obj.filter(foo='bar').select_related('baz') >>> obj.assert_chain_calls(mock.call.filter(foo='bar')) >...
[ "def", "assert_chain_calls", "(", "self", ",", "*", "calls", ")", ":", "all_calls", "=", "self", ".", "__parent", ".", "mock_calls", "[", ":", "]", "not_found", "=", "[", "]", "for", "kall", "in", "calls", ":", "try", ":", "all_calls", ".", "remove", ...
Asserts that a chained method was called (parents in the chain do not matter, nor are they tracked). Use with `mock.call`. >>> obj.filter(foo='bar').select_related('baz') >>> obj.assert_chain_calls(mock.call.filter(foo='bar')) >>> obj.assert_chain_calls(mock.call.select_related('baz'))...
[ "Asserts", "that", "a", "chained", "method", "was", "called", "(", "parents", "in", "the", "chain", "do", "not", "matter", "nor", "are", "they", "tracked", ")", ".", "Use", "with", "mock", ".", "call", "." ]
1168d3255e0d67fbf74a9c71feaccbdafef59d21
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/shared.py#L50-L77
train
dcramer/mock-django
mock_django/signals.py
mock_signal_receiver
def mock_signal_receiver(signal, wraps=None, **kwargs): """ Temporarily attaches a receiver to the provided ``signal`` within the scope of the context manager. The mocked receiver is returned as the ``as`` target of the ``with`` statement. To have the mocked receiver wrap a callable, pass the ...
python
def mock_signal_receiver(signal, wraps=None, **kwargs): """ Temporarily attaches a receiver to the provided ``signal`` within the scope of the context manager. The mocked receiver is returned as the ``as`` target of the ``with`` statement. To have the mocked receiver wrap a callable, pass the ...
[ "def", "mock_signal_receiver", "(", "signal", ",", "wraps", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "wraps", "is", "None", ":", "def", "wraps", "(", "*", "args", ",", "*", "*", "kwrags", ")", ":", "return", "None", "receiver", "=", "m...
Temporarily attaches a receiver to the provided ``signal`` within the scope of the context manager. The mocked receiver is returned as the ``as`` target of the ``with`` statement. To have the mocked receiver wrap a callable, pass the callable as the ``wraps`` keyword argument. All other keyword ar...
[ "Temporarily", "attaches", "a", "receiver", "to", "the", "provided", "signal", "within", "the", "scope", "of", "the", "context", "manager", "." ]
1168d3255e0d67fbf74a9c71feaccbdafef59d21
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/signals.py#L13-L36
train
dcramer/mock-django
mock_django/query.py
QuerySetMock
def QuerySetMock(model, *return_value): """ Get a SharedMock that returns self for most attributes and a new copy of itself for any method that ordinarily generates QuerySets. Set the results to two items: >>> class Post(object): pass >>> objects = QuerySetMock(Post, 'return', 'values') >>...
python
def QuerySetMock(model, *return_value): """ Get a SharedMock that returns self for most attributes and a new copy of itself for any method that ordinarily generates QuerySets. Set the results to two items: >>> class Post(object): pass >>> objects = QuerySetMock(Post, 'return', 'values') >>...
[ "def", "QuerySetMock", "(", "model", ",", "*", "return_value", ")", ":", "def", "make_get", "(", "self", ",", "model", ")", ":", "def", "_get", "(", "*", "a", ",", "*", "*", "k", ")", ":", "results", "=", "list", "(", "self", ")", "if", "len", ...
Get a SharedMock that returns self for most attributes and a new copy of itself for any method that ordinarily generates QuerySets. Set the results to two items: >>> class Post(object): pass >>> objects = QuerySetMock(Post, 'return', 'values') >>> assert list(objects.filter()) == list(objects.all(...
[ "Get", "a", "SharedMock", "that", "returns", "self", "for", "most", "attributes", "and", "a", "new", "copy", "of", "itself", "for", "any", "method", "that", "ordinarily", "generates", "QuerySets", "." ]
1168d3255e0d67fbf74a9c71feaccbdafef59d21
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/query.py#L21-L109
train
trendmicro/flask-ini
flask_ini.py
FlaskIni.read
def read(self, *args, **kwargs): '''Overridden read() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.read(self, *args, **kwargs) self.parse_flask_section() return ret
python
def read(self, *args, **kwargs): '''Overridden read() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.read(self, *args, **kwargs) self.parse_flask_section() return ret
[ "def", "read", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "configparser", ".", "SafeConfigParser", ".", "read", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "parse_flask_section", "(", ...
Overridden read() method to call parse_flask_section() at the end
[ "Overridden", "read", "()", "method", "to", "call", "parse_flask_section", "()", "at", "the", "end" ]
a1e4baa598c9a01021a1333d9c15e4d99c8334dd
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L12-L16
train
trendmicro/flask-ini
flask_ini.py
FlaskIni.readfp
def readfp(self, *args, **kwargs): '''Overridden readfp() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.readfp(self, *args, **kwargs) self.parse_flask_section() return ret
python
def readfp(self, *args, **kwargs): '''Overridden readfp() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.readfp(self, *args, **kwargs) self.parse_flask_section() return ret
[ "def", "readfp", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "configparser", ".", "SafeConfigParser", ".", "readfp", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "parse_flask_section", "(...
Overridden readfp() method to call parse_flask_section() at the end
[ "Overridden", "readfp", "()", "method", "to", "call", "parse_flask_section", "()", "at", "the", "end" ]
a1e4baa598c9a01021a1333d9c15e4d99c8334dd
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L18-L23
train
trendmicro/flask-ini
flask_ini.py
FlaskIni.parse_flask_section
def parse_flask_section(self): '''Parse the [flask] section of your config and hand off the config to the app in context. Config vars should have the same name as their flask equivalent except in all lower-case.''' if self.has_section('flask'): for item in self.items...
python
def parse_flask_section(self): '''Parse the [flask] section of your config and hand off the config to the app in context. Config vars should have the same name as their flask equivalent except in all lower-case.''' if self.has_section('flask'): for item in self.items...
[ "def", "parse_flask_section", "(", "self", ")", ":", "if", "self", ".", "has_section", "(", "'flask'", ")", ":", "for", "item", "in", "self", ".", "items", "(", "'flask'", ")", ":", "self", ".", "_load_item", "(", "item", "[", "0", "]", ")", "else", ...
Parse the [flask] section of your config and hand off the config to the app in context. Config vars should have the same name as their flask equivalent except in all lower-case.
[ "Parse", "the", "[", "flask", "]", "section", "of", "your", "config", "and", "hand", "off", "the", "config", "to", "the", "app", "in", "context", "." ]
a1e4baa598c9a01021a1333d9c15e4d99c8334dd
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L25-L35
train
trendmicro/flask-ini
flask_ini.py
FlaskIni._load_item
def _load_item(self, key): '''Load the specified item from the [flask] section. Type is determined by the type of the equivalent value in app.default_config or string if unknown.''' key_u = key.upper() default = current_app.default_config.get(key_u) # One of the defaul...
python
def _load_item(self, key): '''Load the specified item from the [flask] section. Type is determined by the type of the equivalent value in app.default_config or string if unknown.''' key_u = key.upper() default = current_app.default_config.get(key_u) # One of the defaul...
[ "def", "_load_item", "(", "self", ",", "key", ")", ":", "key_u", "=", "key", ".", "upper", "(", ")", "default", "=", "current_app", ".", "default_config", ".", "get", "(", "key_u", ")", "# One of the default config vars is a timedelta - interpret it", "# as an int...
Load the specified item from the [flask] section. Type is determined by the type of the equivalent value in app.default_config or string if unknown.
[ "Load", "the", "specified", "item", "from", "the", "[", "flask", "]", "section", ".", "Type", "is", "determined", "by", "the", "type", "of", "the", "equivalent", "value", "in", "app", ".", "default_config", "or", "string", "if", "unknown", "." ]
a1e4baa598c9a01021a1333d9c15e4d99c8334dd
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L38-L58
train
guilhermechapiewski/simple-db-migrate
simple_db_migrate/main.py
Main._execute_migrations
def _execute_migrations(self, current_version, destination_version): """ passed a version: this version don't exists in the database and is younger than the last version -> do migrations up until this version this version don't exists in the database and is older than the last ve...
python
def _execute_migrations(self, current_version, destination_version): """ passed a version: this version don't exists in the database and is younger than the last version -> do migrations up until this version this version don't exists in the database and is older than the last ve...
[ "def", "_execute_migrations", "(", "self", ",", "current_version", ",", "destination_version", ")", ":", "is_migration_up", "=", "True", "# check if a version was passed to the program", "if", "self", ".", "config", ".", "get", "(", "\"schema_version\"", ")", ":", "# ...
passed a version: this version don't exists in the database and is younger than the last version -> do migrations up until this version this version don't exists in the database and is older than the last version -> do nothing, is a unpredictable behavior this version exists in the d...
[ "passed", "a", "version", ":", "this", "version", "don", "t", "exists", "in", "the", "database", "and", "is", "younger", "than", "the", "last", "version", "-", ">", "do", "migrations", "up", "until", "this", "version", "this", "version", "don", "t", "exi...
7ea6ffd0c58f70079cc344eae348430c7bdaaab3
https://github.com/guilhermechapiewski/simple-db-migrate/blob/7ea6ffd0c58f70079cc344eae348430c7bdaaab3/simple_db_migrate/main.py#L174-L250
train
spantaleev/flask-sijax
examples/chat.py
csrf_token
def csrf_token(): """ Generate a token string from bytes arrays. The token in the session is user specific. """ if "_csrf_token" not in session: session["_csrf_token"] = os.urandom(128) return hmac.new(app.secret_key, session["_csrf_token"], digestmod=sha1).hexdigest()
python
def csrf_token(): """ Generate a token string from bytes arrays. The token in the session is user specific. """ if "_csrf_token" not in session: session["_csrf_token"] = os.urandom(128) return hmac.new(app.secret_key, session["_csrf_token"], digestmod=sha1).hexdigest()
[ "def", "csrf_token", "(", ")", ":", "if", "\"_csrf_token\"", "not", "in", "session", ":", "session", "[", "\"_csrf_token\"", "]", "=", "os", ".", "urandom", "(", "128", ")", "return", "hmac", ".", "new", "(", "app", ".", "secret_key", ",", "session", "...
Generate a token string from bytes arrays. The token in the session is user specific.
[ "Generate", "a", "token", "string", "from", "bytes", "arrays", ".", "The", "token", "in", "the", "session", "is", "user", "specific", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/examples/chat.py#L17-L25
train
spantaleev/flask-sijax
examples/chat.py
check_csrf_token
def check_csrf_token(): """Checks that token is correct, aborting if not""" if request.method in ("GET",): # not exhaustive list return token = request.form.get("csrf_token") if token is None: app.logger.warning("Expected CSRF Token: not present") abort(400) if not safe_str_c...
python
def check_csrf_token(): """Checks that token is correct, aborting if not""" if request.method in ("GET",): # not exhaustive list return token = request.form.get("csrf_token") if token is None: app.logger.warning("Expected CSRF Token: not present") abort(400) if not safe_str_c...
[ "def", "check_csrf_token", "(", ")", ":", "if", "request", ".", "method", "in", "(", "\"GET\"", ",", ")", ":", "# not exhaustive list", "return", "token", "=", "request", ".", "form", ".", "get", "(", "\"csrf_token\"", ")", "if", "token", "is", "None", "...
Checks that token is correct, aborting if not
[ "Checks", "that", "token", "is", "correct", "aborting", "if", "not" ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/examples/chat.py#L28-L38
train
disqus/nexus
nexus/modules.py
NexusModule.get_request
def get_request(cls): """ Get the HTTPRequest object from thread storage or from a callee by searching each frame in the call stack. """ request = cls.get_global('request') if request: return request try: stack = inspect.stack() exc...
python
def get_request(cls): """ Get the HTTPRequest object from thread storage or from a callee by searching each frame in the call stack. """ request = cls.get_global('request') if request: return request try: stack = inspect.stack() exc...
[ "def", "get_request", "(", "cls", ")", ":", "request", "=", "cls", ".", "get_global", "(", "'request'", ")", "if", "request", ":", "return", "request", "try", ":", "stack", "=", "inspect", ".", "stack", "(", ")", "except", "IndexError", ":", "# in some c...
Get the HTTPRequest object from thread storage or from a callee by searching each frame in the call stack.
[ "Get", "the", "HTTPRequest", "object", "from", "thread", "storage", "or", "from", "a", "callee", "by", "searching", "each", "frame", "in", "the", "call", "stack", "." ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/modules.py#L61-L80
train
spantaleev/flask-sijax
flask_sijax.py
route
def route(app_or_blueprint, rule, **options): """An alternative to :meth:`flask.Flask.route` or :meth:`flask.Blueprint.route` that always adds the ``POST`` method to the allowed endpoint request methods. You should use this for all your view functions that would need to use Sijax. We're doing this bec...
python
def route(app_or_blueprint, rule, **options): """An alternative to :meth:`flask.Flask.route` or :meth:`flask.Blueprint.route` that always adds the ``POST`` method to the allowed endpoint request methods. You should use this for all your view functions that would need to use Sijax. We're doing this bec...
[ "def", "route", "(", "app_or_blueprint", ",", "rule", ",", "*", "*", "options", ")", ":", "def", "decorator", "(", "f", ")", ":", "methods", "=", "options", ".", "pop", "(", "'methods'", ",", "(", "'GET'", ",", "'POST'", ")", ")", "if", "'POST'", "...
An alternative to :meth:`flask.Flask.route` or :meth:`flask.Blueprint.route` that always adds the ``POST`` method to the allowed endpoint request methods. You should use this for all your view functions that would need to use Sijax. We're doing this because Sijax uses ``POST`` for data passing, which ...
[ "An", "alternative", "to", ":", "meth", ":", "flask", ".", "Flask", ".", "route", "or", ":", "meth", ":", "flask", ".", "Blueprint", ".", "route", "that", "always", "adds", "the", "POST", "method", "to", "the", "allowed", "endpoint", "request", "methods"...
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L177-L207
train
spantaleev/flask-sijax
flask_sijax.py
_make_response
def _make_response(sijax_response): """Takes a Sijax response object and returns a valid Flask response object.""" from types import GeneratorType if isinstance(sijax_response, GeneratorType): # Streaming response using a generator (non-JSON response). # Upon returning a response, Flask...
python
def _make_response(sijax_response): """Takes a Sijax response object and returns a valid Flask response object.""" from types import GeneratorType if isinstance(sijax_response, GeneratorType): # Streaming response using a generator (non-JSON response). # Upon returning a response, Flask...
[ "def", "_make_response", "(", "sijax_response", ")", ":", "from", "types", "import", "GeneratorType", "if", "isinstance", "(", "sijax_response", ",", "GeneratorType", ")", ":", "# Streaming response using a generator (non-JSON response).", "# Upon returning a response, Flask wo...
Takes a Sijax response object and returns a valid Flask response object.
[ "Takes", "a", "Sijax", "response", "object", "and", "returns", "a", "valid", "Flask", "response", "object", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L210-L238
train
spantaleev/flask-sijax
flask_sijax.py
Sijax.register_comet_callback
def register_comet_callback(self, *args, **kwargs): """Registers a single Comet callback function (see :ref:`comet-plugin`). Refer to :func:`sijax.plugin.comet.register_comet_callback` for more details - its signature differs slightly. This method's signature is the same, excep...
python
def register_comet_callback(self, *args, **kwargs): """Registers a single Comet callback function (see :ref:`comet-plugin`). Refer to :func:`sijax.plugin.comet.register_comet_callback` for more details - its signature differs slightly. This method's signature is the same, excep...
[ "def", "register_comet_callback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sijax", ".", "plugin", ".", "comet", ".", "register_comet_callback", "(", "self", ".", "_sijax", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Registers a single Comet callback function (see :ref:`comet-plugin`). Refer to :func:`sijax.plugin.comet.register_comet_callback` for more details - its signature differs slightly. This method's signature is the same, except that the first argument that :func:`sijax.plugin.come...
[ "Registers", "a", "single", "Comet", "callback", "function", "(", "see", ":", "ref", ":", "comet", "-", "plugin", ")", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L85-L97
train
spantaleev/flask-sijax
flask_sijax.py
Sijax.register_comet_object
def register_comet_object(self, *args, **kwargs): """Registers all functions from the object as Comet functions (see :ref:`comet-plugin`). This makes mass registration of functions a lot easier. Refer to :func:`sijax.plugin.comet.register_comet_object` for more details -ts sign...
python
def register_comet_object(self, *args, **kwargs): """Registers all functions from the object as Comet functions (see :ref:`comet-plugin`). This makes mass registration of functions a lot easier. Refer to :func:`sijax.plugin.comet.register_comet_object` for more details -ts sign...
[ "def", "register_comet_object", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sijax", ".", "plugin", ".", "comet", ".", "register_comet_object", "(", "self", ".", "_sijax", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Registers all functions from the object as Comet functions (see :ref:`comet-plugin`). This makes mass registration of functions a lot easier. Refer to :func:`sijax.plugin.comet.register_comet_object` for more details -ts signature differs slightly. This method's signature is t...
[ "Registers", "all", "functions", "from", "the", "object", "as", "Comet", "functions", "(", "see", ":", "ref", ":", "comet", "-", "plugin", ")", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L99-L113
train
spantaleev/flask-sijax
flask_sijax.py
Sijax.register_upload_callback
def register_upload_callback(self, *args, **kwargs): """Registers an Upload function (see :ref:`upload-plugin`) to handle a certain form. Refer to :func:`sijax.plugin.upload.register_upload_callback` for more details. This method passes some additional arguments to your handler...
python
def register_upload_callback(self, *args, **kwargs): """Registers an Upload function (see :ref:`upload-plugin`) to handle a certain form. Refer to :func:`sijax.plugin.upload.register_upload_callback` for more details. This method passes some additional arguments to your handler...
[ "def", "register_upload_callback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'args_extra'", "not", "in", "kwargs", ":", "kwargs", "[", "'args_extra'", "]", "=", "[", "request", ".", "files", "]", "return", "sijax", ".", "...
Registers an Upload function (see :ref:`upload-plugin`) to handle a certain form. Refer to :func:`sijax.plugin.upload.register_upload_callback` for more details. This method passes some additional arguments to your handler functions - the ``flask.request.files`` object. ...
[ "Registers", "an", "Upload", "function", "(", "see", ":", "ref", ":", "upload", "-", "plugin", ")", "to", "handle", "a", "certain", "form", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L115-L133
train
spantaleev/flask-sijax
flask_sijax.py
Sijax.execute_callback
def execute_callback(self, *args, **kwargs): """Executes a callback and returns the proper response. Refer to :meth:`sijax.Sijax.execute_callback` for more details. """ response = self._sijax.execute_callback(*args, **kwargs) return _make_response(response)
python
def execute_callback(self, *args, **kwargs): """Executes a callback and returns the proper response. Refer to :meth:`sijax.Sijax.execute_callback` for more details. """ response = self._sijax.execute_callback(*args, **kwargs) return _make_response(response)
[ "def", "execute_callback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_sijax", ".", "execute_callback", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "_make_response", "(", "response", "...
Executes a callback and returns the proper response. Refer to :meth:`sijax.Sijax.execute_callback` for more details.
[ "Executes", "a", "callback", "and", "returns", "the", "proper", "response", "." ]
df9f6d9b8385b3375c119a51aa100491d5445e17
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L160-L166
train
disqus/nexus
nexus/sites.py
NexusSite.has_permission
def has_permission(self, request, extra_permission=None): """ Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. """ permission = request.user.is_active and request.user.is_staff if extra_permission: permission ...
python
def has_permission(self, request, extra_permission=None): """ Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. """ permission = request.user.is_active and request.user.is_staff if extra_permission: permission ...
[ "def", "has_permission", "(", "self", ",", "request", ",", "extra_permission", "=", "None", ")", ":", "permission", "=", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff", "if", "extra_permission", ":", "permission", "=...
Returns True if the given HttpRequest has permission to view *at least one* page in the admin site.
[ "Returns", "True", "if", "the", "given", "HttpRequest", "has", "permission", "to", "view", "*", "at", "least", "one", "*", "page", "in", "the", "admin", "site", "." ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L116-L124
train
disqus/nexus
nexus/sites.py
NexusSite.as_view
def as_view(self, view, cacheable=False, extra_permission=None): """ Wraps a view in authentication/caching logic extra_permission can be used to require an extra permission for this view, such as a module permission """ def inner(request, *args, **kwargs): if not se...
python
def as_view(self, view, cacheable=False, extra_permission=None): """ Wraps a view in authentication/caching logic extra_permission can be used to require an extra permission for this view, such as a module permission """ def inner(request, *args, **kwargs): if not se...
[ "def", "as_view", "(", "self", ",", "view", ",", "cacheable", "=", "False", ",", "extra_permission", "=", "None", ")", ":", "def", "inner", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_permission...
Wraps a view in authentication/caching logic extra_permission can be used to require an extra permission for this view, such as a module permission
[ "Wraps", "a", "view", "in", "authentication", "/", "caching", "logic" ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L126-L149
train
disqus/nexus
nexus/sites.py
NexusSite.media
def media(self, request, module, path): """ Serve static files below a given point in the directory structure. """ if module == 'nexus': document_root = os.path.join(NEXUS_ROOT, 'media') else: document_root = self.get_module(module).media_root pat...
python
def media(self, request, module, path): """ Serve static files below a given point in the directory structure. """ if module == 'nexus': document_root = os.path.join(NEXUS_ROOT, 'media') else: document_root = self.get_module(module).media_root pat...
[ "def", "media", "(", "self", ",", "request", ",", "module", ",", "path", ")", ":", "if", "module", "==", "'nexus'", ":", "document_root", "=", "os", ".", "path", ".", "join", "(", "NEXUS_ROOT", ",", "'media'", ")", "else", ":", "document_root", "=", ...
Serve static files below a given point in the directory structure.
[ "Serve", "static", "files", "below", "a", "given", "point", "in", "the", "directory", "structure", "." ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L211-L250
train
disqus/nexus
nexus/sites.py
NexusSite.login
def login(self, request, form_class=None): "Login form" from django.contrib.auth import login as login_ from django.contrib.auth.forms import AuthenticationForm if form_class is None: form_class = AuthenticationForm if request.POST: form = form_class(req...
python
def login(self, request, form_class=None): "Login form" from django.contrib.auth import login as login_ from django.contrib.auth.forms import AuthenticationForm if form_class is None: form_class = AuthenticationForm if request.POST: form = form_class(req...
[ "def", "login", "(", "self", ",", "request", ",", "form_class", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "login", "as", "login_", "from", "django", ".", "contrib", ".", "auth", ".", "forms", "import", "Authenticatio...
Login form
[ "Login", "form" ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L252-L274
train
disqus/nexus
nexus/sites.py
NexusSite.logout
def logout(self, request): "Logs out user and redirects them to Nexus home" from django.contrib.auth import logout logout(request) return HttpResponseRedirect(reverse('nexus:index', current_app=self.name))
python
def logout(self, request): "Logs out user and redirects them to Nexus home" from django.contrib.auth import logout logout(request) return HttpResponseRedirect(reverse('nexus:index', current_app=self.name))
[ "def", "logout", "(", "self", ",", "request", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "logout", "logout", "(", "request", ")", "return", "HttpResponseRedirect", "(", "reverse", "(", "'nexus:index'", ",", "current_app", "=", "self",...
Logs out user and redirects them to Nexus home
[ "Logs", "out", "user", "and", "redirects", "them", "to", "Nexus", "home" ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L277-L283
train
disqus/nexus
nexus/sites.py
NexusSite.dashboard
def dashboard(self, request): "Basic dashboard panel" # TODO: these should be ajax module_set = [] for namespace, module in self.get_modules(): home_url = module.get_home_url(request) if hasattr(module, 'render_on_dashboard'): # Show by default, u...
python
def dashboard(self, request): "Basic dashboard panel" # TODO: these should be ajax module_set = [] for namespace, module in self.get_modules(): home_url = module.get_home_url(request) if hasattr(module, 'render_on_dashboard'): # Show by default, u...
[ "def", "dashboard", "(", "self", ",", "request", ")", ":", "# TODO: these should be ajax", "module_set", "=", "[", "]", "for", "namespace", ",", "module", "in", "self", ".", "get_modules", "(", ")", ":", "home_url", "=", "module", ".", "get_home_url", "(", ...
Basic dashboard panel
[ "Basic", "dashboard", "panel" ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L285-L299
train
disqus/nexus
nexus/templatetags/nexus_admin.py
submit_row
def submit_row(context): """ Displays the row of buttons for delete and save. """ opts = context['opts'] change = context['change'] is_popup = context['is_popup'] save_as = context['save_as'] return { 'onclick_attrib': (opts.get_ordered_objects() and change ...
python
def submit_row(context): """ Displays the row of buttons for delete and save. """ opts = context['opts'] change = context['change'] is_popup = context['is_popup'] save_as = context['save_as'] return { 'onclick_attrib': (opts.get_ordered_objects() and change ...
[ "def", "submit_row", "(", "context", ")", ":", "opts", "=", "context", "[", "'opts'", "]", "change", "=", "context", "[", "'change'", "]", "is_popup", "=", "context", "[", "'is_popup'", "]", "save_as", "=", "context", "[", "'save_as'", "]", "return", "{"...
Displays the row of buttons for delete and save.
[ "Displays", "the", "row", "of", "buttons", "for", "delete", "and", "save", "." ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/templatetags/nexus_admin.py#L5-L24
train
disqus/nexus
nexus/__init__.py
autodiscover
def autodiscover(site=None): """ Auto-discover INSTALLED_APPS nexus.py modules and fail silently when not present. This forces an import on them to register any api bits they may want. Specifying ``site`` will register all auto discovered modules with the new site. """ # Bail out if autodis...
python
def autodiscover(site=None): """ Auto-discover INSTALLED_APPS nexus.py modules and fail silently when not present. This forces an import on them to register any api bits they may want. Specifying ``site`` will register all auto discovered modules with the new site. """ # Bail out if autodis...
[ "def", "autodiscover", "(", "site", "=", "None", ")", ":", "# Bail out if autodiscover didn't finish loading from a previous call so", "# that we avoid running autodiscover again when the URLconf is loaded by", "# the exception handler to resolve the handler500 view. This prevents an", "# adm...
Auto-discover INSTALLED_APPS nexus.py modules and fail silently when not present. This forces an import on them to register any api bits they may want. Specifying ``site`` will register all auto discovered modules with the new site.
[ "Auto", "-", "discover", "INSTALLED_APPS", "nexus", ".", "py", "modules", "and", "fail", "silently", "when", "not", "present", ".", "This", "forces", "an", "import", "on", "them", "to", "register", "any", "api", "bits", "they", "may", "want", "." ]
d761ac7f24d92237ca9ea2eb8b66476832f66486
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/__init__.py#L23-L83
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_starttag
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' Internal for parsing ''' tagName = tagName.lower() inTag = self._inTag if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS: isSelfClosing = True newTag = ...
python
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' Internal for parsing ''' tagName = tagName.lower() inTag = self._inTag if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS: isSelfClosing = True newTag = ...
[ "def", "handle_starttag", "(", "self", ",", "tagName", ",", "attributeList", ",", "isSelfClosing", "=", "False", ")", ":", "tagName", "=", "tagName", ".", "lower", "(", ")", "inTag", "=", "self", ".", "_inTag", "if", "isSelfClosing", "is", "False", "and", ...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L124-L145
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_endtag
def handle_endtag(self, tagName): ''' Internal for parsing ''' try: foundIt = False inTag = self._inTag for i in range(len(inTag)): if inTag[i].tagName == tagName: foundIt = True break ...
python
def handle_endtag(self, tagName): ''' Internal for parsing ''' try: foundIt = False inTag = self._inTag for i in range(len(inTag)): if inTag[i].tagName == tagName: foundIt = True break ...
[ "def", "handle_endtag", "(", "self", ",", "tagName", ")", ":", "try", ":", "foundIt", "=", "False", "inTag", "=", "self", ".", "_inTag", "for", "i", "in", "range", "(", "len", "(", "inTag", ")", ")", ":", "if", "inTag", "[", "i", "]", ".", "tagNa...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L153-L173
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_data
def handle_data(self, data): ''' Internal for parsing ''' if data: inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText(data) elif data.strip(): #and not self.getRoot(): # Must be text prior to or after root n...
python
def handle_data(self, data): ''' Internal for parsing ''' if data: inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText(data) elif data.strip(): #and not self.getRoot(): # Must be text prior to or after root n...
[ "def", "handle_data", "(", "self", ",", "data", ")", ":", "if", "data", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", ">", "0", ":", "inTag", "[", "-", "1", "]", ".", "appendText", "(", "data", ")", "elif", "data", "...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L176-L186
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_entityref
def handle_entityref(self, entity): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&%s;' %(entity,)) else: raise MultipleRootNodeException()
python
def handle_entityref(self, entity): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&%s;' %(entity,)) else: raise MultipleRootNodeException()
[ "def", "handle_entityref", "(", "self", ",", "entity", ")", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", ">", "0", ":", "inTag", "[", "-", "1", "]", ".", "appendText", "(", "'&%s;'", "%", "(", "entity", ",", ")", ")",...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L188-L196
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_charref
def handle_charref(self, charRef): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&#%s;' %(charRef,)) else: raise MultipleRootNodeException()
python
def handle_charref(self, charRef): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&#%s;' %(charRef,)) else: raise MultipleRootNodeException()
[ "def", "handle_charref", "(", "self", ",", "charRef", ")", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", ">", "0", ":", "inTag", "[", "-", "1", "]", ".", "appendText", "(", "'&#%s;'", "%", "(", "charRef", ",", ")", ")"...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L198-L206
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.handle_comment
def handle_comment(self, comment): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('<!-- %s -->' %(comment,)) else: raise MultipleRootNodeException()
python
def handle_comment(self, comment): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('<!-- %s -->' %(comment,)) else: raise MultipleRootNodeException()
[ "def", "handle_comment", "(", "self", ",", "comment", ")", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", ">", "0", ":", "inTag", "[", "-", "1", "]", ".", "appendText", "(", "'<!-- %s -->'", "%", "(", "comment", ",", ")",...
Internal for parsing
[ "Internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L208-L216
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getRootNodes
def getRootNodes(self): ''' getRootNodes - Gets all objects at the "root" (first level; no parent). Use this if you may have multiple roots (not children of <html>) Use this method to get objects, for example, in an AJAX request where <html> may not be your root. Not...
python
def getRootNodes(self): ''' getRootNodes - Gets all objects at the "root" (first level; no parent). Use this if you may have multiple roots (not children of <html>) Use this method to get objects, for example, in an AJAX request where <html> may not be your root. Not...
[ "def", "getRootNodes", "(", "self", ")", ":", "root", "=", "self", ".", "root", "if", "not", "root", ":", "return", "[", "]", "if", "root", ".", "tagName", "==", "INVISIBLE_ROOT_TAG", ":", "return", "list", "(", "root", ".", "children", ")", "return", ...
getRootNodes - Gets all objects at the "root" (first level; no parent). Use this if you may have multiple roots (not children of <html>) Use this method to get objects, for example, in an AJAX request where <html> may not be your root. Note: If there are multiple root nodes (i.e. no <ht...
[ "getRootNodes", "-", "Gets", "all", "objects", "at", "the", "root", "(", "first", "level", ";", "no", "parent", ")", ".", "Use", "this", "if", "you", "may", "have", "multiple", "roots", "(", "not", "children", "of", "<html", ">", ")", "Use", "this", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L247-L262
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getAllNodes
def getAllNodes(self): ''' getAllNodes - Get every element @return TagCollection<AdvancedTag> ''' ret = TagCollection() for rootNode in self.getRootNodes(): ret.append(rootNode) ret += rootNode.getAllChildNodes() return ret
python
def getAllNodes(self): ''' getAllNodes - Get every element @return TagCollection<AdvancedTag> ''' ret = TagCollection() for rootNode in self.getRootNodes(): ret.append(rootNode) ret += rootNode.getAllChildNodes() return ret
[ "def", "getAllNodes", "(", "self", ")", ":", "ret", "=", "TagCollection", "(", ")", "for", "rootNode", "in", "self", ".", "getRootNodes", "(", ")", ":", "ret", ".", "append", "(", "rootNode", ")", "ret", "+=", "rootNode", ".", "getAllChildNodes", "(", ...
getAllNodes - Get every element @return TagCollection<AdvancedTag>
[ "getAllNodes", "-", "Get", "every", "element" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L264-L278
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsByTagName
def getElementsByTagName(self, tagName, root='root'): ''' getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search...
python
def getElementsByTagName(self, tagName, root='root'): ''' getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search...
[ "def", "getElementsByTagName", "(", "self", ",", "tagName", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", "is", "True", "a...
getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the p...
[ "getElementsByTagName", "-", "Searches", "and", "returns", "all", "elements", "with", "a", "specific", "tag", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L286-L308
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsByName
def getElementsByName(self, name, root='root'): ''' getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if...
python
def getElementsByName(self, name, root='root'): ''' getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if...
[ "def", "getElementsByName", "(", "self", ",", "name", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", "is", "True", "and", ...
getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed tree will ...
[ "getElementsByName", "-", "Searches", "and", "returns", "all", "elements", "with", "a", "specific", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L310-L332
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementById
def getElementById(self, _id, root='root'): ''' getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a spec...
python
def getElementById(self, _id, root='root'): ''' getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a spec...
[ "def", "getElementById", "(", "self", ",", "_id", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "isFromRoot", "is", "True", "and", "root", ".", "id", "==", "_id"...
getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the ...
[ "getElementById", "-", "Searches", "and", "returns", "the", "first", "(", "should", "only", "be", "one", ")", "element", "with", "the", "given", "ID", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L334-L356
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsByClassName
def getElementsByClassName(self, className, root='root'): ''' getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at...
python
def getElementsByClassName(self, className, root='root'): ''' getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at...
[ "def", "getElementsByClassName", "(", "self", ",", "className", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", "is", "True", ...
getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed ...
[ "getElementsByClassName", "-", "Searches", "and", "returns", "all", "elements", "containing", "a", "given", "class", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L358-L380
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsByAttr
def getElementsByAttr(self, attrName, attrValue, root='root'): ''' getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. This is always a full scan. @param attrName <lowercase str> - A lowercase attribute name ...
python
def getElementsByAttr(self, attrName, attrValue, root='root'): ''' getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. This is always a full scan. @param attrName <lowercase str> - A lowercase attribute name ...
[ "def", "getElementsByAttr", "(", "self", ",", "attrName", ",", "attrValue", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", ...
getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. This is always a full scan. @param attrName <lowercase str> - A lowercase attribute name @param attrValue <str> - Expected value of attribute @param ...
[ "getElementsByAttr", "-", "Searches", "the", "full", "tree", "for", "elements", "with", "a", "given", "attribute", "name", "and", "value", "combination", ".", "This", "is", "always", "a", "full", "scan", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L382-L405
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsWithAttrValues
def getElementsWithAttrValues(self, attrName, attrValues, root='root'): ''' getElementsWithAttrValues - Returns elements with an attribute, named by #attrName contains one of the values in the list, #values @param attrName <lowercase str> - A lowercase attribute name @param ...
python
def getElementsWithAttrValues(self, attrName, attrValues, root='root'): ''' getElementsWithAttrValues - Returns elements with an attribute, named by #attrName contains one of the values in the list, #values @param attrName <lowercase str> - A lowercase attribute name @param ...
[ "def", "getElementsWithAttrValues", "(", "self", ",", "attrName", ",", "attrValues", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "type", "(", "attrValues", ")", "!...
getElementsWithAttrValues - Returns elements with an attribute, named by #attrName contains one of the values in the list, #values @param attrName <lowercase str> - A lowercase attribute name @param attrValues set<str> - A set of all valid values. @return - TagCollection of all m...
[ "getElementsWithAttrValues", "-", "Returns", "elements", "with", "an", "attribute", "named", "by", "#attrName", "contains", "one", "of", "the", "values", "in", "the", "list", "#values" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L407-L423
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getElementsCustomFilter
def getElementsCustomFilter(self, filterFunc, root='root'): ''' getElementsCustomFilter - Scan elements using a provided function @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary criteria is met @re...
python
def getElementsCustomFilter(self, filterFunc, root='root'): ''' getElementsCustomFilter - Scan elements using a provided function @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary criteria is met @re...
[ "def", "getElementsCustomFilter", "(", "self", ",", "filterFunc", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", "is", "True"...
getElementsCustomFilter - Scan elements using a provided function @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary criteria is met @return - TagCollection of all matching elements
[ "getElementsCustomFilter", "-", "Scan", "elements", "using", "a", "provided", "function" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L426-L449
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getFirstElementCustomFilter
def getFirstElementCustomFilter(self, filterFunc, root='root'): ''' getFirstElementCustomFilter - Scan elements using a provided function, stop and return the first match. @see getElementsCustomFilter to match multiple elements @param filterFunc <function>(node) - A fun...
python
def getFirstElementCustomFilter(self, filterFunc, root='root'): ''' getFirstElementCustomFilter - Scan elements using a provided function, stop and return the first match. @see getElementsCustomFilter to match multiple elements @param filterFunc <function>(node) - A fun...
[ "def", "getFirstElementCustomFilter", "(", "self", ",", "filterFunc", ",", "root", "=", "'root'", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "isFromRoot", "is", "T...
getFirstElementCustomFilter - Scan elements using a provided function, stop and return the first match. @see getElementsCustomFilter to match multiple elements @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary crite...
[ "getFirstElementCustomFilter", "-", "Scan", "elements", "using", "a", "provided", "function", "stop", "and", "return", "the", "first", "match", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L452-L481
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.contains
def contains(self, em): ''' Checks if #em is found anywhere within this element tree @param em <AdvancedTag> - Tag of interest @return <bool> - If element #em is within this tree ''' for rootNode in self.getRootNodes(): if rootNode.contains(em): ...
python
def contains(self, em): ''' Checks if #em is found anywhere within this element tree @param em <AdvancedTag> - Tag of interest @return <bool> - If element #em is within this tree ''' for rootNode in self.getRootNodes(): if rootNode.contains(em): ...
[ "def", "contains", "(", "self", ",", "em", ")", ":", "for", "rootNode", "in", "self", ".", "getRootNodes", "(", ")", ":", "if", "rootNode", ".", "contains", "(", "em", ")", ":", "return", "True", "return", "False" ]
Checks if #em is found anywhere within this element tree @param em <AdvancedTag> - Tag of interest @return <bool> - If element #em is within this tree
[ "Checks", "if", "#em", "is", "found", "anywhere", "within", "this", "element", "tree" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L511-L523
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.containsUid
def containsUid(self, uid): ''' Check if #uid is found anywhere within this element tree @param uid <uuid.UUID> - Uid @return <bool> - If #uid is found within this tree ''' for rootNode in self.getRootNodes(): if rootNode.containsUid(uid): ...
python
def containsUid(self, uid): ''' Check if #uid is found anywhere within this element tree @param uid <uuid.UUID> - Uid @return <bool> - If #uid is found within this tree ''' for rootNode in self.getRootNodes(): if rootNode.containsUid(uid): ...
[ "def", "containsUid", "(", "self", ",", "uid", ")", ":", "for", "rootNode", "in", "self", ".", "getRootNodes", "(", ")", ":", "if", "rootNode", ".", "containsUid", "(", "uid", ")", ":", "return", "True", "return", "False" ]
Check if #uid is found anywhere within this element tree @param uid <uuid.UUID> - Uid @return <bool> - If #uid is found within this tree
[ "Check", "if", "#uid", "is", "found", "anywhere", "within", "this", "element", "tree" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L527-L539
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.find
def find(self, **kwargs): ''' find - Perform a search of elements using attributes as keys and potential values as values (i.e. parser.find(name='blah', tagname='span') will return all elements in this document with the name "blah" of the tag type "span...
python
def find(self, **kwargs): ''' find - Perform a search of elements using attributes as keys and potential values as values (i.e. parser.find(name='blah', tagname='span') will return all elements in this document with the name "blah" of the tag type "span...
[ "def", "find", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ":", "return", "TagCollection", "(", ")", "# Because of how closures work in python, need a function to generate these lambdas", "# because the closure basically references \"current key in i...
find - Perform a search of elements using attributes as keys and potential values as values (i.e. parser.find(name='blah', tagname='span') will return all elements in this document with the name "blah" of the tag type "span" ) Arguments are key = value, or key...
[ "find", "-", "Perform", "a", "search", "of", "elements", "using", "attributes", "as", "keys", "and", "potential", "values", "as", "values", "(", "i", ".", "e", ".", "parser", ".", "find", "(", "name", "=", "blah", "tagname", "=", "span", ")", "will", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L604-L765
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getHTML
def getHTML(self): ''' getHTML - Get the full HTML as contained within this tree. If parsed from a document, this will contain the original whitespacing. @returns - <str> of html @see getFormattedHTML @see getMiniHTML ...
python
def getHTML(self): ''' getHTML - Get the full HTML as contained within this tree. If parsed from a document, this will contain the original whitespacing. @returns - <str> of html @see getFormattedHTML @see getMiniHTML ...
[ "def", "getHTML", "(", "self", ")", ":", "root", "=", "self", ".", "getRoot", "(", ")", "if", "root", "is", "None", ":", "raise", "ValueError", "(", "'Did not parse anything. Use parseFile or parseStr'", ")", "if", "self", ".", "doctype", ":", "doctypeStr", ...
getHTML - Get the full HTML as contained within this tree. If parsed from a document, this will contain the original whitespacing. @returns - <str> of html @see getFormattedHTML @see getMiniHTML
[ "getHTML", "-", "Get", "the", "full", "HTML", "as", "contained", "within", "this", "tree", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L768-L796
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getFormattedHTML
def getFormattedHTML(self, indent=' '): ''' getFormattedHTML - Get formatted and xhtml of this document, replacing the original whitespace with a pretty-printed version @param indent - space/tab/newline of each level of indent, or integer for how many spaces per level ...
python
def getFormattedHTML(self, indent=' '): ''' getFormattedHTML - Get formatted and xhtml of this document, replacing the original whitespace with a pretty-printed version @param indent - space/tab/newline of each level of indent, or integer for how many spaces per level ...
[ "def", "getFormattedHTML", "(", "self", ",", "indent", "=", "' '", ")", ":", "from", ".", "Formatter", "import", "AdvancedHTMLFormatter", "html", "=", "self", ".", "getHTML", "(", ")", "formatter", "=", "AdvancedHTMLFormatter", "(", "indent", ",", "None", "...
getFormattedHTML - Get formatted and xhtml of this document, replacing the original whitespace with a pretty-printed version @param indent - space/tab/newline of each level of indent, or integer for how many spaces per level @return - <str> Formatted html @...
[ "getFormattedHTML", "-", "Get", "formatted", "and", "xhtml", "of", "this", "document", "replacing", "the", "original", "whitespace", "with", "a", "pretty", "-", "printed", "version" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L807-L824
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.getMiniHTML
def getMiniHTML(self): ''' getMiniHTML - Gets the HTML representation of this document without any pretty formatting and disregarding original whitespace beyond the functional. @return <str> - HTML with only functional whitespace present ''' from .For...
python
def getMiniHTML(self): ''' getMiniHTML - Gets the HTML representation of this document without any pretty formatting and disregarding original whitespace beyond the functional. @return <str> - HTML with only functional whitespace present ''' from .For...
[ "def", "getMiniHTML", "(", "self", ")", ":", "from", ".", "Formatter", "import", "AdvancedHTMLMiniFormatter", "html", "=", "self", ".", "getHTML", "(", ")", "formatter", "=", "AdvancedHTMLMiniFormatter", "(", "None", ")", "# Do not double-encode", "formatter", "."...
getMiniHTML - Gets the HTML representation of this document without any pretty formatting and disregarding original whitespace beyond the functional. @return <str> - HTML with only functional whitespace present
[ "getMiniHTML", "-", "Gets", "the", "HTML", "representation", "of", "this", "document", "without", "any", "pretty", "formatting", "and", "disregarding", "original", "whitespace", "beyond", "the", "functional", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L826-L837
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser._reset
def _reset(self): ''' _reset - reset this object. Assigned to .reset after __init__ call. ''' HTMLParser.reset(self) self.root = None self.doctype = None self._inTag = []
python
def _reset(self): ''' _reset - reset this object. Assigned to .reset after __init__ call. ''' HTMLParser.reset(self) self.root = None self.doctype = None self._inTag = []
[ "def", "_reset", "(", "self", ")", ":", "HTMLParser", ".", "reset", "(", "self", ")", "self", ".", "root", "=", "None", "self", ".", "doctype", "=", "None", "self", ".", "_inTag", "=", "[", "]" ]
_reset - reset this object. Assigned to .reset after __init__ call.
[ "_reset", "-", "reset", "this", "object", ".", "Assigned", "to", ".", "reset", "after", "__init__", "call", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L839-L847
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.feed
def feed(self, contents): ''' feed - Feed contents. Use parseStr or parseFile instead. @param contents - Contents ''' contents = stripIEConditionals(contents) try: HTMLParser.feed(self, contents) except MultipleRootNodeException: ...
python
def feed(self, contents): ''' feed - Feed contents. Use parseStr or parseFile instead. @param contents - Contents ''' contents = stripIEConditionals(contents) try: HTMLParser.feed(self, contents) except MultipleRootNodeException: ...
[ "def", "feed", "(", "self", ",", "contents", ")", ":", "contents", "=", "stripIEConditionals", "(", "contents", ")", "try", ":", "HTMLParser", ".", "feed", "(", "self", ",", "contents", ")", "except", "MultipleRootNodeException", ":", "self", ".", "reset", ...
feed - Feed contents. Use parseStr or parseFile instead. @param contents - Contents
[ "feed", "-", "Feed", "contents", ".", "Use", "parseStr", "or", "parseFile", "instead", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L849-L860
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.parseFile
def parseFile(self, filename): ''' parseFile - Parses a file and creates the DOM tree and indexes @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close. ''' self.reset() if isinstance(...
python
def parseFile(self, filename): ''' parseFile - Parses a file and creates the DOM tree and indexes @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close. ''' self.reset() if isinstance(...
[ "def", "parseFile", "(", "self", ",", "filename", ")", ":", "self", ".", "reset", "(", ")", "if", "isinstance", "(", "filename", ",", "file", ")", ":", "contents", "=", "filename", ".", "read", "(", ")", "else", ":", "with", "codecs", ".", "open", ...
parseFile - Parses a file and creates the DOM tree and indexes @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close.
[ "parseFile", "-", "Parses", "a", "file", "and", "creates", "the", "DOM", "tree", "and", "indexes" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L862-L876
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.parseStr
def parseStr(self, html): ''' parseStr - Parses a string and creates the DOM tree and indexes. @param html <str> - valid HTML ''' self.reset() if isinstance(html, bytes): self.feed(html.decode(self.encoding)) else: self.feed(h...
python
def parseStr(self, html): ''' parseStr - Parses a string and creates the DOM tree and indexes. @param html <str> - valid HTML ''' self.reset() if isinstance(html, bytes): self.feed(html.decode(self.encoding)) else: self.feed(h...
[ "def", "parseStr", "(", "self", ",", "html", ")", ":", "self", ".", "reset", "(", ")", "if", "isinstance", "(", "html", ",", "bytes", ")", ":", "self", ".", "feed", "(", "html", ".", "decode", "(", "self", ".", "encoding", ")", ")", "else", ":", ...
parseStr - Parses a string and creates the DOM tree and indexes. @param html <str> - valid HTML
[ "parseStr", "-", "Parses", "a", "string", "and", "creates", "the", "DOM", "tree", "and", "indexes", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L878-L889
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.createElementFromHTML
def createElementFromHTML(cls, html, encoding='utf-8'): ''' createElementFromHTML - Creates an element from a string of HTML. If this could create multiple root-level elements (children are okay), you must use #createElementsFromHTML which returns a list of element...
python
def createElementFromHTML(cls, html, encoding='utf-8'): ''' createElementFromHTML - Creates an element from a string of HTML. If this could create multiple root-level elements (children are okay), you must use #createElementsFromHTML which returns a list of element...
[ "def", "createElementFromHTML", "(", "cls", ",", "html", ",", "encoding", "=", "'utf-8'", ")", ":", "parser", "=", "cls", "(", "encoding", "=", "encoding", ")", "html", "=", "stripIEConditionals", "(", "html", ")", "try", ":", "HTMLParser", ".", "feed", ...
createElementFromHTML - Creates an element from a string of HTML. If this could create multiple root-level elements (children are okay), you must use #createElementsFromHTML which returns a list of elements created. @param html <str> - Some html data @param e...
[ "createElementFromHTML", "-", "Creates", "an", "element", "from", "a", "string", "of", "HTML", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L904-L936
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.createElementsFromHTML
def createElementsFromHTML(cls, html, encoding='utf-8'): ''' createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements children of these root-level nodes are accessable via the usual means. @param html <str> - Some html d...
python
def createElementsFromHTML(cls, html, encoding='utf-8'): ''' createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements children of these root-level nodes are accessable via the usual means. @param html <str> - Some html d...
[ "def", "createElementsFromHTML", "(", "cls", ",", "html", ",", "encoding", "=", "'utf-8'", ")", ":", "# TODO: If text is present outside a tag, it will be lost.", "parser", "=", "cls", "(", "encoding", "=", "encoding", ")", "parser", ".", "parseStr", "(", "html", ...
createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements children of these root-level nodes are accessable via the usual means. @param html <str> - Some html data @param encoding <str> - Encoding to use for document ...
[ "createElementsFromHTML", "-", "Creates", "elements", "from", "provided", "html", "and", "returns", "a", "list", "of", "the", "root", "-", "level", "elements", "children", "of", "these", "root", "-", "level", "nodes", "are", "accessable", "via", "the", "usual"...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L940-L969
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
AdvancedHTMLParser.createBlocksFromHTML
def createBlocksFromHTML(cls, html, encoding='utf-8'): ''' createBlocksFromHTML - Returns the root level node (unless multiple nodes), and a list of "blocks" added (text and nodes). @return list< str/AdvancedTag > - List of blocks created. May be strings (text nodes) or...
python
def createBlocksFromHTML(cls, html, encoding='utf-8'): ''' createBlocksFromHTML - Returns the root level node (unless multiple nodes), and a list of "blocks" added (text and nodes). @return list< str/AdvancedTag > - List of blocks created. May be strings (text nodes) or...
[ "def", "createBlocksFromHTML", "(", "cls", ",", "html", ",", "encoding", "=", "'utf-8'", ")", ":", "parser", "=", "cls", "(", "encoding", "=", "encoding", ")", "parser", ".", "parseStr", "(", "html", ")", "rootNode", "=", "parser", ".", "getRoot", "(", ...
createBlocksFromHTML - Returns the root level node (unless multiple nodes), and a list of "blocks" added (text and nodes). @return list< str/AdvancedTag > - List of blocks created. May be strings (text nodes) or AdvancedTag (tags) NOTE: Results may be checked b...
[ "createBlocksFromHTML", "-", "Returns", "the", "root", "level", "node", "(", "unless", "multiple", "nodes", ")", "and", "a", "list", "of", "blocks", "added", "(", "text", "and", "nodes", ")", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L972-L995
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.handle_starttag
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' internal for parsing ''' newTag = AdvancedHTMLParser.handle_starttag(self, tagName, attributeList, isSelfClosing) self._indexTag(newTag) return newTag
python
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' internal for parsing ''' newTag = AdvancedHTMLParser.handle_starttag(self, tagName, attributeList, isSelfClosing) self._indexTag(newTag) return newTag
[ "def", "handle_starttag", "(", "self", ",", "tagName", ",", "attributeList", ",", "isSelfClosing", "=", "False", ")", ":", "newTag", "=", "AdvancedHTMLParser", ".", "handle_starttag", "(", "self", ",", "tagName", ",", "attributeList", ",", "isSelfClosing", ")", ...
internal for parsing
[ "internal", "for", "parsing" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1097-L1104
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.reindex
def reindex(self, newIndexIDs=None, newIndexNames=None, newIndexClassNames=None, newIndexTagNames=None): ''' reindex - reindex the tree. Optionally, change what fields are indexed. @param newIndexIDs <bool/None> - None to leave same, otherwise new value to index IDs ...
python
def reindex(self, newIndexIDs=None, newIndexNames=None, newIndexClassNames=None, newIndexTagNames=None): ''' reindex - reindex the tree. Optionally, change what fields are indexed. @param newIndexIDs <bool/None> - None to leave same, otherwise new value to index IDs ...
[ "def", "reindex", "(", "self", ",", "newIndexIDs", "=", "None", ",", "newIndexNames", "=", "None", ",", "newIndexClassNames", "=", "None", ",", "newIndexTagNames", "=", "None", ")", ":", "if", "newIndexIDs", "is", "not", "None", ":", "self", ".", "indexIDs...
reindex - reindex the tree. Optionally, change what fields are indexed. @param newIndexIDs <bool/None> - None to leave same, otherwise new value to index IDs @parma newIndexNames <bool/None> - None to leave same, otherwise new value to index names @param newI...
[ "reindex", "-", "reindex", "the", "tree", ".", "Optionally", "change", "what", "fields", "are", "indexed", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1120-L1139
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.disableIndexing
def disableIndexing(self): ''' disableIndexing - Disables indexing. Consider using plain AdvancedHTMLParser class. Maybe useful in some scenarios where you want to parse, add a ton of elements, then index and do a bunch of searching. ''' self.indexIDs = se...
python
def disableIndexing(self): ''' disableIndexing - Disables indexing. Consider using plain AdvancedHTMLParser class. Maybe useful in some scenarios where you want to parse, add a ton of elements, then index and do a bunch of searching. ''' self.indexIDs = se...
[ "def", "disableIndexing", "(", "self", ")", ":", "self", ".", "indexIDs", "=", "self", ".", "indexNames", "=", "self", ".", "indexClassNames", "=", "self", ".", "indexTagNames", "=", "False", "self", ".", "_resetIndexInternal", "(", ")" ]
disableIndexing - Disables indexing. Consider using plain AdvancedHTMLParser class. Maybe useful in some scenarios where you want to parse, add a ton of elements, then index and do a bunch of searching.
[ "disableIndexing", "-", "Disables", "indexing", ".", "Consider", "using", "plain", "AdvancedHTMLParser", "class", ".", "Maybe", "useful", "in", "some", "scenarios", "where", "you", "want", "to", "parse", "add", "a", "ton", "of", "elements", "then", "index", "a...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1141-L1148
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.addIndexOnAttribute
def addIndexOnAttribute(self, attributeName): ''' addIndexOnAttribute - Add an index for an arbitrary attribute. This will be used by the getElementsByAttr function. You should do this prior to parsing, or call reindex. Otherwise it will be blank. "name" and "id" will have no effect....
python
def addIndexOnAttribute(self, attributeName): ''' addIndexOnAttribute - Add an index for an arbitrary attribute. This will be used by the getElementsByAttr function. You should do this prior to parsing, or call reindex. Otherwise it will be blank. "name" and "id" will have no effect....
[ "def", "addIndexOnAttribute", "(", "self", ",", "attributeName", ")", ":", "attributeName", "=", "attributeName", ".", "lower", "(", ")", "self", ".", "_otherAttributeIndexes", "[", "attributeName", "]", "=", "{", "}", "def", "_otherIndexFunction", "(", "self", ...
addIndexOnAttribute - Add an index for an arbitrary attribute. This will be used by the getElementsByAttr function. You should do this prior to parsing, or call reindex. Otherwise it will be blank. "name" and "id" will have no effect. @param attributeName <lowercase str> - An attrib...
[ "addIndexOnAttribute", "-", "Add", "an", "index", "for", "an", "arbitrary", "attribute", ".", "This", "will", "be", "used", "by", "the", "getElementsByAttr", "function", ".", "You", "should", "do", "this", "prior", "to", "parsing", "or", "call", "reindex", "...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1150-L1168
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.removeIndexOnAttribute
def removeIndexOnAttribute(self, attributeName): ''' removeIndexOnAttribute - Remove an attribute from indexing (for getElementsByAttr function) and remove indexed data. @param attributeName <lowercase str> - An attribute name. Will be lowercased. "name" and "id" will have no effect. ...
python
def removeIndexOnAttribute(self, attributeName): ''' removeIndexOnAttribute - Remove an attribute from indexing (for getElementsByAttr function) and remove indexed data. @param attributeName <lowercase str> - An attribute name. Will be lowercased. "name" and "id" will have no effect. ...
[ "def", "removeIndexOnAttribute", "(", "self", ",", "attributeName", ")", ":", "attributeName", "=", "attributeName", ".", "lower", "(", ")", "if", "attributeName", "in", "self", ".", "otherAttributeIndexFunctions", ":", "del", "self", ".", "otherAttributeIndexFuncti...
removeIndexOnAttribute - Remove an attribute from indexing (for getElementsByAttr function) and remove indexed data. @param attributeName <lowercase str> - An attribute name. Will be lowercased. "name" and "id" will have no effect.
[ "removeIndexOnAttribute", "-", "Remove", "an", "attribute", "from", "indexing", "(", "for", "getElementsByAttr", "function", ")", "and", "remove", "indexed", "data", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1170-L1180
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementsByTagName
def getElementsByTagName(self, tagName, root='root', useIndex=True): ''' getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'...
python
def getElementsByTagName(self, tagName, root='root', useIndex=True): ''' getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'...
[ "def", "getElementsByTagName", "(", "self", ",", "tagName", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "useIndex", "is", "True", "...
getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the p...
[ "getElementsByTagName", "-", "Searches", "and", "returns", "all", "elements", "with", "a", "specific", "tag", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1183-L1202
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementsByName
def getElementsByName(self, name, root='root', useIndex=True): ''' getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a sp...
python
def getElementsByName(self, name, root='root', useIndex=True): ''' getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a sp...
[ "def", "getElementsByName", "(", "self", ",", "name", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "elements", "=", "[", "]", "if", "use...
getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used. ...
[ "getElementsByName", "-", "Searches", "and", "returns", "all", "elements", "with", "a", "specific", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1205-L1226
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementById
def getElementById(self, _id, root='root', useIndex=True): ''' getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search sta...
python
def getElementById(self, _id, root='root', useIndex=True): ''' getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search sta...
[ "def", "getElementById", "(", "self", ",", "_id", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "self", ".", "useIndex", "is", "Tru...
getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tre...
[ "getElementById", "-", "Searches", "and", "returns", "the", "first", "(", "should", "only", "be", "one", ")", "element", "with", "the", "given", "ID", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1229-L1251
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementsByClassName
def getElementsByClassName(self, className, root='root', useIndex=True): ''' getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Sea...
python
def getElementsByClassName(self, className, root='root', useIndex=True): ''' getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Sea...
[ "def", "getElementsByClassName", "(", "self", ",", "className", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "useIndex", "is", "True",...
getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will ...
[ "getElementsByClassName", "-", "Searches", "and", "returns", "all", "elements", "containing", "a", "given", "class", "name", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1254-L1274
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementsByAttr
def getElementsByAttr(self, attrName, attrValue, root='root', useIndex=True): ''' getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. If you want multiple potential values, see getElementsWithAttrValues If you want an index on a r...
python
def getElementsByAttr(self, attrName, attrValue, root='root', useIndex=True): ''' getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. If you want multiple potential values, see getElementsWithAttrValues If you want an index on a r...
[ "def", "getElementsByAttr", "(", "self", ",", "attrName", ",", "attrValue", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "if", "useIndex", ...
getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. If you want multiple potential values, see getElementsWithAttrValues If you want an index on a random attribute, use the addIndexOnAttribute function. @param attrName...
[ "getElementsByAttr", "-", "Searches", "the", "full", "tree", "for", "elements", "with", "a", "given", "attribute", "name", "and", "value", "combination", ".", "If", "you", "want", "multiple", "potential", "values", "see", "getElementsWithAttrValues", "If", "you", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1277-L1299
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Parser.py
IndexedAdvancedHTMLParser.getElementsWithAttrValues
def getElementsWithAttrValues(self, attrName, values, root='root', useIndex=True): ''' getElementsWithAttrValues - Returns elements with an attribute matching one of several values. For a single name/value combination, see getElementsByAttr @param attrName <lowercase str> - A lowerc...
python
def getElementsWithAttrValues(self, attrName, values, root='root', useIndex=True): ''' getElementsWithAttrValues - Returns elements with an attribute matching one of several values. For a single name/value combination, see getElementsByAttr @param attrName <lowercase str> - A lowerc...
[ "def", "getElementsWithAttrValues", "(", "self", ",", "attrName", ",", "values", ",", "root", "=", "'root'", ",", "useIndex", "=", "True", ")", ":", "(", "root", ",", "isFromRoot", ")", "=", "self", ".", "_handleRootArg", "(", "root", ")", "_otherAttribute...
getElementsWithAttrValues - Returns elements with an attribute matching one of several values. For a single name/value combination, see getElementsByAttr @param attrName <lowercase str> - A lowercase attribute name @param attrValues set<str> - List of expected values of attribute ...
[ "getElementsWithAttrValues", "-", "Returns", "elements", "with", "an", "attribute", "matching", "one", "of", "several", "values", ".", "For", "a", "single", "name", "/", "value", "combination", "see", "getElementsByAttr" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1302-L1323
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
uniqueTags
def uniqueTags(tagList): ''' uniqueTags - Returns the unique tags in tagList. @param tagList list<AdvancedTag> : A list of tag objects. ''' ret = [] alreadyAdded = set() for tag in tagList: myUid = tag.getUid() if myUid in alreadyAdded: contin...
python
def uniqueTags(tagList): ''' uniqueTags - Returns the unique tags in tagList. @param tagList list<AdvancedTag> : A list of tag objects. ''' ret = [] alreadyAdded = set() for tag in tagList: myUid = tag.getUid() if myUid in alreadyAdded: contin...
[ "def", "uniqueTags", "(", "tagList", ")", ":", "ret", "=", "[", "]", "alreadyAdded", "=", "set", "(", ")", "for", "tag", "in", "tagList", ":", "myUid", "=", "tag", ".", "getUid", "(", ")", "if", "myUid", "in", "alreadyAdded", ":", "continue", "ret", ...
uniqueTags - Returns the unique tags in tagList. @param tagList list<AdvancedTag> : A list of tag objects.
[ "uniqueTags", "-", "Returns", "the", "unique", "tags", "in", "tagList", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L47-L60
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
toggleAttributesDOM
def toggleAttributesDOM(isEnabled): ''' toggleAttributesDOM - Toggle if the old DOM tag.attributes NamedNodeMap model should be used for the .attributes method, versus a more sane direct dict implementation. The DOM version is always accessable as AdvancedTag.attributesDOM ...
python
def toggleAttributesDOM(isEnabled): ''' toggleAttributesDOM - Toggle if the old DOM tag.attributes NamedNodeMap model should be used for the .attributes method, versus a more sane direct dict implementation. The DOM version is always accessable as AdvancedTag.attributesDOM ...
[ "def", "toggleAttributesDOM", "(", "isEnabled", ")", ":", "if", "isEnabled", ":", "AdvancedTag", ".", "attributes", "=", "AdvancedTag", ".", "attributesDOM", "else", ":", "AdvancedTag", ".", "attributes", "=", "AdvancedTag", ".", "attributesDict" ]
toggleAttributesDOM - Toggle if the old DOM tag.attributes NamedNodeMap model should be used for the .attributes method, versus a more sane direct dict implementation. The DOM version is always accessable as AdvancedTag.attributesDOM The dict version is always accessable as Advanced...
[ "toggleAttributesDOM", "-", "Toggle", "if", "the", "old", "DOM", "tag", ".", "attributes", "NamedNodeMap", "model", "should", "be", "used", "for", "the", ".", "attributes", "method", "versus" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L62-L79
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.cloneNode
def cloneNode(self): ''' cloneNode - Clone this node (tag name and attributes). Does not clone children. Tags will be equal according to isTagEqual method, but will contain a different internal unique id such tag origTag != origTag.cloneNode() , as is the case in JS DOM. ...
python
def cloneNode(self): ''' cloneNode - Clone this node (tag name and attributes). Does not clone children. Tags will be equal according to isTagEqual method, but will contain a different internal unique id such tag origTag != origTag.cloneNode() , as is the case in JS DOM. ...
[ "def", "cloneNode", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "tagName", ",", "self", ".", "getAttributesList", "(", ")", ",", "self", ".", "isSelfClosing", ")" ]
cloneNode - Clone this node (tag name and attributes). Does not clone children. Tags will be equal according to isTagEqual method, but will contain a different internal unique id such tag origTag != origTag.cloneNode() , as is the case in JS DOM.
[ "cloneNode", "-", "Clone", "this", "node", "(", "tag", "name", "and", "attributes", ")", ".", "Does", "not", "clone", "children", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L341-L348
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.appendText
def appendText(self, text): ''' appendText - append some inner text ''' # self.text is just raw string of the text self.text += text self.isSelfClosing = False # inner text means it can't self close anymo # self.blocks is either text or tags, in order of appea...
python
def appendText(self, text): ''' appendText - append some inner text ''' # self.text is just raw string of the text self.text += text self.isSelfClosing = False # inner text means it can't self close anymo # self.blocks is either text or tags, in order of appea...
[ "def", "appendText", "(", "self", ",", "text", ")", ":", "# self.text is just raw string of the text", "self", ".", "text", "+=", "text", "self", ".", "isSelfClosing", "=", "False", "# inner text means it can't self close anymo", "# self.blocks is either text or tags, in orde...
appendText - append some inner text
[ "appendText", "-", "append", "some", "inner", "text" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L408-L416
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeText
def removeText(self, text): ''' removeText - Removes the first occurace of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return text <str/None> - The text in that block (text node) after remove, or None if not found NOTE...
python
def removeText(self, text): ''' removeText - Removes the first occurace of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return text <str/None> - The text in that block (text node) after remove, or None if not found NOTE...
[ "def", "removeText", "(", "self", ",", "text", ")", ":", "# TODO: This would be a good candidate for the refactor of text blocks", "removedBlock", "=", "None", "# Scan all text blocks for \"text\"", "blocks", "=", "self", ".", "blocks", "for", "i", "in", "range", "(", "...
removeText - Removes the first occurace of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return text <str/None> - The text in that block (text node) after remove, or None if not found NOTE: To remove a node, @see removeChild NOT...
[ "removeText", "-", "Removes", "the", "first", "occurace", "of", "given", "text", "in", "a", "text", "node", "(", "i", ".", "e", ".", "not", "part", "of", "a", "tag", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L419-L456
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeTextAll
def removeTextAll(self, text): ''' removeTextAll - Removes ALL occuraces of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return list <str> - All text node containing #text BEFORE the text was removed. Empty list if n...
python
def removeTextAll(self, text): ''' removeTextAll - Removes ALL occuraces of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return list <str> - All text node containing #text BEFORE the text was removed. Empty list if n...
[ "def", "removeTextAll", "(", "self", ",", "text", ")", ":", "# TODO: This would be a good candidate for the refactor of text blocks", "removedBlocks", "=", "[", "]", "blocks", "=", "self", ".", "blocks", "for", "i", "in", "range", "(", "len", "(", "blocks", ")", ...
removeTextAll - Removes ALL occuraces of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return list <str> - All text node containing #text BEFORE the text was removed. Empty list if no text removed NOTE: To remove a node, @se...
[ "removeTextAll", "-", "Removes", "ALL", "occuraces", "of", "given", "text", "in", "a", "text", "node", "(", "i", ".", "e", ".", "not", "part", "of", "a", "tag", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L459-L495
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.remove
def remove(self): ''' remove - Will remove this node from its parent, if it has a parent (thus taking it out of the HTML tree) NOTE: If you are using an IndexedAdvancedHTMLParser, calling this will NOT update the index. You MUST call reindex method manually. ...
python
def remove(self): ''' remove - Will remove this node from its parent, if it has a parent (thus taking it out of the HTML tree) NOTE: If you are using an IndexedAdvancedHTMLParser, calling this will NOT update the index. You MUST call reindex method manually. ...
[ "def", "remove", "(", "self", ")", ":", "if", "self", ".", "parentNode", ":", "self", ".", "parentNode", ".", "removeChild", "(", "self", ")", "# self.parentNode will now be None by 'removeChild' method", "return", "True", "return", "False" ]
remove - Will remove this node from its parent, if it has a parent (thus taking it out of the HTML tree) NOTE: If you are using an IndexedAdvancedHTMLParser, calling this will NOT update the index. You MUST call reindex method manually. @return <bool> - While JS DOM defin...
[ "remove", "-", "Will", "remove", "this", "node", "from", "its", "parent", "if", "it", "has", "a", "parent", "(", "thus", "taking", "it", "out", "of", "the", "HTML", "tree", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L498-L512
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeBlocks
def removeBlocks(self, blocks): ''' removeBlock - Removes a list of blocks (the first occurance of each) from the direct children of this node. @param blocks list<str/AdvancedTag> - List of AdvancedTags for tag nodes, else strings for text nodes @return The removed blocks ...
python
def removeBlocks(self, blocks): ''' removeBlock - Removes a list of blocks (the first occurance of each) from the direct children of this node. @param blocks list<str/AdvancedTag> - List of AdvancedTags for tag nodes, else strings for text nodes @return The removed blocks ...
[ "def", "removeBlocks", "(", "self", ",", "blocks", ")", ":", "ret", "=", "[", "]", "for", "block", "in", "blocks", ":", "if", "issubclass", "(", "block", ".", "__class__", ",", "AdvancedTag", ")", ":", "ret", ".", "append", "(", "self", ".", "removeC...
removeBlock - Removes a list of blocks (the first occurance of each) from the direct children of this node. @param blocks list<str/AdvancedTag> - List of AdvancedTags for tag nodes, else strings for text nodes @return The removed blocks in each slot, or None if None removed. @see...
[ "removeBlock", "-", "Removes", "a", "list", "of", "blocks", "(", "the", "first", "occurance", "of", "each", ")", "from", "the", "direct", "children", "of", "this", "node", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L515-L536
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.appendChild
def appendChild(self, child): ''' appendChild - Append a child to this element. @param child <AdvancedTag> - Append a child element to this element ''' # Associate parentNode of #child to this tag child.parentNode = self # Associate owner document to ch...
python
def appendChild(self, child): ''' appendChild - Append a child to this element. @param child <AdvancedTag> - Append a child element to this element ''' # Associate parentNode of #child to this tag child.parentNode = self # Associate owner document to ch...
[ "def", "appendChild", "(", "self", ",", "child", ")", ":", "# Associate parentNode of #child to this tag", "child", ".", "parentNode", "=", "self", "# Associate owner document to child and all children recursive", "ownerDocument", "=", "self", ".", "ownerDocument", "child", ...
appendChild - Append a child to this element. @param child <AdvancedTag> - Append a child element to this element
[ "appendChild", "-", "Append", "a", "child", "to", "this", "element", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L538-L561
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.appendBlock
def appendBlock(self, block): ''' append / appendBlock - Append a block to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param <str/AdvancedTag> - block to add @return - #block NOTE: To add multiple blocks, @see appendBlocks ...
python
def appendBlock(self, block): ''' append / appendBlock - Append a block to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param <str/AdvancedTag> - block to add @return - #block NOTE: To add multiple blocks, @see appendBlocks ...
[ "def", "appendBlock", "(", "self", ",", "block", ")", ":", "# Determine block type and call appropriate method", "if", "isinstance", "(", "block", ",", "AdvancedTag", ")", ":", "self", ".", "appendNode", "(", "block", ")", "else", ":", "self", ".", "appendText",...
append / appendBlock - Append a block to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param <str/AdvancedTag> - block to add @return - #block NOTE: To add multiple blocks, @see appendBlocks If you know the type, use either @see...
[ "append", "/", "appendBlock", "-", "Append", "a", "block", "to", "this", "element", ".", "A", "block", "can", "be", "a", "string", "(", "text", "node", ")", "or", "an", "AdvancedTag", "(", "tag", "node", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L567-L584
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.appendBlocks
def appendBlocks(self, blocks): ''' appendBlocks - Append blocks to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param blocks list<str/AdvancedTag> - A list, in order to append, of blocks to add. @return - #blocks NOTE: To ad...
python
def appendBlocks(self, blocks): ''' appendBlocks - Append blocks to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param blocks list<str/AdvancedTag> - A list, in order to append, of blocks to add. @return - #blocks NOTE: To ad...
[ "def", "appendBlocks", "(", "self", ",", "blocks", ")", ":", "for", "block", "in", "blocks", ":", "if", "isinstance", "(", "block", ",", "AdvancedTag", ")", ":", "self", ".", "appendNode", "(", "block", ")", "else", ":", "self", ".", "appendText", "(",...
appendBlocks - Append blocks to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param blocks list<str/AdvancedTag> - A list, in order to append, of blocks to add. @return - #blocks NOTE: To add a single block, @see appendBlock If ...
[ "appendBlocks", "-", "Append", "blocks", "to", "this", "element", ".", "A", "block", "can", "be", "a", "string", "(", "text", "node", ")", "or", "an", "AdvancedTag", "(", "tag", "node", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L590-L607
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.appendInnerHTML
def appendInnerHTML(self, html): ''' appendInnerHTML - Appends nodes from arbitrary HTML as if doing element.innerHTML += 'someHTML' in javascript. @param html <str> - Some HTML NOTE: If associated with a document ( AdvancedHTMLParser ), the html will use the encoding assoc...
python
def appendInnerHTML(self, html): ''' appendInnerHTML - Appends nodes from arbitrary HTML as if doing element.innerHTML += 'someHTML' in javascript. @param html <str> - Some HTML NOTE: If associated with a document ( AdvancedHTMLParser ), the html will use the encoding assoc...
[ "def", "appendInnerHTML", "(", "self", ",", "html", ")", ":", "# Late-binding to prevent circular import", "from", ".", "Parser", "import", "AdvancedHTMLParser", "# Inherit encoding from the associated document, if any.", "encoding", "=", "None", "if", "self", ".", "ownerDo...
appendInnerHTML - Appends nodes from arbitrary HTML as if doing element.innerHTML += 'someHTML' in javascript. @param html <str> - Some HTML NOTE: If associated with a document ( AdvancedHTMLParser ), the html will use the encoding associated with that document. ...
[ "appendInnerHTML", "-", "Appends", "nodes", "from", "arbitrary", "HTML", "as", "if", "doing", "element", ".", "innerHTML", "+", "=", "someHTML", "in", "javascript", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L610-L635
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeChild
def removeChild(self, child): ''' removeChild - Remove a child tag, if present. @param child <AdvancedTag> - The child to remove @return - The child [with parentNode cleared] if removed, otherwise None. NOTE: This removes a tag. If removing a text b...
python
def removeChild(self, child): ''' removeChild - Remove a child tag, if present. @param child <AdvancedTag> - The child to remove @return - The child [with parentNode cleared] if removed, otherwise None. NOTE: This removes a tag. If removing a text b...
[ "def", "removeChild", "(", "self", ",", "child", ")", ":", "try", ":", "# Remove from children and blocks", "self", ".", "children", ".", "remove", "(", "child", ")", "self", ".", "blocks", ".", "remove", "(", "child", ")", "# Clear parent node association on ch...
removeChild - Remove a child tag, if present. @param child <AdvancedTag> - The child to remove @return - The child [with parentNode cleared] if removed, otherwise None. NOTE: This removes a tag. If removing a text block, use #removeText function. If y...
[ "removeChild", "-", "Remove", "a", "child", "tag", "if", "present", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L638-L668
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeChildren
def removeChildren(self, children): ''' removeChildren - Remove multiple child AdvancedTags. @see removeChild @return list<AdvancedTag/None> - A list of all tags removed in same order as passed. Item is "None" if it was not attached to this node, and thus wa...
python
def removeChildren(self, children): ''' removeChildren - Remove multiple child AdvancedTags. @see removeChild @return list<AdvancedTag/None> - A list of all tags removed in same order as passed. Item is "None" if it was not attached to this node, and thus wa...
[ "def", "removeChildren", "(", "self", ",", "children", ")", ":", "ret", "=", "[", "]", "for", "child", "in", "children", ":", "ret", ".", "append", "(", "self", ".", "removeChild", "(", "child", ")", ")", "return", "ret" ]
removeChildren - Remove multiple child AdvancedTags. @see removeChild @return list<AdvancedTag/None> - A list of all tags removed in same order as passed. Item is "None" if it was not attached to this node, and thus was not removed.
[ "removeChildren", "-", "Remove", "multiple", "child", "AdvancedTags", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L673-L687
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.removeBlock
def removeBlock(self, block): ''' removeBlock - Removes a single block (text node or AdvancedTag) which is a child of this object. @param block <str/AdvancedTag> - The block (text node or AdvancedTag) to remove. @return Returns the removed block if one was remov...
python
def removeBlock(self, block): ''' removeBlock - Removes a single block (text node or AdvancedTag) which is a child of this object. @param block <str/AdvancedTag> - The block (text node or AdvancedTag) to remove. @return Returns the removed block if one was remov...
[ "def", "removeBlock", "(", "self", ",", "block", ")", ":", "if", "issubclass", "(", "block", ".", "__class__", ",", "AdvancedTag", ")", ":", "return", "self", ".", "removeChild", "(", "block", ")", "else", ":", "return", "self", ".", "removeText", "(", ...
removeBlock - Removes a single block (text node or AdvancedTag) which is a child of this object. @param block <str/AdvancedTag> - The block (text node or AdvancedTag) to remove. @return Returns the removed block if one was removed, or None if requested block is not a child of this ...
[ "removeBlock", "-", "Removes", "a", "single", "block", "(", "text", "node", "or", "AdvancedTag", ")", "which", "is", "a", "child", "of", "this", "object", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L690-L706
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.insertBefore
def insertBefore(self, child, beforeChild): ''' insertBefore - Inserts a child before #beforeChild @param child <AdvancedTag/str> - Child block to insert @param beforeChild <AdvancedTag/str> - Child block to insert before. if None, will be appended @r...
python
def insertBefore(self, child, beforeChild): ''' insertBefore - Inserts a child before #beforeChild @param child <AdvancedTag/str> - Child block to insert @param beforeChild <AdvancedTag/str> - Child block to insert before. if None, will be appended @r...
[ "def", "insertBefore", "(", "self", ",", "child", ",", "beforeChild", ")", ":", "# When the second arg is null/None, the node is appended. The argument is required per JS API, but null is acceptable..", "if", "beforeChild", "is", "None", ":", "return", "self", ".", "appendBlock...
insertBefore - Inserts a child before #beforeChild @param child <AdvancedTag/str> - Child block to insert @param beforeChild <AdvancedTag/str> - Child block to insert before. if None, will be appended @return - The added child. Note, if it is a text block (str), the retu...
[ "insertBefore", "-", "Inserts", "a", "child", "before", "#beforeChild" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L710-L749
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.insertAfter
def insertAfter(self, child, afterChild): ''' insertAfter - Inserts a child after #afterChild @param child <AdvancedTag/str> - Child block to insert @param afterChild <AdvancedTag/str> - Child block to insert after. if None, will be appended @return -...
python
def insertAfter(self, child, afterChild): ''' insertAfter - Inserts a child after #afterChild @param child <AdvancedTag/str> - Child block to insert @param afterChild <AdvancedTag/str> - Child block to insert after. if None, will be appended @return -...
[ "def", "insertAfter", "(", "self", ",", "child", ",", "afterChild", ")", ":", "# If after child is null/None, just append", "if", "afterChild", "is", "None", ":", "return", "self", ".", "appendBlock", "(", "child", ")", "isChildTag", "=", "isTagNode", "(", "chil...
insertAfter - Inserts a child after #afterChild @param child <AdvancedTag/str> - Child block to insert @param afterChild <AdvancedTag/str> - Child block to insert after. if None, will be appended @return - The added child. Note, if it is a text block (str), the return is...
[ "insertAfter", "-", "Inserts", "a", "child", "after", "#afterChild" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L751-L785
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
AdvancedTag.firstChild
def firstChild(self): ''' firstChild - property, Get the first child block, text or tag. @return <str/AdvancedTag/None> - The first child block, or None if no child blocks ''' blocks = object.__getattribute__(self, 'blocks') # First block is empty string for ...
python
def firstChild(self): ''' firstChild - property, Get the first child block, text or tag. @return <str/AdvancedTag/None> - The first child block, or None if no child blocks ''' blocks = object.__getattribute__(self, 'blocks') # First block is empty string for ...
[ "def", "firstChild", "(", "self", ")", ":", "blocks", "=", "object", ".", "__getattribute__", "(", "self", ",", "'blocks'", ")", "# First block is empty string for indent, but don't hardcode incase that changes", "if", "blocks", "[", "0", "]", "==", "''", ":", "firs...
firstChild - property, Get the first child block, text or tag. @return <str/AdvancedTag/None> - The first child block, or None if no child blocks
[ "firstChild", "-", "property", "Get", "the", "first", "child", "block", "text", "or", "tag", "." ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L860-L877
train