repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.post_request
def post_request(self, container, resource=None, params=None, accept=None): """Send a POST request.""" url = self.make_url(container, resource) headers = self._make_headers(accept) try: rsp = requests.post(url, data=params, headers=headers, ve...
python
def post_request(self, container, resource=None, params=None, accept=None): """Send a POST request.""" url = self.make_url(container, resource) headers = self._make_headers(accept) try: rsp = requests.post(url, data=params, headers=headers, ve...
[ "def", "post_request", "(", "self", ",", "container", ",", "resource", "=", "None", ",", "params", "=", "None", ",", "accept", "=", "None", ")", ":", "url", "=", "self", ".", "make_url", "(", "container", ",", "resource", ")", "headers", "=", "self", ...
Send a POST request.
[ "Send", "a", "POST", "request", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L220-L234
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.delete_request
def delete_request(self, container, resource=None, query_items=None, accept=None): """Send a DELETE request.""" url = self.make_url(container, resource) headers = self._make_headers(accept) if query_items and isinstance(query_items, (list, tuple, set)): ...
python
def delete_request(self, container, resource=None, query_items=None, accept=None): """Send a DELETE request.""" url = self.make_url(container, resource) headers = self._make_headers(accept) if query_items and isinstance(query_items, (list, tuple, set)): ...
[ "def", "delete_request", "(", "self", ",", "container", ",", "resource", "=", "None", ",", "query_items", "=", "None", ",", "accept", "=", "None", ")", ":", "url", "=", "self", ".", "make_url", "(", "container", ",", "resource", ")", "headers", "=", "s...
Send a DELETE request.
[ "Send", "a", "DELETE", "request", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L252-L271
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.download_file
def download_file(self, container, resource, save_path=None, accept=None, query_items=None): """Download a file. If a timeout defined, it is not a time limit on the entire download; rather, an exception is raised if the server has not issued a response for timeout ...
python
def download_file(self, container, resource, save_path=None, accept=None, query_items=None): """Download a file. If a timeout defined, it is not a time limit on the entire download; rather, an exception is raised if the server has not issued a response for timeout ...
[ "def", "download_file", "(", "self", ",", "container", ",", "resource", ",", "save_path", "=", "None", ",", "accept", "=", "None", ",", "query_items", "=", "None", ")", ":", "url", "=", "self", ".", "make_url", "(", "container", ",", "resource", ")", "...
Download a file. If a timeout defined, it is not a time limit on the entire download; rather, an exception is raised if the server has not issued a response for timeout seconds (more precisely, if no bytes have been received on the underlying socket for timeout seconds). If no timeout i...
[ "Download", "a", "file", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L273-L319
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.upload_file
def upload_file(self, container, src_file_path, dst_name=None, put=True, content_type=None): """Upload a single file.""" if not os.path.exists(src_file_path): raise RuntimeError('file not found: ' + src_file_path) if not dst_name: dst_name = os.path.ba...
python
def upload_file(self, container, src_file_path, dst_name=None, put=True, content_type=None): """Upload a single file.""" if not os.path.exists(src_file_path): raise RuntimeError('file not found: ' + src_file_path) if not dst_name: dst_name = os.path.ba...
[ "def", "upload_file", "(", "self", ",", "container", ",", "src_file_path", ",", "dst_name", "=", "None", ",", "put", "=", "True", ",", "content_type", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "src_file_path", ")", ":",...
Upload a single file.
[ "Upload", "a", "single", "file", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L321-L350
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.upload_file_mp
def upload_file_mp(self, container, src_file_path, dst_name=None, content_type=None): """Upload a file using multi-part encoding.""" if not os.path.exists(src_file_path): raise RuntimeError('file not found: ' + src_file_path) if not dst_name: dst_na...
python
def upload_file_mp(self, container, src_file_path, dst_name=None, content_type=None): """Upload a file using multi-part encoding.""" if not os.path.exists(src_file_path): raise RuntimeError('file not found: ' + src_file_path) if not dst_name: dst_na...
[ "def", "upload_file_mp", "(", "self", ",", "container", ",", "src_file_path", ",", "dst_name", "=", "None", ",", "content_type", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "src_file_path", ")", ":", "raise", "RuntimeError", ...
Upload a file using multi-part encoding.
[ "Upload", "a", "file", "using", "multi", "-", "part", "encoding", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L352-L371
Spirent/py-stcrestclient
stcrestclient/resthttp.py
RestHttp.upload_files
def upload_files(self, container, src_dst_map, content_type=None): """Upload multiple files.""" if not content_type: content_type = "application/octet.stream" url = self.make_url(container, None, None) headers = self._base_headers multi_files = [] try: ...
python
def upload_files(self, container, src_dst_map, content_type=None): """Upload multiple files.""" if not content_type: content_type = "application/octet.stream" url = self.make_url(container, None, None) headers = self._base_headers multi_files = [] try: ...
[ "def", "upload_files", "(", "self", ",", "container", ",", "src_dst_map", ",", "content_type", "=", "None", ")", ":", "if", "not", "content_type", ":", "content_type", "=", "\"application/octet.stream\"", "url", "=", "self", ".", "make_url", "(", "container", ...
Upload multiple files.
[ "Upload", "multiple", "files", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L373-L397
Spirent/py-stcrestclient
stcrestclient/stcpythonrest.py
StcPythonRest.new_session
def new_session(self, server=None, session_name=None, user_name=None, existing_session=None): """Create a new session or attach to existing. Normally, this function is called automatically, and gets its parameter values from the environment. It is provided as a public funct...
python
def new_session(self, server=None, session_name=None, user_name=None, existing_session=None): """Create a new session or attach to existing. Normally, this function is called automatically, and gets its parameter values from the environment. It is provided as a public funct...
[ "def", "new_session", "(", "self", ",", "server", "=", "None", ",", "session_name", "=", "None", ",", "user_name", "=", "None", ",", "existing_session", "=", "None", ")", ":", "if", "not", "server", ":", "server", "=", "os", ".", "environ", ".", "get",...
Create a new session or attach to existing. Normally, this function is called automatically, and gets its parameter values from the environment. It is provided as a public function for cases when extra control over session creation is required in an automation script that is adapted to...
[ "Create", "a", "new", "session", "or", "attach", "to", "existing", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stcpythonrest.py#L192-L267
Spirent/py-stcrestclient
stcrestclient/stcpythonrest.py
StcPythonRest._end_session
def _end_session(self, kill=None): """End the client session.""" if self._stc: if kill is None: kill = os.environ.get('STC_SESSION_TERMINATE_ON_DISCONNECT') kill = _is_true(kill) self._stc.end_session(kill) self._stc = None
python
def _end_session(self, kill=None): """End the client session.""" if self._stc: if kill is None: kill = os.environ.get('STC_SESSION_TERMINATE_ON_DISCONNECT') kill = _is_true(kill) self._stc.end_session(kill) self._stc = None
[ "def", "_end_session", "(", "self", ",", "kill", "=", "None", ")", ":", "if", "self", ".", "_stc", ":", "if", "kill", "is", "None", ":", "kill", "=", "os", ".", "environ", ".", "get", "(", "'STC_SESSION_TERMINATE_ON_DISCONNECT'", ")", "kill", "=", "_is...
End the client session.
[ "End", "the", "client", "session", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stcpythonrest.py#L274-L281
rtfd/readthedocs-sphinx-ext
readthedocs_ext/embed.py
setup
def setup(app): """ This isn't used in Production, but allows this module to be used as a standalone extension. """ app.add_directive('readthedocs-embed', EmbedDirective) app.add_config_value('readthedocs_embed_project', '', 'html') app.add_config_value('readthedocs_embed_version', '', 'htm...
python
def setup(app): """ This isn't used in Production, but allows this module to be used as a standalone extension. """ app.add_directive('readthedocs-embed', EmbedDirective) app.add_config_value('readthedocs_embed_project', '', 'html') app.add_config_value('readthedocs_embed_version', '', 'htm...
[ "def", "setup", "(", "app", ")", ":", "app", ".", "add_directive", "(", "'readthedocs-embed'", ",", "EmbedDirective", ")", "app", ".", "add_config_value", "(", "'readthedocs_embed_project'", ",", "''", ",", "'html'", ")", "app", ".", "add_config_value", "(", "...
This isn't used in Production, but allows this module to be used as a standalone extension.
[ "This", "isn", "t", "used", "in", "Production", "but", "allows", "this", "module", "to", "be", "used", "as", "a", "standalone", "extension", "." ]
train
https://github.com/rtfd/readthedocs-sphinx-ext/blob/f1a01c51c675d36ac365162ea06814544c2aa410/readthedocs_ext/embed.py#L66-L77
rtfd/readthedocs-sphinx-ext
readthedocs_ext/readthedocs.py
finalize_media
def finalize_media(app): """Point media files at our media server.""" if (app.builder.name == 'readthedocssinglehtmllocalmedia' or app.builder.format != 'html' or not hasattr(app.builder, 'script_files')): return # Use local media for downloadable files # Pull project data ...
python
def finalize_media(app): """Point media files at our media server.""" if (app.builder.name == 'readthedocssinglehtmllocalmedia' or app.builder.format != 'html' or not hasattr(app.builder, 'script_files')): return # Use local media for downloadable files # Pull project data ...
[ "def", "finalize_media", "(", "app", ")", ":", "if", "(", "app", ".", "builder", ".", "name", "==", "'readthedocssinglehtmllocalmedia'", "or", "app", ".", "builder", ".", "format", "!=", "'html'", "or", "not", "hasattr", "(", "app", ".", "builder", ",", ...
Point media files at our media server.
[ "Point", "media", "files", "at", "our", "media", "server", "." ]
train
https://github.com/rtfd/readthedocs-sphinx-ext/blob/f1a01c51c675d36ac365162ea06814544c2aa410/readthedocs_ext/readthedocs.py#L43-L57
rtfd/readthedocs-sphinx-ext
readthedocs_ext/readthedocs.py
update_body
def update_body(app, pagename, templatename, context, doctree): """ Add Read the Docs content to Sphinx body content. This is the most reliable way to inject our content into the page. """ STATIC_URL = context.get('STATIC_URL', DEFAULT_STATIC_URL) online_builders = [ 'readthedocs', 're...
python
def update_body(app, pagename, templatename, context, doctree): """ Add Read the Docs content to Sphinx body content. This is the most reliable way to inject our content into the page. """ STATIC_URL = context.get('STATIC_URL', DEFAULT_STATIC_URL) online_builders = [ 'readthedocs', 're...
[ "def", "update_body", "(", "app", ",", "pagename", ",", "templatename", ",", "context", ",", "doctree", ")", ":", "STATIC_URL", "=", "context", ".", "get", "(", "'STATIC_URL'", ",", "DEFAULT_STATIC_URL", ")", "online_builders", "=", "[", "'readthedocs'", ",", ...
Add Read the Docs content to Sphinx body content. This is the most reliable way to inject our content into the page.
[ "Add", "Read", "the", "Docs", "content", "to", "Sphinx", "body", "content", "." ]
train
https://github.com/rtfd/readthedocs-sphinx-ext/blob/f1a01c51c675d36ac365162ea06814544c2aa410/readthedocs_ext/readthedocs.py#L60-L142
rtfd/readthedocs-sphinx-ext
readthedocs_ext/readthedocs.py
generate_json_artifacts
def generate_json_artifacts(app, pagename, templatename, context, doctree): """ Generate JSON artifacts for each page. This way we can skip generating this in other build step. """ try: # We need to get the output directory where the docs are built # _build/json. build_json ...
python
def generate_json_artifacts(app, pagename, templatename, context, doctree): """ Generate JSON artifacts for each page. This way we can skip generating this in other build step. """ try: # We need to get the output directory where the docs are built # _build/json. build_json ...
[ "def", "generate_json_artifacts", "(", "app", ",", "pagename", ",", "templatename", ",", "context", ",", "doctree", ")", ":", "try", ":", "# We need to get the output directory where the docs are built", "# _build/json.", "build_json", "=", "os", ".", "path", ".", "ab...
Generate JSON artifacts for each page. This way we can skip generating this in other build step.
[ "Generate", "JSON", "artifacts", "for", "each", "page", "." ]
train
https://github.com/rtfd/readthedocs-sphinx-ext/blob/f1a01c51c675d36ac365162ea06814544c2aa410/readthedocs_ext/readthedocs.py#L145-L178
rtfd/readthedocs-sphinx-ext
readthedocs_ext/readthedocs.py
HtmlBuilderMixin._copy_searchtools
def _copy_searchtools(self, renderer=None): """Copy and patch searchtools This uses the included Sphinx version's searchtools, but patches it to remove automatic initialization. This is a fork of ``sphinx.util.fileutil.copy_asset`` """ log.info(bold('copying searchtools....
python
def _copy_searchtools(self, renderer=None): """Copy and patch searchtools This uses the included Sphinx version's searchtools, but patches it to remove automatic initialization. This is a fork of ``sphinx.util.fileutil.copy_asset`` """ log.info(bold('copying searchtools....
[ "def", "_copy_searchtools", "(", "self", ",", "renderer", "=", "None", ")", ":", "log", ".", "info", "(", "bold", "(", "'copying searchtools... '", ")", ",", "nonl", "=", "True", ")", "if", "sphinx", ".", "version_info", "<", "(", "1", ",", "8", ")", ...
Copy and patch searchtools This uses the included Sphinx version's searchtools, but patches it to remove automatic initialization. This is a fork of ``sphinx.util.fileutil.copy_asset``
[ "Copy", "and", "patch", "searchtools" ]
train
https://github.com/rtfd/readthedocs-sphinx-ext/blob/f1a01c51c675d36ac365162ea06814544c2aa410/readthedocs_ext/readthedocs.py#L209-L247
Spirent/py-stcrestclient
stcrestclient/systeminfo.py
stc_system_info
def stc_system_info(stc_addr): """Return dictionary of STC and API information. If a session already exists, then use it to get STC information and avoid taking the time to start a new session. A session is necessary to get STC information. """ stc = stchttp.StcHttp(stc_addr) sessions = s...
python
def stc_system_info(stc_addr): """Return dictionary of STC and API information. If a session already exists, then use it to get STC information and avoid taking the time to start a new session. A session is necessary to get STC information. """ stc = stchttp.StcHttp(stc_addr) sessions = s...
[ "def", "stc_system_info", "(", "stc_addr", ")", ":", "stc", "=", "stchttp", ".", "StcHttp", "(", "stc_addr", ")", "sessions", "=", "stc", ".", "sessions", "(", ")", "if", "sessions", ":", "# If a session already exists, use it to get STC information.", "stc", ".",...
Return dictionary of STC and API information. If a session already exists, then use it to get STC information and avoid taking the time to start a new session. A session is necessary to get STC information.
[ "Return", "dictionary", "of", "STC", "and", "API", "information", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/systeminfo.py#L23-L46
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.new_session
def new_session(self, user_name=None, session_name=None, kill_existing=False, analytics=None): """Create a new test session. The test session is identified by the specified user_name and optional session_name parameters. If a session name is not specified, then the ...
python
def new_session(self, user_name=None, session_name=None, kill_existing=False, analytics=None): """Create a new test session. The test session is identified by the specified user_name and optional session_name parameters. If a session name is not specified, then the ...
[ "def", "new_session", "(", "self", ",", "user_name", "=", "None", ",", "session_name", "=", "None", ",", "kill_existing", "=", "False", ",", "analytics", "=", "None", ")", ":", "if", "self", ".", "started", "(", ")", ":", "return", "False", "if", "not"...
Create a new test session. The test session is identified by the specified user_name and optional session_name parameters. If a session name is not specified, then the server will create one. Arguments: user_name -- User name part of session ID. session_name -- Se...
[ "Create", "a", "new", "test", "session", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L87-L140
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.join_session
def join_session(self, sid): """Attach to an existing session.""" self._rest.add_header('X-STC-API-Session', sid) self._sid = sid try: status, data = self._rest.get_request('objects', 'system1', ['version', 'name']) ex...
python
def join_session(self, sid): """Attach to an existing session.""" self._rest.add_header('X-STC-API-Session', sid) self._sid = sid try: status, data = self._rest.get_request('objects', 'system1', ['version', 'name']) ex...
[ "def", "join_session", "(", "self", ",", "sid", ")", ":", "self", ".", "_rest", ".", "add_header", "(", "'X-STC-API-Session'", ",", "sid", ")", "self", ".", "_sid", "=", "sid", "try", ":", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_r...
Attach to an existing session.
[ "Attach", "to", "an", "existing", "session", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L142-L154
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.end_session
def end_session(self, end_tcsession=True, sid=None): """End this test session. A session can be ended in three ways, depending on the value of the end_tcsession parameter: - end_tcsession=None: Stop using session locally, do not contact server. - end_tcse...
python
def end_session(self, end_tcsession=True, sid=None): """End this test session. A session can be ended in three ways, depending on the value of the end_tcsession parameter: - end_tcsession=None: Stop using session locally, do not contact server. - end_tcse...
[ "def", "end_session", "(", "self", ",", "end_tcsession", "=", "True", ",", "sid", "=", "None", ")", ":", "if", "not", "sid", "or", "sid", "==", "self", ".", "_sid", ":", "if", "not", "self", ".", "started", "(", ")", ":", "return", "False", "sid", ...
End this test session. A session can be ended in three ways, depending on the value of the end_tcsession parameter: - end_tcsession=None: Stop using session locally, do not contact server. - end_tcsession=False: End client controller, but leave te...
[ "End", "this", "test", "session", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L156-L234
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.session_info
def session_info(self, session_id=None): """Get information on session. If session_id is None, the default, then return information about this session. If a session ID is given, then get information about that session. Arguments: session_id -- Id of session to get info...
python
def session_info(self, session_id=None): """Get information on session. If session_id is None, the default, then return information about this session. If a session ID is given, then get information about that session. Arguments: session_id -- Id of session to get info...
[ "def", "session_info", "(", "self", ",", "session_id", "=", "None", ")", ":", "if", "not", "session_id", ":", "if", "not", "self", ".", "started", "(", ")", ":", "return", "[", "]", "session_id", "=", "self", ".", "_sid", "status", ",", "data", "=", ...
Get information on session. If session_id is None, the default, then return information about this session. If a session ID is given, then get information about that session. Arguments: session_id -- Id of session to get info for, if not this session. Return: ...
[ "Get", "information", "on", "session", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L273-L292
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.files
def files(self): """Get list of files, for this session, on server.""" self._check_session() status, data = self._rest.get_request('files') return data
python
def files(self): """Get list of files, for this session, on server.""" self._check_session() status, data = self._rest.get_request('files') return data
[ "def", "files", "(", "self", ")", ":", "self", ".", "_check_session", "(", ")", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'files'", ")", "return", "data" ]
Get list of files, for this session, on server.
[ "Get", "list", "of", "files", "for", "this", "session", "on", "server", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L294-L298
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.bll_version
def bll_version(self): """Get the BLL version this session is connected to. Return: Version string if session started. None if session not started. """ if not self.started(): return None status, data = self._rest.get_request('objects', 'system1', ...
python
def bll_version(self): """Get the BLL version this session is connected to. Return: Version string if session started. None if session not started. """ if not self.started(): return None status, data = self._rest.get_request('objects', 'system1', ...
[ "def", "bll_version", "(", "self", ")", ":", "if", "not", "self", ".", "started", "(", ")", ":", "return", "None", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'objects'", ",", "'system1'", ",", "[", "'version'", ",", "...
Get the BLL version this session is connected to. Return: Version string if session started. None if session not started.
[ "Get", "the", "BLL", "version", "this", "session", "is", "connected", "to", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L309-L320
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.get
def get(self, handle, *args): """Returns the value(s) of one or more object attributes. If multiple arguments, this method returns a dictionary of argument names mapped to the value returned by each argument. If a single argument is given, then the response is a list of values ...
python
def get(self, handle, *args): """Returns the value(s) of one or more object attributes. If multiple arguments, this method returns a dictionary of argument names mapped to the value returned by each argument. If a single argument is given, then the response is a list of values ...
[ "def", "get", "(", "self", ",", "handle", ",", "*", "args", ")", ":", "self", ".", "_check_session", "(", ")", "status", ",", "data", "=", "self", ".", "_rest", ".", "get_request", "(", "'objects'", ",", "str", "(", "handle", ")", ",", "args", ")",...
Returns the value(s) of one or more object attributes. If multiple arguments, this method returns a dictionary of argument names mapped to the value returned by each argument. If a single argument is given, then the response is a list of values for that argument. Arguments: ...
[ "Returns", "the", "value", "(", "s", ")", "of", "one", "or", "more", "object", "attributes", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L336-L360
Spirent/py-stcrestclient
stcrestclient/stchttp.py
StcHttp.create
def create(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 create(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", "create", "(", "self", ",", "object_type", ",", "under", "=", "None", ",", "attributes", "=", "None", ",", "*", "*", "kwattrs", ")", ":", "data", "=", "self", ".", "createx", "(", "object_type", ",", "under", ",", "attributes", ",", "*", "*", ...
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L362-L376
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L378-L401
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L403-L411
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L413-L437
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L439-L459
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L461-L465
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L467-L473
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L475-L479
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L481-L490
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L492-L514
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L516-L532
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L549-L580
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L582-L597
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L599-L627
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L629-L647
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L649-L654
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", "." ]
train
https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/stchttp.py#L656-L684
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", ":" ]
train
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/managers.py#L17-L50
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", "." ]
train
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/shared.py#L50-L77
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", "." ]
train
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/signals.py#L13-L36
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", "." ]
train
https://github.com/dcramer/mock-django/blob/1168d3255e0d67fbf74a9c71feaccbdafef59d21/mock_django/query.py#L21-L109
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" ]
train
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L12-L16
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" ]
train
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L18-L23
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", "." ]
train
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L25-L35
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", "." ]
train
https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L38-L58
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...
train
https://github.com/guilhermechapiewski/simple-db-migrate/blob/7ea6ffd0c58f70079cc344eae348430c7bdaaab3/simple_db_migrate/main.py#L174-L250
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", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/examples/chat.py#L17-L25
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" ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/examples/chat.py#L28-L38
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", "." ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/modules.py#L61-L80
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"...
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L177-L207
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", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L210-L238
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", ")", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L85-L97
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", ")", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L99-L113
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", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L115-L133
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", "." ]
train
https://github.com/spantaleev/flask-sijax/blob/df9f6d9b8385b3375c119a51aa100491d5445e17/flask_sijax.py#L160-L166
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", "." ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L116-L124
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" ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L126-L149
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", "." ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L211-L250
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" ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L252-L274
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" ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L277-L283
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" ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/sites.py#L285-L299
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", "." ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/templatetags/nexus_admin.py#L5-L24
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", "." ]
train
https://github.com/disqus/nexus/blob/d761ac7f24d92237ca9ea2eb8b66476832f66486/nexus/__init__.py#L23-L83
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L124-L145
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L153-L173
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L176-L186
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L188-L196
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L198-L206
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L208-L216
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", ...
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L247-L262
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L264-L278
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L286-L308
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L310-L332
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L334-L356
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L358-L380
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L382-L405
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L407-L423
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L426-L449
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L452-L481
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L511-L523
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L527-L539
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", ...
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L604-L765
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L768-L796
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L807-L824
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L826-L837
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L839-L847
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L849-L860
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L862-L876
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L878-L889
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L904-L936
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"...
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L940-L969
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", ")", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L972-L995
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" ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1097-L1104
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1120-L1139
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...
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1141-L1148
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", "...
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1150-L1168
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1170-L1180
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1183-L1202
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", "." ]
train
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Parser.py#L1205-L1226