repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
jspricke/python-remind
remind.py
Remind.to_vobject
def to_vobject(self, filename=None, uid=None): """Return iCal object of Remind lines If filename and UID are specified, the vObject only contains that event. If only a filename is specified, the vObject contains all events in the file. Otherwise the vObject contains all all objects of al...
python
def to_vobject(self, filename=None, uid=None): """Return iCal object of Remind lines If filename and UID are specified, the vObject only contains that event. If only a filename is specified, the vObject contains all events in the file. Otherwise the vObject contains all all objects of al...
[ "def", "to_vobject", "(", "self", ",", "filename", "=", "None", ",", "uid", "=", "None", ")", ":", "self", ".", "_update", "(", ")", "cal", "=", "iCalendar", "(", ")", "if", "uid", ":", "self", ".", "_gen_vevent", "(", "self", ".", "_reminders", "[...
Return iCal object of Remind lines If filename and UID are specified, the vObject only contains that event. If only a filename is specified, the vObject contains all events in the file. Otherwise the vObject contains all all objects of all files associated with the Remind object. filena...
[ "Return", "iCal", "object", "of", "Remind", "lines", "If", "filename", "and", "UID", "are", "specified", "the", "vObject", "only", "contains", "that", "event", ".", "If", "only", "a", "filename", "is", "specified", "the", "vObject", "contains", "all", "event...
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L311-L332
train
Return iCal object of Remind lines.
jspricke/python-remind
remind.py
Remind.stdin_to_vobject
def stdin_to_vobject(self, lines): """Return iCal object of the Remind commands in lines""" cal = iCalendar() for event in self._parse_remind('-', lines)['-'].values(): self._gen_vevent(event, cal.add('vevent')) return cal
python
def stdin_to_vobject(self, lines): """Return iCal object of the Remind commands in lines""" cal = iCalendar() for event in self._parse_remind('-', lines)['-'].values(): self._gen_vevent(event, cal.add('vevent')) return cal
[ "def", "stdin_to_vobject", "(", "self", ",", "lines", ")", ":", "cal", "=", "iCalendar", "(", ")", "for", "event", "in", "self", ".", "_parse_remind", "(", "'-'", ",", "lines", ")", "[", "'-'", "]", ".", "values", "(", ")", ":", "self", ".", "_gen_...
Return iCal object of the Remind commands in lines
[ "Return", "iCal", "object", "of", "the", "Remind", "commands", "in", "lines" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L334-L339
train
Return iCal object of the Remind commands in lines
jspricke/python-remind
remind.py
Remind._parse_rruleset
def _parse_rruleset(rruleset): """Convert from iCal rrule to Remind recurrence syntax""" # pylint: disable=protected-access if rruleset._rrule[0]._freq == 0: return [] rep = [] if rruleset._rrule[0]._byweekday and len(rruleset._rrule[0]._byweekday) > 1: ...
python
def _parse_rruleset(rruleset): """Convert from iCal rrule to Remind recurrence syntax""" # pylint: disable=protected-access if rruleset._rrule[0]._freq == 0: return [] rep = [] if rruleset._rrule[0]._byweekday and len(rruleset._rrule[0]._byweekday) > 1: ...
[ "def", "_parse_rruleset", "(", "rruleset", ")", ":", "# pylint: disable=protected-access", "if", "rruleset", ".", "_rrule", "[", "0", "]", ".", "_freq", "==", "0", ":", "return", "[", "]", "rep", "=", "[", "]", "if", "rruleset", ".", "_rrule", "[", "0", ...
Convert from iCal rrule to Remind recurrence syntax
[ "Convert", "from", "iCal", "rrule", "to", "Remind", "recurrence", "syntax" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L348-L376
train
Convert from iCal rrule to Remind recurrence syntax
jspricke/python-remind
remind.py
Remind._event_duration
def _event_duration(vevent): """unify dtend and duration to the duration of the given vevent""" if hasattr(vevent, 'dtend'): return vevent.dtend.value - vevent.dtstart.value elif hasattr(vevent, 'duration') and vevent.duration.value: return vevent.duration.value r...
python
def _event_duration(vevent): """unify dtend and duration to the duration of the given vevent""" if hasattr(vevent, 'dtend'): return vevent.dtend.value - vevent.dtstart.value elif hasattr(vevent, 'duration') and vevent.duration.value: return vevent.duration.value r...
[ "def", "_event_duration", "(", "vevent", ")", ":", "if", "hasattr", "(", "vevent", ",", "'dtend'", ")", ":", "return", "vevent", ".", "dtend", ".", "value", "-", "vevent", ".", "dtstart", ".", "value", "elif", "hasattr", "(", "vevent", ",", "'duration'",...
unify dtend and duration to the duration of the given vevent
[ "unify", "dtend", "and", "duration", "to", "the", "duration", "of", "the", "given", "vevent" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L379-L385
train
unify dtend and duration to the duration of the given vevent
jspricke/python-remind
remind.py
Remind._gen_msg
def _gen_msg(vevent, label, tail, sep): """Generate a Remind MSG from the given vevent. Opposite of _gen_description() """ rem = ['MSG'] msg = [] if label: msg.append(label) if hasattr(vevent, 'summary') and vevent.summary.value: msg.appen...
python
def _gen_msg(vevent, label, tail, sep): """Generate a Remind MSG from the given vevent. Opposite of _gen_description() """ rem = ['MSG'] msg = [] if label: msg.append(label) if hasattr(vevent, 'summary') and vevent.summary.value: msg.appen...
[ "def", "_gen_msg", "(", "vevent", ",", "label", ",", "tail", ",", "sep", ")", ":", "rem", "=", "[", "'MSG'", "]", "msg", "=", "[", "]", "if", "label", ":", "msg", ".", "append", "(", "label", ")", "if", "hasattr", "(", "vevent", ",", "'summary'",...
Generate a Remind MSG from the given vevent. Opposite of _gen_description()
[ "Generate", "a", "Remind", "MSG", "from", "the", "given", "vevent", ".", "Opposite", "of", "_gen_description", "()" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L388-L418
train
Generate a Remind MSG from the given vevent.
jspricke/python-remind
remind.py
Remind.to_remind
def to_remind(self, vevent, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): """Generate a Remind command from the given vevent""" remind = ['REM'] trigdates = None if hasattr(vevent, 'rrule'): trigdates = Remind._par...
python
def to_remind(self, vevent, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): """Generate a Remind command from the given vevent""" remind = ['REM'] trigdates = None if hasattr(vevent, 'rrule'): trigdates = Remind._par...
[ "def", "to_remind", "(", "self", ",", "vevent", ",", "label", "=", "None", ",", "priority", "=", "None", ",", "tags", "=", "None", ",", "tail", "=", "None", ",", "sep", "=", "\" \"", ",", "postdate", "=", "None", ",", "posttime", "=", "None", ")", ...
Generate a Remind command from the given vevent
[ "Generate", "a", "Remind", "command", "from", "the", "given", "vevent" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L431-L499
train
Generate a Remind command from a vevent.
jspricke/python-remind
remind.py
Remind.to_reminders
def to_reminders(self, ical, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): """Return Remind commands for all events of a iCalendar""" if not hasattr(ical, 'vevent_list'): return '' reminders = [self.to_remind(vevent, la...
python
def to_reminders(self, ical, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): """Return Remind commands for all events of a iCalendar""" if not hasattr(ical, 'vevent_list'): return '' reminders = [self.to_remind(vevent, la...
[ "def", "to_reminders", "(", "self", ",", "ical", ",", "label", "=", "None", ",", "priority", "=", "None", ",", "tags", "=", "None", ",", "tail", "=", "None", ",", "sep", "=", "\" \"", ",", "postdate", "=", "None", ",", "posttime", "=", "None", ")",...
Return Remind commands for all events of a iCalendar
[ "Return", "Remind", "commands", "for", "all", "events", "of", "a", "iCalendar" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L501-L510
train
Return Remind commands for all events of a iCalendar
jspricke/python-remind
remind.py
Remind.append_vobject
def append_vobject(self, ical, filename=None): """Append a Remind command generated from the iCalendar to the file""" if not filename: filename = self._filename elif filename not in self._reminders: return with self._lock: outdat = self.to_reminders(i...
python
def append_vobject(self, ical, filename=None): """Append a Remind command generated from the iCalendar to the file""" if not filename: filename = self._filename elif filename not in self._reminders: return with self._lock: outdat = self.to_reminders(i...
[ "def", "append_vobject", "(", "self", ",", "ical", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "_filename", "elif", "filename", "not", "in", "self", ".", "_reminders", ":", "return", "with", "self",...
Append a Remind command generated from the iCalendar to the file
[ "Append", "a", "Remind", "command", "generated", "from", "the", "iCalendar", "to", "the", "file" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L516-L527
train
Append a Remind command generated from the iCalendar to the file
jspricke/python-remind
remind.py
Remind.remove
def remove(self, uid, filename=None): """Remove the Remind command with the uid from the file""" if not filename: filename = self._filename elif filename not in self._reminders: return uid = uid.split('@')[0] with self._lock: rem = open(filen...
python
def remove(self, uid, filename=None): """Remove the Remind command with the uid from the file""" if not filename: filename = self._filename elif filename not in self._reminders: return uid = uid.split('@')[0] with self._lock: rem = open(filen...
[ "def", "remove", "(", "self", ",", "uid", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "_filename", "elif", "filename", "not", "in", "self", ".", "_reminders", ":", "return", "uid", "=", "uid", "...
Remove the Remind command with the uid from the file
[ "Remove", "the", "Remind", "command", "with", "the", "uid", "from", "the", "file" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L529-L544
train
Remove the Remind command with the uid from the file
jspricke/python-remind
remind.py
Remind.replace
def replace(self, uid, ical, filename=None): """Update the Remind command with the uid in the file with the new iCalendar""" return self.replace_vobject(uid, readOne(ical), filename)
python
def replace(self, uid, ical, filename=None): """Update the Remind command with the uid in the file with the new iCalendar""" return self.replace_vobject(uid, readOne(ical), filename)
[ "def", "replace", "(", "self", ",", "uid", ",", "ical", ",", "filename", "=", "None", ")", ":", "return", "self", ".", "replace_vobject", "(", "uid", ",", "readOne", "(", "ical", ")", ",", "filename", ")" ]
Update the Remind command with the uid in the file with the new iCalendar
[ "Update", "the", "Remind", "command", "with", "the", "uid", "in", "the", "file", "with", "the", "new", "iCalendar" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L546-L548
train
Update the Remind command with the uid in the file with the iCalendar
jspricke/python-remind
remind.py
Remind.replace_vobject
def replace_vobject(self, uid, ical, filename=None): """Update the Remind command with the uid in the file with the new iCalendar""" if not filename: filename = self._filename elif filename not in self._reminders: return uid = uid.split('@')[0] with self...
python
def replace_vobject(self, uid, ical, filename=None): """Update the Remind command with the uid in the file with the new iCalendar""" if not filename: filename = self._filename elif filename not in self._reminders: return uid = uid.split('@')[0] with self...
[ "def", "replace_vobject", "(", "self", ",", "uid", ",", "ical", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "_filename", "elif", "filename", "not", "in", "self", ".", "_reminders", ":", "return", ...
Update the Remind command with the uid in the file with the new iCalendar
[ "Update", "the", "Remind", "command", "with", "the", "uid", "in", "the", "file", "with", "the", "new", "iCalendar" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L550-L566
train
Update the Remind command with the uid in the file with the new iCalendar
jspricke/python-remind
remind.py
Remind.move_vobject
def move_vobject(self, uid, from_file, to_file): """Move the Remind command with the uid from from_file to to_file""" if from_file not in self._reminders or to_file not in self._reminders: return uid = uid.split('@')[0] with self._lock: rem = open(from_file).rea...
python
def move_vobject(self, uid, from_file, to_file): """Move the Remind command with the uid from from_file to to_file""" if from_file not in self._reminders or to_file not in self._reminders: return uid = uid.split('@')[0] with self._lock: rem = open(from_file).rea...
[ "def", "move_vobject", "(", "self", ",", "uid", ",", "from_file", ",", "to_file", ")", ":", "if", "from_file", "not", "in", "self", ".", "_reminders", "or", "to_file", "not", "in", "self", ".", "_reminders", ":", "return", "uid", "=", "uid", ".", "spli...
Move the Remind command with the uid from from_file to to_file
[ "Move", "the", "Remind", "command", "with", "the", "uid", "from", "from_file", "to", "to_file" ]
dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L568-L582
train
Move the Remind command with the uid from from_file to to_file
heinzK1X/pylibconfig2
pylibconfig2/conf_types.py
Config.expand_include
def expand_include(filename): """ Expand the content of a file into a string. If @include directives are found in the config, they are expanded by this function. In case recursion is detected or a RunTimeError is thrown, ``None`` is returned. """ open_files = set...
python
def expand_include(filename): """ Expand the content of a file into a string. If @include directives are found in the config, they are expanded by this function. In case recursion is detected or a RunTimeError is thrown, ``None`` is returned. """ open_files = set...
[ "def", "expand_include", "(", "filename", ")", ":", "open_files", "=", "set", "(", ")", "def", "_expand_include_rec", "(", "filename", ")", ":", "if", "filename", "in", "open_files", ":", "raise", "RuntimeError", "(", "'Recursive include statement detected for '", ...
Expand the content of a file into a string. If @include directives are found in the config, they are expanded by this function. In case recursion is detected or a RunTimeError is thrown, ``None`` is returned.
[ "Expand", "the", "content", "of", "a", "file", "into", "a", "string", "." ]
f3a851ac780da28a42264c24aac51b54fbd63f81
https://github.com/heinzK1X/pylibconfig2/blob/f3a851ac780da28a42264c24aac51b54fbd63f81/pylibconfig2/conf_types.py#L290-L326
train
Expand the content of a file into a string.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/gui/qt_b26_load_dialog_probes.py
LoadDialogProbes.show_info
def show_info(self): """ displays the doc string of the selected element """ sender = self.sender() tree = sender.parent() index = tree.selectedIndexes() info = '' if index != []: index = index[0] name = str(index.model().itemFromI...
python
def show_info(self): """ displays the doc string of the selected element """ sender = self.sender() tree = sender.parent() index = tree.selectedIndexes() info = '' if index != []: index = index[0] name = str(index.model().itemFromI...
[ "def", "show_info", "(", "self", ")", ":", "sender", "=", "self", ".", "sender", "(", ")", "tree", "=", "sender", ".", "parent", "(", ")", "index", "=", "tree", ".", "selectedIndexes", "(", ")", "info", "=", "''", "if", "index", "!=", "[", "]", "...
displays the doc string of the selected element
[ "displays", "the", "doc", "string", "of", "the", "selected", "element" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_load_dialog_probes.py#L149-L179
train
Displays the doc string of the selected element
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/gui/qt_b26_load_dialog_probes.py
LoadDialogProbes.fill_tree
def fill_tree(self, tree, input_dict): """ fills a tree with nested parameters Args: tree: QtGui.QTreeView parameters: dictionary or Parameter object Returns: """ def removeAll(tree): if tree.model().rowCount() > 0: ...
python
def fill_tree(self, tree, input_dict): """ fills a tree with nested parameters Args: tree: QtGui.QTreeView parameters: dictionary or Parameter object Returns: """ def removeAll(tree): if tree.model().rowCount() > 0: ...
[ "def", "fill_tree", "(", "self", ",", "tree", ",", "input_dict", ")", ":", "def", "removeAll", "(", "tree", ")", ":", "if", "tree", ".", "model", "(", ")", ".", "rowCount", "(", ")", ">", "0", ":", "for", "i", "in", "range", "(", "0", ",", "tre...
fills a tree with nested parameters Args: tree: QtGui.QTreeView parameters: dictionary or Parameter object Returns:
[ "fills", "a", "tree", "with", "nested", "parameters", "Args", ":", "tree", ":", "QtGui", ".", "QTreeView", "parameters", ":", "dictionary", "or", "Parameter", "object" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_load_dialog_probes.py#L204-L242
train
Fills a tree with nested parameters from input_dict.
moonso/ped_parser
ped_parser/individual.py
Individual.check_grandparents
def check_grandparents(self, mother = None, father = None): """ Check if there are any grand parents. Set the grandparents id:s Arguments: mother (Individual): An Individual object that represents the mother father (Individual): An Individual obj...
python
def check_grandparents(self, mother = None, father = None): """ Check if there are any grand parents. Set the grandparents id:s Arguments: mother (Individual): An Individual object that represents the mother father (Individual): An Individual obj...
[ "def", "check_grandparents", "(", "self", ",", "mother", "=", "None", ",", "father", "=", "None", ")", ":", "if", "mother", ":", "if", "mother", ".", "mother", "!=", "'0'", ":", "self", ".", "grandparents", "[", "mother", ".", "mother", "]", "=", "''...
Check if there are any grand parents. Set the grandparents id:s Arguments: mother (Individual): An Individual object that represents the mother father (Individual): An Individual object that represents the father
[ "Check", "if", "there", "are", "any", "grand", "parents", ".", "Set", "the", "grandparents", "id", ":", "s", "Arguments", ":", "mother", "(", "Individual", ")", ":", "An", "Individual", "object", "that", "represents", "the", "mother", "father", "(", "Indiv...
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/individual.py#L98-L120
train
Check if there are any grandparents.
moonso/ped_parser
ped_parser/individual.py
Individual.to_json
def to_json(self): """ Return the individual info in a dictionary for json. """ self.logger.debug("Returning json info") individual_info = { 'family_id': self.family, 'id':self.individual_id, 'sex':str(self.sex), 'phenotype': str(...
python
def to_json(self): """ Return the individual info in a dictionary for json. """ self.logger.debug("Returning json info") individual_info = { 'family_id': self.family, 'id':self.individual_id, 'sex':str(self.sex), 'phenotype': str(...
[ "def", "to_json", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Returning json info\"", ")", "individual_info", "=", "{", "'family_id'", ":", "self", ".", "family", ",", "'id'", ":", "self", ".", "individual_id", ",", "'sex'", ":", ...
Return the individual info in a dictionary for json.
[ "Return", "the", "individual", "info", "in", "a", "dictionary", "for", "json", "." ]
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/individual.py#L122-L136
train
Return the individual info in a dictionary for json.
moonso/ped_parser
ped_parser/individual.py
Individual.to_madeline
def to_madeline(self): """ Return the individual info in a madeline formated string """ #Convert sex to madeleine type self.logger.debug("Returning madeline info") if self.sex == 1: madeline_gender = 'M' elif self.sex == 2: madeline_gender ...
python
def to_madeline(self): """ Return the individual info in a madeline formated string """ #Convert sex to madeleine type self.logger.debug("Returning madeline info") if self.sex == 1: madeline_gender = 'M' elif self.sex == 2: madeline_gender ...
[ "def", "to_madeline", "(", "self", ")", ":", "#Convert sex to madeleine type", "self", ".", "logger", ".", "debug", "(", "\"Returning madeline info\"", ")", "if", "self", ".", "sex", "==", "1", ":", "madeline_gender", "=", "'M'", "elif", "self", ".", "sex", ...
Return the individual info in a madeline formated string
[ "Return", "the", "individual", "info", "in", "a", "madeline", "formated", "string" ]
a7393e47139532782ea3c821aabea33d46f94323
https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/individual.py#L138-L172
train
Return the individual info in a madeline formated string
zero-os/zerotier_client
zerotier/client_utils.py
generate_rfc3339
def generate_rfc3339(d, local_tz=True): """ generate rfc3339 time format input : d = date type local_tz = use local time zone if true, otherwise mark as utc output : rfc3339 string date format. ex : `2008-04-02T20:00:00+07:00` """ try: if local_tz: d = dateti...
python
def generate_rfc3339(d, local_tz=True): """ generate rfc3339 time format input : d = date type local_tz = use local time zone if true, otherwise mark as utc output : rfc3339 string date format. ex : `2008-04-02T20:00:00+07:00` """ try: if local_tz: d = dateti...
[ "def", "generate_rfc3339", "(", "d", ",", "local_tz", "=", "True", ")", ":", "try", ":", "if", "local_tz", ":", "d", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "d", ")", "else", ":", "d", "=", "datetime", ".", "datetime", ".", "utcf...
generate rfc3339 time format input : d = date type local_tz = use local time zone if true, otherwise mark as utc output : rfc3339 string date format. ex : `2008-04-02T20:00:00+07:00`
[ "generate", "rfc3339", "time", "format", "input", ":", "d", "=", "date", "type", "local_tz", "=", "use", "local", "time", "zone", "if", "true", "otherwise", "mark", "as", "utc" ]
03993da11e69d837a0308a2f41ae7b378692fd82
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_utils.py#L5-L32
train
generate rfc3339 time format
zero-os/zerotier_client
zerotier/client_utils.py
_calculate_offset
def _calculate_offset(date, local_tz): """ input : date : date type local_tz : if true, use system timezone, otherwise return 0 return the date of UTC offset. If date does not have any timezone info, we use local timezone, otherwise return 0 """ if local_tz: #handle year bef...
python
def _calculate_offset(date, local_tz): """ input : date : date type local_tz : if true, use system timezone, otherwise return 0 return the date of UTC offset. If date does not have any timezone info, we use local timezone, otherwise return 0 """ if local_tz: #handle year bef...
[ "def", "_calculate_offset", "(", "date", ",", "local_tz", ")", ":", "if", "local_tz", ":", "#handle year before 1970 most sytem there is no timezone information before 1970.", "if", "date", ".", "year", "<", "1970", ":", "# Use 1972 because 1970 doesn't have a leap day", "t",...
input : date : date type local_tz : if true, use system timezone, otherwise return 0 return the date of UTC offset. If date does not have any timezone info, we use local timezone, otherwise return 0
[ "input", ":", "date", ":", "date", "type", "local_tz", ":", "if", "true", "use", "system", "timezone", "otherwise", "return", "0" ]
03993da11e69d837a0308a2f41ae7b378692fd82
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_utils.py#L35-L59
train
Calculate the offset of a node in a node s tree.
zero-os/zerotier_client
zerotier/client_utils.py
_generate_timezone
def _generate_timezone(date, local_tz): """ input : date : date type local_tz : bool offset generated from _calculate_offset offset in seconds offset = 0 -> +00:00 offset = 1800 -> +00:30 offset = -3600 -> -01:00 """ offset = _calculate_offset(date, local_tz) hour = abs...
python
def _generate_timezone(date, local_tz): """ input : date : date type local_tz : bool offset generated from _calculate_offset offset in seconds offset = 0 -> +00:00 offset = 1800 -> +00:30 offset = -3600 -> -01:00 """ offset = _calculate_offset(date, local_tz) hour = abs...
[ "def", "_generate_timezone", "(", "date", ",", "local_tz", ")", ":", "offset", "=", "_calculate_offset", "(", "date", ",", "local_tz", ")", "hour", "=", "abs", "(", "offset", ")", "//", "3600", "minute", "=", "abs", "(", "offset", ")", "%", "3600", "//...
input : date : date type local_tz : bool offset generated from _calculate_offset offset in seconds offset = 0 -> +00:00 offset = 1800 -> +00:30 offset = -3600 -> -01:00
[ "input", ":", "date", ":", "date", "type", "local_tz", ":", "bool" ]
03993da11e69d837a0308a2f41ae7b378692fd82
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_utils.py#L62-L82
train
Generate a timezone string for the given date and local_tz.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/helper_functions.py
module_name_from_path
def module_name_from_path(folder_name, verbose=False): """ takes in a path to a folder or file and return the module path and the path to the module the module is idenitified by the path being in os.path, e.g. if /Users/Projects/Python/ is in os.path, then folder_name = '/Users/PycharmProje...
python
def module_name_from_path(folder_name, verbose=False): """ takes in a path to a folder or file and return the module path and the path to the module the module is idenitified by the path being in os.path, e.g. if /Users/Projects/Python/ is in os.path, then folder_name = '/Users/PycharmProje...
[ "def", "module_name_from_path", "(", "folder_name", ",", "verbose", "=", "False", ")", ":", "# strip off endings", "folder_name", "=", "folder_name", ".", "split", "(", "'.pyc'", ")", "[", "0", "]", "folder_name", "=", "folder_name", ".", "split", "(", "'.py'"...
takes in a path to a folder or file and return the module path and the path to the module the module is idenitified by the path being in os.path, e.g. if /Users/Projects/Python/ is in os.path, then folder_name = '/Users/PycharmProjects/pylabcontrol/pylabcontrol/scripts/script_dummy.pyc' ret...
[ "takes", "in", "a", "path", "to", "a", "folder", "or", "file", "and", "return", "the", "module", "path", "and", "the", "path", "to", "the", "module" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/helper_functions.py#L23-L127
train
Returns the module name from a path to a folder or file.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/helper_functions.py
explore_package
def explore_package(module_name): """ returns all the packages in the module Args: module_name: name of module Returns: """ packages = [] loader = pkgutil.get_loader(module_name) for sub_module in pkgutil.walk_packages([os.path.dirname(loader.get_filename())], ...
python
def explore_package(module_name): """ returns all the packages in the module Args: module_name: name of module Returns: """ packages = [] loader = pkgutil.get_loader(module_name) for sub_module in pkgutil.walk_packages([os.path.dirname(loader.get_filename())], ...
[ "def", "explore_package", "(", "module_name", ")", ":", "packages", "=", "[", "]", "loader", "=", "pkgutil", ".", "get_loader", "(", "module_name", ")", "for", "sub_module", "in", "pkgutil", ".", "walk_packages", "(", "[", "os", ".", "path", ".", "dirname"...
returns all the packages in the module Args: module_name: name of module Returns:
[ "returns", "all", "the", "packages", "in", "the", "module" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/helper_functions.py#L201-L219
train
Returns all the packages in the module_name
CitrineInformatics/pif-dft
dfttopif/parsers/base.py
DFTParser.generate_from_directory
def generate_from_directory(cls, directory): """Create a parser by defining which input files it will read from. Input: directory - str, directory to read from files - str, list of files from which to search. """ files = [os.path.join(directory, f) for f in o...
python
def generate_from_directory(cls, directory): """Create a parser by defining which input files it will read from. Input: directory - str, directory to read from files - str, list of files from which to search. """ files = [os.path.join(directory, f) for f in o...
[ "def", "generate_from_directory", "(", "cls", ",", "directory", ")", ":", "files", "=", "[", "os", ".", "path", ".", "join", "(", "directory", ",", "f", ")", "for", "f", "in", "os", ".", "listdir", "(", "directory", ")", "if", "os", ".", "path", "....
Create a parser by defining which input files it will read from. Input: directory - str, directory to read from files - str, list of files from which to search.
[ "Create", "a", "parser", "by", "defining", "which", "input", "files", "it", "will", "read", "from", "." ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/base.py#L57-L66
train
Create a parser by defining which input files it will read from.
CitrineInformatics/pif-dft
dfttopif/parsers/base.py
DFTParser.get_composition
def get_composition(self): '''Get composition of output structure Returns: String - Composition based on output structure ''' strc = self.get_output_structure() counts = Counter(strc.get_chemical_symbols()) return ''.join(k if counts[k]==1 else '%s%d'...
python
def get_composition(self): '''Get composition of output structure Returns: String - Composition based on output structure ''' strc = self.get_output_structure() counts = Counter(strc.get_chemical_symbols()) return ''.join(k if counts[k]==1 else '%s%d'...
[ "def", "get_composition", "(", "self", ")", ":", "strc", "=", "self", ".", "get_output_structure", "(", ")", "counts", "=", "Counter", "(", "strc", ".", "get_chemical_symbols", "(", ")", ")", "return", "''", ".", "join", "(", "k", "if", "counts", "[", ...
Get composition of output structure Returns: String - Composition based on output structure
[ "Get", "composition", "of", "output", "structure", "Returns", ":", "String", "-", "Composition", "based", "on", "output", "structure" ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/base.py#L137-L146
train
Get composition of output structure Returns: String - Composition based on output structure
CitrineInformatics/pif-dft
dfttopif/parsers/base.py
DFTParser.get_density
def get_density(self): """Compute the density from the output structure""" strc = self.get_output_structure() density = sum(strc.get_masses()) / strc.get_volume() * 1.660539040 return Property(scalars=[Scalar(value=density)], units="g/(cm^3)")
python
def get_density(self): """Compute the density from the output structure""" strc = self.get_output_structure() density = sum(strc.get_masses()) / strc.get_volume() * 1.660539040 return Property(scalars=[Scalar(value=density)], units="g/(cm^3)")
[ "def", "get_density", "(", "self", ")", ":", "strc", "=", "self", ".", "get_output_structure", "(", ")", "density", "=", "sum", "(", "strc", ".", "get_masses", "(", ")", ")", "/", "strc", ".", "get_volume", "(", ")", "*", "1.660539040", "return", "Prop...
Compute the density from the output structure
[ "Compute", "the", "density", "from", "the", "output", "structure" ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/base.py#L148-L152
train
Compute the density from the output structure
CitrineInformatics/pif-dft
dfttopif/parsers/base.py
DFTParser.is_converged
def is_converged(self): '''Whether the calculation has converged Returns: Property where "scalar" is a boolean indicating ''' # Check for cached result if self._converged is None: self._converged = self._is_converged() return Property(scalars=[Scalar...
python
def is_converged(self): '''Whether the calculation has converged Returns: Property where "scalar" is a boolean indicating ''' # Check for cached result if self._converged is None: self._converged = self._is_converged() return Property(scalars=[Scalar...
[ "def", "is_converged", "(", "self", ")", ":", "# Check for cached result", "if", "self", ".", "_converged", "is", "None", ":", "self", ".", "_converged", "=", "self", ".", "_is_converged", "(", ")", "return", "Property", "(", "scalars", "=", "[", "Scalar", ...
Whether the calculation has converged Returns: Property where "scalar" is a boolean indicating
[ "Whether", "the", "calculation", "has", "converged", "Returns", ":", "Property", "where", "scalar", "is", "a", "boolean", "indicating" ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/base.py#L196-L205
train
Whether the calculation has converged Returns a Property where scalar is a boolean indicating
CitrineInformatics/pif-dft
dfttopif/parsers/base.py
DFTParser.get_number_of_atoms
def get_number_of_atoms(self): """Get the number of atoms in the calculated structure. Returns: Property, where number of atoms is a scalar. """ strc = self.get_output_structure() if not strc: return None return Property(scalars=[Scalar(value=len(strc))], uni...
python
def get_number_of_atoms(self): """Get the number of atoms in the calculated structure. Returns: Property, where number of atoms is a scalar. """ strc = self.get_output_structure() if not strc: return None return Property(scalars=[Scalar(value=len(strc))], uni...
[ "def", "get_number_of_atoms", "(", "self", ")", ":", "strc", "=", "self", ".", "get_output_structure", "(", ")", "if", "not", "strc", ":", "return", "None", "return", "Property", "(", "scalars", "=", "[", "Scalar", "(", "value", "=", "len", "(", "strc", ...
Get the number of atoms in the calculated structure. Returns: Property, where number of atoms is a scalar.
[ "Get", "the", "number", "of", "atoms", "in", "the", "calculated", "structure", "." ]
d5411dc1f6c6e8d454b132977ca7ab3bb8131a80
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/base.py#L296-L304
train
Get the number of atoms in the calculated structure.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_write_functions.py
import_sub_modules
def import_sub_modules(module_type): """ imports all the module_type from additional modules that contain module_type This name of those modules is in the config file that is located in the main directory module_type: str that specifies the type of module to be loaded (scripts / instruments) :retur...
python
def import_sub_modules(module_type): """ imports all the module_type from additional modules that contain module_type This name of those modules is in the config file that is located in the main directory module_type: str that specifies the type of module to be loaded (scripts / instruments) :retur...
[ "def", "import_sub_modules", "(", "module_type", ")", ":", "assert", "module_type", "in", "(", "'scripts'", ",", "'instruments'", ")", "path_to_config", "=", "'/'", ".", "join", "(", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "dirname...
imports all the module_type from additional modules that contain module_type This name of those modules is in the config file that is located in the main directory module_type: str that specifies the type of module to be loaded (scripts / instruments) :return: module_list: a list with modules that contain ...
[ "imports", "all", "the", "module_type", "from", "additional", "modules", "that", "contain", "module_type", "This", "name", "of", "those", "modules", "is", "in", "the", "config", "file", "that", "is", "located", "in", "the", "main", "directory", "module_type", ...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_write_functions.py#L24-L39
train
Imports all the module_type from additional modules that contain module_type
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_write_functions.py
get_config_value
def get_config_value(name, path_to_file='config.txt'): """ gets the value for "name" from "path_to_file" config file Args: name: name of varibale in config file path_to_file: path to config file Returns: path to dll if name exists in the file; otherwise, returns None """ # if ...
python
def get_config_value(name, path_to_file='config.txt'): """ gets the value for "name" from "path_to_file" config file Args: name: name of varibale in config file path_to_file: path to config file Returns: path to dll if name exists in the file; otherwise, returns None """ # if ...
[ "def", "get_config_value", "(", "name", ",", "path_to_file", "=", "'config.txt'", ")", ":", "# if the function is called from gui then the file has to be located with respect to the gui folder", "if", "not", "os", ".", "path", ".", "isfile", "(", "path_to_file", ")", ":", ...
gets the value for "name" from "path_to_file" config file Args: name: name of varibale in config file path_to_file: path to config file Returns: path to dll if name exists in the file; otherwise, returns None
[ "gets", "the", "value", "for", "name", "from", "path_to_file", "config", "file", "Args", ":", "name", ":", "name", "of", "varibale", "in", "config", "file", "path_to_file", ":", "path", "to", "config", "file" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_write_functions.py#L41-L74
train
gets the value for name from path_to_file config file
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_write_functions.py
load_b26_file
def load_b26_file(file_name): """ loads a .b26 file into a dictionary Args: file_name: Returns: dictionary with keys instrument, scripts, probes """ # file_name = "Z:\Lab\Cantilever\Measurements\\tmp_\\a" assert os.path.exists(file_name) with open(file_name, 'r') as infile: ...
python
def load_b26_file(file_name): """ loads a .b26 file into a dictionary Args: file_name: Returns: dictionary with keys instrument, scripts, probes """ # file_name = "Z:\Lab\Cantilever\Measurements\\tmp_\\a" assert os.path.exists(file_name) with open(file_name, 'r') as infile: ...
[ "def", "load_b26_file", "(", "file_name", ")", ":", "# file_name = \"Z:\\Lab\\Cantilever\\Measurements\\\\tmp_\\\\a\"", "assert", "os", ".", "path", ".", "exists", "(", "file_name", ")", "with", "open", "(", "file_name", ",", "'r'", ")", "as", "infile", ":", "data...
loads a .b26 file into a dictionary Args: file_name: Returns: dictionary with keys instrument, scripts, probes
[ "loads", "a", ".", "b26", "file", "into", "a", "dictionary" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_write_functions.py#L76-L92
train
Loads a. b26 file into a dictionary
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_write_functions.py
save_b26_file
def save_b26_file(filename, instruments=None, scripts=None, probes=None, overwrite=False, verbose=False): """ save instruments, scripts and probes as a json file Args: filename: instruments: scripts: probes: dictionary of the form {instrument_name : probe_1_of_intrument, prob...
python
def save_b26_file(filename, instruments=None, scripts=None, probes=None, overwrite=False, verbose=False): """ save instruments, scripts and probes as a json file Args: filename: instruments: scripts: probes: dictionary of the form {instrument_name : probe_1_of_intrument, prob...
[ "def", "save_b26_file", "(", "filename", ",", "instruments", "=", "None", ",", "scripts", "=", "None", ",", "probes", "=", "None", ",", "overwrite", "=", "False", ",", "verbose", "=", "False", ")", ":", "# if overwrite is false load existing data and append to new...
save instruments, scripts and probes as a json file Args: filename: instruments: scripts: probes: dictionary of the form {instrument_name : probe_1_of_intrument, probe_2_of_intrument, ...} Returns:
[ "save", "instruments", "scripts", "and", "probes", "as", "a", "json", "file", "Args", ":", "filename", ":", "instruments", ":", "scripts", ":", "probes", ":", "dictionary", "of", "the", "form", "{", "instrument_name", ":", "probe_1_of_intrument", "probe_2_of_int...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_write_functions.py#L95-L160
train
Save a B26 file.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/tools/export_default.py
get_classes_in_folder
def get_classes_in_folder(folder_name, class_type, verbose=False): """ load all the instruments or script objects that are located in folder_name and return a dictionary with the script class name and path_to_python_file Args: folder_name (string): folder in which to search for class objects / o...
python
def get_classes_in_folder(folder_name, class_type, verbose=False): """ load all the instruments or script objects that are located in folder_name and return a dictionary with the script class name and path_to_python_file Args: folder_name (string): folder in which to search for class objects / o...
[ "def", "get_classes_in_folder", "(", "folder_name", ",", "class_type", ",", "verbose", "=", "False", ")", ":", "assert", "class_type", "==", "Instrument", "or", "class_type", "==", "Script", "or", "class_type", ".", "lower", "(", ")", "in", "[", "'instrument'"...
load all the instruments or script objects that are located in folder_name and return a dictionary with the script class name and path_to_python_file Args: folder_name (string): folder in which to search for class objects / or name of module class_type (string or class): class type for which to ...
[ "load", "all", "the", "instruments", "or", "script", "objects", "that", "are", "located", "in", "folder_name", "and", "return", "a", "dictionary", "with", "the", "script", "class", "name", "and", "path_to_python_file", "Args", ":", "folder_name", "(", "string", ...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L26-L83
train
Returns a dictionary with the class name and path_to_python_file for all the classes in the given folder.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/tools/export_default.py
export_default_probes
def export_default_probes(path, module_name = '', raise_errors = False): """ NOT IMPLEMENTED YET tries to instantiate all the instruments that are imported in /instruments/__init__.py and the probes of each instrument that could be instantiated into a .b26 file in the folder path Args: path:...
python
def export_default_probes(path, module_name = '', raise_errors = False): """ NOT IMPLEMENTED YET tries to instantiate all the instruments that are imported in /instruments/__init__.py and the probes of each instrument that could be instantiated into a .b26 file in the folder path Args: path:...
[ "def", "export_default_probes", "(", "path", ",", "module_name", "=", "''", ",", "raise_errors", "=", "False", ")", ":", "raise", "NotImplementedError", "import", "b26_toolkit", ".", "b26_toolkit", ".", "instruments", "as", "instruments", "from", "pylabcontrol", "...
NOT IMPLEMENTED YET tries to instantiate all the instruments that are imported in /instruments/__init__.py and the probes of each instrument that could be instantiated into a .b26 file in the folder path Args: path: target path for .b26 files
[ "NOT", "IMPLEMENTED", "YET", "tries", "to", "instantiate", "all", "the", "instruments", "that", "are", "imported", "in", "/", "instruments", "/", "__init__", ".", "py", "and", "the", "probes", "of", "each", "instrument", "that", "could", "be", "instantiated", ...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L85-L113
train
Export default probes for all instruments in the folder path.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/tools/export_default.py
export_default_scripts
def export_default_scripts(target_folder, source_folder = None, raise_errors = False, verbose=False): """ tries to instantiate all the scripts that are imported in /scripts/__init__.py saves each script that could be instantiated into a .b26 file in the folder path Args: target_folder: target pa...
python
def export_default_scripts(target_folder, source_folder = None, raise_errors = False, verbose=False): """ tries to instantiate all the scripts that are imported in /scripts/__init__.py saves each script that could be instantiated into a .b26 file in the folder path Args: target_folder: target pa...
[ "def", "export_default_scripts", "(", "target_folder", ",", "source_folder", "=", "None", ",", "raise_errors", "=", "False", ",", "verbose", "=", "False", ")", ":", "scripts_to_load", "=", "get_classes_in_folder", "(", "source_folder", ",", "Script", ")", "if", ...
tries to instantiate all the scripts that are imported in /scripts/__init__.py saves each script that could be instantiated into a .b26 file in the folder path Args: target_folder: target path for .b26 files source_folder: location of python script files
[ "tries", "to", "instantiate", "all", "the", "scripts", "that", "are", "imported", "in", "/", "scripts", "/", "__init__", ".", "py", "saves", "each", "script", "that", "could", "be", "instantiated", "into", "a", ".", "b26", "file", "in", "the", "folder", ...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L141-L167
train
Loads all the scripts that are imported in source_folder and saves them into target_folder.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/tools/export_default.py
export
def export(target_folder, source_folders = None, class_type ='all', raise_errors = False): """ exports the existing scripts/instruments (future: probes) into folder as .b26 files Args: target_folder: target location of created .b26 script files source_folder: singel path or list of paths tha...
python
def export(target_folder, source_folders = None, class_type ='all', raise_errors = False): """ exports the existing scripts/instruments (future: probes) into folder as .b26 files Args: target_folder: target location of created .b26 script files source_folder: singel path or list of paths tha...
[ "def", "export", "(", "target_folder", ",", "source_folders", "=", "None", ",", "class_type", "=", "'all'", ",", "raise_errors", "=", "False", ")", ":", "if", "class_type", "not", "in", "(", "'all'", ",", "'scripts'", ",", "'instruments'", ",", "'probes'", ...
exports the existing scripts/instruments (future: probes) into folder as .b26 files Args: target_folder: target location of created .b26 script files source_folder: singel path or list of paths that contains the location of python script files can also be just the name of a module class_type...
[ "exports", "the", "existing", "scripts", "/", "instruments", "(", "future", ":", "probes", ")", "into", "folder", "as", ".", "b26", "files", "Args", ":", "target_folder", ":", "target", "location", "of", "created", ".", "b26", "script", "files", "source_fold...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L170-L212
train
Exports the existing scripts and instruments into a folder.
datamachine/twx
twx/mtproto/mtproto.py
Datacenter.recv_message
def recv_message(self, debug=False): """ Reading socket and receiving message from server. Check the CRC32. """ if debug: packet = self.sock.recv(1024) # reads how many bytes to read hexdump(packet) packet_length_data = self.sock.recv(4) # reads how man...
python
def recv_message(self, debug=False): """ Reading socket and receiving message from server. Check the CRC32. """ if debug: packet = self.sock.recv(1024) # reads how many bytes to read hexdump(packet) packet_length_data = self.sock.recv(4) # reads how man...
[ "def", "recv_message", "(", "self", ",", "debug", "=", "False", ")", ":", "if", "debug", ":", "packet", "=", "self", ".", "sock", ".", "recv", "(", "1024", ")", "# reads how many bytes to read", "hexdump", "(", "packet", ")", "packet_length_data", "=", "se...
Reading socket and receiving message from server. Check the CRC32.
[ "Reading", "socket", "and", "receiving", "message", "from", "server", ".", "Check", "the", "CRC32", "." ]
d9633f12f3647b1e54ba87b70b39df3b7e02b4eb
https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/mtproto/mtproto.py#L248-L286
train
Reads a message from the server and returns it.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.get_category_lists
def get_category_lists(self, init_kwargs=None, additional_parents_aliases=None): """Returns a list of CategoryList objects, associated with this model instance. :param dict|None init_kwargs: :param list|None additional_parents_aliases: :rtype: list|CategoryRequestHandler ...
python
def get_category_lists(self, init_kwargs=None, additional_parents_aliases=None): """Returns a list of CategoryList objects, associated with this model instance. :param dict|None init_kwargs: :param list|None additional_parents_aliases: :rtype: list|CategoryRequestHandler ...
[ "def", "get_category_lists", "(", "self", ",", "init_kwargs", "=", "None", ",", "additional_parents_aliases", "=", "None", ")", ":", "if", "self", ".", "_category_editor", "is", "not", "None", ":", "# Return editor lists instead of plain lists if it's enabled.", "return...
Returns a list of CategoryList objects, associated with this model instance. :param dict|None init_kwargs: :param list|None additional_parents_aliases: :rtype: list|CategoryRequestHandler :return:
[ "Returns", "a", "list", "of", "CategoryList", "objects", "associated", "with", "this", "model", "instance", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L229-L252
train
Returns a list of CategoryList objects associated with this model instance.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.enable_category_lists_editor
def enable_category_lists_editor(self, request, editor_init_kwargs=None, additional_parents_aliases=None, lists_init_kwargs=None, handler_init_kwargs=None): """Enables editor functionality for categories of this object. :param Request request: Django request object ...
python
def enable_category_lists_editor(self, request, editor_init_kwargs=None, additional_parents_aliases=None, lists_init_kwargs=None, handler_init_kwargs=None): """Enables editor functionality for categories of this object. :param Request request: Django request object ...
[ "def", "enable_category_lists_editor", "(", "self", ",", "request", ",", "editor_init_kwargs", "=", "None", ",", "additional_parents_aliases", "=", "None", ",", "lists_init_kwargs", "=", "None", ",", "handler_init_kwargs", "=", "None", ")", ":", "from", ".", "tool...
Enables editor functionality for categories of this object. :param Request request: Django request object :param dict editor_init_kwargs: Keyword args to initialize category lists editor with. See CategoryList.enable_editor() :param list additional_parents_aliases: Aliases of catego...
[ "Enables", "editor", "functionality", "for", "categories", "of", "this", "object", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L254-L277
train
Enables editor functionality for categories of this object.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.add_to_category
def add_to_category(self, category, user): """Add this model instance to a category. :param Category category: Category to add this object to :param User user: User heir who adds :return: """ init_kwargs = { 'category': category, 'creator': user, ...
python
def add_to_category(self, category, user): """Add this model instance to a category. :param Category category: Category to add this object to :param User user: User heir who adds :return: """ init_kwargs = { 'category': category, 'creator': user, ...
[ "def", "add_to_category", "(", "self", ",", "category", ",", "user", ")", ":", "init_kwargs", "=", "{", "'category'", ":", "category", ",", "'creator'", ":", "user", ",", "'linked_object'", ":", "self", "}", "tie", "=", "self", ".", "categories", ".", "m...
Add this model instance to a category. :param Category category: Category to add this object to :param User user: User heir who adds :return:
[ "Add", "this", "model", "instance", "to", "a", "category", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L279-L293
train
Add this model instance to a category.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.remove_from_category
def remove_from_category(self, category): """Removes this object from a given category. :param Category category: :return: """ ctype = ContentType.objects.get_for_model(self) self.categories.model.objects.filter(category=category, content_type=ctype, object_id=self.id).d...
python
def remove_from_category(self, category): """Removes this object from a given category. :param Category category: :return: """ ctype = ContentType.objects.get_for_model(self) self.categories.model.objects.filter(category=category, content_type=ctype, object_id=self.id).d...
[ "def", "remove_from_category", "(", "self", ",", "category", ")", ":", "ctype", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "self", ")", "self", ".", "categories", ".", "model", ".", "objects", ".", "filter", "(", "category", "=", "categ...
Removes this object from a given category. :param Category category: :return:
[ "Removes", "this", "object", "from", "a", "given", "category", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L295-L302
train
Removes this object from a given category.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.get_ties_for_categories_qs
def get_ties_for_categories_qs(cls, categories, user=None, status=None): """Returns a QuerySet of Ties for the given categories. :param list|Category categories: :param User|None user: :param int|None status: :return: """ if not isinstance(categories, list): ...
python
def get_ties_for_categories_qs(cls, categories, user=None, status=None): """Returns a QuerySet of Ties for the given categories. :param list|Category categories: :param User|None user: :param int|None status: :return: """ if not isinstance(categories, list): ...
[ "def", "get_ties_for_categories_qs", "(", "cls", ",", "categories", ",", "user", "=", "None", ",", "status", "=", "None", ")", ":", "if", "not", "isinstance", "(", "categories", ",", "list", ")", ":", "categories", "=", "[", "categories", "]", "category_id...
Returns a QuerySet of Ties for the given categories. :param list|Category categories: :param User|None user: :param int|None status: :return:
[ "Returns", "a", "QuerySet", "of", "Ties", "for", "the", "given", "categories", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L305-L331
train
Returns a QuerySet of Ties for the given categories.
idlesign/django-sitecats
sitecats/models.py
ModelWithCategory.get_from_category_qs
def get_from_category_qs(cls, category): """Returns a QuerySet of objects of this type associated with the given category. :param Category category: :rtype: list :return: """ ids = cls.get_ties_for_categories_qs(category).values_list('object_id').distinct() filte...
python
def get_from_category_qs(cls, category): """Returns a QuerySet of objects of this type associated with the given category. :param Category category: :rtype: list :return: """ ids = cls.get_ties_for_categories_qs(category).values_list('object_id').distinct() filte...
[ "def", "get_from_category_qs", "(", "cls", ",", "category", ")", ":", "ids", "=", "cls", ".", "get_ties_for_categories_qs", "(", "category", ")", ".", "values_list", "(", "'object_id'", ")", ".", "distinct", "(", ")", "filter_kwargs", "=", "{", "'id__in'", "...
Returns a QuerySet of objects of this type associated with the given category. :param Category category: :rtype: list :return:
[ "Returns", "a", "QuerySet", "of", "objects", "of", "this", "type", "associated", "with", "the", "given", "category", "." ]
9b45e91fc0dcb63a0011780437fe28145e3ecce9
https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/models.py#L334-L343
train
Returns a QuerySet of objects of this type associated with the given category.
nmdp-bioinformatics/SeqAnn
scripts/annotate_fasta.py
main
def main(): """This is run if file is directly executed, but not if imported as module. Having this in a separate function allows importing the file into interactive python, and still able to execute the function for testing""" parser = argparse.ArgumentParser() parser.add_argument("-f", "--fil...
python
def main(): """This is run if file is directly executed, but not if imported as module. Having this in a separate function allows importing the file into interactive python, and still able to execute the function for testing""" parser = argparse.ArgumentParser() parser.add_argument("-f", "--fil...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"-f\"", ",", "\"--file\"", ",", "required", "=", "True", ",", "help", "=", "\"input file\"", ",", "type", "=", "str", ")", "...
This is run if file is directly executed, but not if imported as module. Having this in a separate function allows importing the file into interactive python, and still able to execute the function for testing
[ "This", "is", "run", "if", "file", "is", "directly", "executed", "but", "not", "if", "imported", "as", "module", ".", "Having", "this", "in", "a", "separate", "function", "allows", "importing", "the", "file", "into", "interactive", "python", "and", "still", ...
5ce91559b0a4fbe4fb7758e034eb258202632463
https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/scripts/annotate_fasta.py#L17-L91
train
This is the main function for the command line interface. It is run if file is directly executed but not if imported as module and still able to execute the function for testing
hyperledger-archives/indy-ledger
ledger/compact_merkle_tree.py
CompactMerkleTree._push_subtree
def _push_subtree(self, leaves: List[bytes]): """Extend with a full subtree <= the current minimum subtree. The leaves must form a full subtree, i.e. of size 2^k for some k. If there is a minimum subtree (i.e. __mintree_height > 0), then the input subtree must be smaller or of equal siz...
python
def _push_subtree(self, leaves: List[bytes]): """Extend with a full subtree <= the current minimum subtree. The leaves must form a full subtree, i.e. of size 2^k for some k. If there is a minimum subtree (i.e. __mintree_height > 0), then the input subtree must be smaller or of equal siz...
[ "def", "_push_subtree", "(", "self", ",", "leaves", ":", "List", "[", "bytes", "]", ")", ":", "size", "=", "len", "(", "leaves", ")", "if", "count_bits_set", "(", "size", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"invalid subtree with size != 2^k:...
Extend with a full subtree <= the current minimum subtree. The leaves must form a full subtree, i.e. of size 2^k for some k. If there is a minimum subtree (i.e. __mintree_height > 0), then the input subtree must be smaller or of equal size to the minimum subtree. If the subtree is smal...
[ "Extend", "with", "a", "full", "subtree", "<", "=", "the", "current", "minimum", "subtree", "." ]
7210c3b288e07f940eddad09b1dfc6a56be846df
https://github.com/hyperledger-archives/indy-ledger/blob/7210c3b288e07f940eddad09b1dfc6a56be846df/ledger/compact_merkle_tree.py#L91-L132
train
Extend with a full subtree < = current minimum subtree.
tryfer/tryfer
tryfer/trace.py
Trace.child
def child(self, name): """ Create a new instance of this class derived from the current instance such that: (new.trace_id == current.trace_id and new.parent_span_id == current.span_id) The new L{Trace} instance will have a new unique span_id and if set the ...
python
def child(self, name): """ Create a new instance of this class derived from the current instance such that: (new.trace_id == current.trace_id and new.parent_span_id == current.span_id) The new L{Trace} instance will have a new unique span_id and if set the ...
[ "def", "child", "(", "self", ",", "name", ")", ":", "trace", "=", "self", ".", "__class__", "(", "name", ",", "trace_id", "=", "self", ".", "trace_id", ",", "parent_span_id", "=", "self", ".", "span_id", ")", "trace", ".", "set_endpoint", "(", "self", ...
Create a new instance of this class derived from the current instance such that: (new.trace_id == current.trace_id and new.parent_span_id == current.span_id) The new L{Trace} instance will have a new unique span_id and if set the endpoint of the current L{Trace} object...
[ "Create", "a", "new", "instance", "of", "this", "class", "derived", "from", "the", "current", "instance", "such", "that", ":" ]
d4aa45b39eab5ce4b06d6343344afb05a0bf8582
https://github.com/tryfer/tryfer/blob/d4aa45b39eab5ce4b06d6343344afb05a0bf8582/tryfer/trace.py#L91-L111
train
Create a new instance of this class derived from the current instance and set the endpoint of the current instance.
johnnoone/json-spec
src/jsonspec/reference/__init__.py
resolve
def resolve(obj, pointer, registry=None): """resolve a local object :param obj: the local object. :param pointer: the pointer :type pointer: DocumentPointer, str :param registry: the registry. It mays be omited if inner json references document don't refer to...
python
def resolve(obj, pointer, registry=None): """resolve a local object :param obj: the local object. :param pointer: the pointer :type pointer: DocumentPointer, str :param registry: the registry. It mays be omited if inner json references document don't refer to...
[ "def", "resolve", "(", "obj", ",", "pointer", ",", "registry", "=", "None", ")", ":", "registry", "=", "LocalRegistry", "(", "obj", ",", "registry", "or", "{", "}", ")", "local", "=", "DocumentPointer", "(", "pointer", ")", "if", "local", ".", "documen...
resolve a local object :param obj: the local object. :param pointer: the pointer :type pointer: DocumentPointer, str :param registry: the registry. It mays be omited if inner json references document don't refer to other documents. :type registry: Provider, d...
[ "resolve", "a", "local", "object" ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/reference/__init__.py#L24-L62
train
resolve a local object to a base object
toros-astro/corral
corral/template/template/migrations/env.py
run_migrations
def run_migrations(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ with engine.connect() as connection: context.configure( connection=connection, target_metadata=Model.metadata) ...
python
def run_migrations(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ with engine.connect() as connection: context.configure( connection=connection, target_metadata=Model.metadata) ...
[ "def", "run_migrations", "(", ")", ":", "with", "engine", ".", "connect", "(", ")", "as", "connection", ":", "context", ".", "configure", "(", "connection", "=", "connection", ",", "target_metadata", "=", "Model", ".", "metadata", ")", "with", "context", "...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
75474b38ff366330d33644461a902d07374a5bbc
https://github.com/toros-astro/corral/blob/75474b38ff366330d33644461a902d07374a5bbc/corral/template/template/migrations/env.py#L44-L57
train
Run migrations in online mode.
abarmat/python-oembed
oembed/__init__.py
OEmbedEndpoint.addUrlScheme
def addUrlScheme(self, url): ''' Add a url scheme to this endpoint. It takes a url string and create the OEmbedUrlScheme object internally. Args: url: The url string that represents a url scheme to add. ''' #@TODO: validate invalid url format according to ht...
python
def addUrlScheme(self, url): ''' Add a url scheme to this endpoint. It takes a url string and create the OEmbedUrlScheme object internally. Args: url: The url string that represents a url scheme to add. ''' #@TODO: validate invalid url format according to ht...
[ "def", "addUrlScheme", "(", "self", ",", "url", ")", ":", "#@TODO: validate invalid url format according to http://oembed.com/", "if", "not", "isinstance", "(", "url", ",", "str", ")", ":", "raise", "TypeError", "(", "'url must be a string value'", ")", "if", "not", ...
Add a url scheme to this endpoint. It takes a url string and create the OEmbedUrlScheme object internally. Args: url: The url string that represents a url scheme to add.
[ "Add", "a", "url", "scheme", "to", "this", "endpoint", ".", "It", "takes", "a", "url", "string", "and", "create", "the", "OEmbedUrlScheme", "object", "internally", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L240-L254
train
Adds a url scheme to this endpoint. It takes a url string and create an OEmbedUrlScheme object internally.
abarmat/python-oembed
oembed/__init__.py
OEmbedEndpoint.match
def match(self, url): ''' Try to find if url matches against any of the schemes within this endpoint. Args: url: The url to match against each scheme Returns: True if a matching scheme was found for the url, False otherwise ''' try: ...
python
def match(self, url): ''' Try to find if url matches against any of the schemes within this endpoint. Args: url: The url to match against each scheme Returns: True if a matching scheme was found for the url, False otherwise ''' try: ...
[ "def", "match", "(", "self", ",", "url", ")", ":", "try", ":", "urlSchemes", "=", "self", ".", "_urlSchemes", ".", "itervalues", "(", ")", "# Python 2", "except", "AttributeError", ":", "urlSchemes", "=", "self", ".", "_urlSchemes", ".", "values", "(", "...
Try to find if url matches against any of the schemes within this endpoint. Args: url: The url to match against each scheme Returns: True if a matching scheme was found for the url, False otherwise
[ "Try", "to", "find", "if", "url", "matches", "against", "any", "of", "the", "schemes", "within", "this", "endpoint", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L279-L298
train
Try to find if url matches against any of the schemes within this ArcGIS endpoint.
abarmat/python-oembed
oembed/__init__.py
OEmbedEndpoint.request
def request(self, url, **opt): ''' Format the input url and optional parameters, and provides the final url where to get the given resource. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: The complete ...
python
def request(self, url, **opt): ''' Format the input url and optional parameters, and provides the final url where to get the given resource. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: The complete ...
[ "def", "request", "(", "self", ",", "url", ",", "*", "*", "opt", ")", ":", "params", "=", "opt", "params", "[", "'url'", "]", "=", "url", "urlApi", "=", "self", ".", "_urlApi", "if", "'format'", "in", "params", "and", "self", ".", "_implicitFormat", ...
Format the input url and optional parameters, and provides the final url where to get the given resource. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: The complete url of the endpoint and resource.
[ "Format", "the", "input", "url", "and", "optional", "parameters", "and", "provides", "the", "final", "url", "where", "to", "get", "the", "given", "resource", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L300-L323
train
Format the input url and optional parameters and provides the final url of the endpoint and resource.
abarmat/python-oembed
oembed/__init__.py
OEmbedEndpoint.get
def get(self, url, **opt): ''' Convert the resource url to a complete url and then fetch the data from it. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: OEmbedResponse object according to data fetched...
python
def get(self, url, **opt): ''' Convert the resource url to a complete url and then fetch the data from it. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: OEmbedResponse object according to data fetched...
[ "def", "get", "(", "self", ",", "url", ",", "*", "*", "opt", ")", ":", "return", "self", ".", "fetch", "(", "self", ".", "request", "(", "url", ",", "*", "*", "opt", ")", ")" ]
Convert the resource url to a complete url and then fetch the data from it. Args: url: The url of an OEmbed resource. **opt: Parameters passed to the url. Returns: OEmbedResponse object according to data fetched
[ "Convert", "the", "resource", "url", "to", "a", "complete", "url", "and", "then", "fetch", "the", "data", "from", "it", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L325-L337
train
Fetch the data from the url and return the result.
abarmat/python-oembed
oembed/__init__.py
OEmbedEndpoint.fetch
def fetch(self, url): ''' Fetch url and create a response object according to the mime-type. Args: url: The url to fetch data from Returns: OEmbedResponse object according to data fetched ''' opener = self._urllib.build_opener() opener.ad...
python
def fetch(self, url): ''' Fetch url and create a response object according to the mime-type. Args: url: The url to fetch data from Returns: OEmbedResponse object according to data fetched ''' opener = self._urllib.build_opener() opener.ad...
[ "def", "fetch", "(", "self", ",", "url", ")", ":", "opener", "=", "self", ".", "_urllib", ".", "build_opener", "(", ")", "opener", ".", "addheaders", "=", "self", ".", "_requestHeaders", ".", "items", "(", ")", "response", "=", "opener", ".", "open", ...
Fetch url and create a response object according to the mime-type. Args: url: The url to fetch data from Returns: OEmbedResponse object according to data fetched
[ "Fetch", "url", "and", "create", "a", "response", "object", "according", "to", "the", "mime", "-", "type", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L339-L369
train
Fetch url and create a response object according to the mime - type.
abarmat/python-oembed
oembed/__init__.py
OEmbedConsumer.embed
def embed(self, url, format='json', **opt): ''' Get an OEmbedResponse from one of the providers configured in this consumer according to the resource url. Args: url: The url of the resource to get. format: Desired response format. **opt: Optional para...
python
def embed(self, url, format='json', **opt): ''' Get an OEmbedResponse from one of the providers configured in this consumer according to the resource url. Args: url: The url of the resource to get. format: Desired response format. **opt: Optional para...
[ "def", "embed", "(", "self", ",", "url", ",", "format", "=", "'json'", ",", "*", "*", "opt", ")", ":", "if", "format", "not", "in", "[", "'json'", ",", "'xml'", "]", ":", "raise", "OEmbedInvalidRequest", "(", "'Format must be json or xml'", ")", "opt", ...
Get an OEmbedResponse from one of the providers configured in this consumer according to the resource url. Args: url: The url of the resource to get. format: Desired response format. **opt: Optional parameters to pass in the url to the provider. Returns: ...
[ "Get", "an", "OEmbedResponse", "from", "one", "of", "the", "providers", "configured", "in", "this", "consumer", "according", "to", "the", "resource", "url", "." ]
bb3d14213e0ac91aa998af67182826b6f1529fe6
https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L488-L504
train
Get an OEmbedResponse object from one of the providers configured in this object.
lreis2415/PyGeoC
examples/ex03_run_taudem_functions.py
pitremove_example
def pitremove_example(): """run function of TauDEM, take pitremove as an example. Compare the max, min, and average of rawdem and filled DEM. The result will be:: RawDEM: Max: 284.07, Min: 139.11, Mean: 203.92 FilledDEM: Max: 284.07, Min: 139.11, Mean: 203.93 """ dem = '../tests/da...
python
def pitremove_example(): """run function of TauDEM, take pitremove as an example. Compare the max, min, and average of rawdem and filled DEM. The result will be:: RawDEM: Max: 284.07, Min: 139.11, Mean: 203.92 FilledDEM: Max: 284.07, Min: 139.11, Mean: 203.93 """ dem = '../tests/da...
[ "def", "pitremove_example", "(", ")", ":", "dem", "=", "'../tests/data/Jamaica_dem.tif'", "wp", "=", "'../tests/data/tmp_results'", "fel", "=", "'dem_pitremoved.tif'", "taudem_bin", "=", "None", "mpi_bin", "=", "None", "num_proc", "=", "2", "TauDEM", ".", "pitremove...
run function of TauDEM, take pitremove as an example. Compare the max, min, and average of rawdem and filled DEM. The result will be:: RawDEM: Max: 284.07, Min: 139.11, Mean: 203.92 FilledDEM: Max: 284.07, Min: 139.11, Mean: 203.93
[ "run", "function", "of", "TauDEM", "take", "pitremove", "as", "an", "example", ".", "Compare", "the", "max", "min", "and", "average", "of", "rawdem", "and", "filled", "DEM", ".", "The", "result", "will", "be", "::" ]
9a92d1a229bb74298e3c57f27c97079980b5f729
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex03_run_taudem_functions.py#L10-L34
train
run function of TauDEM take pitremove as an example. Compare the max min and average of rawDEM and filled DEM
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator.get_iterator_type
def get_iterator_type(script_settings, subscripts={}): """ figures out the iterator type based on the script settings and (optionally) subscripts Args: script_settings: iterator_type subscripts: subscripts Returns: """ if 'iterator_type' in scrip...
python
def get_iterator_type(script_settings, subscripts={}): """ figures out the iterator type based on the script settings and (optionally) subscripts Args: script_settings: iterator_type subscripts: subscripts Returns: """ if 'iterator_type' in scrip...
[ "def", "get_iterator_type", "(", "script_settings", ",", "subscripts", "=", "{", "}", ")", ":", "if", "'iterator_type'", "in", "script_settings", ":", "# figure out the iterator type", "if", "script_settings", "[", "'iterator_type'", "]", "==", "'Loop'", ":", "itera...
figures out the iterator type based on the script settings and (optionally) subscripts Args: script_settings: iterator_type subscripts: subscripts Returns:
[ "figures", "out", "the", "iterator", "type", "based", "on", "the", "script", "settings", "and", "(", "optionally", ")", "subscripts", "Args", ":", "script_settings", ":", "iterator_type", "subscripts", ":", "subscripts", "Returns", ":" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L66-L93
train
returns the iterator type based on the script settings and subscripts
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator._function
def _function(self): ''' Runs either a loop or a parameter sweep over the subscripts in the order defined by the parameter_list 'script_order' ''' def get_sweep_parameters(): """ Returns: the paramter values over which to sweep """ #in both...
python
def _function(self): ''' Runs either a loop or a parameter sweep over the subscripts in the order defined by the parameter_list 'script_order' ''' def get_sweep_parameters(): """ Returns: the paramter values over which to sweep """ #in both...
[ "def", "_function", "(", "self", ")", ":", "def", "get_sweep_parameters", "(", ")", ":", "\"\"\"\n Returns: the paramter values over which to sweep\n \"\"\"", "#in both cases, param values have tolist to make sure that they are python types (ex float) rather than numpy"...
Runs either a loop or a parameter sweep over the subscripts in the order defined by the parameter_list 'script_order'
[ "Runs", "either", "a", "loop", "or", "a", "parameter", "sweep", "over", "the", "subscripts", "in", "the", "order", "defined", "by", "the", "parameter_list", "script_order" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L95-L249
train
This is the main function that runs the sweep over the subscripts of the current resource.
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator._receive_signal
def _receive_signal(self, progress_subscript): """ this function takes care of signals emitted by the subscripts Args: progress_subscript: progress of subscript """ self.progress = self._estimate_progress() self.updateProgress.emit(int(self.progress))
python
def _receive_signal(self, progress_subscript): """ this function takes care of signals emitted by the subscripts Args: progress_subscript: progress of subscript """ self.progress = self._estimate_progress() self.updateProgress.emit(int(self.progress))
[ "def", "_receive_signal", "(", "self", ",", "progress_subscript", ")", ":", "self", ".", "progress", "=", "self", ".", "_estimate_progress", "(", ")", "self", ".", "updateProgress", ".", "emit", "(", "int", "(", "self", ".", "progress", ")", ")" ]
this function takes care of signals emitted by the subscripts Args: progress_subscript: progress of subscript
[ "this", "function", "takes", "care", "of", "signals", "emitted", "by", "the", "subscripts", "Args", ":", "progress_subscript", ":", "progress", "of", "subscript" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L351-L359
train
This function is called by the _process_signal_subscript method to update the internal progress of the current process.
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator.to_dict
def to_dict(self): """ Returns: itself as a dictionary """ dictator = Script.to_dict(self) # the dynamically created ScriptIterator classes have a generic name # replace this with ScriptIterator to indicate that this class is of type ScriptIterator dictator[self.n...
python
def to_dict(self): """ Returns: itself as a dictionary """ dictator = Script.to_dict(self) # the dynamically created ScriptIterator classes have a generic name # replace this with ScriptIterator to indicate that this class is of type ScriptIterator dictator[self.n...
[ "def", "to_dict", "(", "self", ")", ":", "dictator", "=", "Script", ".", "to_dict", "(", "self", ")", "# the dynamically created ScriptIterator classes have a generic name", "# replace this with ScriptIterator to indicate that this class is of type ScriptIterator", "dictator", "[",...
Returns: itself as a dictionary
[ "Returns", ":", "itself", "as", "a", "dictionary" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L405-L414
train
Returns itself as a dictionary
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator.create_dynamic_script_class
def create_dynamic_script_class(script_information, script_iterators={},verbose=False): ''' creates all the dynamic classes in the script and the class of the script itself and updates the script info with these new classes Args: script_information: A dictionary describing t...
python
def create_dynamic_script_class(script_information, script_iterators={},verbose=False): ''' creates all the dynamic classes in the script and the class of the script itself and updates the script info with these new classes Args: script_information: A dictionary describing t...
[ "def", "create_dynamic_script_class", "(", "script_information", ",", "script_iterators", "=", "{", "}", ",", "verbose", "=", "False", ")", ":", "def", "set_up_dynamic_script", "(", "script_information", ",", "script_iterators", ",", "verbose", "=", "verbose", ")", ...
creates all the dynamic classes in the script and the class of the script itself and updates the script info with these new classes Args: script_information: A dictionary describing the ScriptIterator, or an existing object script_iterators: dictionary with the scriptiterators (...
[ "creates", "all", "the", "dynamic", "classes", "in", "the", "script", "and", "the", "class", "of", "the", "script", "itself", "and", "updates", "the", "script", "info", "with", "these", "new", "classes" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L566-L772
train
Create the dynamic class of the class containing the scripts in the scriptIterator.
LISE-B26/pylabcontrol
pylabcontrol/core/script_iterator.py
ScriptIterator.get_script_iterator
def get_script_iterator(package_name, verbose = False): """ Args: package_name: name of package Returns: the script_iterators of the package as a dictionary """ packs = hf.explore_package(package_name + '.core') print(packs) script_iterator = {} ...
python
def get_script_iterator(package_name, verbose = False): """ Args: package_name: name of package Returns: the script_iterators of the package as a dictionary """ packs = hf.explore_package(package_name + '.core') print(packs) script_iterator = {} ...
[ "def", "get_script_iterator", "(", "package_name", ",", "verbose", "=", "False", ")", ":", "packs", "=", "hf", ".", "explore_package", "(", "package_name", "+", "'.core'", ")", "print", "(", "packs", ")", "script_iterator", "=", "{", "}", "for", "p", "in",...
Args: package_name: name of package Returns: the script_iterators of the package as a dictionary
[ "Args", ":", "package_name", ":", "name", "of", "package" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/core/script_iterator.py#L775-L797
train
Returns the script iterators of the given package as a dictionary.
sastrarobotics/pyHerkulex
herkulex.py
connect
def connect(portname, baudrate): """ Connect to the Herkulex bus Connect to serial port to which Herkulex Servos are attatched Args: portname (str): The serial port name baudrate (int): The serial port baudrate Raises: SerialException: Error occured while opening serial port ...
python
def connect(portname, baudrate): """ Connect to the Herkulex bus Connect to serial port to which Herkulex Servos are attatched Args: portname (str): The serial port name baudrate (int): The serial port baudrate Raises: SerialException: Error occured while opening serial port ...
[ "def", "connect", "(", "portname", ",", "baudrate", ")", ":", "global", "SERPORT", "try", ":", "SERPORT", "=", "serial", ".", "Serial", "(", "portname", ",", "baudrate", ",", "timeout", "=", "0.1", ")", "except", ":", "raise", "HerkulexError", "(", "\"co...
Connect to the Herkulex bus Connect to serial port to which Herkulex Servos are attatched Args: portname (str): The serial port name baudrate (int): The serial port baudrate Raises: SerialException: Error occured while opening serial port
[ "Connect", "to", "the", "Herkulex", "bus" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L152-L168
train
Connect to the Herkulex bus and return the object that represents the Herkulex object
sastrarobotics/pyHerkulex
herkulex.py
checksum1
def checksum1(data, stringlength): """ Calculate Checksum 1 Calculate the ckecksum 1 required for the herkulex data packet Args: data (list): the data of which checksum is to be calculated stringlength (int): the length of the data Returns: int: The calculated checksum 1 ...
python
def checksum1(data, stringlength): """ Calculate Checksum 1 Calculate the ckecksum 1 required for the herkulex data packet Args: data (list): the data of which checksum is to be calculated stringlength (int): the length of the data Returns: int: The calculated checksum 1 ...
[ "def", "checksum1", "(", "data", ",", "stringlength", ")", ":", "value_buffer", "=", "0", "for", "count", "in", "range", "(", "0", ",", "stringlength", ")", ":", "value_buffer", "=", "value_buffer", "^", "data", "[", "count", "]", "return", "value_buffer",...
Calculate Checksum 1 Calculate the ckecksum 1 required for the herkulex data packet Args: data (list): the data of which checksum is to be calculated stringlength (int): the length of the data Returns: int: The calculated checksum 1
[ "Calculate", "Checksum", "1" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L184-L199
train
Calculate the checksum 1 required for the herkulex data packet
sastrarobotics/pyHerkulex
herkulex.py
send_data
def send_data(data): """ Send data to herkulex Paketize & write the packet to serial port Args: data (list): the data to be sent Raises: SerialException: Error occured while opening serial port """ datalength = len(data) csm1 = checksum1(data, datalength) csm2 = checks...
python
def send_data(data): """ Send data to herkulex Paketize & write the packet to serial port Args: data (list): the data to be sent Raises: SerialException: Error occured while opening serial port """ datalength = len(data) csm1 = checksum1(data, datalength) csm2 = checks...
[ "def", "send_data", "(", "data", ")", ":", "datalength", "=", "len", "(", "data", ")", "csm1", "=", "checksum1", "(", "data", ",", "datalength", ")", "csm2", "=", "checksum2", "(", "csm1", ")", "data", ".", "insert", "(", "0", ",", "0xFF", ")", "da...
Send data to herkulex Paketize & write the packet to serial port Args: data (list): the data to be sent Raises: SerialException: Error occured while opening serial port
[ "Send", "data", "to", "herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L216-L245
train
Send data to the herkulex Paketize & write the packet to the serial port
sastrarobotics/pyHerkulex
herkulex.py
clear_errors
def clear_errors(): """ Clears the errors register of all Herkulex servos Args: none """ data = [] data.append(0x0B) data.append(BROADCAST_ID) data.append(RAM_WRITE_REQ) data.append(STATUS_ERROR_RAM) data.append(BYTE2) data.append(0x00) data.append(0x00) send_da...
python
def clear_errors(): """ Clears the errors register of all Herkulex servos Args: none """ data = [] data.append(0x0B) data.append(BROADCAST_ID) data.append(RAM_WRITE_REQ) data.append(STATUS_ERROR_RAM) data.append(BYTE2) data.append(0x00) data.append(0x00) send_da...
[ "def", "clear_errors", "(", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x0B", ")", "data", ".", "append", "(", "BROADCAST_ID", ")", "data", ".", "append", "(", "RAM_WRITE_REQ", ")", "data", ".", "append", "(", "STATUS_ERROR_RAM", ")"...
Clears the errors register of all Herkulex servos Args: none
[ "Clears", "the", "errors", "register", "of", "all", "Herkulex", "servos" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L248-L263
train
Clears the errors register of all Herkulex servos.
sastrarobotics/pyHerkulex
herkulex.py
scale
def scale(input_value, input_min, input_max, out_min, out_max): """ scale a value from one range to another """ # Figure out how 'wide' each range is input_span = input_max - input_min output_span = out_max - out_min # Convert the left range into a 0-1 range (float) valuescaled = float(input...
python
def scale(input_value, input_min, input_max, out_min, out_max): """ scale a value from one range to another """ # Figure out how 'wide' each range is input_span = input_max - input_min output_span = out_max - out_min # Convert the left range into a 0-1 range (float) valuescaled = float(input...
[ "def", "scale", "(", "input_value", ",", "input_min", ",", "input_max", ",", "out_min", ",", "out_max", ")", ":", "# Figure out how 'wide' each range is", "input_span", "=", "input_max", "-", "input_min", "output_span", "=", "out_max", "-", "out_min", "# Convert the...
scale a value from one range to another
[ "scale", "a", "value", "from", "one", "range", "to", "another" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L265-L274
train
scale a value from one range to another range
sastrarobotics/pyHerkulex
herkulex.py
scan_servos
def scan_servos(): """Scan for the herkulex servos connected This function will scan for all the herkulex servos connected to the bus. Args: none Returns: list: a list of tuples of the form [(id, model)] """ servos = [] for servo_id in range(0x00, 0xFE): model = get_model(servo_id)...
python
def scan_servos(): """Scan for the herkulex servos connected This function will scan for all the herkulex servos connected to the bus. Args: none Returns: list: a list of tuples of the form [(id, model)] """ servos = [] for servo_id in range(0x00, 0xFE): model = get_model(servo_id)...
[ "def", "scan_servos", "(", ")", ":", "servos", "=", "[", "]", "for", "servo_id", "in", "range", "(", "0x00", ",", "0xFE", ")", ":", "model", "=", "get_model", "(", "servo_id", ")", "if", "model", ":", "servos", "+=", "[", "(", "servo_id", ",", "mod...
Scan for the herkulex servos connected This function will scan for all the herkulex servos connected to the bus. Args: none Returns: list: a list of tuples of the form [(id, model)]
[ "Scan", "for", "the", "herkulex", "servos", "connected" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L276-L293
train
This function scans for the herkulex servos connected to the bus and returns a list of tuples of the form [ id model )
sastrarobotics/pyHerkulex
herkulex.py
get_model
def get_model(servoid): """ Get the servo model This function gets the model of the herkules servo, provided its id Args: servoid(int): the id of the servo Returns: int: an integer corresponding to the model number 0x06 for DRS-602 0x04 for DRS-402 ...
python
def get_model(servoid): """ Get the servo model This function gets the model of the herkules servo, provided its id Args: servoid(int): the id of the servo Returns: int: an integer corresponding to the model number 0x06 for DRS-602 0x04 for DRS-402 ...
[ "def", "get_model", "(", "servoid", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "servoid", ")", "data", ".", "append", "(", "EEP_READ_REQ", ")", "data", ".", "append", "(", "MODEL_NO1_EEP", ")...
Get the servo model This function gets the model of the herkules servo, provided its id Args: servoid(int): the id of the servo Returns: int: an integer corresponding to the model number 0x06 for DRS-602 0x04 for DRS-402 0x02 for DRS-202
[ "Get", "the", "servo", "model" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L295-L321
train
This function gets the model of the servo
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_status
def get_servo_status(self): """ Get the error status of servo This function gets the error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet """ data = [] ...
python
def get_servo_status(self): """ Get the error status of servo This function gets the error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet """ data = [] ...
[ "def", "get_servo_status", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", ...
Get the error status of servo This function gets the error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet
[ "Get", "the", "error", "status", "of", "servo" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L379-L405
train
This function returns the error status of the servo
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_status_detail
def get_servo_status_detail(self): """ Get the detailed error status of servo This function gets the detailed error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet ...
python
def get_servo_status_detail(self): """ Get the detailed error status of servo This function gets the detailed error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet ...
[ "def", "get_servo_status_detail", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", ...
Get the detailed error status of servo This function gets the detailed error status (if any) of the servo Args: none Returns: int: an integer corresponding to the servo status * refer datasheet
[ "Get", "the", "detailed", "error", "status", "of", "servo" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L407-L433
train
This function returns the ultimate detailed error status of the servo
sastrarobotics/pyHerkulex
herkulex.py
servo.set_led
def set_led(self, colorcode): """ Set the LED Color of Herkulex Args: colorcode (int): The code for colors (0x00-OFF 0x02-BLUE 0x03-CYAN 0x04-RED ...
python
def set_led(self, colorcode): """ Set the LED Color of Herkulex Args: colorcode (int): The code for colors (0x00-OFF 0x02-BLUE 0x03-CYAN 0x04-RED ...
[ "def", "set_led", "(", "self", ",", "colorcode", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x0A", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_WRITE_REQ", ")", "data", ".", "appe...
Set the LED Color of Herkulex Args: colorcode (int): The code for colors (0x00-OFF 0x02-BLUE 0x03-CYAN 0x04-RED 0x05-ORANGE 0x...
[ "Set", "the", "LED", "Color", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L435-L455
train
Set the LED Color of Herkulex
sastrarobotics/pyHerkulex
herkulex.py
servo.brake_on
def brake_on(self): """ Set the Brakes of Herkulex In braked mode, position control and velocity control will not work, enable torque before that Args: none """ data = [] data.append(0x0A) data.append(self.servoid) data.append(RAM_WRI...
python
def brake_on(self): """ Set the Brakes of Herkulex In braked mode, position control and velocity control will not work, enable torque before that Args: none """ data = [] data.append(0x0A) data.append(self.servoid) data.append(RAM_WRI...
[ "def", "brake_on", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x0A", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_WRITE_REQ", ")", "data", ".", "append", "(", "TORQUE...
Set the Brakes of Herkulex In braked mode, position control and velocity control will not work, enable torque before that Args: none
[ "Set", "the", "Brakes", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L457-L473
train
Set the Brakes of Herkulex in braked mode.
sastrarobotics/pyHerkulex
herkulex.py
servo.torque_off
def torque_off(self): """ Set the torques of Herkulex to zero In this mode, position control and velocity control will not work, enable torque before that. Also the servo shaft is freely movable Args: none """ data = [] data.append(0x0A) ...
python
def torque_off(self): """ Set the torques of Herkulex to zero In this mode, position control and velocity control will not work, enable torque before that. Also the servo shaft is freely movable Args: none """ data = [] data.append(0x0A) ...
[ "def", "torque_off", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x0A", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_WRITE_REQ", ")", "data", ".", "append", "(", "TORQ...
Set the torques of Herkulex to zero In this mode, position control and velocity control will not work, enable torque before that. Also the servo shaft is freely movable Args: none
[ "Set", "the", "torques", "of", "Herkulex", "to", "zero" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L475-L492
train
Set the torques of Herkulex to zero.
sastrarobotics/pyHerkulex
herkulex.py
servo.torque_on
def torque_on(self): """ Enable the torques of Herkulex In this mode, position control and velocity control will work. Args: none """ data = [] data.append(0x0A) data.append(self.servoid) data.append(RAM_WRITE_REQ) data.append...
python
def torque_on(self): """ Enable the torques of Herkulex In this mode, position control and velocity control will work. Args: none """ data = [] data.append(0x0A) data.append(self.servoid) data.append(RAM_WRITE_REQ) data.append...
[ "def", "torque_on", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x0A", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_WRITE_REQ", ")", "data", ".", "append", "(", "TORQU...
Enable the torques of Herkulex In this mode, position control and velocity control will work. Args: none
[ "Enable", "the", "torques", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L494-L510
train
Enable the torques of Herkulex in this mode.
sastrarobotics/pyHerkulex
herkulex.py
servo.get_torque_state
def get_torque_state(self): """ get the torque state of motor Returns: bool: True if torque is enabled, else False """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(TORQUE_CONTROL_RAM) data...
python
def get_torque_state(self): """ get the torque state of motor Returns: bool: True if torque is enabled, else False """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(TORQUE_CONTROL_RAM) data...
[ "def", "get_torque_state", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", ...
get the torque state of motor Returns: bool: True if torque is enabled, else False
[ "get", "the", "torque", "state", "of", "motor" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L512-L530
train
get the torque state of motor
sastrarobotics/pyHerkulex
herkulex.py
servo.set_servo_position
def set_servo_position(self, goalposition, goaltime, led): """ Set the position of Herkulex Enable torque using torque_on function before calling this Args: goalposition (int): The desired position, min-0 & max-1023 goaltime (int): the time taken to move from present ...
python
def set_servo_position(self, goalposition, goaltime, led): """ Set the position of Herkulex Enable torque using torque_on function before calling this Args: goalposition (int): The desired position, min-0 & max-1023 goaltime (int): the time taken to move from present ...
[ "def", "set_servo_position", "(", "self", ",", "goalposition", ",", "goaltime", ",", "led", ")", ":", "goalposition_msb", "=", "int", "(", "goalposition", ")", ">>", "8", "goalposition_lsb", "=", "int", "(", "goalposition", ")", "&", "0xff", "data", "=", "...
Set the position of Herkulex Enable torque using torque_on function before calling this Args: goalposition (int): The desired position, min-0 & max-1023 goaltime (int): the time taken to move from present position to goalposition led (int): the LED col...
[ "Set", "the", "position", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L532-L560
train
Set the position of the servo in the specified time range.
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_position
def get_servo_position(self): """ Gets the current position of Herkulex Args: none Returns: int: position of the servo- 0 to 1023 Raises: SerialException: Error occured while opening serial port """ #global SERPORT data = [...
python
def get_servo_position(self): """ Gets the current position of Herkulex Args: none Returns: int: position of the servo- 0 to 1023 Raises: SerialException: Error occured while opening serial port """ #global SERPORT data = [...
[ "def", "get_servo_position", "(", "self", ")", ":", "#global SERPORT", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", "."...
Gets the current position of Herkulex Args: none Returns: int: position of the servo- 0 to 1023 Raises: SerialException: Error occured while opening serial port
[ "Gets", "the", "current", "position", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L562-L594
train
Gets the current position of the Herkulex.
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_temperature
def get_servo_temperature(self): """ Gets the current temperature of Herkulex Args: none Returns: int: the current temperature register of Herkulex Raises: SerialException: Error occured while opening serial port """ data = [] ...
python
def get_servo_temperature(self): """ Gets the current temperature of Herkulex Args: none Returns: int: the current temperature register of Herkulex Raises: SerialException: Error occured while opening serial port """ data = [] ...
[ "def", "get_servo_temperature", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(...
Gets the current temperature of Herkulex Args: none Returns: int: the current temperature register of Herkulex Raises: SerialException: Error occured while opening serial port
[ "Gets", "the", "current", "temperature", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L596-L621
train
Gets the current temperature of Herkulex
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_torque
def get_servo_torque(self): """ Gets the current torque of Herkulex Gives the current load on the servo shaft. It is actually the PWM value to the motors Args: none Returns: int: the torque on servo shaft. range from -1023 to 1023 Raises: ...
python
def get_servo_torque(self): """ Gets the current torque of Herkulex Gives the current load on the servo shaft. It is actually the PWM value to the motors Args: none Returns: int: the torque on servo shaft. range from -1023 to 1023 Raises: ...
[ "def", "get_servo_torque", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", ...
Gets the current torque of Herkulex Gives the current load on the servo shaft. It is actually the PWM value to the motors Args: none Returns: int: the torque on servo shaft. range from -1023 to 1023 Raises: SerialException: Error occured wh...
[ "Gets", "the", "current", "torque", "of", "Herkulex" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L623-L654
train
Gets the current torque of Herkulex.
sastrarobotics/pyHerkulex
herkulex.py
servo.set_servo_speed
def set_servo_speed(self, goalspeed, led): """ Set the Herkulex in continuous rotation mode Args: goalspeed (int): the speed , range -1023 to 1023 led (int): the LED color 0x00 LED off 0x04 GREEN 0x08 BLUE ...
python
def set_servo_speed(self, goalspeed, led): """ Set the Herkulex in continuous rotation mode Args: goalspeed (int): the speed , range -1023 to 1023 led (int): the LED color 0x00 LED off 0x04 GREEN 0x08 BLUE ...
[ "def", "set_servo_speed", "(", "self", ",", "goalspeed", ",", "led", ")", ":", "if", "goalspeed", ">", "0", ":", "goalspeed_msb", "=", "(", "int", "(", "goalspeed", ")", "&", "0xFF00", ")", ">>", "8", "goalspeed_lsb", "=", "int", "(", "goalspeed", ")",...
Set the Herkulex in continuous rotation mode Args: goalspeed (int): the speed , range -1023 to 1023 led (int): the LED color 0x00 LED off 0x04 GREEN 0x08 BLUE 0x10 RED
[ "Set", "the", "Herkulex", "in", "continuous", "rotation", "mode" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L656-L686
train
Set the Herkulex in continuous rotation mode.
sastrarobotics/pyHerkulex
herkulex.py
servo.set_position_p
def set_position_p(self, pvalue): """ Set the P gain of the position PID Args: pvalue (int): P value """ pvalue_msb = int(pvalue) >> 8 pvalue_lsb = int(pvalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(...
python
def set_position_p(self, pvalue): """ Set the P gain of the position PID Args: pvalue (int): P value """ pvalue_msb = int(pvalue) >> 8 pvalue_lsb = int(pvalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(...
[ "def", "set_position_p", "(", "self", ",", "pvalue", ")", ":", "pvalue_msb", "=", "int", "(", "pvalue", ")", ">>", "8", "pvalue_lsb", "=", "int", "(", "pvalue", ")", "&", "0xff", "data", "=", "[", "]", "data", ".", "append", "(", "0x0B", ")", "data...
Set the P gain of the position PID Args: pvalue (int): P value
[ "Set", "the", "P", "gain", "of", "the", "position", "PID" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L688-L705
train
Set the P gain of the ethernet ethernet
sastrarobotics/pyHerkulex
herkulex.py
servo.set_position_i
def set_position_i(self, ivalue): """ Set the I gain of the position PID Args: ivalue (int): I value """ ivalue_msb = int(ivalue) >> 8 ivalue_lsb = int(ivalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(R...
python
def set_position_i(self, ivalue): """ Set the I gain of the position PID Args: ivalue (int): I value """ ivalue_msb = int(ivalue) >> 8 ivalue_lsb = int(ivalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(R...
[ "def", "set_position_i", "(", "self", ",", "ivalue", ")", ":", "ivalue_msb", "=", "int", "(", "ivalue", ")", ">>", "8", "ivalue_lsb", "=", "int", "(", "ivalue", ")", "&", "0xff", "data", "=", "[", "]", "data", ".", "append", "(", "0x0B", ")", "data...
Set the I gain of the position PID Args: ivalue (int): I value
[ "Set", "the", "I", "gain", "of", "the", "position", "PID" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L707-L724
train
Set the I gain of the position PID
sastrarobotics/pyHerkulex
herkulex.py
servo.set_position_d
def set_position_d(self, dvalue): """ Set the D gain of the PID Args: dvalue (int): D value """ dvalue_msb = int(dvalue) >> 8 dvalue_lsb = int(dvalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(RAM_WRITE_R...
python
def set_position_d(self, dvalue): """ Set the D gain of the PID Args: dvalue (int): D value """ dvalue_msb = int(dvalue) >> 8 dvalue_lsb = int(dvalue) & 0xff data = [] data.append(0x0B) data.append(self.servoid) data.append(RAM_WRITE_R...
[ "def", "set_position_d", "(", "self", ",", "dvalue", ")", ":", "dvalue_msb", "=", "int", "(", "dvalue", ")", ">>", "8", "dvalue_lsb", "=", "int", "(", "dvalue", ")", "&", "0xff", "data", "=", "[", "]", "data", ".", "append", "(", "0x0B", ")", "data...
Set the D gain of the PID Args: dvalue (int): D value
[ "Set", "the", "D", "gain", "of", "the", "PID" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L726-L742
train
Set the D gain of the PID
sastrarobotics/pyHerkulex
herkulex.py
servo.get_position_p
def get_position_p(self): """ Get the P value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KP_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
python
def get_position_p(self): """ Get the P value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KP_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
[ "def", "get_position_p", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", "P...
Get the P value of the current PID for position
[ "Get", "the", "P", "value", "of", "the", "current", "PID", "for", "position" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L744-L760
train
Get the P value of the current PID for position
sastrarobotics/pyHerkulex
herkulex.py
servo.get_position_i
def get_position_i(self): """ Get the I value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KI_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
python
def get_position_i(self): """ Get the I value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KI_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
[ "def", "get_position_i", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", "P...
Get the I value of the current PID for position
[ "Get", "the", "I", "value", "of", "the", "current", "PID", "for", "position" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L762-L778
train
Get the I value of the current PID for position
sastrarobotics/pyHerkulex
herkulex.py
servo.get_position_d
def get_position_d(self): """ Get the D value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KD_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
python
def get_position_d(self): """ Get the D value of the current PID for position """ data = [] data.append(0x09) data.append(self.servoid) data.append(RAM_READ_REQ) data.append(POSITION_KD_RAM) data.append(BYTE2) send_data(data) rxdata = [] ...
[ "def", "get_position_d", "(", "self", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "0x09", ")", "data", ".", "append", "(", "self", ".", "servoid", ")", "data", ".", "append", "(", "RAM_READ_REQ", ")", "data", ".", "append", "(", "P...
Get the D value of the current PID for position
[ "Get", "the", "D", "value", "of", "the", "current", "PID", "for", "position" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L780-L796
train
Get the D value of the current PID for position
sastrarobotics/pyHerkulex
herkulex.py
servo.save_pid_eeprom
def save_pid_eeprom(self): """ saves the PID values from RAM to EEPROM """ pval = self.get_position_p() ival = self.get_position_i() dval = self.get_position_d() #write P value pvalue_msb = int(pval) >> 8 pvalue_lsb = int(pval) & 0xff data_p = [...
python
def save_pid_eeprom(self): """ saves the PID values from RAM to EEPROM """ pval = self.get_position_p() ival = self.get_position_i() dval = self.get_position_d() #write P value pvalue_msb = int(pval) >> 8 pvalue_lsb = int(pval) & 0xff data_p = [...
[ "def", "save_pid_eeprom", "(", "self", ")", ":", "pval", "=", "self", ".", "get_position_p", "(", ")", "ival", "=", "self", ".", "get_position_i", "(", ")", "dval", "=", "self", ".", "get_position_d", "(", ")", "#write P value", "pvalue_msb", "=", "int", ...
saves the PID values from RAM to EEPROM
[ "saves", "the", "PID", "values", "from", "RAM", "to", "EEPROM" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L798-L846
train
Saves the PID values from RAM to EEPROM.
sastrarobotics/pyHerkulex
herkulex.py
servo.set_servo_angle
def set_servo_angle(self, goalangle, goaltime, led): """ Sets the servo angle (in degrees) Enable torque using torque_on function before calling this Args: goalangle (int): The desired angle in degrees, range -150 to 150 goaltime (int): the time taken to move from prese...
python
def set_servo_angle(self, goalangle, goaltime, led): """ Sets the servo angle (in degrees) Enable torque using torque_on function before calling this Args: goalangle (int): The desired angle in degrees, range -150 to 150 goaltime (int): the time taken to move from prese...
[ "def", "set_servo_angle", "(", "self", ",", "goalangle", ",", "goaltime", ",", "led", ")", ":", "if", "(", "self", ".", "servomodel", "==", "0x06", ")", "or", "(", "self", ".", "servomodel", "==", "0x04", ")", ":", "goalposition", "=", "scale", "(", ...
Sets the servo angle (in degrees) Enable torque using torque_on function before calling this Args: goalangle (int): The desired angle in degrees, range -150 to 150 goaltime (int): the time taken to move from present position to goalposition led (int): t...
[ "Sets", "the", "servo", "angle", "(", "in", "degrees", ")" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L848-L868
train
Sets the servo angle in degrees.
sastrarobotics/pyHerkulex
herkulex.py
servo.get_servo_angle
def get_servo_angle(self): """ Gets the current angle of the servo in degrees Args: none Returns: int : the current servo angle """ servoposition = self.get_servo_position() if (self.servomodel==0x06) or (self.servomodel == 0x04): re...
python
def get_servo_angle(self): """ Gets the current angle of the servo in degrees Args: none Returns: int : the current servo angle """ servoposition = self.get_servo_position() if (self.servomodel==0x06) or (self.servomodel == 0x04): re...
[ "def", "get_servo_angle", "(", "self", ")", ":", "servoposition", "=", "self", ".", "get_servo_position", "(", ")", "if", "(", "self", ".", "servomodel", "==", "0x06", ")", "or", "(", "self", ".", "servomodel", "==", "0x04", ")", ":", "return", "scale", ...
Gets the current angle of the servo in degrees Args: none Returns: int : the current servo angle
[ "Gets", "the", "current", "angle", "of", "the", "servo", "in", "degrees" ]
3a42046cbfea8c7e343a04f42facba5e7bca570e
https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L870-L883
train
Gets the current angle of the servo in degrees
johnnoone/json-spec
src/jsonspec/cli.py
disable_logging
def disable_logging(func): return func """ Temporary disable logging. """ handler = logging.NullHandler() @wraps(func) def wrapper(*args, **kwargs): logger = logging.getLogger() logger.addHandler(handler) resp = func(*args, **kwargs) logger.removeHandler(hand...
python
def disable_logging(func): return func """ Temporary disable logging. """ handler = logging.NullHandler() @wraps(func) def wrapper(*args, **kwargs): logger = logging.getLogger() logger.addHandler(handler) resp = func(*args, **kwargs) logger.removeHandler(hand...
[ "def", "disable_logging", "(", "func", ")", ":", "return", "func", "handler", "=", "logging", ".", "NullHandler", "(", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", "=", "logging...
Temporary disable logging.
[ "Temporary", "disable", "logging", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/cli.py#L28-L42
train
Disable logging.
johnnoone/json-spec
src/jsonspec/cli.py
format_output
def format_output(func): return func """ Format output. """ @wraps(func) def wrapper(*args, **kwargs): try: response = func(*args, **kwargs) except Exception as error: print(colored(error, 'red'), file=sys.stderr) sys.exit(1) else: ...
python
def format_output(func): return func """ Format output. """ @wraps(func) def wrapper(*args, **kwargs): try: response = func(*args, **kwargs) except Exception as error: print(colored(error, 'red'), file=sys.stderr) sys.exit(1) else: ...
[ "def", "format_output", "(", "func", ")", ":", "return", "func", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "response", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs"...
Format output.
[ "Format", "output", "." ]
f91981724cea0c366bd42a6670eb07bbe31c0e0c
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/cli.py#L45-L61
train
A decorator that returns a function that formats the output of the passed in function.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_probes.py
ReadProbes.run
def run(self): """ this is the actual execution of the ReadProbes thread: continuously read values from the probes """ if self.probes is None: self._stop = True while True: if self._stop: break self.probes_values = { ...
python
def run(self): """ this is the actual execution of the ReadProbes thread: continuously read values from the probes """ if self.probes is None: self._stop = True while True: if self._stop: break self.probes_values = { ...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "probes", "is", "None", ":", "self", ".", "_stop", "=", "True", "while", "True", ":", "if", "self", ".", "_stop", ":", "break", "self", ".", "probes_values", "=", "{", "instrument_name", ":", ...
this is the actual execution of the ReadProbes thread: continuously read values from the probes
[ "this", "is", "the", "actual", "execution", "of", "the", "ReadProbes", "thread", ":", "continuously", "read", "values", "from", "the", "probes" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_probes.py#L49-L68
train
This method is the main thread that reads values from the probes_values attribute of the class.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_probes.py
ReadProbes.start
def start(self, *args, **kwargs): """ start the read_probe thread """ self._stop = False super(ReadProbes, self).start(*args, **kwargs)
python
def start(self, *args, **kwargs): """ start the read_probe thread """ self._stop = False super(ReadProbes, self).start(*args, **kwargs)
[ "def", "start", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_stop", "=", "False", "super", "(", "ReadProbes", ",", "self", ")", ".", "start", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
start the read_probe thread
[ "start", "the", "read_probe", "thread" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_probes.py#L70-L75
train
start the read probe thread
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_probes.py
ReadProbes.quit
def quit(self, *args, **kwargs): # real signature unknown """ quit the read_probe thread """ self._stop = True super(ReadProbes, self).quit(*args, **kwargs)
python
def quit(self, *args, **kwargs): # real signature unknown """ quit the read_probe thread """ self._stop = True super(ReadProbes, self).quit(*args, **kwargs)
[ "def", "quit", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# real signature unknown", "self", ".", "_stop", "=", "True", "super", "(", "ReadProbes", ",", "self", ")", ".", "quit", "(", "*", "args", ",", "*", "*", "kwargs", ")...
quit the read_probe thread
[ "quit", "the", "read_probe", "thread" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_probes.py#L78-L83
train
quit the read probe thread
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script._set_current_subscript
def _set_current_subscript(self, active): """ sets the current subscript and keeps a counter of how ofter a particular subscript has been executed this information is usefull when implementing a status update or plotting functions that depend on which subscript is being executed keeps t...
python
def _set_current_subscript(self, active): """ sets the current subscript and keeps a counter of how ofter a particular subscript has been executed this information is usefull when implementing a status update or plotting functions that depend on which subscript is being executed keeps t...
[ "def", "_set_current_subscript", "(", "self", ",", "active", ")", ":", "current_subscript", "=", "self", ".", "sender", "(", ")", "if", "active", ":", "for", "subscript_name", "in", "list", "(", "self", ".", "_current_subscript_stage", "[", "'subscript_exec_coun...
sets the current subscript and keeps a counter of how ofter a particular subscript has been executed this information is usefull when implementing a status update or plotting functions that depend on which subscript is being executed keeps track of the following dictionary: self._current_subscr...
[ "sets", "the", "current", "subscript", "and", "keeps", "a", "counter", "of", "how", "ofter", "a", "particular", "subscript", "has", "been", "executed", "this", "information", "is", "usefull", "when", "implementing", "a", "status", "update", "or", "plotting", "...
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L147-L185
train
Sets the current subscript and keeps a counter of how often a particular subscript has been executed and keeps a counter of how often a particular subscript has been executed.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.log
def log(self, string): """ appends input string to log file and sends it to log function (self.log_function) Returns: """ self.log_data.append(string) if self.log_function is None: print(string) else: self.log_function(string)
python
def log(self, string): """ appends input string to log file and sends it to log function (self.log_function) Returns: """ self.log_data.append(string) if self.log_function is None: print(string) else: self.log_function(string)
[ "def", "log", "(", "self", ",", "string", ")", ":", "self", ".", "log_data", ".", "append", "(", "string", ")", "if", "self", ".", "log_function", "is", "None", ":", "print", "(", "string", ")", "else", ":", "self", ".", "log_function", "(", "string"...
appends input string to log file and sends it to log function (self.log_function) Returns:
[ "appends", "input", "string", "to", "log", "file", "and", "sends", "it", "to", "log", "function", "(", "self", ".", "log_function", ")", "Returns", ":" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L198-L209
train
Append input string to log file and sends it to log function
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.update
def update(self, settings): ''' updates the internal dictionary Args: settings: parameters to be set # mabe in the future: # Returns: boolean that is true if update successful ''' if 'settings' in settings: self._settings.update(settings['...
python
def update(self, settings): ''' updates the internal dictionary Args: settings: parameters to be set # mabe in the future: # Returns: boolean that is true if update successful ''' if 'settings' in settings: self._settings.update(settings['...
[ "def", "update", "(", "self", ",", "settings", ")", ":", "if", "'settings'", "in", "settings", ":", "self", ".", "_settings", ".", "update", "(", "settings", "[", "'settings'", "]", ")", "else", ":", "self", ".", "_settings", ".", "update", "(", "setti...
updates the internal dictionary Args: settings: parameters to be set # mabe in the future: # Returns: boolean that is true if update successful
[ "updates", "the", "internal", "dictionary", "Args", ":", "settings", ":", "parameters", "to", "be", "set", "#", "mabe", "in", "the", "future", ":", "#", "Returns", ":", "boolean", "that", "is", "true", "if", "update", "successful" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L304-L324
train
Updates the internal dictionary with the given parameters.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.remaining_time
def remaining_time(self): """ estimates the time remaining until script is finished """ elapsed_time = (datetime.datetime.now() - self.start_time).total_seconds() # safety to avoid devision by zero if self.progress == 0: self.progress = 1 estimated_to...
python
def remaining_time(self): """ estimates the time remaining until script is finished """ elapsed_time = (datetime.datetime.now() - self.start_time).total_seconds() # safety to avoid devision by zero if self.progress == 0: self.progress = 1 estimated_to...
[ "def", "remaining_time", "(", "self", ")", ":", "elapsed_time", "=", "(", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "self", ".", "start_time", ")", ".", "total_seconds", "(", ")", "# safety to avoid devision by zero", "if", "self", ".", "progre...
estimates the time remaining until script is finished
[ "estimates", "the", "time", "remaining", "until", "script", "is", "finished" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L340-L351
train
estimates the time remaining until script is finished
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script._receive_signal
def _receive_signal(self, progress): """ this function takes care of signals emitted by the subscripts the default behaviour is that it just reemits the signal Args: progress: progress of subscript """ # print(datetime.datetime.now().strftime("%B %d, %Y %H:%M:...
python
def _receive_signal(self, progress): """ this function takes care of signals emitted by the subscripts the default behaviour is that it just reemits the signal Args: progress: progress of subscript """ # print(datetime.datetime.now().strftime("%B %d, %Y %H:%M:...
[ "def", "_receive_signal", "(", "self", ",", "progress", ")", ":", "# print(datetime.datetime.now().strftime(\"%B %d, %Y %H:%M:%S\"), self.name,QtCore.QThread.currentThread(), self._current_subscript_stage['current_subscript'].name,", "# 'received signal. emitting....')", "self", ".", "...
this function takes care of signals emitted by the subscripts the default behaviour is that it just reemits the signal Args: progress: progress of subscript
[ "this", "function", "takes", "care", "of", "signals", "emitted", "by", "the", "subscripts", "the", "default", "behaviour", "is", "that", "it", "just", "reemits", "the", "signal", "Args", ":", "progress", ":", "progress", "of", "subscript" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L372-L383
train
This function is called by the main thread when the main thread is listening for a signal. It will emit the updateProgress signal and update the progress object.
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/scripts.py
Script.run
def run(self): """ executes the script :return: boolean if execution of script finished succesfully """ self.log_data.clear() self._plot_refresh = True # flag that requests that plot axes are refreshed when self.plot is called next time self.is_running = True ...
python
def run(self): """ executes the script :return: boolean if execution of script finished succesfully """ self.log_data.clear() self._plot_refresh = True # flag that requests that plot axes are refreshed when self.plot is called next time self.is_running = True ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "log_data", ".", "clear", "(", ")", "self", ".", "_plot_refresh", "=", "True", "# flag that requests that plot axes are refreshed when self.plot is called next time", "self", ".", "is_running", "=", "True", "self", "...
executes the script :return: boolean if execution of script finished succesfully
[ "executes", "the", "script", ":", "return", ":", "boolean", "if", "execution", "of", "script", "finished", "succesfully" ]
67482e5157fcd1c40705e5c2cacfb93564703ed0
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/scripts.py#L385-L443
train
Runs the script and returns True if execution of script finished successfully.