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
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser._traverse
def _traverse(self, n=1): """Traverse state history. Used by `back` and `forward` methods. :param int n: Cursor increment. Positive values move forward in the browser history; negative values move backward. """ if not self.history: raise exceptions.RoboError('No...
python
def _traverse(self, n=1): """Traverse state history. Used by `back` and `forward` methods. :param int n: Cursor increment. Positive values move forward in the browser history; negative values move backward. """ if not self.history: raise exceptions.RoboError('No...
[ "def", "_traverse", "(", "self", ",", "n", "=", "1", ")", ":", "if", "not", "self", ".", "history", ":", "raise", "exceptions", ".", "RoboError", "(", "'Not tracking history'", ")", "cursor", "=", "self", ".", "_cursor", "+", "n", "if", "cursor", ">=",...
Traverse state history. Used by `back` and `forward` methods. :param int n: Cursor increment. Positive values move forward in the browser history; negative values move backward.
[ "Traverse", "state", "history", ".", "Used", "by", "back", "and", "forward", "methods", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L230-L242
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.get_link
def get_link(self, text=None, *args, **kwargs): """Find an anchor or button by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: BeautifulSoup tag if found, else None """ return helpers.find( ...
python
def get_link(self, text=None, *args, **kwargs): """Find an anchor or button by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: BeautifulSoup tag if found, else None """ return helpers.find( ...
[ "def", "get_link", "(", "self", ",", "text", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "helpers", ".", "find", "(", "self", ".", "parsed", ",", "_link_ptn", ",", "text", "=", "text", ",", "*", "args", ",", "*", ...
Find an anchor or button by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: BeautifulSoup tag if found, else None
[ "Find", "an", "anchor", "or", "button", "by", "containing", "text", "as", "well", "as", "standard", "BeautifulSoup", "arguments", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L260-L270
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.get_links
def get_links(self, text=None, *args, **kwargs): """Find anchors or buttons by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: List of BeautifulSoup tags """ return helpers.find_all( ...
python
def get_links(self, text=None, *args, **kwargs): """Find anchors or buttons by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: List of BeautifulSoup tags """ return helpers.find_all( ...
[ "def", "get_links", "(", "self", ",", "text", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "helpers", ".", "find_all", "(", "self", ".", "parsed", ",", "_link_ptn", ",", "text", "=", "text", ",", "*", "args", ",", "...
Find anchors or buttons by containing text, as well as standard BeautifulSoup arguments. :param text: String or regex to be matched in link text :return: List of BeautifulSoup tags
[ "Find", "anchors", "or", "buttons", "by", "containing", "text", "as", "well", "as", "standard", "BeautifulSoup", "arguments", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L272-L282
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.get_form
def get_form(self, id=None, *args, **kwargs): """Find form by ID, as well as standard BeautifulSoup arguments. :param str id: Form ID :return: BeautifulSoup tag if found, else None """ if id: kwargs['id'] = id form = self.find(_form_ptn, *args, **kwargs) ...
python
def get_form(self, id=None, *args, **kwargs): """Find form by ID, as well as standard BeautifulSoup arguments. :param str id: Form ID :return: BeautifulSoup tag if found, else None """ if id: kwargs['id'] = id form = self.find(_form_ptn, *args, **kwargs) ...
[ "def", "get_form", "(", "self", ",", "id", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "id", ":", "kwargs", "[", "'id'", "]", "=", "id", "form", "=", "self", ".", "find", "(", "_form_ptn", ",", "*", "args", ",", "*...
Find form by ID, as well as standard BeautifulSoup arguments. :param str id: Form ID :return: BeautifulSoup tag if found, else None
[ "Find", "form", "by", "ID", "as", "well", "as", "standard", "BeautifulSoup", "arguments", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L284-L295
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.get_forms
def get_forms(self, *args, **kwargs): """Find forms by standard BeautifulSoup arguments. :args: Positional arguments to `BeautifulSoup::find_all` :args: Keyword arguments to `BeautifulSoup::find_all` :return: List of BeautifulSoup tags """ forms = self.find_all(_form_pt...
python
def get_forms(self, *args, **kwargs): """Find forms by standard BeautifulSoup arguments. :args: Positional arguments to `BeautifulSoup::find_all` :args: Keyword arguments to `BeautifulSoup::find_all` :return: List of BeautifulSoup tags """ forms = self.find_all(_form_pt...
[ "def", "get_forms", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "forms", "=", "self", ".", "find_all", "(", "_form_ptn", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "[", "Form", "(", "form", ")", "for", "form",...
Find forms by standard BeautifulSoup arguments. :args: Positional arguments to `BeautifulSoup::find_all` :args: Keyword arguments to `BeautifulSoup::find_all` :return: List of BeautifulSoup tags
[ "Find", "forms", "by", "standard", "BeautifulSoup", "arguments", ".", ":", "args", ":", "Positional", "arguments", "to", "BeautifulSoup", "::", "find_all", ":", "args", ":", "Keyword", "arguments", "to", "BeautifulSoup", "::", "find_all" ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L297-L309
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.follow_link
def follow_link(self, link, **kwargs): """Click a link. :param Tag link: Link to click :param kwargs: Keyword arguments to `Session::send` """ try: href = link['href'] except KeyError: raise exceptions.RoboError('Link element must have "href" ' ...
python
def follow_link(self, link, **kwargs): """Click a link. :param Tag link: Link to click :param kwargs: Keyword arguments to `Session::send` """ try: href = link['href'] except KeyError: raise exceptions.RoboError('Link element must have "href" ' ...
[ "def", "follow_link", "(", "self", ",", "link", ",", "*", "*", "kwargs", ")", ":", "try", ":", "href", "=", "link", "[", "'href'", "]", "except", "KeyError", ":", "raise", "exceptions", ".", "RoboError", "(", "'Link element must have \"href\" '", "'attribute...
Click a link. :param Tag link: Link to click :param kwargs: Keyword arguments to `Session::send`
[ "Click", "a", "link", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L311-L323
jmcarp/robobrowser
robobrowser/browser.py
RoboBrowser.submit_form
def submit_form(self, form, submit=None, **kwargs): """Submit a form. :param Form form: Filled-out form object :param Submit submit: Optional `Submit` to click, if form includes multiple submits :param kwargs: Keyword arguments to `Session::send` """ # Get H...
python
def submit_form(self, form, submit=None, **kwargs): """Submit a form. :param Form form: Filled-out form object :param Submit submit: Optional `Submit` to click, if form includes multiple submits :param kwargs: Keyword arguments to `Session::send` """ # Get H...
[ "def", "submit_form", "(", "self", ",", "form", ",", "submit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Get HTTP verb", "method", "=", "form", ".", "method", ".", "upper", "(", ")", "# Send request", "url", "=", "self", ".", "_build_url", "("...
Submit a form. :param Form form: Filled-out form object :param Submit submit: Optional `Submit` to click, if form includes multiple submits :param kwargs: Keyword arguments to `Session::send`
[ "Submit", "a", "form", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L325-L346
jmcarp/robobrowser
robobrowser/helpers.py
find_all
def find_all(soup, name=None, attrs=None, recursive=True, text=None, limit=None, **kwargs): """The `find` and `find_all` methods of `BeautifulSoup` don't handle the `text` parameter combined with other parameters. This is necessary for e.g. finding links containing a string or pattern. This me...
python
def find_all(soup, name=None, attrs=None, recursive=True, text=None, limit=None, **kwargs): """The `find` and `find_all` methods of `BeautifulSoup` don't handle the `text` parameter combined with other parameters. This is necessary for e.g. finding links containing a string or pattern. This me...
[ "def", "find_all", "(", "soup", ",", "name", "=", "None", ",", "attrs", "=", "None", ",", "recursive", "=", "True", ",", "text", "=", "None", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "text", "is", "None", ":", "return",...
The `find` and `find_all` methods of `BeautifulSoup` don't handle the `text` parameter combined with other parameters. This is necessary for e.g. finding links containing a string or pattern. This method first searches by text content, and then by the standard BeautifulSoup arguments.
[ "The", "find", "and", "find_all", "methods", "of", "BeautifulSoup", "don", "t", "handle", "the", "text", "parameter", "combined", "with", "other", "parameters", ".", "This", "is", "necessary", "for", "e", ".", "g", ".", "finding", "links", "containing", "a",...
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/helpers.py#L20-L43
jmcarp/robobrowser
robobrowser/helpers.py
find
def find(soup, name=None, attrs=None, recursive=True, text=None, **kwargs): """Modified find method; see `find_all`, above. """ tags = find_all( soup, name, attrs or {}, recursive, text, 1, **kwargs ) if tags: return tags[0]
python
def find(soup, name=None, attrs=None, recursive=True, text=None, **kwargs): """Modified find method; see `find_all`, above. """ tags = find_all( soup, name, attrs or {}, recursive, text, 1, **kwargs ) if tags: return tags[0]
[ "def", "find", "(", "soup", ",", "name", "=", "None", ",", "attrs", "=", "None", ",", "recursive", "=", "True", ",", "text", "=", "None", ",", "*", "*", "kwargs", ")", ":", "tags", "=", "find_all", "(", "soup", ",", "name", ",", "attrs", "or", ...
Modified find method; see `find_all`, above.
[ "Modified", "find", "method", ";", "see", "find_all", "above", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/helpers.py#L46-L54
jmcarp/robobrowser
robobrowser/helpers.py
ensure_soup
def ensure_soup(value, parser=None): """Coerce a value (or list of values) to Tag (or list of Tag). :param value: String, BeautifulSoup, Tag, or list of the above :param str parser: Parser to use; defaults to BeautifulSoup default :return: Tag or list of Tags """ if isinstance(value, Beautiful...
python
def ensure_soup(value, parser=None): """Coerce a value (or list of values) to Tag (or list of Tag). :param value: String, BeautifulSoup, Tag, or list of the above :param str parser: Parser to use; defaults to BeautifulSoup default :return: Tag or list of Tags """ if isinstance(value, Beautiful...
[ "def", "ensure_soup", "(", "value", ",", "parser", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "BeautifulSoup", ")", ":", "return", "value", ".", "find", "(", ")", "if", "isinstance", "(", "value", ",", "Tag", ")", ":", "return", "v...
Coerce a value (or list of values) to Tag (or list of Tag). :param value: String, BeautifulSoup, Tag, or list of the above :param str parser: Parser to use; defaults to BeautifulSoup default :return: Tag or list of Tags
[ "Coerce", "a", "value", "(", "or", "list", "of", "values", ")", "to", "Tag", "(", "or", "list", "of", "Tag", ")", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/helpers.py#L57-L75
jmcarp/robobrowser
robobrowser/helpers.py
lowercase_attr_names
def lowercase_attr_names(tag): """Lower-case all attribute names of the provided BeautifulSoup tag. Note: this mutates the tag's attribute names and does not return a new tag. :param Tag: BeautifulSoup tag """ # Use list comprehension instead of dict comprehension for 2.6 support tag.attrs...
python
def lowercase_attr_names(tag): """Lower-case all attribute names of the provided BeautifulSoup tag. Note: this mutates the tag's attribute names and does not return a new tag. :param Tag: BeautifulSoup tag """ # Use list comprehension instead of dict comprehension for 2.6 support tag.attrs...
[ "def", "lowercase_attr_names", "(", "tag", ")", ":", "# Use list comprehension instead of dict comprehension for 2.6 support", "tag", ".", "attrs", "=", "dict", "(", "[", "(", "key", ".", "lower", "(", ")", ",", "value", ")", "for", "key", ",", "value", "in", ...
Lower-case all attribute names of the provided BeautifulSoup tag. Note: this mutates the tag's attribute names and does not return a new tag. :param Tag: BeautifulSoup tag
[ "Lower", "-", "case", "all", "attribute", "names", "of", "the", "provided", "BeautifulSoup", "tag", ".", "Note", ":", "this", "mutates", "the", "tag", "s", "attribute", "names", "and", "does", "not", "return", "a", "new", "tag", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/helpers.py#L78-L90
jmcarp/robobrowser
robobrowser/forms/fields.py
Select._set_initial
def _set_initial(self, initial): """If no option is selected initially, select the first option. """ super(Select, self)._set_initial(initial) if not self._value and self.options: self.value = self.options[0]
python
def _set_initial(self, initial): """If no option is selected initially, select the first option. """ super(Select, self)._set_initial(initial) if not self._value and self.options: self.value = self.options[0]
[ "def", "_set_initial", "(", "self", ",", "initial", ")", ":", "super", "(", "Select", ",", "self", ")", ".", "_set_initial", "(", "initial", ")", "if", "not", "self", ".", "_value", "and", "self", ".", "options", ":", "self", ".", "value", "=", "self...
If no option is selected initially, select the first option.
[ "If", "no", "option", "is", "selected", "initially", "select", "the", "first", "option", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/fields.py#L209-L214
jmcarp/robobrowser
robobrowser/compat.py
encode_if_py2
def encode_if_py2(func): """If Python 2.x, return decorated function encoding unicode return value to UTF-8; else noop. """ if not PY2: return func def wrapped(*args, **kwargs): ret = func(*args, **kwargs) if not isinstance(ret, unicode): raise TypeError('Wrapped ...
python
def encode_if_py2(func): """If Python 2.x, return decorated function encoding unicode return value to UTF-8; else noop. """ if not PY2: return func def wrapped(*args, **kwargs): ret = func(*args, **kwargs) if not isinstance(ret, unicode): raise TypeError('Wrapped ...
[ "def", "encode_if_py2", "(", "func", ")", ":", "if", "not", "PY2", ":", "return", "func", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "not", "i...
If Python 2.x, return decorated function encoding unicode return value to UTF-8; else noop.
[ "If", "Python", "2", ".", "x", "return", "decorated", "function", "encoding", "unicode", "return", "value", "to", "UTF", "-", "8", ";", "else", "noop", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/compat.py#L35-L46
jmcarp/robobrowser
robobrowser/cache.py
RoboCache._reduce_age
def _reduce_age(self, now): """Reduce size of cache by date. :param datetime.datetime now: Current time """ if self.max_age: keys = [ key for key, value in iteritems(self.data) if now - value['date'] > self.max_age ] f...
python
def _reduce_age(self, now): """Reduce size of cache by date. :param datetime.datetime now: Current time """ if self.max_age: keys = [ key for key, value in iteritems(self.data) if now - value['date'] > self.max_age ] f...
[ "def", "_reduce_age", "(", "self", ",", "now", ")", ":", "if", "self", ".", "max_age", ":", "keys", "=", "[", "key", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "data", ")", "if", "now", "-", "value", "[", "'date'", "]", ">",...
Reduce size of cache by date. :param datetime.datetime now: Current time
[ "Reduce", "size", "of", "cache", "by", "date", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/cache.py#L26-L38
jmcarp/robobrowser
robobrowser/cache.py
RoboCache._reduce_count
def _reduce_count(self): """Reduce size of cache by count. """ if self.max_count: while len(self.data) > self.max_count: self.data.popitem(last=False)
python
def _reduce_count(self): """Reduce size of cache by count. """ if self.max_count: while len(self.data) > self.max_count: self.data.popitem(last=False)
[ "def", "_reduce_count", "(", "self", ")", ":", "if", "self", ".", "max_count", ":", "while", "len", "(", "self", ".", "data", ")", ">", "self", ".", "max_count", ":", "self", ".", "data", ".", "popitem", "(", "last", "=", "False", ")" ]
Reduce size of cache by count.
[ "Reduce", "size", "of", "cache", "by", "count", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/cache.py#L40-L46
jmcarp/robobrowser
robobrowser/cache.py
RoboCache.store
def store(self, response): """Store response in cache, skipping if code is forbidden. :param requests.Response response: HTTP response """ if response.status_code not in CACHE_CODES: return now = datetime.datetime.now() self.data[response.url] = { ...
python
def store(self, response): """Store response in cache, skipping if code is forbidden. :param requests.Response response: HTTP response """ if response.status_code not in CACHE_CODES: return now = datetime.datetime.now() self.data[response.url] = { ...
[ "def", "store", "(", "self", ",", "response", ")", ":", "if", "response", ".", "status_code", "not", "in", "CACHE_CODES", ":", "return", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "self", ".", "data", "[", "response", ".", "url", ...
Store response in cache, skipping if code is forbidden. :param requests.Response response: HTTP response
[ "Store", "response", "in", "cache", "skipping", "if", "code", "is", "forbidden", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/cache.py#L48-L63
jmcarp/robobrowser
robobrowser/cache.py
RoboCache.retrieve
def retrieve(self, request): """Look up request in cache, skipping if verb is forbidden. :param requests.Request request: HTTP request """ if request.method not in CACHE_VERBS: return try: response = self.data[request.url]['response'] logger....
python
def retrieve(self, request): """Look up request in cache, skipping if verb is forbidden. :param requests.Request request: HTTP request """ if request.method not in CACHE_VERBS: return try: response = self.data[request.url]['response'] logger....
[ "def", "retrieve", "(", "self", ",", "request", ")", ":", "if", "request", ".", "method", "not", "in", "CACHE_VERBS", ":", "return", "try", ":", "response", "=", "self", ".", "data", "[", "request", ".", "url", "]", "[", "'response'", "]", "logger", ...
Look up request in cache, skipping if verb is forbidden. :param requests.Request request: HTTP request
[ "Look", "up", "request", "in", "cache", "skipping", "if", "verb", "is", "forbidden", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/cache.py#L65-L78
jmcarp/robobrowser
robobrowser/forms/form.py
_group_flat_tags
def _group_flat_tags(tag, tags): """Extract tags sharing the same name as the provided tag. Used to collect options for radio and checkbox inputs. :param Tag tag: BeautifulSoup tag :param list tags: List of tags :return: List of matching tags """ grouped = [tag] name = tag.get('name', ...
python
def _group_flat_tags(tag, tags): """Extract tags sharing the same name as the provided tag. Used to collect options for radio and checkbox inputs. :param Tag tag: BeautifulSoup tag :param list tags: List of tags :return: List of matching tags """ grouped = [tag] name = tag.get('name', ...
[ "def", "_group_flat_tags", "(", "tag", ",", "tags", ")", ":", "grouped", "=", "[", "tag", "]", "name", "=", "tag", ".", "get", "(", "'name'", ",", "''", ")", ".", "lower", "(", ")", "while", "tags", "and", "tags", "[", "0", "]", ".", "get", "("...
Extract tags sharing the same name as the provided tag. Used to collect options for radio and checkbox inputs. :param Tag tag: BeautifulSoup tag :param list tags: List of tags :return: List of matching tags
[ "Extract", "tags", "sharing", "the", "same", "name", "as", "the", "provided", "tag", ".", "Used", "to", "collect", "options", "for", "radio", "and", "checkbox", "inputs", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L23-L36
jmcarp/robobrowser
robobrowser/forms/form.py
_parse_fields
def _parse_fields(parsed): """Parse form fields from HTML. :param BeautifulSoup parsed: Parsed HTML :return OrderedDict: Collection of field objects """ # Note: Call this `out` to avoid name conflict with `fields` module out = [] # Prepare field tags tags = parsed.find_all(_tag_ptn) ...
python
def _parse_fields(parsed): """Parse form fields from HTML. :param BeautifulSoup parsed: Parsed HTML :return OrderedDict: Collection of field objects """ # Note: Call this `out` to avoid name conflict with `fields` module out = [] # Prepare field tags tags = parsed.find_all(_tag_ptn) ...
[ "def", "_parse_fields", "(", "parsed", ")", ":", "# Note: Call this `out` to avoid name conflict with `fields` module", "out", "=", "[", "]", "# Prepare field tags", "tags", "=", "parsed", ".", "find_all", "(", "_tag_ptn", ")", "for", "tag", "in", "tags", ":", "help...
Parse form fields from HTML. :param BeautifulSoup parsed: Parsed HTML :return OrderedDict: Collection of field objects
[ "Parse", "form", "fields", "from", "HTML", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L64-L88
jmcarp/robobrowser
robobrowser/forms/form.py
Payload.add
def add(self, data, key=None): """Add field values to container. :param dict data: Serialized values for field :param str key: Optional key; if not provided, values will be added to `self.payload`. """ sink = self.options[key] if key is not None else self.data ...
python
def add(self, data, key=None): """Add field values to container. :param dict data: Serialized values for field :param str key: Optional key; if not provided, values will be added to `self.payload`. """ sink = self.options[key] if key is not None else self.data ...
[ "def", "add", "(", "self", ",", "data", ",", "key", "=", "None", ")", ":", "sink", "=", "self", ".", "options", "[", "key", "]", "if", "key", "is", "not", "None", "else", "self", ".", "data", "for", "key", ",", "value", "in", "iteritems", "(", ...
Add field values to container. :param dict data: Serialized values for field :param str key: Optional key; if not provided, values will be added to `self.payload`.
[ "Add", "field", "values", "to", "container", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L122-L132
jmcarp/robobrowser
robobrowser/forms/form.py
Payload.to_requests
def to_requests(self, method='get'): """Export to Requests format. :param str method: Request method :return: Dict of keyword arguments formatted for `requests.request` """ out = {} data_key = 'params' if method.lower() == 'get' else 'data' out[data_key] = self....
python
def to_requests(self, method='get'): """Export to Requests format. :param str method: Request method :return: Dict of keyword arguments formatted for `requests.request` """ out = {} data_key = 'params' if method.lower() == 'get' else 'data' out[data_key] = self....
[ "def", "to_requests", "(", "self", ",", "method", "=", "'get'", ")", ":", "out", "=", "{", "}", "data_key", "=", "'params'", "if", "method", ".", "lower", "(", ")", "==", "'get'", "else", "'data'", "out", "[", "data_key", "]", "=", "self", ".", "da...
Export to Requests format. :param str method: Request method :return: Dict of keyword arguments formatted for `requests.request`
[ "Export", "to", "Requests", "format", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L134-L148
jmcarp/robobrowser
robobrowser/forms/form.py
Form.add_field
def add_field(self, field): """Add a field. :param field: Field to add :raise: ValueError if `field` is not an instance of `BaseField`. """ if not isinstance(field, fields.BaseField): raise ValueError('Argument "field" must be an instance of ' ...
python
def add_field(self, field): """Add a field. :param field: Field to add :raise: ValueError if `field` is not an instance of `BaseField`. """ if not isinstance(field, fields.BaseField): raise ValueError('Argument "field" must be an instance of ' ...
[ "def", "add_field", "(", "self", ",", "field", ")", ":", "if", "not", "isinstance", "(", "field", ",", "fields", ".", "BaseField", ")", ":", "raise", "ValueError", "(", "'Argument \"field\" must be an instance of '", "'BaseField'", ")", "self", ".", "fields", ...
Add a field. :param field: Field to add :raise: ValueError if `field` is not an instance of `BaseField`.
[ "Add", "a", "field", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L178-L188
jmcarp/robobrowser
robobrowser/forms/form.py
Form.serialize
def serialize(self, submit=None): """Serialize each form field to a Payload container. :param Submit submit: Optional `Submit` to click, if form includes multiple submits :return: Payload instance """ include_fields = prepare_fields(self.fields, self.submit_fields, ...
python
def serialize(self, submit=None): """Serialize each form field to a Payload container. :param Submit submit: Optional `Submit` to click, if form includes multiple submits :return: Payload instance """ include_fields = prepare_fields(self.fields, self.submit_fields, ...
[ "def", "serialize", "(", "self", ",", "submit", "=", "None", ")", ":", "include_fields", "=", "prepare_fields", "(", "self", ".", "fields", ",", "self", ".", "submit_fields", ",", "submit", ")", "return", "Payload", ".", "from_fields", "(", "include_fields",...
Serialize each form field to a Payload container. :param Submit submit: Optional `Submit` to click, if form includes multiple submits :return: Payload instance
[ "Serialize", "each", "form", "field", "to", "a", "Payload", "container", "." ]
train
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/forms/form.py#L218-L227
oschuett/appmode
appmode/server_extension.py
AppmodeHandler.get
def get(self, path): """get renders the notebook template if a name is given, or redirects to the '/files/' handler if the name is not given.""" path = path.strip('/') self.log.info('Appmode get: %s', path) # Abort if the app path is not below configured trusted_path. i...
python
def get(self, path): """get renders the notebook template if a name is given, or redirects to the '/files/' handler if the name is not given.""" path = path.strip('/') self.log.info('Appmode get: %s', path) # Abort if the app path is not below configured trusted_path. i...
[ "def", "get", "(", "self", ",", "path", ")", ":", "path", "=", "path", ".", "strip", "(", "'/'", ")", "self", ".", "log", ".", "info", "(", "'Appmode get: %s'", ",", "path", ")", "# Abort if the app path is not below configured trusted_path.", "if", "not", "...
get renders the notebook template if a name is given, or redirects to the '/files/' handler if the name is not given.
[ "get", "renders", "the", "notebook", "template", "if", "a", "name", "is", "given", "or", "redirects", "to", "the", "/", "files", "/", "handler", "if", "the", "name", "is", "not", "given", "." ]
train
https://github.com/oschuett/appmode/blob/0decaa8e20edada518867b290f3a8ea0c78faa88/appmode/server_extension.py#L37-L86
paxosglobal/subconscious
subconscious/model.py
RedisModel.save
async def save(self, db): """Save the object to Redis. """ kwargs = {} for col in self._auto_columns: if not self.has_real_data(col.name): kwargs[col.name] = await col.auto_generate(db, self) self.__dict__.update(kwargs) # we have to delete th...
python
async def save(self, db): """Save the object to Redis. """ kwargs = {} for col in self._auto_columns: if not self.has_real_data(col.name): kwargs[col.name] = await col.auto_generate(db, self) self.__dict__.update(kwargs) # we have to delete th...
[ "async", "def", "save", "(", "self", ",", "db", ")", ":", "kwargs", "=", "{", "}", "for", "col", "in", "self", ".", "_auto_columns", ":", "if", "not", "self", ".", "has_real_data", "(", "col", ".", "name", ")", ":", "kwargs", "[", "col", ".", "na...
Save the object to Redis.
[ "Save", "the", "object", "to", "Redis", "." ]
train
https://github.com/paxosglobal/subconscious/blob/bc4feabde574462ff59009b32181d12867f0aa3d/subconscious/model.py#L204-L221
paxosglobal/subconscious
subconscious/model.py
RedisModel.load
async def load(cls, db, identifier=None, redis_key=None): """Load the object from redis. Use the identifier (colon-separated composite keys or the primary key) or the redis_key. """ if not identifier and not redis_key: raise InvalidQuery('Must supply identifier or redis_key')...
python
async def load(cls, db, identifier=None, redis_key=None): """Load the object from redis. Use the identifier (colon-separated composite keys or the primary key) or the redis_key. """ if not identifier and not redis_key: raise InvalidQuery('Must supply identifier or redis_key')...
[ "async", "def", "load", "(", "cls", ",", "db", ",", "identifier", "=", "None", ",", "redis_key", "=", "None", ")", ":", "if", "not", "identifier", "and", "not", "redis_key", ":", "raise", "InvalidQuery", "(", "'Must supply identifier or redis_key'", ")", "if...
Load the object from redis. Use the identifier (colon-separated composite keys or the primary key) or the redis_key.
[ "Load", "the", "object", "from", "redis", ".", "Use", "the", "identifier", "(", "colon", "-", "separated", "composite", "keys", "or", "the", "primary", "key", ")", "or", "the", "redis_key", "." ]
train
https://github.com/paxosglobal/subconscious/blob/bc4feabde574462ff59009b32181d12867f0aa3d/subconscious/model.py#L227-L251
paxosglobal/subconscious
subconscious/model.py
RedisModel.filter_by
async def filter_by(cls, db, offset=None, limit=None, **kwargs): """Query by attributes iteratively. Ordering is not supported Example: User.get_by(db, age=[32, 54]) User.get_by(db, age=23, name="guido") """ if limit and type(limit) is not int: raise ...
python
async def filter_by(cls, db, offset=None, limit=None, **kwargs): """Query by attributes iteratively. Ordering is not supported Example: User.get_by(db, age=[32, 54]) User.get_by(db, age=23, name="guido") """ if limit and type(limit) is not int: raise ...
[ "async", "def", "filter_by", "(", "cls", ",", "db", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "limit", "and", "type", "(", "limit", ")", "is", "not", "int", ":", "raise", "InvalidQuery", "(", ...
Query by attributes iteratively. Ordering is not supported Example: User.get_by(db, age=[32, 54]) User.get_by(db, age=23, name="guido")
[ "Query", "by", "attributes", "iteratively", ".", "Ordering", "is", "not", "supported", "Example", ":", "User", ".", "get_by", "(", "db", "age", "=", "[", "32", "54", "]", ")", "User", ".", "get_by", "(", "db", "age", "=", "23", "name", "=", "guido", ...
train
https://github.com/paxosglobal/subconscious/blob/bc4feabde574462ff59009b32181d12867f0aa3d/subconscious/model.py#L339-L362
paxosglobal/subconscious
subconscious/model.py
RedisModel.get_object_or_none
async def get_object_or_none(cls, db, **kwargs): """ Returns the first object exists for this query or None. WARNING: if there are more than 1 results in cls that satisfy the conditions in kwargs, only 1 random result will be returned """ async for obj in cls.filter_by(db...
python
async def get_object_or_none(cls, db, **kwargs): """ Returns the first object exists for this query or None. WARNING: if there are more than 1 results in cls that satisfy the conditions in kwargs, only 1 random result will be returned """ async for obj in cls.filter_by(db...
[ "async", "def", "get_object_or_none", "(", "cls", ",", "db", ",", "*", "*", "kwargs", ")", ":", "async", "for", "obj", "in", "cls", ".", "filter_by", "(", "db", ",", "limit", "=", "1", ",", "*", "*", "kwargs", ")", ":", "return", "obj", "return", ...
Returns the first object exists for this query or None. WARNING: if there are more than 1 results in cls that satisfy the conditions in kwargs, only 1 random result will be returned
[ "Returns", "the", "first", "object", "exists", "for", "this", "query", "or", "None", ".", "WARNING", ":", "if", "there", "are", "more", "than", "1", "results", "in", "cls", "that", "satisfy", "the", "conditions", "in", "kwargs", "only", "1", "random", "r...
train
https://github.com/paxosglobal/subconscious/blob/bc4feabde574462ff59009b32181d12867f0aa3d/subconscious/model.py#L365-L373
pahaz/sshtunnel
sshtunnel.py
check_address
def check_address(address): """ Check if the format of the address is correct Arguments: address (tuple): (``str``, ``int``) representing an IP address and port, respectively .. note:: alternatively a local ``address`` can be a ``str`` when worki...
python
def check_address(address): """ Check if the format of the address is correct Arguments: address (tuple): (``str``, ``int``) representing an IP address and port, respectively .. note:: alternatively a local ``address`` can be a ``str`` when worki...
[ "def", "check_address", "(", "address", ")", ":", "if", "isinstance", "(", "address", ",", "tuple", ")", ":", "check_host", "(", "address", "[", "0", "]", ")", "check_port", "(", "address", "[", "1", "]", ")", "elif", "isinstance", "(", "address", ",",...
Check if the format of the address is correct Arguments: address (tuple): (``str``, ``int``) representing an IP address and port, respectively .. note:: alternatively a local ``address`` can be a ``str`` when working with UNIX domain sock...
[ "Check", "if", "the", "format", "of", "the", "address", "is", "correct" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L88-L119
pahaz/sshtunnel
sshtunnel.py
check_addresses
def check_addresses(address_list, is_remote=False): """ Check if the format of the addresses is correct Arguments: address_list (list[tuple]): Sequence of (``str``, ``int``) pairs, each representing an IP address and port respectively .. note:: w...
python
def check_addresses(address_list, is_remote=False): """ Check if the format of the addresses is correct Arguments: address_list (list[tuple]): Sequence of (``str``, ``int``) pairs, each representing an IP address and port respectively .. note:: w...
[ "def", "check_addresses", "(", "address_list", ",", "is_remote", "=", "False", ")", ":", "assert", "all", "(", "isinstance", "(", "x", ",", "(", "tuple", ",", "string_types", ")", ")", "for", "x", "in", "address_list", ")", "if", "(", "is_remote", "and",...
Check if the format of the addresses is correct Arguments: address_list (list[tuple]): Sequence of (``str``, ``int``) pairs, each representing an IP address and port respectively .. note:: when supported by the platform, one or more of the elements in ...
[ "Check", "if", "the", "format", "of", "the", "addresses", "is", "correct" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L122-L154
pahaz/sshtunnel
sshtunnel.py
create_logger
def create_logger(logger=None, loglevel=None, capture_warnings=True, add_paramiko_handler=True): """ Attach or create a new logger and add a console handler if not present Arguments: logger (Optional[logging.Logger]): :class:`loggin...
python
def create_logger(logger=None, loglevel=None, capture_warnings=True, add_paramiko_handler=True): """ Attach or create a new logger and add a console handler if not present Arguments: logger (Optional[logging.Logger]): :class:`loggin...
[ "def", "create_logger", "(", "logger", "=", "None", ",", "loglevel", "=", "None", ",", "capture_warnings", "=", "True", ",", "add_paramiko_handler", "=", "True", ")", ":", "logger", "=", "logger", "or", "logging", ".", "getLogger", "(", "'{0}.SSHTunnelForwarde...
Attach or create a new logger and add a console handler if not present Arguments: logger (Optional[logging.Logger]): :class:`logging.Logger` instance; a new one is created if this argument is empty loglevel (Optional[str or int]): :class:`logging.Logger`'s leve...
[ "Attach", "or", "create", "a", "new", "logger", "and", "add", "a", "console", "handler", "if", "not", "present" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L157-L213
pahaz/sshtunnel
sshtunnel.py
_add_handler
def _add_handler(logger, handler=None, loglevel=None): """ Add a handler to an existing logging.Logger object """ handler.setLevel(loglevel or DEFAULT_LOGLEVEL) if handler.level <= logging.DEBUG: _fmt = '%(asctime)s| %(levelname)-4.3s|%(threadName)10.9s/' \ '%(lineno)04d@%(mod...
python
def _add_handler(logger, handler=None, loglevel=None): """ Add a handler to an existing logging.Logger object """ handler.setLevel(loglevel or DEFAULT_LOGLEVEL) if handler.level <= logging.DEBUG: _fmt = '%(asctime)s| %(levelname)-4.3s|%(threadName)10.9s/' \ '%(lineno)04d@%(mod...
[ "def", "_add_handler", "(", "logger", ",", "handler", "=", "None", ",", "loglevel", "=", "None", ")", ":", "handler", ".", "setLevel", "(", "loglevel", "or", "DEFAULT_LOGLEVEL", ")", "if", "handler", ".", "level", "<=", "logging", ".", "DEBUG", ":", "_fm...
Add a handler to an existing logging.Logger object
[ "Add", "a", "handler", "to", "an", "existing", "logging", ".", "Logger", "object" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L216-L229
pahaz/sshtunnel
sshtunnel.py
_check_paramiko_handlers
def _check_paramiko_handlers(logger=None): """ Add a console handler for paramiko.transport's logger if not present """ paramiko_logger = logging.getLogger('paramiko.transport') if not paramiko_logger.handlers: if logger: paramiko_logger.handlers = logger.handlers else: ...
python
def _check_paramiko_handlers(logger=None): """ Add a console handler for paramiko.transport's logger if not present """ paramiko_logger = logging.getLogger('paramiko.transport') if not paramiko_logger.handlers: if logger: paramiko_logger.handlers = logger.handlers else: ...
[ "def", "_check_paramiko_handlers", "(", "logger", "=", "None", ")", ":", "paramiko_logger", "=", "logging", ".", "getLogger", "(", "'paramiko.transport'", ")", "if", "not", "paramiko_logger", ".", "handlers", ":", "if", "logger", ":", "paramiko_logger", ".", "ha...
Add a console handler for paramiko.transport's logger if not present
[ "Add", "a", "console", "handler", "for", "paramiko", ".", "transport", "s", "logger", "if", "not", "present" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L232-L246
pahaz/sshtunnel
sshtunnel.py
_remove_none_values
def _remove_none_values(dictionary): """ Remove dictionary keys whose value is None """ return list(map(dictionary.pop, [i for i in dictionary if dictionary[i] is None]))
python
def _remove_none_values(dictionary): """ Remove dictionary keys whose value is None """ return list(map(dictionary.pop, [i for i in dictionary if dictionary[i] is None]))
[ "def", "_remove_none_values", "(", "dictionary", ")", ":", "return", "list", "(", "map", "(", "dictionary", ".", "pop", ",", "[", "i", "for", "i", "in", "dictionary", "if", "dictionary", "[", "i", "]", "is", "None", "]", ")", ")" ]
Remove dictionary keys whose value is None
[ "Remove", "dictionary", "keys", "whose", "value", "is", "None" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L263-L266
pahaz/sshtunnel
sshtunnel.py
open_tunnel
def open_tunnel(*args, **kwargs): """ Open an SSH Tunnel, wrapper for :class:`SSHTunnelForwarder` Arguments: destination (Optional[tuple]): SSH server's IP address and port in the format (``ssh_address``, ``ssh_port``) Keyword Arguments: debug_level (Optional[in...
python
def open_tunnel(*args, **kwargs): """ Open an SSH Tunnel, wrapper for :class:`SSHTunnelForwarder` Arguments: destination (Optional[tuple]): SSH server's IP address and port in the format (``ssh_address``, ``ssh_port``) Keyword Arguments: debug_level (Optional[in...
[ "def", "open_tunnel", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Attach a console handler to the logger or create one if not passed", "kwargs", "[", "'logger'", "]", "=", "create_logger", "(", "logger", "=", "kwargs", ".", "get", "(", "'logger'", ",",...
Open an SSH Tunnel, wrapper for :class:`SSHTunnelForwarder` Arguments: destination (Optional[tuple]): SSH server's IP address and port in the format (``ssh_address``, ``ssh_port``) Keyword Arguments: debug_level (Optional[int or str]): log level for :class:`...
[ "Open", "an", "SSH", "Tunnel", "wrapper", "for", ":", "class", ":", "SSHTunnelForwarder" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1562-L1627
pahaz/sshtunnel
sshtunnel.py
_bindlist
def _bindlist(input_str): """ Define type of data expected for remote and local bind address lists Returns a tuple (ip_address, port) whose elements are (str, int) """ try: ip_port = input_str.split(':') if len(ip_port) == 1: _ip = ip_port[0] _port = None ...
python
def _bindlist(input_str): """ Define type of data expected for remote and local bind address lists Returns a tuple (ip_address, port) whose elements are (str, int) """ try: ip_port = input_str.split(':') if len(ip_port) == 1: _ip = ip_port[0] _port = None ...
[ "def", "_bindlist", "(", "input_str", ")", ":", "try", ":", "ip_port", "=", "input_str", ".", "split", "(", "':'", ")", "if", "len", "(", "ip_port", ")", "==", "1", ":", "_ip", "=", "ip_port", "[", "0", "]", "_port", "=", "None", "else", ":", "("...
Define type of data expected for remote and local bind address lists Returns a tuple (ip_address, port) whose elements are (str, int)
[ "Define", "type", "of", "data", "expected", "for", "remote", "and", "local", "bind", "address", "lists", "Returns", "a", "tuple", "(", "ip_address", "port", ")", "whose", "elements", "are", "(", "str", "int", ")" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1630-L1651
pahaz/sshtunnel
sshtunnel.py
_parse_arguments
def _parse_arguments(args=None): """ Parse arguments directly passed from CLI """ parser = argparse.ArgumentParser( description='Pure python ssh tunnel utils\n' 'Version {0}'.format(__version__), formatter_class=argparse.RawTextHelpFormatter ) parser.add_argu...
python
def _parse_arguments(args=None): """ Parse arguments directly passed from CLI """ parser = argparse.ArgumentParser( description='Pure python ssh tunnel utils\n' 'Version {0}'.format(__version__), formatter_class=argparse.RawTextHelpFormatter ) parser.add_argu...
[ "def", "_parse_arguments", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Pure python ssh tunnel utils\\n'", "'Version {0}'", ".", "format", "(", "__version__", ")", ",", "formatter_class", "=", "ar...
Parse arguments directly passed from CLI
[ "Parse", "arguments", "directly", "passed", "from", "CLI" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1654-L1808
pahaz/sshtunnel
sshtunnel.py
_cli_main
def _cli_main(args=None): """ Pass input arguments to open_tunnel Mandatory: ssh_address, -R (remote bind address list) Optional: -U (username) we may gather it from SSH_CONFIG_FILE or current username -p (server_port), defaults to 22 -P (password) -L (local_bind_ad...
python
def _cli_main(args=None): """ Pass input arguments to open_tunnel Mandatory: ssh_address, -R (remote bind address list) Optional: -U (username) we may gather it from SSH_CONFIG_FILE or current username -p (server_port), defaults to 22 -P (password) -L (local_bind_ad...
[ "def", "_cli_main", "(", "args", "=", "None", ")", ":", "arguments", "=", "_parse_arguments", "(", "args", ")", "# Remove all \"None\" input values", "_remove_none_values", "(", "arguments", ")", "verbosity", "=", "min", "(", "arguments", ".", "pop", "(", "'verb...
Pass input arguments to open_tunnel Mandatory: ssh_address, -R (remote bind address list) Optional: -U (username) we may gather it from SSH_CONFIG_FILE or current username -p (server_port), defaults to 22 -P (password) -L (local_bind_address), default to 0.0.0.0:22 ...
[ "Pass", "input", "arguments", "to", "open_tunnel" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1811-L1849
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.local_is_up
def local_is_up(self, target): """ Check if a tunnel is up (remote target's host is reachable on TCP target's port) Arguments: target (tuple): tuple of type (``str``, ``int``) indicating the listen IP address and port Return: ...
python
def local_is_up(self, target): """ Check if a tunnel is up (remote target's host is reachable on TCP target's port) Arguments: target (tuple): tuple of type (``str``, ``int``) indicating the listen IP address and port Return: ...
[ "def", "local_is_up", "(", "self", ",", "target", ")", ":", "try", ":", "check_address", "(", "target", ")", "except", "ValueError", ":", "self", ".", "logger", ".", "warning", "(", "'Target must be a tuple (IP, port), where IP '", "'is a string (i.e. \"192.168.0.1\")...
Check if a tunnel is up (remote target's host is reachable on TCP target's port) Arguments: target (tuple): tuple of type (``str``, ``int``) indicating the listen IP address and port Return: boolean .. deprecated:: 0.1.0 ...
[ "Check", "if", "a", "tunnel", "is", "up", "(", "remote", "target", "s", "host", "is", "reachable", "on", "TCP", "target", "s", "port", ")" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L726-L754
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._make_ssh_forward_handler_class
def _make_ssh_forward_handler_class(self, remote_address_): """ Make SSH Handler class """ class Handler(_ForwardHandler): remote_address = remote_address_ ssh_transport = self._transport logger = self.logger return Handler
python
def _make_ssh_forward_handler_class(self, remote_address_): """ Make SSH Handler class """ class Handler(_ForwardHandler): remote_address = remote_address_ ssh_transport = self._transport logger = self.logger return Handler
[ "def", "_make_ssh_forward_handler_class", "(", "self", ",", "remote_address_", ")", ":", "class", "Handler", "(", "_ForwardHandler", ")", ":", "remote_address", "=", "remote_address_", "ssh_transport", "=", "self", ".", "_transport", "logger", "=", "self", ".", "l...
Make SSH Handler class
[ "Make", "SSH", "Handler", "class" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L756-L764
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._make_ssh_forward_server
def _make_ssh_forward_server(self, remote_address, local_bind_address): """ Make SSH forward proxy Server class """ _Handler = self._make_ssh_forward_handler_class(remote_address) try: if isinstance(local_bind_address, string_types): forward_maker_clas...
python
def _make_ssh_forward_server(self, remote_address, local_bind_address): """ Make SSH forward proxy Server class """ _Handler = self._make_ssh_forward_handler_class(remote_address) try: if isinstance(local_bind_address, string_types): forward_maker_clas...
[ "def", "_make_ssh_forward_server", "(", "self", ",", "remote_address", ",", "local_bind_address", ")", ":", "_Handler", "=", "self", ".", "_make_ssh_forward_handler_class", "(", "remote_address", ")", "try", ":", "if", "isinstance", "(", "local_bind_address", ",", "...
Make SSH forward proxy Server class
[ "Make", "SSH", "forward", "proxy", "Server", "class" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L773-L810
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._read_ssh_config
def _read_ssh_config(ssh_host, ssh_config_file, ssh_username=None, ssh_pkey=None, ssh_port=None, ssh_proxy=None, compression=None, logger=None): ...
python
def _read_ssh_config(ssh_host, ssh_config_file, ssh_username=None, ssh_pkey=None, ssh_port=None, ssh_proxy=None, compression=None, logger=None): ...
[ "def", "_read_ssh_config", "(", "ssh_host", ",", "ssh_config_file", ",", "ssh_username", "=", "None", ",", "ssh_pkey", "=", "None", ",", "ssh_port", "=", "None", ",", "ssh_proxy", "=", "None", ",", "compression", "=", "None", ",", "logger", "=", "None", ")...
Read ssh_config_file and tries to look for user (ssh_username), identityfile (ssh_pkey), port (ssh_port) and proxycommand (ssh_proxy) entries for ssh_host
[ "Read", "ssh_config_file", "and", "tries", "to", "look", "for", "user", "(", "ssh_username", ")", "identityfile", "(", "ssh_pkey", ")", "port", "(", "ssh_port", ")", "and", "proxycommand", "(", "ssh_proxy", ")", "entries", "for", "ssh_host" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L920-L978
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.get_agent_keys
def get_agent_keys(logger=None): """ Load public keys from any available SSH agent Arguments: logger (Optional[logging.Logger]) Return: list """ paramiko_agent = paramiko.Agent() agent_keys = paramiko_agent.get_keys() if logger: ...
python
def get_agent_keys(logger=None): """ Load public keys from any available SSH agent Arguments: logger (Optional[logging.Logger]) Return: list """ paramiko_agent = paramiko.Agent() agent_keys = paramiko_agent.get_keys() if logger: ...
[ "def", "get_agent_keys", "(", "logger", "=", "None", ")", ":", "paramiko_agent", "=", "paramiko", ".", "Agent", "(", ")", "agent_keys", "=", "paramiko_agent", ".", "get_keys", "(", ")", "if", "logger", ":", "logger", ".", "info", "(", "'{0} keys loaded from ...
Load public keys from any available SSH agent Arguments: logger (Optional[logging.Logger]) Return: list
[ "Load", "public", "keys", "from", "any", "available", "SSH", "agent" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L981-L994
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.get_keys
def get_keys(logger=None, host_pkey_directories=None, allow_agent=False): """ Load public keys from any available SSH agent or local .ssh directory. Arguments: logger (Optional[logging.Logger]) host_pkey_directories (Optional[list[str]]): List of...
python
def get_keys(logger=None, host_pkey_directories=None, allow_agent=False): """ Load public keys from any available SSH agent or local .ssh directory. Arguments: logger (Optional[logging.Logger]) host_pkey_directories (Optional[list[str]]): List of...
[ "def", "get_keys", "(", "logger", "=", "None", ",", "host_pkey_directories", "=", "None", ",", "allow_agent", "=", "False", ")", ":", "keys", "=", "SSHTunnelForwarder", ".", "get_agent_keys", "(", "logger", "=", "logger", ")", "if", "allow_agent", "else", "[...
Load public keys from any available SSH agent or local .ssh directory. Arguments: logger (Optional[logging.Logger]) host_pkey_directories (Optional[list[str]]): List of local directories where host SSH pkeys in the format "id_*" are searched. For...
[ "Load", "public", "keys", "from", "any", "available", "SSH", "agent", "or", "local", ".", "ssh", "directory", "." ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L997-L1045
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._consolidate_binds
def _consolidate_binds(local_binds, remote_binds): """ Fill local_binds with defaults when no value/s were specified, leaving paramiko to decide in which local port the tunnel will be open """ count = len(remote_binds) - len(local_binds) if count < 0: raise Va...
python
def _consolidate_binds(local_binds, remote_binds): """ Fill local_binds with defaults when no value/s were specified, leaving paramiko to decide in which local port the tunnel will be open """ count = len(remote_binds) - len(local_binds) if count < 0: raise Va...
[ "def", "_consolidate_binds", "(", "local_binds", ",", "remote_binds", ")", ":", "count", "=", "len", "(", "remote_binds", ")", "-", "len", "(", "local_binds", ")", "if", "count", "<", "0", ":", "raise", "ValueError", "(", "'Too many local bind addresses '", "'...
Fill local_binds with defaults when no value/s were specified, leaving paramiko to decide in which local port the tunnel will be open
[ "Fill", "local_binds", "with", "defaults", "when", "no", "value", "/", "s", "were", "specified", "leaving", "paramiko", "to", "decide", "in", "which", "local", "port", "the", "tunnel", "will", "be", "open" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1048-L1058
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._consolidate_auth
def _consolidate_auth(ssh_password=None, ssh_pkey=None, ssh_pkey_password=None, allow_agent=True, host_pkey_directories=None, logger=None): """ Get sure authentication inform...
python
def _consolidate_auth(ssh_password=None, ssh_pkey=None, ssh_pkey_password=None, allow_agent=True, host_pkey_directories=None, logger=None): """ Get sure authentication inform...
[ "def", "_consolidate_auth", "(", "ssh_password", "=", "None", ",", "ssh_pkey", "=", "None", ",", "ssh_pkey_password", "=", "None", ",", "allow_agent", "=", "True", ",", "host_pkey_directories", "=", "None", ",", "logger", "=", "None", ")", ":", "ssh_loaded_pke...
Get sure authentication information is in place. ``ssh_pkey`` may be of classes: - ``str`` - in this case it represents a private key file; public key will be obtained from it - ``paramiko.Pkey`` - it will be transparently added to loaded keys
[ "Get", "sure", "authentication", "information", "is", "in", "place", ".", "ssh_pkey", "may", "be", "of", "classes", ":", "-", "str", "-", "in", "this", "case", "it", "represents", "a", "private", "key", "file", ";", "public", "key", "will", "be", "obtain...
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1061-L1097
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._get_transport
def _get_transport(self): """ Return the SSH transport to the remote gateway """ if self.ssh_proxy: if isinstance(self.ssh_proxy, paramiko.proxy.ProxyCommand): proxy_repr = repr(self.ssh_proxy.cmd[1]) else: proxy_repr = repr(self.ssh_proxy) ...
python
def _get_transport(self): """ Return the SSH transport to the remote gateway """ if self.ssh_proxy: if isinstance(self.ssh_proxy, paramiko.proxy.ProxyCommand): proxy_repr = repr(self.ssh_proxy.cmd[1]) else: proxy_repr = repr(self.ssh_proxy) ...
[ "def", "_get_transport", "(", "self", ")", ":", "if", "self", ".", "ssh_proxy", ":", "if", "isinstance", "(", "self", ".", "ssh_proxy", ",", "paramiko", ".", "proxy", ".", "ProxyCommand", ")", ":", "proxy_repr", "=", "repr", "(", "self", ".", "ssh_proxy"...
Return the SSH transport to the remote gateway
[ "Return", "the", "SSH", "transport", "to", "the", "remote", "gateway" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1105-L1124
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._create_tunnels
def _create_tunnels(self): """ Create SSH tunnels on top of a transport to the remote gateway """ if not self.is_active: try: self._connect_to_gateway() except socket.gaierror: # raised by paramiko.Transport msg = 'Could not resolv...
python
def _create_tunnels(self): """ Create SSH tunnels on top of a transport to the remote gateway """ if not self.is_active: try: self._connect_to_gateway() except socket.gaierror: # raised by paramiko.Transport msg = 'Could not resolv...
[ "def", "_create_tunnels", "(", "self", ")", ":", "if", "not", "self", ".", "is_active", ":", "try", ":", "self", ".", "_connect_to_gateway", "(", ")", "except", "socket", ".", "gaierror", ":", "# raised by paramiko.Transport", "msg", "=", "'Could not resolve IP ...
Create SSH tunnels on top of a transport to the remote gateway
[ "Create", "SSH", "tunnels", "on", "top", "of", "a", "transport", "to", "the", "remote", "gateway" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1126-L1148
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._process_deprecated
def _process_deprecated(attrib, deprecated_attrib, kwargs): """ Processes optional deprecate arguments """ if deprecated_attrib not in DEPRECATIONS: raise ValueError('{0} not included in deprecations list' .format(deprecated_attrib)) if de...
python
def _process_deprecated(attrib, deprecated_attrib, kwargs): """ Processes optional deprecate arguments """ if deprecated_attrib not in DEPRECATIONS: raise ValueError('{0} not included in deprecations list' .format(deprecated_attrib)) if de...
[ "def", "_process_deprecated", "(", "attrib", ",", "deprecated_attrib", ",", "kwargs", ")", ":", "if", "deprecated_attrib", "not", "in", "DEPRECATIONS", ":", "raise", "ValueError", "(", "'{0} not included in deprecations list'", ".", "format", "(", "deprecated_attrib", ...
Processes optional deprecate arguments
[ "Processes", "optional", "deprecate", "arguments" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1176-L1195
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.read_private_key_file
def read_private_key_file(pkey_file, pkey_password=None, key_type=None, logger=None): """ Get SSH Public key from a private key file, given an optional password Arguments: pkey_file (str): ...
python
def read_private_key_file(pkey_file, pkey_password=None, key_type=None, logger=None): """ Get SSH Public key from a private key file, given an optional password Arguments: pkey_file (str): ...
[ "def", "read_private_key_file", "(", "pkey_file", ",", "pkey_password", "=", "None", ",", "key_type", "=", "None", ",", "logger", "=", "None", ")", ":", "ssh_pkey", "=", "None", "for", "pkey_class", "in", "(", "key_type", ",", ")", "if", "key_type", "else"...
Get SSH Public key from a private key file, given an optional password Arguments: pkey_file (str): File containing a private key (RSA, DSS or ECDSA) Keyword Arguments: pkey_password (Optional[str]): Password to decrypt the private key ...
[ "Get", "SSH", "Public", "key", "from", "a", "private", "key", "file", "given", "an", "optional", "password" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1198-L1241
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._check_tunnel
def _check_tunnel(self, _srv): """ Check if tunnel is already established """ if self.skip_tunnel_checkup: self.tunnel_is_up[_srv.local_address] = True return self.logger.info('Checking tunnel to: {0}'.format(_srv.remote_address)) if isinstance(_srv.local_address,...
python
def _check_tunnel(self, _srv): """ Check if tunnel is already established """ if self.skip_tunnel_checkup: self.tunnel_is_up[_srv.local_address] = True return self.logger.info('Checking tunnel to: {0}'.format(_srv.remote_address)) if isinstance(_srv.local_address,...
[ "def", "_check_tunnel", "(", "self", ",", "_srv", ")", ":", "if", "self", ".", "skip_tunnel_checkup", ":", "self", ".", "tunnel_is_up", "[", "_srv", ".", "local_address", "]", "=", "True", "return", "self", ".", "logger", ".", "info", "(", "'Checking tunne...
Check if tunnel is already established
[ "Check", "if", "tunnel", "is", "already", "established" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1243-L1277
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.start
def start(self): """ Start the SSH tunnels """ if self.is_alive: self.logger.warning('Already started!') return self._create_tunnels() if not self.is_active: self._raise(BaseSSHTunnelForwarderError, reason='Could not establish s...
python
def start(self): """ Start the SSH tunnels """ if self.is_alive: self.logger.warning('Already started!') return self._create_tunnels() if not self.is_active: self._raise(BaseSSHTunnelForwarderError, reason='Could not establish s...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "is_alive", ":", "self", ".", "logger", ".", "warning", "(", "'Already started!'", ")", "return", "self", ".", "_create_tunnels", "(", ")", "if", "not", "self", ".", "is_active", ":", "self", "....
Start the SSH tunnels
[ "Start", "the", "SSH", "tunnels" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1287-L1308
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.stop
def stop(self): """ Shut the tunnel down. .. note:: This **had** to be handled with care before ``0.1.0``: - if a port redirection is opened - the destination is not reachable - we attempt a connection to that tunnel (``SYN`` is sent and acknow...
python
def stop(self): """ Shut the tunnel down. .. note:: This **had** to be handled with care before ``0.1.0``: - if a port redirection is opened - the destination is not reachable - we attempt a connection to that tunnel (``SYN`` is sent and acknow...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "'Closing all open connections...'", ")", "opened_address_text", "=", "', '", ".", "join", "(", "(", "address_to_str", "(", "k", ".", "local_address", ")", "for", "k", "in", "se...
Shut the tunnel down. .. note:: This **had** to be handled with care before ``0.1.0``: - if a port redirection is opened - the destination is not reachable - we attempt a connection to that tunnel (``SYN`` is sent and acknowledged, then a ``FIN`` packet is sen...
[ "Shut", "the", "tunnel", "down", "." ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1310-L1335
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._connect_to_gateway
def _connect_to_gateway(self): """ Open connection to SSH gateway - First try with all keys loaded from an SSH agent (if allowed) - Then with those passed directly or read from ~/.ssh/config - As last resort, try with a provided password """ for key in self.ssh...
python
def _connect_to_gateway(self): """ Open connection to SSH gateway - First try with all keys loaded from an SSH agent (if allowed) - Then with those passed directly or read from ~/.ssh/config - As last resort, try with a provided password """ for key in self.ssh...
[ "def", "_connect_to_gateway", "(", "self", ")", ":", "for", "key", "in", "self", ".", "ssh_pkeys", ":", "self", ".", "logger", ".", "debug", "(", "'Trying to log in with key: {0}'", ".", "format", "(", "hexlify", "(", "key", ".", "get_fingerprint", "(", ")",...
Open connection to SSH gateway - First try with all keys loaded from an SSH agent (if allowed) - Then with those passed directly or read from ~/.ssh/config - As last resort, try with a provided password
[ "Open", "connection", "to", "SSH", "gateway", "-", "First", "try", "with", "all", "keys", "loaded", "from", "an", "SSH", "agent", "(", "if", "allowed", ")", "-", "Then", "with", "those", "passed", "directly", "or", "read", "from", "~", "/", ".", "ssh",...
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1346-L1381
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._serve_forever_wrapper
def _serve_forever_wrapper(self, _srv, poll_interval=0.1): """ Wrapper for the server created for a SSH forward """ self.logger.info('Opening tunnel: {0} <> {1}'.format( address_to_str(_srv.local_address), address_to_str(_srv.remote_address)) ) _sr...
python
def _serve_forever_wrapper(self, _srv, poll_interval=0.1): """ Wrapper for the server created for a SSH forward """ self.logger.info('Opening tunnel: {0} <> {1}'.format( address_to_str(_srv.local_address), address_to_str(_srv.remote_address)) ) _sr...
[ "def", "_serve_forever_wrapper", "(", "self", ",", "_srv", ",", "poll_interval", "=", "0.1", ")", ":", "self", ".", "logger", ".", "info", "(", "'Opening tunnel: {0} <> {1}'", ".", "format", "(", "address_to_str", "(", "_srv", ".", "local_address", ")", ",", ...
Wrapper for the server created for a SSH forward
[ "Wrapper", "for", "the", "server", "created", "for", "a", "SSH", "forward" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1383-L1396
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder._stop_transport
def _stop_transport(self): """ Close the underlying transport when nothing more is needed """ try: self._check_is_started() except (BaseSSHTunnelForwarderError, HandlerSSHTunnelForwarderError) as e: self.logger.warning(e) for _srv in self._server_l...
python
def _stop_transport(self): """ Close the underlying transport when nothing more is needed """ try: self._check_is_started() except (BaseSSHTunnelForwarderError, HandlerSSHTunnelForwarderError) as e: self.logger.warning(e) for _srv in self._server_l...
[ "def", "_stop_transport", "(", "self", ")", ":", "try", ":", "self", ".", "_check_is_started", "(", ")", "except", "(", "BaseSSHTunnelForwarderError", ",", "HandlerSSHTunnelForwarderError", ")", "as", "e", ":", "self", ".", "logger", ".", "warning", "(", "e", ...
Close the underlying transport when nothing more is needed
[ "Close", "the", "underlying", "transport", "when", "nothing", "more", "is", "needed" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1398-L1422
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.local_bind_ports
def local_bind_ports(self): """ Return a list containing the ports of local side of the TCP tunnels """ self._check_is_started() return [_server.local_port for _server in self._server_list if _server.local_port is not None]
python
def local_bind_ports(self): """ Return a list containing the ports of local side of the TCP tunnels """ self._check_is_started() return [_server.local_port for _server in self._server_list if _server.local_port is not None]
[ "def", "local_bind_ports", "(", "self", ")", ":", "self", ".", "_check_is_started", "(", ")", "return", "[", "_server", ".", "local_port", "for", "_server", "in", "self", ".", "_server_list", "if", "_server", ".", "local_port", "is", "not", "None", "]" ]
Return a list containing the ports of local side of the TCP tunnels
[ "Return", "a", "list", "containing", "the", "ports", "of", "local", "side", "of", "the", "TCP", "tunnels" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1455-L1461
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.local_bind_hosts
def local_bind_hosts(self): """ Return a list containing the IP addresses listening for the tunnels """ self._check_is_started() return [_server.local_host for _server in self._server_list if _server.local_host is not None]
python
def local_bind_hosts(self): """ Return a list containing the IP addresses listening for the tunnels """ self._check_is_started() return [_server.local_host for _server in self._server_list if _server.local_host is not None]
[ "def", "local_bind_hosts", "(", "self", ")", ":", "self", ".", "_check_is_started", "(", ")", "return", "[", "_server", ".", "local_host", "for", "_server", "in", "self", ".", "_server_list", "if", "_server", ".", "local_host", "is", "not", "None", "]" ]
Return a list containing the IP addresses listening for the tunnels
[ "Return", "a", "list", "containing", "the", "IP", "addresses", "listening", "for", "the", "tunnels" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1464-L1470
pahaz/sshtunnel
sshtunnel.py
SSHTunnelForwarder.tunnel_bindings
def tunnel_bindings(self): """ Return a dictionary containing the active local<>remote tunnel_bindings """ return dict((_server.remote_address, _server.local_address) for _server in self._server_list if self.tunnel_is_up[_server.local_address])
python
def tunnel_bindings(self): """ Return a dictionary containing the active local<>remote tunnel_bindings """ return dict((_server.remote_address, _server.local_address) for _server in self._server_list if self.tunnel_is_up[_server.local_address])
[ "def", "tunnel_bindings", "(", "self", ")", ":", "return", "dict", "(", "(", "_server", ".", "remote_address", ",", "_server", ".", "local_address", ")", "for", "_server", "in", "self", ".", "_server_list", "if", "self", ".", "tunnel_is_up", "[", "_server", ...
Return a dictionary containing the active local<>remote tunnel_bindings
[ "Return", "a", "dictionary", "containing", "the", "active", "local<", ">", "remote", "tunnel_bindings" ]
train
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1481-L1487
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
get_submodules
def get_submodules(module): """ This function imports all sub-modules of the supplied module and returns a dictionary with module names as keys and the sub-module objects as values. If the supplied parameter is not a module object, a RuntimeError is raised. :param module: Module object from which t...
python
def get_submodules(module): """ This function imports all sub-modules of the supplied module and returns a dictionary with module names as keys and the sub-module objects as values. If the supplied parameter is not a module object, a RuntimeError is raised. :param module: Module object from which t...
[ "def", "get_submodules", "(", "module", ")", ":", "if", "not", "inspect", ".", "ismodule", "(", "module", ")", ":", "raise", "RuntimeError", "(", "'Can only extract submodules from a module object, '", "'for example imported via importlib.import_module'", ")", "submodules",...
This function imports all sub-modules of the supplied module and returns a dictionary with module names as keys and the sub-module objects as values. If the supplied parameter is not a module object, a RuntimeError is raised. :param module: Module object from which to import sub-modules. :return: Dict ...
[ "This", "function", "imports", "all", "sub", "-", "modules", "of", "the", "supplied", "module", "and", "returns", "a", "dictionary", "with", "module", "names", "as", "keys", "and", "the", "sub", "-", "module", "objects", "as", "values", ".", "If", "the", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L42-L73
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
get_members
def get_members(obj, predicate=None): """ Returns all members of an object for which the supplied predicate is true and that do not begin with __. Keep in mind that the supplied function must accept a potentially very broad range of inputs, because the members of an object can be of any type. The functi...
python
def get_members(obj, predicate=None): """ Returns all members of an object for which the supplied predicate is true and that do not begin with __. Keep in mind that the supplied function must accept a potentially very broad range of inputs, because the members of an object can be of any type. The functi...
[ "def", "get_members", "(", "obj", ",", "predicate", "=", "None", ")", ":", "members", "=", "{", "member", ":", "getattr", "(", "obj", ",", "member", ")", "for", "member", "in", "dir", "(", "obj", ")", "if", "not", "member", ".", "startswith", "(", ...
Returns all members of an object for which the supplied predicate is true and that do not begin with __. Keep in mind that the supplied function must accept a potentially very broad range of inputs, because the members of an object can be of any type. The function puts those members into a dict with the mem...
[ "Returns", "all", "members", "of", "an", "object", "for", "which", "the", "supplied", "predicate", "is", "true", "and", "that", "do", "not", "begin", "with", "__", ".", "Keep", "in", "mind", "that", "the", "supplied", "function", "must", "accept", "a", "...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L76-L94
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
extract_module_name
def extract_module_name(absolute_path): """ This function tries to extract a valid module name from the basename of the supplied path. If it's a directory, the directory name is returned, if it's a file, the file name without extension is returned. If the basename starts with _ or . or it's a file with ...
python
def extract_module_name(absolute_path): """ This function tries to extract a valid module name from the basename of the supplied path. If it's a directory, the directory name is returned, if it's a file, the file name without extension is returned. If the basename starts with _ or . or it's a file with ...
[ "def", "extract_module_name", "(", "absolute_path", ")", ":", "base_name", "=", "osp", ".", "basename", "(", "osp", ".", "normpath", "(", "absolute_path", ")", ")", "# If the basename starts with _ it's probably __init__.py or __pycache__ or something internal.", "# At the mo...
This function tries to extract a valid module name from the basename of the supplied path. If it's a directory, the directory name is returned, if it's a file, the file name without extension is returned. If the basename starts with _ or . or it's a file with an ending different from .py, the function retur...
[ "This", "function", "tries", "to", "extract", "a", "valid", "module", "name", "from", "the", "basename", "of", "the", "supplied", "path", ".", "If", "it", "s", "a", "directory", "the", "directory", "name", "is", "returned", "if", "it", "s", "a", "file", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L97-L124
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
dict_strict_update
def dict_strict_update(base_dict, update_dict): """ This function updates base_dict with update_dict if and only if update_dict does not contain keys that are not already in base_dict. It is essentially a more strict interpretation of the term "updating" the dict. If update_dict contains keys that ...
python
def dict_strict_update(base_dict, update_dict): """ This function updates base_dict with update_dict if and only if update_dict does not contain keys that are not already in base_dict. It is essentially a more strict interpretation of the term "updating" the dict. If update_dict contains keys that ...
[ "def", "dict_strict_update", "(", "base_dict", ",", "update_dict", ")", ":", "additional_keys", "=", "set", "(", "update_dict", ".", "keys", "(", ")", ")", "-", "set", "(", "base_dict", ".", "keys", "(", ")", ")", "if", "len", "(", "additional_keys", ")"...
This function updates base_dict with update_dict if and only if update_dict does not contain keys that are not already in base_dict. It is essentially a more strict interpretation of the term "updating" the dict. If update_dict contains keys that are not in base_dict, a RuntimeError is raised. :param ...
[ "This", "function", "updates", "base_dict", "with", "update_dict", "if", "and", "only", "if", "update_dict", "does", "not", "contain", "keys", "that", "are", "not", "already", "in", "base_dict", ".", "It", "is", "essentially", "a", "more", "strict", "interpret...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L127-L145
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
format_doc_text
def format_doc_text(text): """ A very thin wrapper around textwrap.fill to consistently wrap documentation text for display in a command line environment. The text is wrapped to 99 characters with an indentation depth of 4 spaces. Each line is wrapped independently in order to preserve manually adde...
python
def format_doc_text(text): """ A very thin wrapper around textwrap.fill to consistently wrap documentation text for display in a command line environment. The text is wrapped to 99 characters with an indentation depth of 4 spaces. Each line is wrapped independently in order to preserve manually adde...
[ "def", "format_doc_text", "(", "text", ")", ":", "return", "'\\n'", ".", "join", "(", "textwrap", ".", "fill", "(", "line", ",", "width", "=", "99", ",", "initial_indent", "=", "' '", ",", "subsequent_indent", "=", "' '", ")", "for", "line", "in", ...
A very thin wrapper around textwrap.fill to consistently wrap documentation text for display in a command line environment. The text is wrapped to 99 characters with an indentation depth of 4 spaces. Each line is wrapped independently in order to preserve manually added line breaks. :param text: The te...
[ "A", "very", "thin", "wrapper", "around", "textwrap", ".", "fill", "to", "consistently", "wrap", "documentation", "text", "for", "display", "in", "a", "command", "line", "environment", ".", "The", "text", "is", "wrapped", "to", "99", "characters", "with", "a...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L250-L263
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
is_compatible_with_framework
def is_compatible_with_framework(version): """ Returns ``True`` if the supplied version is compatible with the current framework version, otherwise the function returns ``False``. Evaluation of versions is performed using the `semantic_version`_-package: .. sourcecode:: Python is_compatibl...
python
def is_compatible_with_framework(version): """ Returns ``True`` if the supplied version is compatible with the current framework version, otherwise the function returns ``False``. Evaluation of versions is performed using the `semantic_version`_-package: .. sourcecode:: Python is_compatibl...
[ "def", "is_compatible_with_framework", "(", "version", ")", ":", "if", "version", "is", "None", ":", "return", "None", "lewis_version", "=", "Version", ".", "coerce", "(", "__version__", ")", "return", "lewis_version", "==", "Version", ".", "coerce", "(", "ver...
Returns ``True`` if the supplied version is compatible with the current framework version, otherwise the function returns ``False``. Evaluation of versions is performed using the `semantic_version`_-package: .. sourcecode:: Python is_compatible_with_framework('2.0.0') All whitespace is stripp...
[ "Returns", "True", "if", "the", "supplied", "version", "is", "compatible", "with", "the", "current", "framework", "version", "otherwise", "the", "function", "returns", "False", ".", "Evaluation", "of", "versions", "is", "performed", "using", "the", "semantic_versi...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L357-L379
DMSC-Instrument-Data/lewis
src/lewis/core/utils.py
FromOptionalDependency.do_import
def do_import(self, *names): """ Tries to import names from the module specified on initialization of the FromOptionalDependency-object. In case an ImportError occurs, the requested names are replaced with stub objects. :param names: List of strings that are used as type names. ...
python
def do_import(self, *names): """ Tries to import names from the module specified on initialization of the FromOptionalDependency-object. In case an ImportError occurs, the requested names are replaced with stub objects. :param names: List of strings that are used as type names. ...
[ "def", "do_import", "(", "self", ",", "*", "names", ")", ":", "try", ":", "module_object", "=", "importlib", ".", "import_module", "(", "self", ".", "_module", ")", "objects", "=", "tuple", "(", "getattr", "(", "module_object", ",", "name", ")", "for", ...
Tries to import names from the module specified on initialization of the FromOptionalDependency-object. In case an ImportError occurs, the requested names are replaced with stub objects. :param names: List of strings that are used as type names. :return: Tuple of actual symbols or stub ...
[ "Tries", "to", "import", "names", "from", "the", "module", "specified", "on", "initialization", "of", "the", "FromOptionalDependency", "-", "object", ".", "In", "case", "an", "ImportError", "occurs", "the", "requested", "names", "are", "replaced", "with", "stub"...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/utils.py#L226-L247
DMSC-Instrument-Data/lewis
src/lewis/core/control_server.py
ExposedObject._add_member_wrappers
def _add_member_wrappers(self, member): """ This method probes the supplied member of the wrapped object and inserts an appropriate entry into the internal method map. Getters and setters for properties get a suffix ':get' and ':set' respectively. :param member: The member of th...
python
def _add_member_wrappers(self, member): """ This method probes the supplied member of the wrapped object and inserts an appropriate entry into the internal method map. Getters and setters for properties get a suffix ':get' and ':set' respectively. :param member: The member of th...
[ "def", "_add_member_wrappers", "(", "self", ",", "member", ")", ":", "method_object", "=", "getattr", "(", "type", "(", "self", ".", "_object", ")", ",", "member", ",", "None", ")", "or", "getattr", "(", "self", ".", "_object", ",", "member", ")", "if"...
This method probes the supplied member of the wrapped object and inserts an appropriate entry into the internal method map. Getters and setters for properties get a suffix ':get' and ':set' respectively. :param member: The member of the wrapped object to expose
[ "This", "method", "probes", "the", "supplied", "member", "of", "the", "wrapped", "object", "and", "inserts", "an", "appropriate", "entry", "into", "the", "internal", "method", "map", ".", "Getters", "and", "setters", "for", "properties", "get", "a", "suffix", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_server.py#L106-L119
DMSC-Instrument-Data/lewis
src/lewis/core/control_server.py
ExposedObject.get_api
def get_api(self): """ This method returns the class name and a list of exposed methods. It is exposed to RPC-clients by an instance of ExposedObjectCollection. :return: A dictionary describing the exposed API (consisting of a class name and methods). """ return {'class'...
python
def get_api(self): """ This method returns the class name and a list of exposed methods. It is exposed to RPC-clients by an instance of ExposedObjectCollection. :return: A dictionary describing the exposed API (consisting of a class name and methods). """ return {'class'...
[ "def", "get_api", "(", "self", ")", ":", "return", "{", "'class'", ":", "type", "(", "self", ".", "_object", ")", ".", "__name__", ",", "'methods'", ":", "list", "(", "self", ".", "_function_map", ".", "keys", "(", ")", ")", "}" ]
This method returns the class name and a list of exposed methods. It is exposed to RPC-clients by an instance of ExposedObjectCollection. :return: A dictionary describing the exposed API (consisting of a class name and methods).
[ "This", "method", "returns", "the", "class", "name", "and", "a", "list", "of", "exposed", "methods", ".", "It", "is", "exposed", "to", "RPC", "-", "clients", "by", "an", "instance", "of", "ExposedObjectCollection", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_server.py#L121-L128
DMSC-Instrument-Data/lewis
src/lewis/core/control_server.py
ExposedObjectCollection.add_object
def add_object(self, obj, name): """ Adds the supplied object to the collection under the supplied name. If the name is already in use, a RuntimeError is raised. If the object is not an instance of :class:`ExposedObject`, the method automatically constructs one. :param obj: Obje...
python
def add_object(self, obj, name): """ Adds the supplied object to the collection under the supplied name. If the name is already in use, a RuntimeError is raised. If the object is not an instance of :class:`ExposedObject`, the method automatically constructs one. :param obj: Obje...
[ "def", "add_object", "(", "self", ",", "obj", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_object_map", ":", "raise", "RuntimeError", "(", "'An object is already registered under that name.'", ")", "exposed_object", "=", "self", ".", "_object_map", ...
Adds the supplied object to the collection under the supplied name. If the name is already in use, a RuntimeError is raised. If the object is not an instance of :class:`ExposedObject`, the method automatically constructs one. :param obj: Object to add to the collection. :param name: Nam...
[ "Adds", "the", "supplied", "object", "to", "the", "collection", "under", "the", "supplied", "name", ".", "If", "the", "name", "is", "already", "in", "use", "a", "RuntimeError", "is", "raised", ".", "If", "the", "object", "is", "not", "an", "instance", "o...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_server.py#L200-L217
DMSC-Instrument-Data/lewis
src/lewis/core/control_server.py
ExposedObjectCollection.remove_object
def remove_object(self, name): """ Remove the object exposed under that name. If no object is registered under the supplied name, a RuntimeError is raised. :param name: Name of object to be removed. """ if name not in self._object_map: raise RuntimeError('No ...
python
def remove_object(self, name): """ Remove the object exposed under that name. If no object is registered under the supplied name, a RuntimeError is raised. :param name: Name of object to be removed. """ if name not in self._object_map: raise RuntimeError('No ...
[ "def", "remove_object", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_object_map", ":", "raise", "RuntimeError", "(", "'No object with name {} is registered.'", ".", "format", "(", "name", ")", ")", "for", "fn_name", "in", "li...
Remove the object exposed under that name. If no object is registered under the supplied name, a RuntimeError is raised. :param name: Name of object to be removed.
[ "Remove", "the", "object", "exposed", "under", "that", "name", ".", "If", "no", "object", "is", "registered", "under", "the", "supplied", "name", "a", "RuntimeError", "is", "raised", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_server.py#L219-L233
DMSC-Instrument-Data/lewis
src/lewis/devices/julabo/devices/device.py
SimulatedJulabo.set_set_point
def set_set_point(self, param): """ Sets the target temperature. :param param: The new temperature in C. Must be positive. :return: Empty string. """ if self.temperature_low_limit <= param <= self.temperature_high_limit: self.set_point_temperature = param ...
python
def set_set_point(self, param): """ Sets the target temperature. :param param: The new temperature in C. Must be positive. :return: Empty string. """ if self.temperature_low_limit <= param <= self.temperature_high_limit: self.set_point_temperature = param ...
[ "def", "set_set_point", "(", "self", ",", "param", ")", ":", "if", "self", ".", "temperature_low_limit", "<=", "param", "<=", "self", ".", "temperature_high_limit", ":", "self", ".", "set_point_temperature", "=", "param", "return", "\"\"" ]
Sets the target temperature. :param param: The new temperature in C. Must be positive. :return: Empty string.
[ "Sets", "the", "target", "temperature", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/julabo/devices/device.py#L73-L82
DMSC-Instrument-Data/lewis
src/lewis/devices/julabo/devices/device.py
SimulatedJulabo.set_circulating
def set_circulating(self, param): """ Sets whether to circulate - in effect whether the heater is on. :param param: The mode to set, must be 0 or 1. :return: Empty string. """ if param == 0: self.is_circulating = param self.circulate_commanded = F...
python
def set_circulating(self, param): """ Sets whether to circulate - in effect whether the heater is on. :param param: The mode to set, must be 0 or 1. :return: Empty string. """ if param == 0: self.is_circulating = param self.circulate_commanded = F...
[ "def", "set_circulating", "(", "self", ",", "param", ")", ":", "if", "param", "==", "0", ":", "self", ".", "is_circulating", "=", "param", "self", ".", "circulate_commanded", "=", "False", "elif", "param", "==", "1", ":", "self", ".", "is_circulating", "...
Sets whether to circulate - in effect whether the heater is on. :param param: The mode to set, must be 0 or 1. :return: Empty string.
[ "Sets", "whether", "to", "circulate", "-", "in", "effect", "whether", "the", "heater", "is", "on", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/julabo/devices/device.py#L84-L97
DMSC-Instrument-Data/lewis
src/lewis/core/simulation.py
SimulationFactory.get_protocols
def get_protocols(self, device): """Returns a list of available protocols for the specified device.""" return self._reg.device_builder(device, self._rv).protocols
python
def get_protocols(self, device): """Returns a list of available protocols for the specified device.""" return self._reg.device_builder(device, self._rv).protocols
[ "def", "get_protocols", "(", "self", ",", "device", ")", ":", "return", "self", ".", "_reg", ".", "device_builder", "(", "device", ",", "self", ".", "_rv", ")", ".", "protocols" ]
Returns a list of available protocols for the specified device.
[ "Returns", "a", "list", "of", "available", "protocols", "for", "the", "specified", "device", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/simulation.py#L433-L435
DMSC-Instrument-Data/lewis
src/lewis/core/simulation.py
SimulationFactory.create
def create(self, device, setup=None, protocols=None, control_server=None): """ Creates a :class:`Simulation` according to the supplied parameters. :param device: Name of device. :param setup: Name of the setup for device creation. :param protocols: Dictionary where each key is a...
python
def create(self, device, setup=None, protocols=None, control_server=None): """ Creates a :class:`Simulation` according to the supplied parameters. :param device: Name of device. :param setup: Name of the setup for device creation. :param protocols: Dictionary where each key is a...
[ "def", "create", "(", "self", ",", "device", ",", "setup", "=", "None", ",", "protocols", "=", "None", ",", "control_server", "=", "None", ")", ":", "device_builder", "=", "self", ".", "_reg", ".", "device_builder", "(", "device", ",", "self", ".", "_r...
Creates a :class:`Simulation` according to the supplied parameters. :param device: Name of device. :param setup: Name of the setup for device creation. :param protocols: Dictionary where each key is assigned a dictionary with options for the corresponding :class:`~lewi...
[ "Creates", "a", ":", "class", ":", "Simulation", "according", "to", "the", "supplied", "parameters", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/simulation.py#L437-L469
DMSC-Instrument-Data/lewis
src/lewis/core/devices.py
is_device
def is_device(obj): """ Returns True if obj is a device type (derived from DeviceBase), but not defined in :mod:`lewis.core.devices` or :mod:`lewis.devices`. :param obj: Object to test. :return: True if obj is a device type. """ return isinstance(obj, type) and issubclass( obj, Devi...
python
def is_device(obj): """ Returns True if obj is a device type (derived from DeviceBase), but not defined in :mod:`lewis.core.devices` or :mod:`lewis.devices`. :param obj: Object to test. :return: True if obj is a device type. """ return isinstance(obj, type) and issubclass( obj, Devi...
[ "def", "is_device", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "type", ")", "and", "issubclass", "(", "obj", ",", "DeviceBase", ")", "and", "obj", ".", "__module__", "not", "in", "(", "'lewis.devices'", ",", "'lewis.core.devices'", ")" ...
Returns True if obj is a device type (derived from DeviceBase), but not defined in :mod:`lewis.core.devices` or :mod:`lewis.devices`. :param obj: Object to test. :return: True if obj is a device type.
[ "Returns", "True", "if", "obj", "is", "a", "device", "type", "(", "derived", "from", "DeviceBase", ")", "but", "not", "defined", "in", ":", "mod", ":", "lewis", ".", "core", ".", "devices", "or", ":", "mod", ":", "lewis", ".", "devices", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/devices.py#L93-L102
DMSC-Instrument-Data/lewis
src/lewis/core/devices.py
is_interface
def is_interface(obj): """ Returns True if obj is an interface (derived from :class:`InterfaceBase`), but not defined in :mod:`lewis.adapters`, where concrete interfaces for protocols are defined. :param obj: Object to test. :return: True if obj is an interface type. """ return isinstance(o...
python
def is_interface(obj): """ Returns True if obj is an interface (derived from :class:`InterfaceBase`), but not defined in :mod:`lewis.adapters`, where concrete interfaces for protocols are defined. :param obj: Object to test. :return: True if obj is an interface type. """ return isinstance(o...
[ "def", "is_interface", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "type", ")", "and", "issubclass", "(", "obj", ",", "InterfaceBase", ")", "and", "not", "(", "obj", ".", "__module__", ".", "startswith", "(", "'lewis.core.devices'", ")",...
Returns True if obj is an interface (derived from :class:`InterfaceBase`), but not defined in :mod:`lewis.adapters`, where concrete interfaces for protocols are defined. :param obj: Object to test. :return: True if obj is an interface type.
[ "Returns", "True", "if", "obj", "is", "an", "interface", "(", "derived", "from", ":", "class", ":", "InterfaceBase", ")", "but", "not", "defined", "in", ":", "mod", ":", "lewis", ".", "adapters", "where", "concrete", "interfaces", "for", "protocols", "are"...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/devices.py#L105-L116
DMSC-Instrument-Data/lewis
src/lewis/core/approaches.py
linear
def linear(current, target, rate, dt): """ This function returns the new value after moving towards target at the given speed constantly for the time dt. If for example the current position is 10 and the target is -20, the returned value will be less than 10 if rate and dt are greater than 0: ...
python
def linear(current, target, rate, dt): """ This function returns the new value after moving towards target at the given speed constantly for the time dt. If for example the current position is 10 and the target is -20, the returned value will be less than 10 if rate and dt are greater than 0: ...
[ "def", "linear", "(", "current", ",", "target", ",", "rate", ",", "dt", ")", ":", "sign", "=", "(", "target", ">", "current", ")", "-", "(", "target", "<", "current", ")", "if", "not", "sign", ":", "return", "current", "new_value", "=", "current", ...
This function returns the new value after moving towards target at the given speed constantly for the time dt. If for example the current position is 10 and the target is -20, the returned value will be less than 10 if rate and dt are greater than 0: .. sourcecode:: Python new_pos = linea...
[ "This", "function", "returns", "the", "new", "value", "after", "moving", "towards", "target", "at", "the", "given", "speed", "constantly", "for", "the", "time", "dt", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/approaches.py#L26-L61
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
BoundPV.meta
def meta(self): """Value of the bound meta-property on the target.""" if not self._pv.meta_data_property or not self._meta_target: return {} return getattr(self._meta_target, self._pv.meta_data_property)
python
def meta(self): """Value of the bound meta-property on the target.""" if not self._pv.meta_data_property or not self._meta_target: return {} return getattr(self._meta_target, self._pv.meta_data_property)
[ "def", "meta", "(", "self", ")", ":", "if", "not", "self", ".", "_pv", ".", "meta_data_property", "or", "not", "self", ".", "_meta_target", ":", "return", "{", "}", "return", "getattr", "(", "self", ".", "_meta_target", ",", "self", ".", "_pv", ".", ...
Value of the bound meta-property on the target.
[ "Value", "of", "the", "bound", "meta", "-", "property", "on", "the", "target", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L93-L98
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
BoundPV.doc
def doc(self): """Docstring of property on target or override specified on PV-object.""" return self._pv.doc or inspect.getdoc( getattr(type(self._target), self._pv.property, None)) or ''
python
def doc(self): """Docstring of property on target or override specified on PV-object.""" return self._pv.doc or inspect.getdoc( getattr(type(self._target), self._pv.property, None)) or ''
[ "def", "doc", "(", "self", ")", ":", "return", "self", ".", "_pv", ".", "doc", "or", "inspect", ".", "getdoc", "(", "getattr", "(", "type", "(", "self", ".", "_target", ")", ",", "self", ".", "_pv", ".", "property", ",", "None", ")", ")", "or", ...
Docstring of property on target or override specified on PV-object.
[ "Docstring", "of", "property", "on", "target", "or", "override", "specified", "on", "PV", "-", "object", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L116-L119
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV.bind
def bind(self, *targets): """ Tries to bind the PV to one of the supplied targets. Targets are inspected according to the order in which they are supplied. :param targets: Objects to inspect from. :return: BoundPV instance with the PV bound to the target property. """ ...
python
def bind(self, *targets): """ Tries to bind the PV to one of the supplied targets. Targets are inspected according to the order in which they are supplied. :param targets: Objects to inspect from. :return: BoundPV instance with the PV bound to the target property. """ ...
[ "def", "bind", "(", "self", ",", "*", "targets", ")", ":", "self", ".", "property", "=", "'value'", "self", ".", "meta_data_property", "=", "'meta'", "return", "BoundPV", "(", "self", ",", "self", ".", "_get_target", "(", "self", ".", "property", ",", ...
Tries to bind the PV to one of the supplied targets. Targets are inspected according to the order in which they are supplied. :param targets: Objects to inspect from. :return: BoundPV instance with the PV bound to the target property.
[ "Tries", "to", "bind", "the", "PV", "to", "one", "of", "the", "supplied", "targets", ".", "Targets", "are", "inspected", "according", "to", "the", "order", "in", "which", "they", "are", "supplied", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L224-L237
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._get_specification
def _get_specification(self, spec): """ Helper method to create a homogeneous representation of a specified getter or getter/setter pair. :param spec: Function specification 'getter', (getter,) or (getter,setter) :return: Harmonized getter/setter specification, (getter, setter)...
python
def _get_specification(self, spec): """ Helper method to create a homogeneous representation of a specified getter or getter/setter pair. :param spec: Function specification 'getter', (getter,) or (getter,setter) :return: Harmonized getter/setter specification, (getter, setter)...
[ "def", "_get_specification", "(", "self", ",", "spec", ")", ":", "if", "spec", "is", "None", "or", "callable", "(", "spec", ")", "or", "isinstance", "(", "spec", ",", "string_types", ")", ":", "spec", "=", "(", "spec", ",", ")", "if", "len", "(", "...
Helper method to create a homogeneous representation of a specified getter or getter/setter pair. :param spec: Function specification 'getter', (getter,) or (getter,setter) :return: Harmonized getter/setter specification, (getter, setter)
[ "Helper", "method", "to", "create", "a", "homogeneous", "representation", "of", "a", "specified", "getter", "or", "getter", "/", "setter", "pair", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L239-L251
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._get_target
def _get_target(self, prop, *targets): """ The actual target methods are retrieved (possibly from the list of targets) and a wrapper-property is installed on a throwaway type that is specifically created for the purpose of holding this property if necessary. In that case, an instance of ...
python
def _get_target(self, prop, *targets): """ The actual target methods are retrieved (possibly from the list of targets) and a wrapper-property is installed on a throwaway type that is specifically created for the purpose of holding this property if necessary. In that case, an instance of ...
[ "def", "_get_target", "(", "self", ",", "prop", ",", "*", "targets", ")", ":", "if", "prop", "is", "None", ":", "return", "None", "raw_getter", ",", "raw_setter", "=", "self", ".", "_specifications", ".", "get", "(", "prop", ",", "(", "None", ",", "N...
The actual target methods are retrieved (possibly from the list of targets) and a wrapper-property is installed on a throwaway type that is specifically created for the purpose of holding this property if necessary. In that case, an instance of this type (with the wrapper-property forwarding cal...
[ "The", "actual", "target", "methods", "are", "retrieved", "(", "possibly", "from", "the", "list", "of", "targets", ")", "and", "a", "wrapper", "-", "property", "is", "installed", "on", "a", "throwaway", "type", "that", "is", "specifically", "created", "for",...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L253-L306
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._create_getter
def _create_getter(self, func, *targets): """ Returns a function wrapping the supplied function. The returned wrapper can be used as the getter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the getter-concept (no argument...
python
def _create_getter(self, func, *targets): """ Returns a function wrapping the supplied function. The returned wrapper can be used as the getter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the getter-concept (no argument...
[ "def", "_create_getter", "(", "self", ",", "func", ",", "*", "targets", ")", ":", "if", "not", "func", ":", "return", "None", "final_callable", "=", "self", ".", "_get_callable", "(", "func", ",", "*", "targets", ")", "if", "not", "self", ".", "_functi...
Returns a function wrapping the supplied function. The returned wrapper can be used as the getter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the getter-concept (no arguments except self). :param func: Callable or name of meth...
[ "Returns", "a", "function", "wrapping", "the", "supplied", "function", ".", "The", "returned", "wrapper", "can", "be", "used", "as", "the", "getter", "in", "a", "property", "definition", ".", "Raises", "a", "RuntimeError", "if", "the", "signature", "of", "th...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L308-L333
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._create_setter
def _create_setter(self, func, *targets): """ Returns a function wrapping the supplied function. The returned wrapper can be used as the setter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the setter-concept (exactly one...
python
def _create_setter(self, func, *targets): """ Returns a function wrapping the supplied function. The returned wrapper can be used as the setter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the setter-concept (exactly one...
[ "def", "_create_setter", "(", "self", ",", "func", ",", "*", "targets", ")", ":", "if", "not", "func", ":", "return", "None", "func", "=", "self", ".", "_get_callable", "(", "func", ",", "*", "targets", ")", "if", "not", "self", ".", "_function_has_n_a...
Returns a function wrapping the supplied function. The returned wrapper can be used as the setter in a property definition. Raises a RuntimeError if the signature of the supplied function is not compatible with the setter-concept (exactly one argument except self). :param func: Callable or name...
[ "Returns", "a", "function", "wrapping", "the", "supplied", "function", ".", "The", "returned", "wrapper", "can", "be", "used", "as", "the", "setter", "in", "a", "property", "definition", ".", "Raises", "a", "RuntimeError", "if", "the", "signature", "of", "th...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L335-L359
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._get_callable
def _get_callable(self, func, *targets): """ If func is already a callable, it is returned directly. If it's a string, it is assumed to be a method on one of the objects supplied in targets and that is returned. If no method with the specified name is found, an AttributeError is raised. ...
python
def _get_callable(self, func, *targets): """ If func is already a callable, it is returned directly. If it's a string, it is assumed to be a method on one of the objects supplied in targets and that is returned. If no method with the specified name is found, an AttributeError is raised. ...
[ "def", "_get_callable", "(", "self", ",", "func", ",", "*", "targets", ")", ":", "if", "not", "callable", "(", "func", ")", ":", "func_name", "=", "func", "func", "=", "next", "(", "(", "getattr", "(", "obj", ",", "func", ",", "None", ")", "for", ...
If func is already a callable, it is returned directly. If it's a string, it is assumed to be a method on one of the objects supplied in targets and that is returned. If no method with the specified name is found, an AttributeError is raised. :param func: Callable or name of method on one objec...
[ "If", "func", "is", "already", "a", "callable", "it", "is", "returned", "directly", ".", "If", "it", "s", "a", "string", "it", "is", "assumed", "to", "be", "a", "method", "on", "one", "of", "the", "objects", "supplied", "in", "targets", "and", "that", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L361-L381
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
PV._function_has_n_args
def _function_has_n_args(self, func, n): """ Returns true if func has n arguments. Arguments with default and self for methods are not considered. """ if inspect.ismethod(func): n += 1 argspec = inspect.getargspec(func) defaults = argspec.defaults or ...
python
def _function_has_n_args(self, func, n): """ Returns true if func has n arguments. Arguments with default and self for methods are not considered. """ if inspect.ismethod(func): n += 1 argspec = inspect.getargspec(func) defaults = argspec.defaults or ...
[ "def", "_function_has_n_args", "(", "self", ",", "func", ",", "n", ")", ":", "if", "inspect", ".", "ismethod", "(", "func", ")", ":", "n", "+=", "1", "argspec", "=", "inspect", ".", "getargspec", "(", "func", ")", "defaults", "=", "argspec", ".", "de...
Returns true if func has n arguments. Arguments with default and self for methods are not considered.
[ "Returns", "true", "if", "func", "has", "n", "arguments", ".", "Arguments", "with", "default", "and", "self", "for", "methods", "are", "not", "considered", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L383-L394
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
EpicsAdapter.start_server
def start_server(self): """ Creates a pcaspy-server. .. note:: The server does not process requests unless :meth:`handle` is called regularly. """ if self._server is None: self._server = SimpleServer() self._server.createPV(prefix=self._optio...
python
def start_server(self): """ Creates a pcaspy-server. .. note:: The server does not process requests unless :meth:`handle` is called regularly. """ if self._server is None: self._server = SimpleServer() self._server.createPV(prefix=self._optio...
[ "def", "start_server", "(", "self", ")", ":", "if", "self", ".", "_server", "is", "None", ":", "self", ".", "_server", "=", "SimpleServer", "(", ")", "self", ".", "_server", ".", "createPV", "(", "prefix", "=", "self", ".", "_options", ".", "prefix", ...
Creates a pcaspy-server. .. note:: The server does not process requests unless :meth:`handle` is called regularly.
[ "Creates", "a", "pcaspy", "-", "server", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L550-L568
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
EpicsAdapter.handle
def handle(self, cycle_delay=0.1): """ Call this method to spend about ``cycle_delay`` seconds processing requests in the pcaspy server. Under load, for example when running ``caget`` at a high frequency, the actual time spent in the method may be much shorter. This effect is not...
python
def handle(self, cycle_delay=0.1): """ Call this method to spend about ``cycle_delay`` seconds processing requests in the pcaspy server. Under load, for example when running ``caget`` at a high frequency, the actual time spent in the method may be much shorter. This effect is not...
[ "def", "handle", "(", "self", ",", "cycle_delay", "=", "0.1", ")", ":", "if", "self", ".", "_server", "is", "not", "None", ":", "self", ".", "_server", ".", "process", "(", "cycle_delay", ")", "self", ".", "_driver", ".", "process_pv_updates", "(", ")"...
Call this method to spend about ``cycle_delay`` seconds processing requests in the pcaspy server. Under load, for example when running ``caget`` at a high frequency, the actual time spent in the method may be much shorter. This effect is not corrected for. :param cycle_delay: Approximat...
[ "Call", "this", "method", "to", "spend", "about", "cycle_delay", "seconds", "processing", "requests", "in", "the", "pcaspy", "server", ".", "Under", "load", "for", "example", "when", "running", "caget", "at", "a", "high", "frequency", "the", "actual", "time", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L578-L589
DMSC-Instrument-Data/lewis
src/lewis/adapters/epics.py
EpicsInterface._bind_device
def _bind_device(self): """ This method transforms the ``self.pvs`` dict of :class:`PV` objects ``self.bound_pvs``, a dict of :class:`BoundPV` objects, the keys are always the PV-names that are exposed via ChannelAccess. In the transformation process, the method tries to find wh...
python
def _bind_device(self): """ This method transforms the ``self.pvs`` dict of :class:`PV` objects ``self.bound_pvs``, a dict of :class:`BoundPV` objects, the keys are always the PV-names that are exposed via ChannelAccess. In the transformation process, the method tries to find wh...
[ "def", "_bind_device", "(", "self", ")", ":", "self", ".", "bound_pvs", "=", "{", "}", "for", "pv_name", ",", "pv", "in", "self", ".", "pvs", ".", "items", "(", ")", ":", "try", ":", "self", ".", "bound_pvs", "[", "pv_name", "]", "=", "pv", ".", ...
This method transforms the ``self.pvs`` dict of :class:`PV` objects ``self.bound_pvs``, a dict of :class:`BoundPV` objects, the keys are always the PV-names that are exposed via ChannelAccess. In the transformation process, the method tries to find whether the attribute specified by PV'...
[ "This", "method", "transforms", "the", "self", ".", "pvs", "dict", "of", ":", "class", ":", "PV", "objects", "self", ".", "bound_pvs", "a", "dict", "of", ":", "class", ":", "BoundPV", "objects", "the", "keys", "are", "always", "the", "PV", "-", "names"...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/epics.py#L661-L683
DMSC-Instrument-Data/lewis
src/lewis/core/control_client.py
ControlClient.json_rpc
def json_rpc(self, method, *args): """ This method takes a ZMQ REQ-socket and submits a JSON-object containing the RPC (JSON-RPC 2.0 format) to the supplied method with the supplied arguments. Then it waits for a reply from the server and blocks until it has received a JSON-respo...
python
def json_rpc(self, method, *args): """ This method takes a ZMQ REQ-socket and submits a JSON-object containing the RPC (JSON-RPC 2.0 format) to the supplied method with the supplied arguments. Then it waits for a reply from the server and blocks until it has received a JSON-respo...
[ "def", "json_rpc", "(", "self", ",", "method", ",", "*", "args", ")", ":", "request_id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "try", ":", "self", ".", "_socket", ".", "send_json", "(", "{", "'method'", ":", "method", ",", "'params'...
This method takes a ZMQ REQ-socket and submits a JSON-object containing the RPC (JSON-RPC 2.0 format) to the supplied method with the supplied arguments. Then it waits for a reply from the server and blocks until it has received a JSON-response. The method returns the response and the id it used...
[ "This", "method", "takes", "a", "ZMQ", "REQ", "-", "socket", "and", "submits", "a", "JSON", "-", "object", "containing", "the", "RPC", "(", "JSON", "-", "RPC", "2", ".", "0", "format", ")", "to", "the", "supplied", "method", "with", "the", "supplied", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_client.py#L101-L127
DMSC-Instrument-Data/lewis
src/lewis/core/control_client.py
ControlClient.get_object_collection
def get_object_collection(self, object_name=''): """ If the remote end exposes a collection of objects under the supplied object name (empty for top level), this method returns a dictionary of these objects stored under their names on the server. This function performs n + 1 cal...
python
def get_object_collection(self, object_name=''): """ If the remote end exposes a collection of objects under the supplied object name (empty for top level), this method returns a dictionary of these objects stored under their names on the server. This function performs n + 1 cal...
[ "def", "get_object_collection", "(", "self", ",", "object_name", "=", "''", ")", ":", "object_names", "=", "self", ".", "get_object", "(", "object_name", ")", ".", "get_objects", "(", ")", "return", "{", "obj", ":", "self", ".", "get_object", "(", "obj", ...
If the remote end exposes a collection of objects under the supplied object name (empty for top level), this method returns a dictionary of these objects stored under their names on the server. This function performs n + 1 calls to the server, where n is the number of objects. :param o...
[ "If", "the", "remote", "end", "exposes", "a", "collection", "of", "objects", "under", "the", "supplied", "object", "name", "(", "empty", "for", "top", "level", ")", "this", "method", "returns", "a", "dictionary", "of", "these", "objects", "stored", "under", ...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_client.py#L141-L155
DMSC-Instrument-Data/lewis
src/lewis/core/control_client.py
ObjectProxy._make_request
def _make_request(self, method, *args): """ This method performs a JSON-RPC request via the object's ZMQ socket. If successful, the result is returned, otherwise exceptions are raised. Server side exceptions are raised using the same type as on the server if they are part of the exceptio...
python
def _make_request(self, method, *args): """ This method performs a JSON-RPC request via the object's ZMQ socket. If successful, the result is returned, otherwise exceptions are raised. Server side exceptions are raised using the same type as on the server if they are part of the exceptio...
[ "def", "_make_request", "(", "self", ",", "method", ",", "*", "args", ")", ":", "response", ",", "request_id", "=", "self", ".", "_connection", ".", "json_rpc", "(", "self", ".", "_prefix", "+", "method", ",", "*", "args", ")", "if", "'id'", "not", "...
This method performs a JSON-RPC request via the object's ZMQ socket. If successful, the result is returned, otherwise exceptions are raised. Server side exceptions are raised using the same type as on the server if they are part of the exceptions-module. Otherwise, a RemoteException is raised. ...
[ "This", "method", "performs", "a", "JSON", "-", "RPC", "request", "via", "the", "object", "s", "ZMQ", "socket", ".", "If", "successful", "the", "result", "is", "returned", "otherwise", "exceptions", "are", "raised", ".", "Server", "side", "exceptions", "are"...
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/control_client.py#L194-L229
DMSC-Instrument-Data/lewis
src/lewis/devices/linkam_t95/interfaces/stream_interface.py
LinkamT95StreamInterface.get_status
def get_status(self): """ Models "T Command" functionality of device. Returns all available status information about the device as single byte array. :return: Byte array consisting of 10 status bytes. """ # "The first command sent must be a 'T' command" from T95 manual...
python
def get_status(self): """ Models "T Command" functionality of device. Returns all available status information about the device as single byte array. :return: Byte array consisting of 10 status bytes. """ # "The first command sent must be a 'T' command" from T95 manual...
[ "def", "get_status", "(", "self", ")", ":", "# \"The first command sent must be a 'T' command\" from T95 manual", "self", ".", "device", ".", "serial_command_mode", "=", "True", "Tarray", "=", "[", "0x80", "]", "*", "10", "# Status byte (SB1)", "Tarray", "[", "0", "...
Models "T Command" functionality of device. Returns all available status information about the device as single byte array. :return: Byte array consisting of 10 status bytes.
[ "Models", "T", "Command", "functionality", "of", "device", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/linkam_t95/interfaces/stream_interface.py#L49-L85
DMSC-Instrument-Data/lewis
src/lewis/devices/linkam_t95/interfaces/stream_interface.py
LinkamT95StreamInterface.set_rate
def set_rate(self, param): """ Models "Rate Command" functionality of device. Sets the target rate of temperature change. :param param: Rate of temperature change in C/min, multiplied by 100, as a string. Must be positive. :return: Empty string. """ # TO...
python
def set_rate(self, param): """ Models "Rate Command" functionality of device. Sets the target rate of temperature change. :param param: Rate of temperature change in C/min, multiplied by 100, as a string. Must be positive. :return: Empty string. """ # TO...
[ "def", "set_rate", "(", "self", ",", "param", ")", ":", "# TODO: Is not having leading zeroes / 4 digits an error?", "rate", "=", "int", "(", "param", ")", "if", "1", "<=", "rate", "<=", "15000", ":", "self", ".", "device", ".", "temperature_rate", "=", "rate"...
Models "Rate Command" functionality of device. Sets the target rate of temperature change. :param param: Rate of temperature change in C/min, multiplied by 100, as a string. Must be positive. :return: Empty string.
[ "Models", "Rate", "Command", "functionality", "of", "device", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/linkam_t95/interfaces/stream_interface.py#L87-L101
DMSC-Instrument-Data/lewis
src/lewis/devices/linkam_t95/interfaces/stream_interface.py
LinkamT95StreamInterface.set_limit
def set_limit(self, param): """ Models "Limit Command" functionality of device. Sets the target temperate to be reached. :param param: Target temperature in C, multiplied by 10, as a string. Can be negative. :return: Empty string. """ # TODO: Is not having leadi...
python
def set_limit(self, param): """ Models "Limit Command" functionality of device. Sets the target temperate to be reached. :param param: Target temperature in C, multiplied by 10, as a string. Can be negative. :return: Empty string. """ # TODO: Is not having leadi...
[ "def", "set_limit", "(", "self", ",", "param", ")", ":", "# TODO: Is not having leading zeroes / 4 digits an error?", "limit", "=", "int", "(", "param", ")", "if", "-", "2000", "<=", "limit", "<=", "6000", ":", "self", ".", "device", ".", "temperature_limit", ...
Models "Limit Command" functionality of device. Sets the target temperate to be reached. :param param: Target temperature in C, multiplied by 10, as a string. Can be negative. :return: Empty string.
[ "Models", "Limit", "Command", "functionality", "of", "device", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/linkam_t95/interfaces/stream_interface.py#L103-L116
DMSC-Instrument-Data/lewis
src/lewis/devices/linkam_t95/interfaces/stream_interface.py
LinkamT95StreamInterface.pump_command
def pump_command(self, param): """ Models "LNP Pump Commands" functionality of device. Switches between automatic or manual pump mode, and adjusts speed when in manual mode. :param param: 'a0' for auto, 'm0' for manual, [0-N] for speed. :return: """ lookup = [c ...
python
def pump_command(self, param): """ Models "LNP Pump Commands" functionality of device. Switches between automatic or manual pump mode, and adjusts speed when in manual mode. :param param: 'a0' for auto, 'm0' for manual, [0-N] for speed. :return: """ lookup = [c ...
[ "def", "pump_command", "(", "self", ",", "param", ")", ":", "lookup", "=", "[", "c", "for", "c", "in", "\"0123456789:;<=>?@ABCDEFGHIJKLMN\"", "]", "if", "param", "==", "\"a0\"", ":", "self", ".", "device", ".", "pump_manual_mode", "=", "False", "elif", "pa...
Models "LNP Pump Commands" functionality of device. Switches between automatic or manual pump mode, and adjusts speed when in manual mode. :param param: 'a0' for auto, 'm0' for manual, [0-N] for speed. :return:
[ "Models", "LNP", "Pump", "Commands", "functionality", "of", "device", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/linkam_t95/interfaces/stream_interface.py#L172-L190
DMSC-Instrument-Data/lewis
src/lewis/core/statemachine.py
HasContext.set_context
def set_context(self, new_context): """Assigns the new context to the member variable ``_context``.""" self._context = new_context if hasattr(self, '_set_logging_context'): self._set_logging_context(self._context)
python
def set_context(self, new_context): """Assigns the new context to the member variable ``_context``.""" self._context = new_context if hasattr(self, '_set_logging_context'): self._set_logging_context(self._context)
[ "def", "set_context", "(", "self", ",", "new_context", ")", ":", "self", ".", "_context", "=", "new_context", "if", "hasattr", "(", "self", ",", "'_set_logging_context'", ")", ":", "self", ".", "_set_logging_context", "(", "self", ".", "_context", ")" ]
Assigns the new context to the member variable ``_context``.
[ "Assigns", "the", "new", "context", "to", "the", "member", "variable", "_context", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/statemachine.py#L56-L61
DMSC-Instrument-Data/lewis
src/lewis/devices/linkam_t95/devices/device.py
SimulatedLinkamT95._initialize_data
def _initialize_data(self): """ This method is called once on construction. After that, it may be manually called again to reset the device to its default state. After the first call during construction, the class is frozen. This means that attempting to define a new member var...
python
def _initialize_data(self): """ This method is called once on construction. After that, it may be manually called again to reset the device to its default state. After the first call during construction, the class is frozen. This means that attempting to define a new member var...
[ "def", "_initialize_data", "(", "self", ")", ":", "self", ".", "serial_command_mode", "=", "False", "self", ".", "pump_overspeed", "=", "False", "self", ".", "start_commanded", "=", "False", "self", ".", "stop_commanded", "=", "False", "self", ".", "hold_comma...
This method is called once on construction. After that, it may be manually called again to reset the device to its default state. After the first call during construction, the class is frozen. This means that attempting to define a new member variable will raise an exception. This is t...
[ "This", "method", "is", "called", "once", "on", "construction", ".", "After", "that", "it", "may", "be", "manually", "called", "again", "to", "reset", "the", "device", "to", "its", "default", "state", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/devices/linkam_t95/devices/device.py#L28-L54
DMSC-Instrument-Data/lewis
src/lewis/core/logging.py
has_log
def has_log(target): """ This is a decorator to add logging functionality to a class or function. Applying this decorator to a class or function will add two new members: - ``log`` is an instance of ``logging.Logger``. The name of the logger is set to ``lewis.Foo`` for a class named Foo. ...
python
def has_log(target): """ This is a decorator to add logging functionality to a class or function. Applying this decorator to a class or function will add two new members: - ``log`` is an instance of ``logging.Logger``. The name of the logger is set to ``lewis.Foo`` for a class named Foo. ...
[ "def", "has_log", "(", "target", ")", ":", "logger_name", "=", "target", ".", "__name__", "def", "get_logger_name", "(", "context", "=", "None", ")", ":", "log_names", "=", "[", "root_logger_name", ",", "logger_name", "]", "if", "context", "is", "not", "No...
This is a decorator to add logging functionality to a class or function. Applying this decorator to a class or function will add two new members: - ``log`` is an instance of ``logging.Logger``. The name of the logger is set to ``lewis.Foo`` for a class named Foo. - ``_set_logging_context`` is a m...
[ "This", "is", "a", "decorator", "to", "add", "logging", "functionality", "to", "a", "class", "or", "function", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/logging.py#L44-L122
DMSC-Instrument-Data/lewis
src/lewis/scripts/__init__.py
get_usage_text
def get_usage_text(parser, indent=None): """ This small helper function extracts the help information from an ArgumentParser instance and indents the text by the number of spaces supplied in the indent-argument. :param parser: ArgumentParser object. :param indent: Number of spaces to put before eac...
python
def get_usage_text(parser, indent=None): """ This small helper function extracts the help information from an ArgumentParser instance and indents the text by the number of spaces supplied in the indent-argument. :param parser: ArgumentParser object. :param indent: Number of spaces to put before eac...
[ "def", "get_usage_text", "(", "parser", ",", "indent", "=", "None", ")", ":", "usage_text", "=", "StringIO", "(", ")", "parser", ".", "print_help", "(", "usage_text", ")", "usage_string", "=", "usage_text", ".", "getvalue", "(", ")", "if", "indent", "is", ...
This small helper function extracts the help information from an ArgumentParser instance and indents the text by the number of spaces supplied in the indent-argument. :param parser: ArgumentParser object. :param indent: Number of spaces to put before each line or None. :return: Formatted help string of...
[ "This", "small", "helper", "function", "extracts", "the", "help", "information", "from", "an", "ArgumentParser", "instance", "and", "indents", "the", "text", "by", "the", "number", "of", "spaces", "supplied", "in", "the", "indent", "-", "argument", "." ]
train
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/scripts/__init__.py#L23-L40