repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
3ll3d00d/vibe | backend/src/analyser/common/uploadcontroller.py | UploadController.writeOutput | def writeOutput(self, filename, samples, srcFs, targetFs):
"""
Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None
"""
import li... | python | def writeOutput(self, filename, samples, srcFs, targetFs):
"""
Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None
"""
import li... | [
"def",
"writeOutput",
"(",
"self",
",",
"filename",
",",
"samples",
",",
"srcFs",
",",
"targetFs",
")",
":",
"import",
"librosa",
"inputLength",
"=",
"samples",
".",
"shape",
"[",
"-",
"1",
"]",
"if",
"srcFs",
"!=",
"targetFs",
":",
"if",
"inputLength",
... | Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None | [
"Resamples",
"the",
"signal",
"to",
"the",
"targetFs",
"and",
"writes",
"it",
"to",
"filename",
".",
":",
"param",
"filename",
":",
"the",
"filename",
".",
":",
"param",
"signal",
":",
"the",
"signal",
"to",
"resample",
".",
":",
"param",
"targetFs",
":"... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L194-L219 |
3ll3d00d/vibe | backend/src/analyser/common/uploadcontroller.py | UploadController.delete | def delete(self, name):
"""
Deletes the named entry.
:param name: the entry.
:return: the deleted entry.
"""
i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None))
if entry is not None:
logger.info("Deleti... | python | def delete(self, name):
"""
Deletes the named entry.
:param name: the entry.
:return: the deleted entry.
"""
i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None))
if entry is not None:
logger.info("Deleti... | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"i",
",",
"entry",
"=",
"next",
"(",
"(",
"(",
"i",
",",
"x",
")",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"self",
".",
"_uploadCache",
")",
"if",
"x",
"[",
"'name'",
"]",
"==",
"name... | Deletes the named entry.
:param name: the entry.
:return: the deleted entry. | [
"Deletes",
"the",
"named",
"entry",
".",
":",
"param",
"name",
":",
"the",
"entry",
".",
":",
"return",
":",
"the",
"deleted",
"entry",
"."
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L221-L235 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | eparOptionFactory | def eparOptionFactory(master, statusBar, param, defaultParam,
doScroll, fieldWidths,
plugIn=None, editedCallbackObj=None,
helpCallbackObj=None, mainGuiObj=None,
defaultsVerb="Default", bg=None, indent=False,
fl... | python | def eparOptionFactory(master, statusBar, param, defaultParam,
doScroll, fieldWidths,
plugIn=None, editedCallbackObj=None,
helpCallbackObj=None, mainGuiObj=None,
defaultsVerb="Default", bg=None, indent=False,
fl... | [
"def",
"eparOptionFactory",
"(",
"master",
",",
"statusBar",
",",
"param",
",",
"defaultParam",
",",
"doScroll",
",",
"fieldWidths",
",",
"plugIn",
"=",
"None",
",",
"editedCallbackObj",
"=",
"None",
",",
"helpCallbackObj",
"=",
"None",
",",
"mainGuiObj",
"=",... | Return EparOption item of appropriate type for the parameter param | [
"Return",
"EparOption",
"item",
"of",
"appropriate",
"type",
"for",
"the",
"parameter",
"param"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L910-L940 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.extraBindingsForSelectableText | def extraBindingsForSelectableText(self):
""" Collect in 1 place the bindings needed for watchTextSelection() """
# See notes in watchTextSelection
self.entry.bind('<FocusIn>', self.watchTextSelection, "+")
self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+")
self.e... | python | def extraBindingsForSelectableText(self):
""" Collect in 1 place the bindings needed for watchTextSelection() """
# See notes in watchTextSelection
self.entry.bind('<FocusIn>', self.watchTextSelection, "+")
self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+")
self.e... | [
"def",
"extraBindingsForSelectableText",
"(",
"self",
")",
":",
"# See notes in watchTextSelection",
"self",
".",
"entry",
".",
"bind",
"(",
"'<FocusIn>'",
",",
"self",
".",
"watchTextSelection",
",",
"\"+\"",
")",
"self",
".",
"entry",
".",
"bind",
"(",
"'<Butt... | Collect in 1 place the bindings needed for watchTextSelection() | [
"Collect",
"in",
"1",
"place",
"the",
"bindings",
"needed",
"for",
"watchTextSelection",
"()"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L243-L251 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.focusOut | def focusOut(self, event=None):
"""Clear selection (if text is selected in this widget)"""
# do nothing if this isn't a text-enabled widget
if not self.isSelectable:
return
if self.entryCheck(event) is None:
# Entry value is OK
# Save the last selectio... | python | def focusOut(self, event=None):
"""Clear selection (if text is selected in this widget)"""
# do nothing if this isn't a text-enabled widget
if not self.isSelectable:
return
if self.entryCheck(event) is None:
# Entry value is OK
# Save the last selectio... | [
"def",
"focusOut",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# do nothing if this isn't a text-enabled widget",
"if",
"not",
"self",
".",
"isSelectable",
":",
"return",
"if",
"self",
".",
"entryCheck",
"(",
"event",
")",
"is",
"None",
":",
"# Entry va... | Clear selection (if text is selected in this widget) | [
"Clear",
"selection",
"(",
"if",
"text",
"is",
"selected",
"in",
"this",
"widget",
")"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L257-L281 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.watchTextSelection | def watchTextSelection(self, event=None):
""" Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). """
# Note that this isn't perfect - it is a key click be... | python | def watchTextSelection(self, event=None):
""" Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). """
# Note that this isn't perfect - it is a key click be... | [
"def",
"watchTextSelection",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Note that this isn't perfect - it is a key click behind when",
"# selections are made via shift-arrow. If this becomes important, it",
"# can likely be fixed with after().",
"if",
"self",
".",
"entry",... | Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). | [
"Callback",
"used",
"to",
"see",
"if",
"there",
"is",
"a",
"new",
"text",
"selection",
".",
"In",
"certain",
"cases",
"we",
"manually",
"add",
"the",
"text",
"to",
"the",
"clipboard",
"(",
"though",
"on",
"most",
"platforms",
"the",
"correct",
"behavior",
... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L283-L296 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.focusIn | def focusIn(self, event=None):
"""Select all text (if applicable) on taking focus"""
try:
# doScroll returns false if the call was ignored because the
# last call also came from this widget. That avoids unwanted
# scrolls and text selection when the focus moves in an... | python | def focusIn(self, event=None):
"""Select all text (if applicable) on taking focus"""
try:
# doScroll returns false if the call was ignored because the
# last call also came from this widget. That avoids unwanted
# scrolls and text selection when the focus moves in an... | [
"def",
"focusIn",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"try",
":",
"# doScroll returns false if the call was ignored because the",
"# last call also came from this widget. That avoids unwanted",
"# scrolls and text selection when the focus moves in and out",
"# of the win... | Select all text (if applicable) on taking focus | [
"Select",
"all",
"text",
"(",
"if",
"applicable",
")",
"on",
"taking",
"focus"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L302-L316 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.widgetEdited | def widgetEdited(self, event=None, val=None, action='entry', skipDups=True):
""" A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as so... | python | def widgetEdited(self, event=None, val=None, action='entry', skipDups=True):
""" A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as so... | [
"def",
"widgetEdited",
"(",
"self",
",",
"event",
"=",
"None",
",",
"val",
"=",
"None",
",",
"action",
"=",
"'entry'",
",",
"skipDups",
"=",
"True",
")",
":",
"# be as lightweight as possible if obj doesn't care about this stuff",
"if",
"not",
"self",
".",
"_edi... | A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as soon as need be (immed. on click?). This is smart enough to
be called multiple... | [
"A",
"general",
"method",
"for",
"firing",
"any",
"applicable",
"triggers",
"when",
"a",
"value",
"has",
"been",
"set",
".",
"This",
"is",
"meant",
"to",
"be",
"easily",
"callable",
"from",
"any",
"part",
"of",
"this",
"class",
"(",
"or",
"its",
"subclas... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L347-L380 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.popupChoices | def popupChoices(self, event=None):
"""Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available.
"""
# don't bother if all items are disabled
if N... | python | def popupChoices(self, event=None):
"""Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available.
"""
# don't bother if all items are disabled
if N... | [
"def",
"popupChoices",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# don't bother if all items are disabled",
"if",
"NORMAL",
"not",
"in",
"(",
"self",
".",
"browserEnabled",
",",
"self",
".",
"clearEnabled",
",",
"self",
".",
"unlearnEnabled",
",",
"se... | Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available. | [
"Popup",
"right",
"-",
"click",
"menu",
"of",
"special",
"parameter",
"operations"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L392-L436 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.fileBrowser | def fileBrowser(self):
"""Invoke a tkinter file dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askopenfilename(parent=self.entry, title="Select File")
else:
from . import filedlg
self.fd = filedlg.PersistLoadFileDialog(self.entry,
"... | python | def fileBrowser(self):
"""Invoke a tkinter file dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askopenfilename(parent=self.entry, title="Select File")
else:
from . import filedlg
self.fd = filedlg.PersistLoadFileDialog(self.entry,
"... | [
"def",
"fileBrowser",
"(",
"self",
")",
":",
"if",
"capable",
".",
"OF_TKFD_IN_EPAR",
":",
"fname",
"=",
"askopenfilename",
"(",
"parent",
"=",
"self",
".",
"entry",
",",
"title",
"=",
"\"Select File\"",
")",
"else",
":",
"from",
".",
"import",
"filedlg",
... | Invoke a tkinter file dialog | [
"Invoke",
"a",
"tkinter",
"file",
"dialog"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L438-L456 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.dirBrowser | def dirBrowser(self):
"""Invoke a tkinter directory dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askdirectory(parent=self.entry, title="Select Directory")
else:
raise NotImplementedError('Fix popupChoices() logic.')
if not fname:
return # canceled
... | python | def dirBrowser(self):
"""Invoke a tkinter directory dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askdirectory(parent=self.entry, title="Select Directory")
else:
raise NotImplementedError('Fix popupChoices() logic.')
if not fname:
return # canceled
... | [
"def",
"dirBrowser",
"(",
"self",
")",
":",
"if",
"capable",
".",
"OF_TKFD_IN_EPAR",
":",
"fname",
"=",
"askdirectory",
"(",
"parent",
"=",
"self",
".",
"entry",
",",
"title",
"=",
"\"Select Directory\"",
")",
"else",
":",
"raise",
"NotImplementedError",
"("... | Invoke a tkinter directory dialog | [
"Invoke",
"a",
"tkinter",
"directory",
"dialog"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L458-L471 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.forceValue | def forceValue(self, newVal, noteEdited=False):
"""Force-set a parameter entry to the given value"""
if newVal is None:
newVal = ""
self.choice.set(newVal)
if noteEdited:
self.widgetEdited(val=newVal, skipDups=False) | python | def forceValue(self, newVal, noteEdited=False):
"""Force-set a parameter entry to the given value"""
if newVal is None:
newVal = ""
self.choice.set(newVal)
if noteEdited:
self.widgetEdited(val=newVal, skipDups=False) | [
"def",
"forceValue",
"(",
"self",
",",
"newVal",
",",
"noteEdited",
"=",
"False",
")",
":",
"if",
"newVal",
"is",
"None",
":",
"newVal",
"=",
"\"\"",
"self",
".",
"choice",
".",
"set",
"(",
"newVal",
")",
"if",
"noteEdited",
":",
"self",
".",
"widget... | Force-set a parameter entry to the given value | [
"Force",
"-",
"set",
"a",
"parameter",
"entry",
"to",
"the",
"given",
"value"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L477-L483 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.unlearnValue | def unlearnValue(self):
"""Unlearn a parameter value by setting it back to its default"""
defaultValue = self.defaultParamInfo.get(field = "p_filename",
native = 0, prompt = 0)
self.choice.set(defaultValue) | python | def unlearnValue(self):
"""Unlearn a parameter value by setting it back to its default"""
defaultValue = self.defaultParamInfo.get(field = "p_filename",
native = 0, prompt = 0)
self.choice.set(defaultValue) | [
"def",
"unlearnValue",
"(",
"self",
")",
":",
"defaultValue",
"=",
"self",
".",
"defaultParamInfo",
".",
"get",
"(",
"field",
"=",
"\"p_filename\"",
",",
"native",
"=",
"0",
",",
"prompt",
"=",
"0",
")",
"self",
".",
"choice",
".",
"set",
"(",
"default... | Unlearn a parameter value by setting it back to its default | [
"Unlearn",
"a",
"parameter",
"value",
"by",
"setting",
"it",
"back",
"to",
"its",
"default"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L491-L495 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.setActiveState | def setActiveState(self, active):
""" Use this to enable or disable (grey out) a parameter. """
st = DISABLED
if active: st = NORMAL
self.entry.configure(state=st)
self.inputLabel.configure(state=st)
self.promptLabel.configure(state=st) | python | def setActiveState(self, active):
""" Use this to enable or disable (grey out) a parameter. """
st = DISABLED
if active: st = NORMAL
self.entry.configure(state=st)
self.inputLabel.configure(state=st)
self.promptLabel.configure(state=st) | [
"def",
"setActiveState",
"(",
"self",
",",
"active",
")",
":",
"st",
"=",
"DISABLED",
"if",
"active",
":",
"st",
"=",
"NORMAL",
"self",
".",
"entry",
".",
"configure",
"(",
"state",
"=",
"st",
")",
"self",
".",
"inputLabel",
".",
"configure",
"(",
"s... | Use this to enable or disable (grey out) a parameter. | [
"Use",
"this",
"to",
"enable",
"or",
"disable",
"(",
"grey",
"out",
")",
"a",
"parameter",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L508-L514 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EparOption.flagThisPar | def flagThisPar(self, currentVal, force):
""" If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to a... | python | def flagThisPar(self, currentVal, force):
""" If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to a... | [
"def",
"flagThisPar",
"(",
"self",
",",
"currentVal",
",",
"force",
")",
":",
"# Get out ASAP if we can",
"if",
"(",
"not",
"force",
")",
"and",
"(",
"not",
"self",
".",
"_flagNonDefaultVals",
")",
":",
"return",
"# handle simple case before comparing values (quick ... | If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to allow this mehtod to make smart
time-saving dec... | [
"If",
"this",
"par",
"s",
"value",
"is",
"different",
"from",
"the",
"default",
"value",
"it",
"is",
"here",
"that",
"we",
"flag",
"it",
"somehow",
"as",
"such",
".",
"This",
"basic",
"version",
"simply",
"makes",
"the",
"surrounding",
"text",
"red",
"("... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L516-L547 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EnumEparOption.keypress | def keypress(self, event):
"""Allow keys typed in widget to select items"""
try:
self.choice.set(self.shortcuts[event.keysym])
except KeyError:
# key not found (probably a bug, since we intend to catch
# only events from shortcut keys, but ignore it anyway)
... | python | def keypress(self, event):
"""Allow keys typed in widget to select items"""
try:
self.choice.set(self.shortcuts[event.keysym])
except KeyError:
# key not found (probably a bug, since we intend to catch
# only events from shortcut keys, but ignore it anyway)
... | [
"def",
"keypress",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"choice",
".",
"set",
"(",
"self",
".",
"shortcuts",
"[",
"event",
".",
"keysym",
"]",
")",
"except",
"KeyError",
":",
"# key not found (probably a bug, since we intend to catch",... | Allow keys typed in widget to select items | [
"Allow",
"keys",
"typed",
"in",
"widget",
"to",
"select",
"items"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L641-L648 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | EnumEparOption.postcmd | def postcmd(self):
"""Make sure proper entry is activated when menu is posted"""
value = self.choice.get()
try:
index = self.paramInfo.choice.index(value)
self.entry.menu.activate(index)
except ValueError:
# initial null value may not be in list
... | python | def postcmd(self):
"""Make sure proper entry is activated when menu is posted"""
value = self.choice.get()
try:
index = self.paramInfo.choice.index(value)
self.entry.menu.activate(index)
except ValueError:
# initial null value may not be in list
... | [
"def",
"postcmd",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"choice",
".",
"get",
"(",
")",
"try",
":",
"index",
"=",
"self",
".",
"paramInfo",
".",
"choice",
".",
"index",
"(",
"value",
")",
"self",
".",
"entry",
".",
"menu",
".",
"activ... | Make sure proper entry is activated when menu is posted | [
"Make",
"sure",
"proper",
"entry",
"is",
"activated",
"when",
"menu",
"is",
"posted"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L650-L658 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | BooleanEparOption.convertToNative | def convertToNative(self, aVal):
""" Convert to native bool; interpret certain strings. """
if aVal is None:
return None
if isinstance(aVal, bool): return aVal
# otherwise interpret strings
return str(aVal).lower() in ('1','on','yes','true') | python | def convertToNative(self, aVal):
""" Convert to native bool; interpret certain strings. """
if aVal is None:
return None
if isinstance(aVal, bool): return aVal
# otherwise interpret strings
return str(aVal).lower() in ('1','on','yes','true') | [
"def",
"convertToNative",
"(",
"self",
",",
"aVal",
")",
":",
"if",
"aVal",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"aVal",
",",
"bool",
")",
":",
"return",
"aVal",
"# otherwise interpret strings",
"return",
"str",
"(",
"aVal",
")",
... | Convert to native bool; interpret certain strings. | [
"Convert",
"to",
"native",
"bool",
";",
"interpret",
"certain",
"strings",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L674-L680 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | BooleanEparOption.toggle | def toggle(self, event=None):
"""Toggle value between Yes and No"""
if self.choice.get() == "yes":
self.rbno.select()
else:
self.rbyes.select()
self.widgetEdited() | python | def toggle(self, event=None):
"""Toggle value between Yes and No"""
if self.choice.get() == "yes":
self.rbno.select()
else:
self.rbyes.select()
self.widgetEdited() | [
"def",
"toggle",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"choice",
".",
"get",
"(",
")",
"==",
"\"yes\"",
":",
"self",
".",
"rbno",
".",
"select",
"(",
")",
"else",
":",
"self",
".",
"rbyes",
".",
"select",
"(",
")"... | Toggle value between Yes and No | [
"Toggle",
"value",
"between",
"Yes",
"and",
"No"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L780-L786 |
spacetelescope/stsci.tools | lib/stsci/tools/eparoption.py | NumberEparOption.entryCheck | def entryCheck(self, event = None, repair = True):
""" Ensure any INDEF entry is uppercase, before base class behavior """
valupr = self.choice.get().upper()
if valupr.strip() == 'INDEF':
self.choice.set(valupr)
return EparOption.entryCheck(self, event, repair = repair) | python | def entryCheck(self, event = None, repair = True):
""" Ensure any INDEF entry is uppercase, before base class behavior """
valupr = self.choice.get().upper()
if valupr.strip() == 'INDEF':
self.choice.set(valupr)
return EparOption.entryCheck(self, event, repair = repair) | [
"def",
"entryCheck",
"(",
"self",
",",
"event",
"=",
"None",
",",
"repair",
"=",
"True",
")",
":",
"valupr",
"=",
"self",
".",
"choice",
".",
"get",
"(",
")",
".",
"upper",
"(",
")",
"if",
"valupr",
".",
"strip",
"(",
")",
"==",
"'INDEF'",
":",
... | Ensure any INDEF entry is uppercase, before base class behavior | [
"Ensure",
"any",
"INDEF",
"entry",
"is",
"uppercase",
"before",
"base",
"class",
"behavior"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L881-L886 |
spacetelescope/stsci.tools | lib/stsci/tools/xyinterp.py | xyinterp | def xyinterp(x,y,xval):
"""
:Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that ... | python | def xyinterp(x,y,xval):
"""
:Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that ... | [
"def",
"xyinterp",
"(",
"x",
",",
"y",
",",
"xval",
")",
":",
"#Enforce conditions on x, y, and xval:",
"#x and y must correspond",
"if",
"len",
"(",
"x",
")",
"!=",
"len",
"(",
"y",
")",
":",
"raise",
"ValueError",
"(",
"\"Input arrays must be equal lengths\"",
... | :Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that information to properly interpolate
th... | [
":",
"Purpose",
":",
"Interpolates",
"y",
"based",
"on",
"the",
"given",
"xval",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/xyinterp.py#L28-L102 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050._setSampleSizeBytes | def _setSampleSizeBytes(self):
"""
updates the current record of the packet size per sample and the relationship between this and the fifo reads.
"""
self.sampleSizeBytes = self.getPacketSize()
if self.sampleSizeBytes > 0:
self.maxBytesPerFifoRead = (32 // self.sampl... | python | def _setSampleSizeBytes(self):
"""
updates the current record of the packet size per sample and the relationship between this and the fifo reads.
"""
self.sampleSizeBytes = self.getPacketSize()
if self.sampleSizeBytes > 0:
self.maxBytesPerFifoRead = (32 // self.sampl... | [
"def",
"_setSampleSizeBytes",
"(",
"self",
")",
":",
"self",
".",
"sampleSizeBytes",
"=",
"self",
".",
"getPacketSize",
"(",
")",
"if",
"self",
".",
"sampleSizeBytes",
">",
"0",
":",
"self",
".",
"maxBytesPerFifoRead",
"=",
"(",
"32",
"//",
"self",
".",
... | updates the current record of the packet size per sample and the relationship between this and the fifo reads. | [
"updates",
"the",
"current",
"record",
"of",
"the",
"packet",
"size",
"per",
"sample",
"and",
"the",
"relationship",
"between",
"this",
"and",
"the",
"fifo",
"reads",
"."
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L265-L271 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.getPacketSize | def getPacketSize(self):
"""
the current packet size.
:return: the current packet size based on the enabled registers.
"""
size = 0
if self.isAccelerometerEnabled():
size += 6
if self.isGyroEnabled():
size += 6
if self.isTemperature... | python | def getPacketSize(self):
"""
the current packet size.
:return: the current packet size based on the enabled registers.
"""
size = 0
if self.isAccelerometerEnabled():
size += 6
if self.isGyroEnabled():
size += 6
if self.isTemperature... | [
"def",
"getPacketSize",
"(",
"self",
")",
":",
"size",
"=",
"0",
"if",
"self",
".",
"isAccelerometerEnabled",
"(",
")",
":",
"size",
"+=",
"6",
"if",
"self",
".",
"isGyroEnabled",
"(",
")",
":",
"size",
"+=",
"6",
"if",
"self",
".",
"isTemperatureEnabl... | the current packet size.
:return: the current packet size based on the enabled registers. | [
"the",
"current",
"packet",
"size",
".",
":",
"return",
":",
"the",
"current",
"packet",
"size",
"based",
"on",
"the",
"enabled",
"registers",
"."
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L273-L285 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.initialiseDevice | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | python | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | [
"def",
"initialiseDevice",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Initialising device\"",
")",
"self",
".",
"getInterruptStatus",
"(",
")",
"self",
".",
"setAccelerometerSensitivity",
"(",
"self",
".",
"_accelerationFactor",
"*",
"32768.0",
")",
... | performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return: | [
"performs",
"initialisation",
"of",
"the",
"device",
":",
"param",
"batchSize",
":",
"the",
"no",
"of",
"samples",
"that",
"each",
"provideData",
"call",
"should",
"yield",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L287-L308 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.enableAccelerometer | def enableAccelerometer(self):
"""
Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling acceleration sensor")
self.fifoSensorMask |= self.enableAccelerometerMask
self._acc... | python | def enableAccelerometer(self):
"""
Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling acceleration sensor")
self.fifoSensorMask |= self.enableAccelerometerMask
self._acc... | [
"def",
"enableAccelerometer",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling acceleration sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableAccelerometerMask",
"self",
".",
"_accelEnabled",
"=",
"True",
"self",
".",
"_setSam... | Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return: | [
"Specifies",
"the",
"device",
"should",
"write",
"acceleration",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L317-L325 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.disableAccelerometer | def disableAccelerometer(self):
"""
Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return:
"""
logger.debug("Disabling acceleration sensor")
self.fifoSensorMask &= ~self.enableAccelerometerMask
... | python | def disableAccelerometer(self):
"""
Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return:
"""
logger.debug("Disabling acceleration sensor")
self.fifoSensorMask &= ~self.enableAccelerometerMask
... | [
"def",
"disableAccelerometer",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling acceleration sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableAccelerometerMask",
"self",
".",
"_accelEnabled",
"=",
"False",
"self",
".",
... | Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return: | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"acceleration",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L327-L336 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.enableGyro | def enableGyro(self):
"""
Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling gyro sensor")
self.fifoSensorMask |= self.enableGyroMask
self._gyroEnabled = True
self._set... | python | def enableGyro(self):
"""
Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling gyro sensor")
self.fifoSensorMask |= self.enableGyroMask
self._gyroEnabled = True
self._set... | [
"def",
"enableGyro",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling gyro sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableGyroMask",
"self",
".",
"_gyroEnabled",
"=",
"True",
"self",
".",
"_setSampleSizeBytes",
"(",
")"... | Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return: | [
"Specifies",
"the",
"device",
"should",
"write",
"gyro",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L345-L353 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.disableGyro | def disableGyro(self):
"""
Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling gyro sensor")
self.fifoSensorMask &= ~self.enableGyroMask
self._gyroEnabled = False
s... | python | def disableGyro(self):
"""
Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling gyro sensor")
self.fifoSensorMask &= ~self.enableGyroMask
self._gyroEnabled = False
s... | [
"def",
"disableGyro",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling gyro sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableGyroMask",
"self",
".",
"_gyroEnabled",
"=",
"False",
"self",
".",
"_setSampleSizeBytes",
... | Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return: | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"gyro",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L355-L363 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.enableTemperature | def enableTemperature(self):
"""
Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling temperature sensor")
self.fifoSensorMask |= self.enableTemperatureMask
self._setSampl... | python | def enableTemperature(self):
"""
Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling temperature sensor")
self.fifoSensorMask |= self.enableTemperatureMask
self._setSampl... | [
"def",
"enableTemperature",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling temperature sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableTemperatureMask",
"self",
".",
"_setSampleSizeBytes",
"(",
")"
] | Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return: | [
"Specifies",
"the",
"device",
"should",
"write",
"temperature",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L372-L379 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.disableTemperature | def disableTemperature(self):
"""
Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling temperature sensor")
self.fifoSensorMask &= ~self.enableTemperatureMask
self._s... | python | def disableTemperature(self):
"""
Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling temperature sensor")
self.fifoSensorMask &= ~self.enableTemperatureMask
self._s... | [
"def",
"disableTemperature",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling temperature sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableTemperatureMask",
"self",
".",
"_setSampleSizeBytes",
"(",
")"
] | Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return: | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"temperature",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L381-L388 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.setGyroSensitivity | def setGyroSensitivity(self, value):
"""
Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity.
"""
try:
self.i2c_io.write(self.MPU6050_ADDRESS, se... | python | def setGyroSensitivity(self, value):
"""
Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity.
"""
try:
self.i2c_io.write(self.MPU6050_ADDRESS, se... | [
"def",
"setGyroSensitivity",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_GYRO_CONFIG",
",",
"{",
"250",
":",
"0",
",",
"500",
":",
"8",
",",
... | Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity. | [
"Sets",
"the",
"gyro",
"sensitivity",
"to",
"250",
"500",
"1000",
"or",
"2000",
"according",
"to",
"the",
"given",
"value",
"(",
"and",
"implicitly",
"disables",
"the",
"self",
"tests",
")",
":",
"param",
"value",
":",
"the",
"target",
"sensitivity",
"."
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L390-L404 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.setAccelerometerSensitivity | def setAccelerometerSensitivity(self, value):
"""
Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity.
"""
# note that this implicitly disables t... | python | def setAccelerometerSensitivity(self, value):
"""
Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity.
"""
# note that this implicitly disables t... | [
"def",
"setAccelerometerSensitivity",
"(",
"self",
",",
"value",
")",
":",
"# note that this implicitly disables the self tests on each axis",
"# i.e. the full byte is actually 000[accel]000 where the 1st 3 are the accelerometer self tests, the next two",
"# values are the actual sensitivity and... | Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity. | [
"Sets",
"the",
"accelerometer",
"sensitivity",
"to",
"2",
"4",
"8",
"or",
"16",
"according",
"to",
"the",
"given",
"value",
".",
"Throws",
"an",
"ArgumentError",
"if",
"the",
"value",
"provided",
"is",
"not",
"valid",
".",
":",
"param",
"value",
":",
"th... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L406-L426 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.setSampleRate | def setSampleRate(self, targetSampleRate):
"""
Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target... | python | def setSampleRate(self, targetSampleRate):
"""
Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target... | [
"def",
"setSampleRate",
"(",
"self",
",",
"targetSampleRate",
")",
":",
"sampleRateDenominator",
"=",
"int",
"(",
"(",
"8000",
"/",
"min",
"(",
"targetSampleRate",
",",
"1000",
")",
")",
"-",
"1",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
... | Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target sample rate is therefore capped at 1kHz.
:param target... | [
"Sets",
"the",
"internal",
"sample",
"rate",
"of",
"the",
"MPU",
"-",
"6050",
"this",
"requires",
"writing",
"a",
"value",
"to",
"the",
"device",
"to",
"set",
"the",
"sample",
"rate",
"as",
"Gyroscope",
"Output",
"Rate",
"/",
"(",
"1",
"+",
"SMPLRT_DIV",... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L428-L439 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.resetFifo | def resetFifo(self):
"""
Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return:
"""
logger.debug("Resetting FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000)
pass
se... | python | def resetFifo(self):
"""
Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return:
"""
logger.debug("Resetting FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000)
pass
se... | [
"def",
"resetFifo",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Resetting FIFO\"",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_USER_CTRL",
",",
"0b00000000",
")",
"pass",
"self",
"... | Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return: | [
"Resets",
"the",
"FIFO",
"by",
"first",
"disabling",
"the",
"FIFO",
"then",
"sending",
"a",
"FIFO_RESET",
"and",
"then",
"re",
"-",
"enabling",
"the",
"FIFO",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L441-L452 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.enableFifo | def enableFifo(self):
"""
Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return:
"""
logger.debug("Enabling FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0)
self.resetFifo()
self.i2c_io.writ... | python | def enableFifo(self):
"""
Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return:
"""
logger.debug("Enabling FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0)
self.resetFifo()
self.i2c_io.writ... | [
"def",
"enableFifo",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling FIFO\"",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_EN",
",",
"0",
")",
"self",
".",
"resetFifo",
... | Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return: | [
"Enables",
"the",
"FIFO",
"resets",
"it",
"and",
"then",
"sets",
"which",
"values",
"should",
"be",
"written",
"to",
"the",
"FIFO",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L454-L463 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.getFifoCount | def getFifoCount(self):
"""
gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample.
"""
bytes = self.i... | python | def getFifoCount(self):
"""
gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample.
"""
bytes = self.i... | [
"def",
"getFifoCount",
"(",
"self",
")",
":",
"bytes",
"=",
"self",
".",
"i2c_io",
".",
"readBlock",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_COUNTH",
",",
"2",
")",
"count",
"=",
"(",
"bytes",
"[",
"0",
"]",
"<<",
"8",
... | gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample. | [
"gets",
"the",
"amount",
"of",
"data",
"available",
"on",
"the",
"FIFO",
"right",
"now",
".",
":",
"return",
":",
"the",
"number",
"of",
"bytes",
"available",
"on",
"the",
"FIFO",
"which",
"will",
"be",
"proportional",
"to",
"the",
"number",
"of",
"sampl... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L474-L483 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.getDataFromFIFO | def getDataFromFIFO(self, bytesToRead):
"""
reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the byte... | python | def getDataFromFIFO(self, bytesToRead):
"""
reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the byte... | [
"def",
"getDataFromFIFO",
"(",
"self",
",",
"bytesToRead",
")",
":",
"return",
"self",
".",
"i2c_io",
".",
"readBlock",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_R_W",
",",
"bytesToRead",
")"
] | reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the bytes read. | [
"reads",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"FIFO",
"should",
"be",
"called",
"after",
"a",
"call",
"to",
"getFifoCount",
"to",
"ensure",
"there",
"is",
"new",
"data",
"available",
"(",
"to",
"avoid",
"reading",
"duplicate",
"data",
... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L485-L492 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.provideData | def provideData(self):
"""
reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict.
... | python | def provideData(self):
"""
reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict.
... | [
"def",
"provideData",
"(",
"self",
")",
":",
"samples",
"=",
"[",
"]",
"fifoBytesAvailable",
"=",
"0",
"fifoWasReset",
"=",
"False",
"logger",
".",
"debug",
"(",
"\">> provideData target %d samples\"",
",",
"self",
".",
"samplesPerBatch",
")",
"iterations",
"=",... | reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict. | [
"reads",
"a",
"batchSize",
"batch",
"of",
"data",
"from",
"the",
"FIFO",
"while",
"attempting",
"to",
"optimise",
"the",
"number",
"of",
"times",
"we",
"have",
"to",
"read",
"from",
"the",
"device",
"itself",
".",
":",
"return",
":",
"a",
"list",
"of",
... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L494-L564 |
3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.unpackSample | def unpackSample(self, rawData):
"""
unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set.
"""
length = len(rawData)
# TODO error if not multiple of 2
... | python | def unpackSample(self, rawData):
"""
unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set.
"""
length = len(rawData)
# TODO error if not multiple of 2
... | [
"def",
"unpackSample",
"(",
"self",
",",
"rawData",
")",
":",
"length",
"=",
"len",
"(",
"rawData",
")",
"# TODO error if not multiple of 2",
"# logger.debug(\">> unpacking sample %d length %d\", self._sampleIdx, length)",
"unpacked",
"=",
"struct",
".",
"unpack",
"(",
"\... | unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set. | [
"unpacks",
"a",
"single",
"sample",
"of",
"data",
"(",
"where",
"sample",
"length",
"is",
"based",
"on",
"the",
"currently",
"enabled",
"sensors",
")",
".",
":",
"param",
"rawData",
":",
"the",
"data",
"to",
"convert",
":",
"return",
":",
"a",
"converted... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L566-L603 |
spacetelescope/stsci.tools | lib/stsci/tools/textutil.py | wrap | def wrap(text, width, *args, **kwargs):
"""
Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap`
"""
return sum([textwrap.wrap(line, width, *args, **kwargs)
if line... | python | def wrap(text, width, *args, **kwargs):
"""
Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap`
"""
return sum([textwrap.wrap(line, width, *args, **kwargs)
if line... | [
"def",
"wrap",
"(",
"text",
",",
"width",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sum",
"(",
"[",
"textwrap",
".",
"wrap",
"(",
"line",
",",
"width",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"line",
"else",
... | Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap` | [
"Like",
":",
"func",
":",
"textwrap",
".",
"wrap",
"but",
"preserves",
"existing",
"newlines",
"which",
":",
"func",
":",
"textwrap",
".",
"wrap",
"does",
"not",
"otherwise",
"handle",
"well",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L7-L18 |
spacetelescope/stsci.tools | lib/stsci/tools/textutil.py | textbox | def textbox(text, width=78, boxchar='#', indent=0):
"""
Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# ... | python | def textbox(text, width=78, boxchar='#', indent=0):
"""
Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# ... | [
"def",
"textbox",
"(",
"text",
",",
"width",
"=",
"78",
",",
"boxchar",
"=",
"'#'",
",",
"indent",
"=",
"0",
")",
":",
"min_width",
"=",
"len",
"(",
"boxchar",
")",
"*",
"2",
"+",
"3",
"width",
"=",
"max",
"(",
"width",
"-",
"indent",
",",
"min... | Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# #
################
Parameters
-------... | [
"Outputs",
"line",
"-",
"wrapped",
"text",
"wrapped",
"in",
"a",
"box",
"drawn",
"with",
"a",
"repeated",
"(",
"usually",
"ASCII",
")",
"character",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L21-L72 |
titilambert/pyhydroquebec | pyhydroquebec/__main__.py | main | def main():
"""Entrypoint function."""
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username',
help='Hydro Quebec username')
parser.add_argument('-p', '--password',
help='Password')
parser.add_argument('-j', '--json', action='store_t... | python | def main():
"""Entrypoint function."""
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username',
help='Hydro Quebec username')
parser.add_argument('-p', '--password',
help='Password')
parser.add_argument('-j', '--json', action='store_t... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-u'",
",",
"'--username'",
",",
"help",
"=",
"'Hydro Quebec username'",
")",
"parser",
".",
"add_argument",
"(",
"'-p'",
",",
"'... | Entrypoint function. | [
"Entrypoint",
"function",
"."
] | train | https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/__main__.py#L14-L89 |
fitnr/convertdate | convertdate/holidays.py | easter | def easter(year):
'''Calculate western easter'''
# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html
c = trunc(year / 100)
n = year - 19 * trunc(year / 19)
k = trunc((c - 17) / 25)
i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15
i = i - 30 * trunc(i / 30)
i = i ... | python | def easter(year):
'''Calculate western easter'''
# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html
c = trunc(year / 100)
n = year - 19 * trunc(year / 19)
k = trunc((c - 17) / 25)
i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15
i = i - 30 * trunc(i / 30)
i = i ... | [
"def",
"easter",
"(",
"year",
")",
":",
"# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html",
"c",
"=",
"trunc",
"(",
"year",
"/",
"100",
")",
"n",
"=",
"year",
"-",
"19",
"*",
"trunc",
"(",
"year",
"/",
"19",
")",
"k",
"=",
"trunc",
"(",
... | Calculate western easter | [
"Calculate",
"western",
"easter"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L75-L95 |
fitnr/convertdate | convertdate/holidays.py | independence_day | def independence_day(year, observed=None):
'''July 4th'''
day = 4
if observed:
if calendar.weekday(year, JUL, 4) == SAT:
day = 3
if calendar.weekday(year, JUL, 4) == SUN:
day = 5
return (year, JUL, day) | python | def independence_day(year, observed=None):
'''July 4th'''
day = 4
if observed:
if calendar.weekday(year, JUL, 4) == SAT:
day = 3
if calendar.weekday(year, JUL, 4) == SUN:
day = 5
return (year, JUL, day) | [
"def",
"independence_day",
"(",
"year",
",",
"observed",
"=",
"None",
")",
":",
"day",
"=",
"4",
"if",
"observed",
":",
"if",
"calendar",
".",
"weekday",
"(",
"year",
",",
"JUL",
",",
"4",
")",
"==",
"SAT",
":",
"day",
"=",
"3",
"if",
"calendar",
... | July 4th | [
"July",
"4th"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L122-L133 |
fitnr/convertdate | convertdate/holidays.py | columbus_day | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | python | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | [
"def",
"columbus_day",
"(",
"year",
",",
"country",
"=",
"'usa'",
")",
":",
"if",
"country",
"==",
"'usa'",
":",
"return",
"nth_day_of_month",
"(",
"2",
",",
"MON",
",",
"OCT",
",",
"year",
")",
"else",
":",
"return",
"(",
"year",
",",
"OCT",
",",
... | in USA: 2nd Monday in Oct
Elsewhere: Oct 12 | [
"in",
"USA",
":",
"2nd",
"Monday",
"in",
"Oct",
"Elsewhere",
":",
"Oct",
"12"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L141-L147 |
fitnr/convertdate | convertdate/holidays.py | thanksgiving | def thanksgiving(year, country='usa'):
'''USA: last Thurs. of November, Canada: 2nd Mon. of October'''
if country == 'usa':
if year in [1940, 1941]:
return nth_day_of_month(3, THU, NOV, year)
elif year == 1939:
return nth_day_of_month(4, THU, NOV, year)
else:
... | python | def thanksgiving(year, country='usa'):
'''USA: last Thurs. of November, Canada: 2nd Mon. of October'''
if country == 'usa':
if year in [1940, 1941]:
return nth_day_of_month(3, THU, NOV, year)
elif year == 1939:
return nth_day_of_month(4, THU, NOV, year)
else:
... | [
"def",
"thanksgiving",
"(",
"year",
",",
"country",
"=",
"'usa'",
")",
":",
"if",
"country",
"==",
"'usa'",
":",
"if",
"year",
"in",
"[",
"1940",
",",
"1941",
"]",
":",
"return",
"nth_day_of_month",
"(",
"3",
",",
"THU",
",",
"NOV",
",",
"year",
")... | USA: last Thurs. of November, Canada: 2nd Mon. of October | [
"USA",
":",
"last",
"Thurs",
".",
"of",
"November",
"Canada",
":",
"2nd",
"Mon",
".",
"of",
"October"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L173-L184 |
spacetelescope/stsci.tools | lib/stsci/tools/linefit.py | linefit | def linefit(x, y, weights=None):
"""
Parameters
----------
y: 1D numpy array
The data to be fitted
x: 1D numpy array
The x values of the y array. x and y must
have the same shape.
weights: 1D numpy array, must have the same shape as x and y
weight values
E... | python | def linefit(x, y, weights=None):
"""
Parameters
----------
y: 1D numpy array
The data to be fitted
x: 1D numpy array
The x values of the y array. x and y must
have the same shape.
weights: 1D numpy array, must have the same shape as x and y
weight values
E... | [
"def",
"linefit",
"(",
"x",
",",
"y",
",",
"weights",
"=",
"None",
")",
":",
"if",
"len",
"(",
"x",
")",
"!=",
"len",
"(",
"y",
")",
":",
"print",
"(",
"\"Error: X and Y must have equal size\\n\"",
")",
"return",
"n",
"=",
"len",
"(",
"x",
")",
"w"... | Parameters
----------
y: 1D numpy array
The data to be fitted
x: 1D numpy array
The x values of the y array. x and y must
have the same shape.
weights: 1D numpy array, must have the same shape as x and y
weight values
Examples
--------
>>> import numpy as N... | [
"Parameters",
"----------",
"y",
":",
"1D",
"numpy",
"array",
"The",
"data",
"to",
"be",
"fitted",
"x",
":",
"1D",
"numpy",
"array",
"The",
"x",
"values",
"of",
"the",
"y",
"array",
".",
"x",
"and",
"y",
"must",
"have",
"the",
"same",
"shape",
".",
... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/linefit.py#L19-L72 |
3ll3d00d/vibe | backend/src/analyser/resources/analyse.py | Analyse.get | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Analysing ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.COMPLETE)
... | python | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Analysing ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.COMPLETE)
... | [
"def",
"get",
"(",
"self",
",",
"measurementId",
")",
":",
"logger",
".",
"info",
"(",
"'Analysing '",
"+",
"measurementId",
")",
"measurement",
"=",
"self",
".",
"_measurementController",
".",
"getMeasurement",
"(",
"measurementId",
",",
"MeasurementStatus",
".... | Analyses the measurement with the given parameters
:param measurementId:
:return: | [
"Analyses",
"the",
"measurement",
"with",
"the",
"given",
"parameters",
":",
"param",
"measurementId",
":",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/analyse.py#L13-L49 |
3ll3d00d/vibe | backend/src/analyser/common/targetstatecontroller.py | _applyTargetState | def _applyTargetState(targetState, md, httpclient):
"""
compares the current device state against the targetStateProvider and issues updates as necessary to ensure the
device is
at that state.
:param md:
:param targetState: the target state.
:param httpclient: the http client
:return:
... | python | def _applyTargetState(targetState, md, httpclient):
"""
compares the current device state against the targetStateProvider and issues updates as necessary to ensure the
device is
at that state.
:param md:
:param targetState: the target state.
:param httpclient: the http client
:return:
... | [
"def",
"_applyTargetState",
"(",
"targetState",
",",
"md",
",",
"httpclient",
")",
":",
"anyUpdate",
"=",
"False",
"if",
"md",
"[",
"'fs'",
"]",
"!=",
"targetState",
".",
"fs",
":",
"logger",
".",
"info",
"(",
"\"Updating fs from \"",
"+",
"str",
"(",
"m... | compares the current device state against the targetStateProvider and issues updates as necessary to ensure the
device is
at that state.
:param md:
:param targetState: the target state.
:param httpclient: the http client
:return: | [
"compares",
"the",
"current",
"device",
"state",
"against",
"the",
"targetStateProvider",
"and",
"issues",
"updates",
"as",
"necessary",
"to",
"ensure",
"the",
"device",
"is",
"at",
"that",
"state",
".",
":",
"param",
"md",
":",
":",
"param",
"targetState",
... | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L78-L130 |
3ll3d00d/vibe | backend/src/analyser/common/targetstatecontroller.py | TargetStateController.updateDeviceState | def updateDeviceState(self, device):
"""
Updates the target state on the specified device.
:param targetState: the target state to reach.
:param device: the device to update.
:return:
"""
# this is only threadsafe because the targetstate is effectively immutable, ... | python | def updateDeviceState(self, device):
"""
Updates the target state on the specified device.
:param targetState: the target state to reach.
:param device: the device to update.
:return:
"""
# this is only threadsafe because the targetstate is effectively immutable, ... | [
"def",
"updateDeviceState",
"(",
"self",
",",
"device",
")",
":",
"# this is only threadsafe because the targetstate is effectively immutable, if it becomes mutable in future then",
"# funkiness may result",
"self",
".",
"_reactor",
".",
"offer",
"(",
"REACH_TARGET_STATE",
",",
"... | Updates the target state on the specified device.
:param targetState: the target state to reach.
:param device: the device to update.
:return: | [
"Updates",
"the",
"target",
"state",
"on",
"the",
"specified",
"device",
".",
":",
"param",
"targetState",
":",
"the",
"target",
"state",
"to",
"reach",
".",
":",
"param",
"device",
":",
"the",
"device",
"to",
"update",
".",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L25-L34 |
3ll3d00d/vibe | backend/src/analyser/common/targetstatecontroller.py | TargetStateController.updateTargetState | def updateTargetState(self, newState):
"""
Updates the system target state and propagates that to all devices.
:param newState:
:return:
"""
self._targetStateProvider.state = loadTargetState(newState, self._targetStateProvider.state)
for device in self.deviceContr... | python | def updateTargetState(self, newState):
"""
Updates the system target state and propagates that to all devices.
:param newState:
:return:
"""
self._targetStateProvider.state = loadTargetState(newState, self._targetStateProvider.state)
for device in self.deviceContr... | [
"def",
"updateTargetState",
"(",
"self",
",",
"newState",
")",
":",
"self",
".",
"_targetStateProvider",
".",
"state",
"=",
"loadTargetState",
"(",
"newState",
",",
"self",
".",
"_targetStateProvider",
".",
"state",
")",
"for",
"device",
"in",
"self",
".",
"... | Updates the system target state and propagates that to all devices.
:param newState:
:return: | [
"Updates",
"the",
"system",
"target",
"state",
"and",
"propagates",
"that",
"to",
"all",
"devices",
".",
":",
"param",
"newState",
":",
":",
"return",
":"
] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L36-L44 |
spacetelescope/stsci.tools | lib/stsci/tools/convertlog.py | convert | def convert(input, width=132, output=None, keep=False):
"""Input ASCII trailer file "input" will be read.
The contents will then be written out to a FITS file in the same format
as used by 'stwfits' from IRAF.
Parameters
===========
input : str
Filename of input ASCII trailer file
... | python | def convert(input, width=132, output=None, keep=False):
"""Input ASCII trailer file "input" will be read.
The contents will then be written out to a FITS file in the same format
as used by 'stwfits' from IRAF.
Parameters
===========
input : str
Filename of input ASCII trailer file
... | [
"def",
"convert",
"(",
"input",
",",
"width",
"=",
"132",
",",
"output",
"=",
"None",
",",
"keep",
"=",
"False",
")",
":",
"# open input trailer file",
"trl",
"=",
"open",
"(",
"input",
")",
"# process all lines",
"lines",
"=",
"np",
".",
"array",
"(",
... | Input ASCII trailer file "input" will be read.
The contents will then be written out to a FITS file in the same format
as used by 'stwfits' from IRAF.
Parameters
===========
input : str
Filename of input ASCII trailer file
width : int
Number of characters wide to use for defin... | [
"Input",
"ASCII",
"trailer",
"file",
"input",
"will",
"be",
"read",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertlog.py#L53-L112 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | flatten_errors | def flatten_errors(cfg, res, levels=None, results=None):
"""
An example function that will turn a nested dictionary of results
(as returned by ``ConfigObj.validate``) into a flat list.
``cfg`` is the ConfigObj instance being checked, ``res`` is the results
dictionary returned by ``validate``.
... | python | def flatten_errors(cfg, res, levels=None, results=None):
"""
An example function that will turn a nested dictionary of results
(as returned by ``ConfigObj.validate``) into a flat list.
``cfg`` is the ConfigObj instance being checked, ``res`` is the results
dictionary returned by ``validate``.
... | [
"def",
"flatten_errors",
"(",
"cfg",
",",
"res",
",",
"levels",
"=",
"None",
",",
"results",
"=",
"None",
")",
":",
"if",
"levels",
"is",
"None",
":",
"# first time called",
"levels",
"=",
"[",
"]",
"results",
"=",
"[",
"]",
"if",
"res",
"==",
"True"... | An example function that will turn a nested dictionary of results
(as returned by ``ConfigObj.validate``) into a flat list.
``cfg`` is the ConfigObj instance being checked, ``res`` is the results
dictionary returned by ``validate``.
(This is a recursive function, so you shouldn't use the ``levels`` or... | [
"An",
"example",
"function",
"that",
"will",
"turn",
"a",
"nested",
"dictionary",
"of",
"results",
"(",
"as",
"returned",
"by",
"ConfigObj",
".",
"validate",
")",
"into",
"a",
"flat",
"list",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2396-L2453 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | get_extra_values | def get_extra_values(conf, _prepend=()):
"""
Find all the values and sections not in the configspec from a validated
ConfigObj.
``get_extra_values`` returns a list of tuples where each tuple represents
either an extra section, or an extra value.
The tuples contain two values, a tuple represent... | python | def get_extra_values(conf, _prepend=()):
"""
Find all the values and sections not in the configspec from a validated
ConfigObj.
``get_extra_values`` returns a list of tuples where each tuple represents
either an extra section, or an extra value.
The tuples contain two values, a tuple represent... | [
"def",
"get_extra_values",
"(",
"conf",
",",
"_prepend",
"=",
"(",
")",
")",
":",
"out",
"=",
"[",
"]",
"out",
".",
"extend",
"(",
"[",
"(",
"_prepend",
",",
"name",
")",
"for",
"name",
"in",
"conf",
".",
"extra_values",
"]",
")",
"for",
"name",
... | Find all the values and sections not in the configspec from a validated
ConfigObj.
``get_extra_values`` returns a list of tuples where each tuple represents
either an extra section, or an extra value.
The tuples contain two values, a tuple representing the section the value
is in and the name of t... | [
"Find",
"all",
"the",
"values",
"and",
"sections",
"not",
"in",
"the",
"configspec",
"from",
"a",
"validated",
"ConfigObj",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2456-L2479 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | InterpolationEngine._fetch | def _fetch(self, key):
"""Helper function to fetch values from owning section.
Returns a 2-tuple: the value, and the section where it was found.
"""
# switch off interpolation before we try and fetch anything !
save_interp = self.section.main.interpolation
self.section.m... | python | def _fetch(self, key):
"""Helper function to fetch values from owning section.
Returns a 2-tuple: the value, and the section where it was found.
"""
# switch off interpolation before we try and fetch anything !
save_interp = self.section.main.interpolation
self.section.m... | [
"def",
"_fetch",
"(",
"self",
",",
"key",
")",
":",
"# switch off interpolation before we try and fetch anything !",
"save_interp",
"=",
"self",
".",
"section",
".",
"main",
".",
"interpolation",
"self",
".",
"section",
".",
"main",
".",
"interpolation",
"=",
"Fal... | Helper function to fetch values from owning section.
Returns a 2-tuple: the value, and the section where it was found. | [
"Helper",
"function",
"to",
"fetch",
"values",
"from",
"owning",
"section",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L381-L412 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.pop | def pop(self, key, default=MISSING):
"""
'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised'
"""
try:
val = self[key]
except KeyError:
if default is... | python | def pop(self, key, default=MISSING):
"""
'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised'
"""
try:
val = self[key]
except KeyError:
if default is... | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"MISSING",
")",
":",
"try",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"except",
"KeyError",
":",
"if",
"default",
"is",
"MISSING",
":",
"raise",
"val",
"=",
"default",
"else",
":",
"del",
... | 'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised' | [
"D",
".",
"pop",
"(",
"k",
"[",
"d",
"]",
")",
"-",
">",
"v",
"remove",
"specified",
"key",
"and",
"return",
"the",
"corresponding",
"value",
".",
"If",
"key",
"is",
"not",
"found",
"d",
"is",
"returned",
"if",
"given",
"otherwise",
"KeyError",
"is",... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L680-L693 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.popitem | def popitem(self):
"""Pops the first (key,val)"""
sequence = (self.scalars + self.sections)
if not sequence:
raise KeyError(": 'popitem(): dictionary is empty'")
key = sequence[0]
val = self[key]
del self[key]
return key, val | python | def popitem(self):
"""Pops the first (key,val)"""
sequence = (self.scalars + self.sections)
if not sequence:
raise KeyError(": 'popitem(): dictionary is empty'")
key = sequence[0]
val = self[key]
del self[key]
return key, val | [
"def",
"popitem",
"(",
"self",
")",
":",
"sequence",
"=",
"(",
"self",
".",
"scalars",
"+",
"self",
".",
"sections",
")",
"if",
"not",
"sequence",
":",
"raise",
"KeyError",
"(",
"\": 'popitem(): dictionary is empty'\"",
")",
"key",
"=",
"sequence",
"[",
"0... | Pops the first (key,val) | [
"Pops",
"the",
"first",
"(",
"key",
"val",
")"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L696-L704 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.clear | def clear(self):
"""
A version of clear that also affects scalars/sections
Also clears comments and configspec.
Leaves other attributes alone :
depth/main/parent are not affected
"""
dict.clear(self)
self.scalars = []
self.sections = []
... | python | def clear(self):
"""
A version of clear that also affects scalars/sections
Also clears comments and configspec.
Leaves other attributes alone :
depth/main/parent are not affected
"""
dict.clear(self)
self.scalars = []
self.sections = []
... | [
"def",
"clear",
"(",
"self",
")",
":",
"dict",
".",
"clear",
"(",
"self",
")",
"self",
".",
"scalars",
"=",
"[",
"]",
"self",
".",
"sections",
"=",
"[",
"]",
"self",
".",
"comments",
"=",
"{",
"}",
"self",
".",
"inline_comments",
"=",
"{",
"}",
... | A version of clear that also affects scalars/sections
Also clears comments and configspec.
Leaves other attributes alone :
depth/main/parent are not affected | [
"A",
"version",
"of",
"clear",
"that",
"also",
"affects",
"scalars",
"/",
"sections",
"Also",
"clears",
"comments",
"and",
"configspec",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L707-L722 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.items | def items(self):
"""D.items() -> list of D's (key, value) pairs, as 2-tuples"""
return list(zip((self.scalars + self.sections), list(self.values()))) | python | def items(self):
"""D.items() -> list of D's (key, value) pairs, as 2-tuples"""
return list(zip((self.scalars + self.sections), list(self.values()))) | [
"def",
"items",
"(",
"self",
")",
":",
"return",
"list",
"(",
"zip",
"(",
"(",
"self",
".",
"scalars",
"+",
"self",
".",
"sections",
")",
",",
"list",
"(",
"self",
".",
"values",
"(",
")",
")",
")",
")"
] | D.items() -> list of D's (key, value) pairs, as 2-tuples | [
"D",
".",
"items",
"()",
"-",
">",
"list",
"of",
"D",
"s",
"(",
"key",
"value",
")",
"pairs",
"as",
"2",
"-",
"tuples"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L734-L736 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.dict | def dict(self):
"""
Return a deepcopy of self as a dictionary.
All members that are ``Section`` instances are recursively turned to
ordinary dictionaries - by calling their ``dict`` method.
>>> n = a.dict() # doctest: +SKIP
>>> n == a # doctest: +SKIP
1
... | python | def dict(self):
"""
Return a deepcopy of self as a dictionary.
All members that are ``Section`` instances are recursively turned to
ordinary dictionaries - by calling their ``dict`` method.
>>> n = a.dict() # doctest: +SKIP
>>> n == a # doctest: +SKIP
1
... | [
"def",
"dict",
"(",
"self",
")",
":",
"newdict",
"=",
"{",
"}",
"for",
"entry",
"in",
"self",
":",
"this_entry",
"=",
"self",
"[",
"entry",
"]",
"if",
"isinstance",
"(",
"this_entry",
",",
"Section",
")",
":",
"this_entry",
"=",
"this_entry",
".",
"d... | Return a deepcopy of self as a dictionary.
All members that are ``Section`` instances are recursively turned to
ordinary dictionaries - by calling their ``dict`` method.
>>> n = a.dict() # doctest: +SKIP
>>> n == a # doctest: +SKIP
1
>>> n is a # doctest: +SKIP
... | [
"Return",
"a",
"deepcopy",
"of",
"self",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L782-L807 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.merge | def merge(self, indict):
"""
A recursive update - useful for merging config files.
>>> a = '''[section1]
... option1 = True
... [[subsection]]
... more_options = False
... # end of file'''.splitlines()
>>> b = '''# File is user.ini
... | python | def merge(self, indict):
"""
A recursive update - useful for merging config files.
>>> a = '''[section1]
... option1 = True
... [[subsection]]
... more_options = False
... # end of file'''.splitlines()
>>> b = '''# File is user.ini
... | [
"def",
"merge",
"(",
"self",
",",
"indict",
")",
":",
"for",
"key",
",",
"val",
"in",
"list",
"(",
"indict",
".",
"items",
"(",
")",
")",
":",
"if",
"(",
"key",
"in",
"self",
"and",
"isinstance",
"(",
"self",
"[",
"key",
"]",
",",
"dict",
")",
... | A recursive update - useful for merging config files.
>>> a = '''[section1]
... option1 = True
... [[subsection]]
... more_options = False
... # end of file'''.splitlines()
>>> b = '''# File is user.ini
... [section1]
... option1 =... | [
"A",
"recursive",
"update",
"-",
"useful",
"for",
"merging",
"config",
"files",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L810-L834 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.rename | def rename(self, oldkey, newkey):
"""
Change a keyname to another, without changing position in sequence.
Implemented so that transformations can be made on keys,
as well as on values. (used by encode and decode)
Also renames comments.
"""
if oldkey in self.scal... | python | def rename(self, oldkey, newkey):
"""
Change a keyname to another, without changing position in sequence.
Implemented so that transformations can be made on keys,
as well as on values. (used by encode and decode)
Also renames comments.
"""
if oldkey in self.scal... | [
"def",
"rename",
"(",
"self",
",",
"oldkey",
",",
"newkey",
")",
":",
"if",
"oldkey",
"in",
"self",
".",
"scalars",
":",
"the_list",
"=",
"self",
".",
"scalars",
"elif",
"oldkey",
"in",
"self",
".",
"sections",
":",
"the_list",
"=",
"self",
".",
"sec... | Change a keyname to another, without changing position in sequence.
Implemented so that transformations can be made on keys,
as well as on values. (used by encode and decode)
Also renames comments. | [
"Change",
"a",
"keyname",
"to",
"another",
"without",
"changing",
"position",
"in",
"sequence",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L837-L864 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.walk | def walk(self, function, raise_errors=True,
call_on_sections=False, **keywargs):
"""
Walk every member and call a function on the keyword and value.
Return a dictionary of the return values
If the function raises an exception, raise the errror
unless ``raise_errors=... | python | def walk(self, function, raise_errors=True,
call_on_sections=False, **keywargs):
"""
Walk every member and call a function on the keyword and value.
Return a dictionary of the return values
If the function raises an exception, raise the errror
unless ``raise_errors=... | [
"def",
"walk",
"(",
"self",
",",
"function",
",",
"raise_errors",
"=",
"True",
",",
"call_on_sections",
"=",
"False",
",",
"*",
"*",
"keywargs",
")",
":",
"out",
"=",
"{",
"}",
"# scalars first",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".... | Walk every member and call a function on the keyword and value.
Return a dictionary of the return values
If the function raises an exception, raise the errror
unless ``raise_errors=False``, in which case set the return value to
``False``.
Any unrecognised keyword arguments you... | [
"Walk",
"every",
"member",
"and",
"call",
"a",
"function",
"on",
"the",
"keyword",
"and",
"value",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L867-L949 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.as_bool | def as_bool(self, key):
"""
Accepts a key as input. The corresponding value must be a string or
the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to
retain compatibility with Python 2.2.
If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns
... | python | def as_bool(self, key):
"""
Accepts a key as input. The corresponding value must be a string or
the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to
retain compatibility with Python 2.2.
If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns
... | [
"def",
"as_bool",
"(",
"self",
",",
"key",
")",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"if",
"val",
"==",
"True",
":",
"return",
"True",
"elif",
"val",
"==",
"False",
":",
"return",
"False",
"else",
":",
"try",
":",
"if",
"not",
"isinstance",
... | Accepts a key as input. The corresponding value must be a string or
the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to
retain compatibility with Python 2.2.
If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns
``True``.
If the string is one ... | [
"Accepts",
"a",
"key",
"as",
"input",
".",
"The",
"corresponding",
"value",
"must",
"be",
"a",
"string",
"or",
"the",
"objects",
"(",
"True",
"or",
"1",
")",
"or",
"(",
"False",
"or",
"0",
")",
".",
"We",
"allow",
"0",
"and",
"1",
"to",
"retain",
... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L952-L993 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.as_list | def as_list(self, key):
"""
A convenience method which fetches the specified value, guaranteeing
that it is a list.
>>> a = ConfigObj()
>>> a['a'] = 1
>>> a.as_list('a')
[1]
>>> a['a'] = (1,)
>>> a.as_list('a')
[1]
>>> a['a'] = [1]... | python | def as_list(self, key):
"""
A convenience method which fetches the specified value, guaranteeing
that it is a list.
>>> a = ConfigObj()
>>> a['a'] = 1
>>> a.as_list('a')
[1]
>>> a['a'] = (1,)
>>> a.as_list('a')
[1]
>>> a['a'] = [1]... | [
"def",
"as_list",
"(",
"self",
",",
"key",
")",
":",
"result",
"=",
"self",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"result",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"return",
"list",
"(",
"result",
")",
"return",
"[",
"result",
"]"
] | A convenience method which fetches the specified value, guaranteeing
that it is a list.
>>> a = ConfigObj()
>>> a['a'] = 1
>>> a.as_list('a')
[1]
>>> a['a'] = (1,)
>>> a.as_list('a')
[1]
>>> a['a'] = [1]
>>> a.as_list('a')
[1] | [
"A",
"convenience",
"method",
"which",
"fetches",
"the",
"specified",
"value",
"guaranteeing",
"that",
"it",
"is",
"a",
"list",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1039-L1058 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.restore_default | def restore_default(self, key):
"""
Restore (and return) default value for the specified key.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
If there is no default value for this key, ``KeyError`` is raised.
"""
... | python | def restore_default(self, key):
"""
Restore (and return) default value for the specified key.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
If there is no default value for this key, ``KeyError`` is raised.
"""
... | [
"def",
"restore_default",
"(",
"self",
",",
"key",
")",
":",
"default",
"=",
"self",
".",
"default_values",
"[",
"key",
"]",
"dict",
".",
"__setitem__",
"(",
"self",
",",
"key",
",",
"default",
")",
"if",
"key",
"not",
"in",
"self",
".",
"defaults",
... | Restore (and return) default value for the specified key.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
If there is no default value for this key, ``KeyError`` is raised. | [
"Restore",
"(",
"and",
"return",
")",
"default",
"value",
"for",
"the",
"specified",
"key",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1061-L1074 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | Section.restore_defaults | def restore_defaults(self):
"""
Recursively restore default values to all members
that have them.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
It doesn't delete or modify entries without default values.
""... | python | def restore_defaults(self):
"""
Recursively restore default values to all members
that have them.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
It doesn't delete or modify entries without default values.
""... | [
"def",
"restore_defaults",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"default_values",
":",
"self",
".",
"restore_default",
"(",
"key",
")",
"for",
"section",
"in",
"self",
".",
"sections",
":",
"self",
"[",
"section",
"]",
".",
"restore_de... | Recursively restore default values to all members
that have them.
This method will only work for a ConfigObj that was created
with a configspec and has been validated.
It doesn't delete or modify entries without default values. | [
"Recursively",
"restore",
"default",
"values",
"to",
"all",
"members",
"that",
"have",
"them",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1077-L1091 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._handle_bom | def _handle_bom(self, infile):
"""
Handle any BOM, and decode if necessary.
If an encoding is specified, that *must* be used - but the BOM should
still be removed (and the BOM attribute set).
(If the encoding is wrongly specified, then a BOM for an alternative
encoding ... | python | def _handle_bom(self, infile):
"""
Handle any BOM, and decode if necessary.
If an encoding is specified, that *must* be used - but the BOM should
still be removed (and the BOM attribute set).
(If the encoding is wrongly specified, then a BOM for an alternative
encoding ... | [
"def",
"_handle_bom",
"(",
"self",
",",
"infile",
")",
":",
"if",
"(",
"(",
"self",
".",
"encoding",
"is",
"not",
"None",
")",
"and",
"(",
"self",
".",
"encoding",
".",
"lower",
"(",
")",
"not",
"in",
"BOM_LIST",
")",
")",
":",
"# No need to check fo... | Handle any BOM, and decode if necessary.
If an encoding is specified, that *must* be used - but the BOM should
still be removed (and the BOM attribute set).
(If the encoding is wrongly specified, then a BOM for an alternative
encoding won't be discovered or removed.)
If an enc... | [
"Handle",
"any",
"BOM",
"and",
"decode",
"if",
"necessary",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1395-L1493 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._decode | def _decode(self, infile, encoding):
"""
Decode infile to unicode. Using the specified encoding.
if is a string, it also needs converting to a list.
"""
if isinstance(infile, string_types):
# can't be unicode
# NOTE: Could raise a ``UnicodeDecodeError``
... | python | def _decode(self, infile, encoding):
"""
Decode infile to unicode. Using the specified encoding.
if is a string, it also needs converting to a list.
"""
if isinstance(infile, string_types):
# can't be unicode
# NOTE: Could raise a ``UnicodeDecodeError``
... | [
"def",
"_decode",
"(",
"self",
",",
"infile",
",",
"encoding",
")",
":",
"if",
"isinstance",
"(",
"infile",
",",
"string_types",
")",
":",
"# can't be unicode",
"# NOTE: Could raise a ``UnicodeDecodeError``",
"return",
"infile",
".",
"decode",
"(",
"encoding",
")"... | Decode infile to unicode. Using the specified encoding.
if is a string, it also needs converting to a list. | [
"Decode",
"infile",
"to",
"unicode",
".",
"Using",
"the",
"specified",
"encoding",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1504-L1524 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._decode_element | def _decode_element(self, line):
"""Decode element to unicode if necessary."""
if not self.encoding:
return line
if isinstance(line, str) and self.default_encoding:
return line.decode(self.default_encoding)
return line | python | def _decode_element(self, line):
"""Decode element to unicode if necessary."""
if not self.encoding:
return line
if isinstance(line, str) and self.default_encoding:
return line.decode(self.default_encoding)
return line | [
"def",
"_decode_element",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"self",
".",
"encoding",
":",
"return",
"line",
"if",
"isinstance",
"(",
"line",
",",
"str",
")",
"and",
"self",
".",
"default_encoding",
":",
"return",
"line",
".",
"decode",
"... | Decode element to unicode if necessary. | [
"Decode",
"element",
"to",
"unicode",
"if",
"necessary",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1527-L1533 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._parse | def _parse(self, infile):
"""Actually parse the config file."""
temp_list_values = self.list_values
if self.unrepr:
self.list_values = False
comment_list = []
done_start = False
this_section = self
maxline = len(infile) - 1
cur_index = -1
... | python | def _parse(self, infile):
"""Actually parse the config file."""
temp_list_values = self.list_values
if self.unrepr:
self.list_values = False
comment_list = []
done_start = False
this_section = self
maxline = len(infile) - 1
cur_index = -1
... | [
"def",
"_parse",
"(",
"self",
",",
"infile",
")",
":",
"temp_list_values",
"=",
"self",
".",
"list_values",
"if",
"self",
".",
"unrepr",
":",
"self",
".",
"list_values",
"=",
"False",
"comment_list",
"=",
"[",
"]",
"done_start",
"=",
"False",
"this_section... | Actually parse the config file. | [
"Actually",
"parse",
"the",
"config",
"file",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1547-L1712 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._match_depth | def _match_depth(self, sect, depth):
"""
Given a section and a depth level, walk back through the sections
parents to see if the depth level matches a previous section.
Return a reference to the right section,
or raise a SyntaxError.
"""
while depth < sect.depth:... | python | def _match_depth(self, sect, depth):
"""
Given a section and a depth level, walk back through the sections
parents to see if the depth level matches a previous section.
Return a reference to the right section,
or raise a SyntaxError.
"""
while depth < sect.depth:... | [
"def",
"_match_depth",
"(",
"self",
",",
"sect",
",",
"depth",
")",
":",
"while",
"depth",
"<",
"sect",
".",
"depth",
":",
"if",
"sect",
"is",
"sect",
".",
"parent",
":",
"# we've reached the top level already",
"raise",
"SyntaxError",
"(",
")",
"sect",
"=... | Given a section and a depth level, walk back through the sections
parents to see if the depth level matches a previous section.
Return a reference to the right section,
or raise a SyntaxError. | [
"Given",
"a",
"section",
"and",
"a",
"depth",
"level",
"walk",
"back",
"through",
"the",
"sections",
"parents",
"to",
"see",
"if",
"the",
"depth",
"level",
"matches",
"a",
"previous",
"section",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1715-L1731 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._handle_error | def _handle_error(self, text, ErrorClass, infile, cur_index):
"""
Handle an error according to the error settings.
Either raise the error or store it.
The error will have occured at ``cur_index``
"""
line = infile[cur_index]
cur_index += 1
message = text ... | python | def _handle_error(self, text, ErrorClass, infile, cur_index):
"""
Handle an error according to the error settings.
Either raise the error or store it.
The error will have occured at ``cur_index``
"""
line = infile[cur_index]
cur_index += 1
message = text ... | [
"def",
"_handle_error",
"(",
"self",
",",
"text",
",",
"ErrorClass",
",",
"infile",
",",
"cur_index",
")",
":",
"line",
"=",
"infile",
"[",
"cur_index",
"]",
"cur_index",
"+=",
"1",
"message",
"=",
"text",
"%",
"cur_index",
"error",
"=",
"ErrorClass",
"(... | Handle an error according to the error settings.
Either raise the error or store it.
The error will have occured at ``cur_index`` | [
"Handle",
"an",
"error",
"according",
"to",
"the",
"error",
"settings",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1734-L1750 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._unquote | def _unquote(self, value):
"""Return an unquoted version of a value"""
if not value:
# should only happen during parsing of lists
raise SyntaxError
if (value[0] == value[-1]) and (value[0] in ('"', "'")):
value = value[1:-1]
return value | python | def _unquote(self, value):
"""Return an unquoted version of a value"""
if not value:
# should only happen during parsing of lists
raise SyntaxError
if (value[0] == value[-1]) and (value[0] in ('"', "'")):
value = value[1:-1]
return value | [
"def",
"_unquote",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"# should only happen during parsing of lists",
"raise",
"SyntaxError",
"if",
"(",
"value",
"[",
"0",
"]",
"==",
"value",
"[",
"-",
"1",
"]",
")",
"and",
"(",
"value",
"["... | Return an unquoted version of a value | [
"Return",
"an",
"unquoted",
"version",
"of",
"a",
"value"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1753-L1760 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._quote | def _quote(self, value, multiline=True):
"""
Return a safely quoted version of a value.
Raise a ConfigObjError if the value cannot be safely quoted.
If multiline is ``True`` (default) then use triple quotes
if necessary.
* Don't quote values that don't need it.
... | python | def _quote(self, value, multiline=True):
"""
Return a safely quoted version of a value.
Raise a ConfigObjError if the value cannot be safely quoted.
If multiline is ``True`` (default) then use triple quotes
if necessary.
* Don't quote values that don't need it.
... | [
"def",
"_quote",
"(",
"self",
",",
"value",
",",
"multiline",
"=",
"True",
")",
":",
"if",
"multiline",
"and",
"self",
".",
"write_empty_values",
"and",
"value",
"==",
"''",
":",
"# Only if multiline is set, so that it is used for values not",
"# keys, and not values ... | Return a safely quoted version of a value.
Raise a ConfigObjError if the value cannot be safely quoted.
If multiline is ``True`` (default) then use triple quotes
if necessary.
* Don't quote values that don't need it.
* Recursively quote members of a list and return a comma join... | [
"Return",
"a",
"safely",
"quoted",
"version",
"of",
"a",
"value",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1763-L1829 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._handle_value | def _handle_value(self, value):
"""
Given a value string, unquote, remove comment,
handle lists. (including empty and single member lists)
"""
if self._inspec:
# Parsing a configspec so don't handle comments
return (value, '')
# do we look for list... | python | def _handle_value(self, value):
"""
Given a value string, unquote, remove comment,
handle lists. (including empty and single member lists)
"""
if self._inspec:
# Parsing a configspec so don't handle comments
return (value, '')
# do we look for list... | [
"def",
"_handle_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_inspec",
":",
"# Parsing a configspec so don't handle comments",
"return",
"(",
"value",
",",
"''",
")",
"# do we look for lists in values ?",
"if",
"not",
"self",
".",
"list_values",
... | Given a value string, unquote, remove comment,
handle lists. (including empty and single member lists) | [
"Given",
"a",
"value",
"string",
"unquote",
"remove",
"comment",
"handle",
"lists",
".",
"(",
"including",
"empty",
"and",
"single",
"member",
"lists",
")"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1852-L1898 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._multiline | def _multiline(self, value, infile, cur_index, maxline):
"""Extract the value, where we are in a multiline situation."""
quot = value[:3]
newvalue = value[3:]
single_line = self._triple_quote[quot][0]
multi_line = self._triple_quote[quot][1]
mat = single_line.match(value)... | python | def _multiline(self, value, infile, cur_index, maxline):
"""Extract the value, where we are in a multiline situation."""
quot = value[:3]
newvalue = value[3:]
single_line = self._triple_quote[quot][0]
multi_line = self._triple_quote[quot][1]
mat = single_line.match(value)... | [
"def",
"_multiline",
"(",
"self",
",",
"value",
",",
"infile",
",",
"cur_index",
",",
"maxline",
")",
":",
"quot",
"=",
"value",
"[",
":",
"3",
"]",
"newvalue",
"=",
"value",
"[",
"3",
":",
"]",
"single_line",
"=",
"self",
".",
"_triple_quote",
"[",
... | Extract the value, where we are in a multiline situation. | [
"Extract",
"the",
"value",
"where",
"we",
"are",
"in",
"a",
"multiline",
"situation",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1901-L1933 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._handle_configspec | def _handle_configspec(self, configspec):
"""Parse the configspec."""
# FIXME: Should we check that the configspec was created with the
# correct settings ? (i.e. ``list_values=False``)
if not isinstance(configspec, ConfigObj):
try:
configspec = ConfigO... | python | def _handle_configspec(self, configspec):
"""Parse the configspec."""
# FIXME: Should we check that the configspec was created with the
# correct settings ? (i.e. ``list_values=False``)
if not isinstance(configspec, ConfigObj):
try:
configspec = ConfigO... | [
"def",
"_handle_configspec",
"(",
"self",
",",
"configspec",
")",
":",
"# FIXME: Should we check that the configspec was created with the",
"# correct settings ? (i.e. ``list_values=False``)",
"if",
"not",
"isinstance",
"(",
"configspec",
",",
"ConfigObj",
")",
":",
"try... | Parse the configspec. | [
"Parse",
"the",
"configspec",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1936-L1953 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._set_configspec | def _set_configspec(self, section, copy):
"""
Called by validate. Handles setting the configspec on subsections
including sections to be validated by __many__
"""
configspec = section.configspec
many = configspec.get('__many__')
if isinstance(many, dict):
... | python | def _set_configspec(self, section, copy):
"""
Called by validate. Handles setting the configspec on subsections
including sections to be validated by __many__
"""
configspec = section.configspec
many = configspec.get('__many__')
if isinstance(many, dict):
... | [
"def",
"_set_configspec",
"(",
"self",
",",
"section",
",",
"copy",
")",
":",
"configspec",
"=",
"section",
".",
"configspec",
"many",
"=",
"configspec",
".",
"get",
"(",
"'__many__'",
")",
"if",
"isinstance",
"(",
"many",
",",
"dict",
")",
":",
"for",
... | Called by validate. Handles setting the configspec on subsections
including sections to be validated by __many__ | [
"Called",
"by",
"validate",
".",
"Handles",
"setting",
"the",
"configspec",
"on",
"subsections",
"including",
"sections",
"to",
"be",
"validated",
"by",
"__many__"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1957-L1982 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._write_line | def _write_line(self, indent_string, entry, this_entry, comment):
"""Write an individual line, for the write method"""
# NOTE: the calls to self._quote here handles non-StringType values.
if not self.unrepr:
val = self._decode_element(self._quote(this_entry))
else:
... | python | def _write_line(self, indent_string, entry, this_entry, comment):
"""Write an individual line, for the write method"""
# NOTE: the calls to self._quote here handles non-StringType values.
if not self.unrepr:
val = self._decode_element(self._quote(this_entry))
else:
... | [
"def",
"_write_line",
"(",
"self",
",",
"indent_string",
",",
"entry",
",",
"this_entry",
",",
"comment",
")",
":",
"# NOTE: the calls to self._quote here handles non-StringType values.",
"if",
"not",
"self",
".",
"unrepr",
":",
"val",
"=",
"self",
".",
"_decode_ele... | Write an individual line, for the write method | [
"Write",
"an",
"individual",
"line",
"for",
"the",
"write",
"method"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1985-L1996 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._write_marker | def _write_marker(self, indent_string, depth, entry, comment):
"""Write a section marker line"""
return '%s%s%s%s%s' % (indent_string,
self._a_to_u('[' * depth),
self._quote(self._decode_element(entry), multiline=False),
... | python | def _write_marker(self, indent_string, depth, entry, comment):
"""Write a section marker line"""
return '%s%s%s%s%s' % (indent_string,
self._a_to_u('[' * depth),
self._quote(self._decode_element(entry), multiline=False),
... | [
"def",
"_write_marker",
"(",
"self",
",",
"indent_string",
",",
"depth",
",",
"entry",
",",
"comment",
")",
":",
"return",
"'%s%s%s%s%s'",
"%",
"(",
"indent_string",
",",
"self",
".",
"_a_to_u",
"(",
"'['",
"*",
"depth",
")",
",",
"self",
".",
"_quote",
... | Write a section marker line | [
"Write",
"a",
"section",
"marker",
"line"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1999-L2005 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj._handle_comment | def _handle_comment(self, comment):
"""Deal with a comment."""
if not comment:
return ''
start = self.indent_type
if not comment.startswith('#'):
start += self._a_to_u(' # ')
return (start + comment) | python | def _handle_comment(self, comment):
"""Deal with a comment."""
if not comment:
return ''
start = self.indent_type
if not comment.startswith('#'):
start += self._a_to_u(' # ')
return (start + comment) | [
"def",
"_handle_comment",
"(",
"self",
",",
"comment",
")",
":",
"if",
"not",
"comment",
":",
"return",
"''",
"start",
"=",
"self",
".",
"indent_type",
"if",
"not",
"comment",
".",
"startswith",
"(",
"'#'",
")",
":",
"start",
"+=",
"self",
".",
"_a_to_... | Deal with a comment. | [
"Deal",
"with",
"a",
"comment",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2008-L2015 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj.write | def write(self, outfile=None, section=None):
"""
Write the current ConfigObj as a file
tekNico: FIXME: use StringIO instead of real files
>>> filename = a.filename # doctest: +SKIP
>>> a.filename = 'test.ini' # doctest: +SKIP
>>> a.write() # doctest: +SKIP
... | python | def write(self, outfile=None, section=None):
"""
Write the current ConfigObj as a file
tekNico: FIXME: use StringIO instead of real files
>>> filename = a.filename # doctest: +SKIP
>>> a.filename = 'test.ini' # doctest: +SKIP
>>> a.write() # doctest: +SKIP
... | [
"def",
"write",
"(",
"self",
",",
"outfile",
"=",
"None",
",",
"section",
"=",
"None",
")",
":",
"if",
"self",
".",
"indent_type",
"is",
"None",
":",
"# this can be true if initialised from a dictionary",
"self",
".",
"indent_type",
"=",
"DEFAULT_INDENT_TYPE",
"... | Write the current ConfigObj as a file
tekNico: FIXME: use StringIO instead of real files
>>> filename = a.filename # doctest: +SKIP
>>> a.filename = 'test.ini' # doctest: +SKIP
>>> a.write() # doctest: +SKIP
>>> a.filename = filename # doctest: +SKIP
>>> a == Con... | [
"Write",
"the",
"current",
"ConfigObj",
"as",
"a",
"file"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2020-L2128 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj.validate | def validate(self, validator, preserve_errors=False, copy=False,
section=None):
"""
Test the ConfigObj against a configspec.
It uses the ``validator`` object from *validate.py*.
To run ``validate`` on the current ConfigObj, call: ::
test = config.validate(... | python | def validate(self, validator, preserve_errors=False, copy=False,
section=None):
"""
Test the ConfigObj against a configspec.
It uses the ``validator`` object from *validate.py*.
To run ``validate`` on the current ConfigObj, call: ::
test = config.validate(... | [
"def",
"validate",
"(",
"self",
",",
"validator",
",",
"preserve_errors",
"=",
"False",
",",
"copy",
"=",
"False",
",",
"section",
"=",
"None",
")",
":",
"if",
"section",
"is",
"None",
":",
"if",
"self",
".",
"configspec",
"is",
"None",
":",
"raise",
... | Test the ConfigObj against a configspec.
It uses the ``validator`` object from *validate.py*.
To run ``validate`` on the current ConfigObj, call: ::
test = config.validate(validator)
(Normally having previously passed in the configspec when the ConfigObj
was created - you... | [
"Test",
"the",
"ConfigObj",
"against",
"a",
"configspec",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2130-L2334 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj.reset | def reset(self):
"""Clear ConfigObj instance and restore to 'freshly created' state."""
self.clear()
self._initialise()
# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)
# requires an empty dictionary
self.configspec = None
# ... | python | def reset(self):
"""Clear ConfigObj instance and restore to 'freshly created' state."""
self.clear()
self._initialise()
# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)
# requires an empty dictionary
self.configspec = None
# ... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"_initialise",
"(",
")",
"# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)",
"# requires an empty dictionary",
"self",
".",
"configspec",
"=",
"None"... | Clear ConfigObj instance and restore to 'freshly created' state. | [
"Clear",
"ConfigObj",
"instance",
"and",
"restore",
"to",
"freshly",
"created",
"state",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2337-L2345 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | ConfigObj.reload | def reload(self):
"""
Reload a ConfigObj from file.
This method raises a ``ReloadError`` if the ConfigObj doesn't have
a filename attribute pointing to a file.
"""
if not isinstance(self.filename, string_types):
raise ReloadError()
filename = self.fi... | python | def reload(self):
"""
Reload a ConfigObj from file.
This method raises a ``ReloadError`` if the ConfigObj doesn't have
a filename attribute pointing to a file.
"""
if not isinstance(self.filename, string_types):
raise ReloadError()
filename = self.fi... | [
"def",
"reload",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"filename",
",",
"string_types",
")",
":",
"raise",
"ReloadError",
"(",
")",
"filename",
"=",
"self",
".",
"filename",
"current_options",
"=",
"{",
"}",
"for",
"entry",
... | Reload a ConfigObj from file.
This method raises a ``ReloadError`` if the ConfigObj doesn't have
a filename attribute pointing to a file. | [
"Reload",
"a",
"ConfigObj",
"from",
"file",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2348-L2370 |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | SimpleVal.check | def check(self, check, member, missing=False):
"""A dummy check method, always returns the value unchanged."""
if missing:
raise self.baseErrorClass()
return member | python | def check(self, check, member, missing=False):
"""A dummy check method, always returns the value unchanged."""
if missing:
raise self.baseErrorClass()
return member | [
"def",
"check",
"(",
"self",
",",
"check",
",",
"member",
",",
"missing",
"=",
"False",
")",
":",
"if",
"missing",
":",
"raise",
"self",
".",
"baseErrorClass",
"(",
")",
"return",
"member"
] | A dummy check method, always returns the value unchanged. | [
"A",
"dummy",
"check",
"method",
"always",
"returns",
"the",
"value",
"unchanged",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2389-L2393 |
spacetelescope/stsci.tools | lib/stsci/tools/convertwaiveredfits.py | _processCommandLineArgs | def _processCommandLineArgs():
"""
Get the command line arguments
Parameters: NONE
Returns:
files list of file specifications to be converted
outputFileNames list of output file specifications
(one per input file)
... | python | def _processCommandLineArgs():
"""
Get the command line arguments
Parameters: NONE
Returns:
files list of file specifications to be converted
outputFileNames list of output file specifications
(one per input file)
... | [
"def",
"_processCommandLineArgs",
"(",
")",
":",
"import",
"getopt",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"\"hvmo:\"",
",",
"[",
"\"help\"",
",",
"\"verbose\"",
",",
"\"multiEx... | Get the command line arguments
Parameters: NONE
Returns:
files list of file specifications to be converted
outputFileNames list of output file specifications
(one per input file)
Default: a list of None value... | [
"Get",
"the",
"command",
"line",
"arguments"
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L156-L246 |
spacetelescope/stsci.tools | lib/stsci/tools/convertwaiveredfits.py | _verify | def _verify(waiveredHdul):
"""
Verify that the input HDUList is for a waivered FITS file.
Parameters:
waiveredHdul HDUList object to be verified
Returns: None
Exceptions:
ValueError Input HDUList is not for a waivered FITS file
"""
if len... | python | def _verify(waiveredHdul):
"""
Verify that the input HDUList is for a waivered FITS file.
Parameters:
waiveredHdul HDUList object to be verified
Returns: None
Exceptions:
ValueError Input HDUList is not for a waivered FITS file
"""
if len... | [
"def",
"_verify",
"(",
"waiveredHdul",
")",
":",
"if",
"len",
"(",
"waiveredHdul",
")",
"==",
"2",
":",
"#",
"# There must be exactly 2 HDU's",
"#",
"if",
"waiveredHdul",
"[",
"0",
"]",
".",
"header",
"[",
"'NAXIS'",
"]",
">",
"0",
":",
"#",
"# The Prima... | Verify that the input HDUList is for a waivered FITS file.
Parameters:
waiveredHdul HDUList object to be verified
Returns: None
Exceptions:
ValueError Input HDUList is not for a waivered FITS file | [
"Verify",
"that",
"the",
"input",
"HDUList",
"is",
"for",
"a",
"waivered",
"FITS",
"file",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L248-L288 |
spacetelescope/stsci.tools | lib/stsci/tools/convertwaiveredfits.py | toMultiExtensionFits | def toMultiExtensionFits(waiveredObject,
multiExtensionFileName=None,
forceFileOutput=False,
verbose=False):
"""
Convert the input waivered FITS object to a multi-extension FITS
HDUList object. Generate an output multi-exten... | python | def toMultiExtensionFits(waiveredObject,
multiExtensionFileName=None,
forceFileOutput=False,
verbose=False):
"""
Convert the input waivered FITS object to a multi-extension FITS
HDUList object. Generate an output multi-exten... | [
"def",
"toMultiExtensionFits",
"(",
"waiveredObject",
",",
"multiExtensionFileName",
"=",
"None",
",",
"forceFileOutput",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"waiveredObject",
",",
"fits",
".",
"HDUList",
")",
":",
"w... | Convert the input waivered FITS object to a multi-extension FITS
HDUList object. Generate an output multi-extension FITS file if
requested.
Parameters:
waiveredObject input object representing a waivered FITS file;
either a astroyp.io.fits.HDUList object, ... | [
"Convert",
"the",
"input",
"waivered",
"FITS",
"object",
"to",
"a",
"multi",
"-",
"extension",
"FITS",
"HDUList",
"object",
".",
"Generate",
"an",
"output",
"multi",
"-",
"extension",
"FITS",
"file",
"if",
"requested",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L290-L512 |
spacetelescope/stsci.tools | lib/stsci/tools/convertwaiveredfits.py | convertwaiveredfits | def convertwaiveredfits(waiveredObject,
outputFileName=None,
forceFileOutput=False,
convertTo='multiExtension',
verbose=False):
"""
Convert the input waivered FITS object to various formats. The
default ... | python | def convertwaiveredfits(waiveredObject,
outputFileName=None,
forceFileOutput=False,
convertTo='multiExtension',
verbose=False):
"""
Convert the input waivered FITS object to various formats. The
default ... | [
"def",
"convertwaiveredfits",
"(",
"waiveredObject",
",",
"outputFileName",
"=",
"None",
",",
"forceFileOutput",
"=",
"False",
",",
"convertTo",
"=",
"'multiExtension'",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"convertTo",
"==",
"'multiExtension'",
":",
"f... | Convert the input waivered FITS object to various formats. The
default conversion format is multi-extension FITS. Generate an output
file in the desired format if requested.
Parameters:
waiveredObject input object representing a waivered FITS file;
either... | [
"Convert",
"the",
"input",
"waivered",
"FITS",
"object",
"to",
"various",
"formats",
".",
"The",
"default",
"conversion",
"format",
"is",
"multi",
"-",
"extension",
"FITS",
".",
"Generate",
"an",
"output",
"file",
"in",
"the",
"desired",
"format",
"if",
"req... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L515-L563 |
fitnr/convertdate | convertdate/persian.py | to_jd | def to_jd(year, month, day):
'''Determine Julian day from Persian date'''
if year >= 0:
y = 474
else:
y = 473
epbase = year - y
epyear = 474 + (epbase % 2820)
if month <= 7:
m = (month - 1) * 31
else:
m = (month - 1) * 30 + 6
return day + m + trunc(((ep... | python | def to_jd(year, month, day):
'''Determine Julian day from Persian date'''
if year >= 0:
y = 474
else:
y = 473
epbase = year - y
epyear = 474 + (epbase % 2820)
if month <= 7:
m = (month - 1) * 31
else:
m = (month - 1) * 30 + 6
return day + m + trunc(((ep... | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"if",
"year",
">=",
"0",
":",
"y",
"=",
"474",
"else",
":",
"y",
"=",
"473",
"epbase",
"=",
"year",
"-",
"y",
"epyear",
"=",
"474",
"+",
"(",
"epbase",
"%",
"2820",
")",
"if",
... | Determine Julian day from Persian date | [
"Determine",
"Julian",
"day",
"from",
"Persian",
"date"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/persian.py#L33-L48 |
fitnr/convertdate | convertdate/persian.py | from_jd | def from_jd(jd):
'''Calculate Persian date from Julian day'''
jd = trunc(jd) + 0.5
depoch = jd - to_jd(475, 1, 1)
cycle = trunc(depoch / 1029983)
cyear = (depoch % 1029983)
if cyear == 1029982:
ycycle = 2820
else:
aux1 = trunc(cyear / 366)
aux2 = cyear % 366
... | python | def from_jd(jd):
'''Calculate Persian date from Julian day'''
jd = trunc(jd) + 0.5
depoch = jd - to_jd(475, 1, 1)
cycle = trunc(depoch / 1029983)
cyear = (depoch % 1029983)
if cyear == 1029982:
ycycle = 2820
else:
aux1 = trunc(cyear / 366)
aux2 = cyear % 366
... | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"jd",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"depoch",
"=",
"jd",
"-",
"to_jd",
"(",
"475",
",",
"1",
",",
"1",
")",
"cycle",
"=",
"trunc",
"(",
"depoch",
"/",
"1029983",
")",
"cyear",
"=",
"(",
"depo... | Calculate Persian date from Julian day | [
"Calculate",
"Persian",
"date",
"from",
"Julian",
"day"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/persian.py#L51-L80 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | setup_global_logging | def setup_global_logging():
"""
Initializes capture of stdout/stderr, Python warnings, and exceptions;
redirecting them to the loggers for the modules from which they originated.
"""
global global_logging_started
if not PY3K:
sys.exc_clear()
if global_logging_started:
retu... | python | def setup_global_logging():
"""
Initializes capture of stdout/stderr, Python warnings, and exceptions;
redirecting them to the loggers for the modules from which they originated.
"""
global global_logging_started
if not PY3K:
sys.exc_clear()
if global_logging_started:
retu... | [
"def",
"setup_global_logging",
"(",
")",
":",
"global",
"global_logging_started",
"if",
"not",
"PY3K",
":",
"sys",
".",
"exc_clear",
"(",
")",
"if",
"global_logging_started",
":",
"return",
"orig_logger_class",
"=",
"logging",
".",
"getLoggerClass",
"(",
")",
"l... | Initializes capture of stdout/stderr, Python warnings, and exceptions;
redirecting them to the loggers for the modules from which they originated. | [
"Initializes",
"capture",
"of",
"stdout",
"/",
"stderr",
"Python",
"warnings",
"and",
"exceptions",
";",
"redirecting",
"them",
"to",
"the",
"loggers",
"for",
"the",
"modules",
"from",
"which",
"they",
"originated",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L390-L428 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | teardown_global_logging | def teardown_global_logging():
"""Disable global logging of stdio, warnings, and exceptions."""
global global_logging_started
if not global_logging_started:
return
stdout_logger = logging.getLogger(__name__ + '.stdout')
stderr_logger = logging.getLogger(__name__ + '.stderr')
if sys.std... | python | def teardown_global_logging():
"""Disable global logging of stdio, warnings, and exceptions."""
global global_logging_started
if not global_logging_started:
return
stdout_logger = logging.getLogger(__name__ + '.stdout')
stderr_logger = logging.getLogger(__name__ + '.stderr')
if sys.std... | [
"def",
"teardown_global_logging",
"(",
")",
":",
"global",
"global_logging_started",
"if",
"not",
"global_logging_started",
":",
"return",
"stdout_logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
"+",
"'.stdout'",
")",
"stderr_logger",
"=",
"logging",
"."... | Disable global logging of stdio, warnings, and exceptions. | [
"Disable",
"global",
"logging",
"of",
"stdio",
"warnings",
"and",
"exceptions",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L431-L464 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | create_logger | def create_logger(name, format='%(levelname)s: %(message)s', datefmt=None,
stream=None, level=logging.INFO, filename=None, filemode='w',
filelevel=None, propagate=True):
"""
Do basic configuration for the logging system. Similar to
logging.basicConfig but the logger ``nam... | python | def create_logger(name, format='%(levelname)s: %(message)s', datefmt=None,
stream=None, level=logging.INFO, filename=None, filemode='w',
filelevel=None, propagate=True):
"""
Do basic configuration for the logging system. Similar to
logging.basicConfig but the logger ``nam... | [
"def",
"create_logger",
"(",
"name",
",",
"format",
"=",
"'%(levelname)s: %(message)s'",
",",
"datefmt",
"=",
"None",
",",
"stream",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"INFO",
",",
"filename",
"=",
"None",
",",
"filemode",
"=",
"'w'",
",",
"... | Do basic configuration for the logging system. Similar to
logging.basicConfig but the logger ``name`` is configurable and both a file
output and a stream output can be created. Returns a logger object.
The default behaviour is to create a logger called ``name`` with a null
handled, and to use the "%(le... | [
"Do",
"basic",
"configuration",
"for",
"the",
"logging",
"system",
".",
"Similar",
"to",
"logging",
".",
"basicConfig",
"but",
"the",
"logger",
"name",
"is",
"configurable",
"and",
"both",
"a",
"file",
"output",
"and",
"a",
"stream",
"output",
"can",
"be",
... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L469-L527 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | StreamTeeLogger.set_stream | def set_stream(self, stream):
"""
Set the stream that this logger is meant to replace. Usually this will
be either `sys.stdout` or `sys.stderr`, but can be any object with
`write()` and `flush()` methods, as supported by
`logging.StreamHandler`.
"""
for handler ... | python | def set_stream(self, stream):
"""
Set the stream that this logger is meant to replace. Usually this will
be either `sys.stdout` or `sys.stderr`, but can be any object with
`write()` and `flush()` methods, as supported by
`logging.StreamHandler`.
"""
for handler ... | [
"def",
"set_stream",
"(",
"self",
",",
"stream",
")",
":",
"for",
"handler",
"in",
"self",
".",
"handlers",
"[",
":",
"]",
":",
"if",
"isinstance",
"(",
"handler",
",",
"logging",
".",
"StreamHandler",
")",
":",
"self",
".",
"handlers",
".",
"remove",
... | Set the stream that this logger is meant to replace. Usually this will
be either `sys.stdout` or `sys.stderr`, but can be any object with
`write()` and `flush()` methods, as supported by
`logging.StreamHandler`. | [
"Set",
"the",
"stream",
"that",
"this",
"logger",
"is",
"meant",
"to",
"replace",
".",
"Usually",
"this",
"will",
"be",
"either",
"sys",
".",
"stdout",
"or",
"sys",
".",
"stderr",
"but",
"can",
"be",
"any",
"object",
"with",
"write",
"()",
"and",
"flus... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L206-L224 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | StreamTeeLogger.write | def write(self, message):
"""
Buffers each message until a newline is reached. Each complete line is
then published to the logging system through ``self.log()``.
"""
self.__thread_local_ctx.write_count += 1
try:
if self.__thread_local_ctx.write_count > 1:
... | python | def write(self, message):
"""
Buffers each message until a newline is reached. Each complete line is
then published to the logging system through ``self.log()``.
"""
self.__thread_local_ctx.write_count += 1
try:
if self.__thread_local_ctx.write_count > 1:
... | [
"def",
"write",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"__thread_local_ctx",
".",
"write_count",
"+=",
"1",
"try",
":",
"if",
"self",
".",
"__thread_local_ctx",
".",
"write_count",
">",
"1",
":",
"return",
"# For each line in the buffer ending with ... | Buffers each message until a newline is reached. Each complete line is
then published to the logging system through ``self.log()``. | [
"Buffers",
"each",
"message",
"until",
"a",
"newline",
"is",
"reached",
".",
"Each",
"complete",
"line",
"is",
"then",
"published",
"to",
"the",
"logging",
"system",
"through",
"self",
".",
"log",
"()",
"."
] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L226-L245 |
spacetelescope/stsci.tools | lib/stsci/tools/logutil.py | StreamTeeLogger.find_actual_caller | def find_actual_caller(self):
"""
Returns the full-qualified module name, full pathname, line number, and
function in which `StreamTeeLogger.write()` was called. For example,
if this instance is used to replace `sys.stdout`, this will return the
location of any print statement.
... | python | def find_actual_caller(self):
"""
Returns the full-qualified module name, full pathname, line number, and
function in which `StreamTeeLogger.write()` was called. For example,
if this instance is used to replace `sys.stdout`, this will return the
location of any print statement.
... | [
"def",
"find_actual_caller",
"(",
"self",
")",
":",
"# Gleaned from code in the logging module itself...",
"try",
":",
"f",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"##f = inspect.currentframe(1)",
"except",
"Exception",
":",
"f",
"=",
"None",
"# On some versions ... | Returns the full-qualified module name, full pathname, line number, and
function in which `StreamTeeLogger.write()` was called. For example,
if this instance is used to replace `sys.stdout`, this will return the
location of any print statement. | [
"Returns",
"the",
"full",
"-",
"qualified",
"module",
"name",
"full",
"pathname",
"line",
"number",
"and",
"function",
"in",
"which",
"StreamTeeLogger",
".",
"write",
"()",
"was",
"called",
".",
"For",
"example",
"if",
"this",
"instance",
"is",
"used",
"to",... | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L274-L310 |
selik/xport | xport/__init__.py | load | def load(fp):
'''
Deserialize ``fp`` (a ``.read()``-supporting file-like object
containing a XPORT document) to a Python object.
'''
reader = reading.Reader(fp)
keys = reader.fields
columns = {k: [] for k in keys}
for row in reader:
for key, value in zip(keys, row):
c... | python | def load(fp):
'''
Deserialize ``fp`` (a ``.read()``-supporting file-like object
containing a XPORT document) to a Python object.
'''
reader = reading.Reader(fp)
keys = reader.fields
columns = {k: [] for k in keys}
for row in reader:
for key, value in zip(keys, row):
c... | [
"def",
"load",
"(",
"fp",
")",
":",
"reader",
"=",
"reading",
".",
"Reader",
"(",
"fp",
")",
"keys",
"=",
"reader",
".",
"fields",
"columns",
"=",
"{",
"k",
":",
"[",
"]",
"for",
"k",
"in",
"keys",
"}",
"for",
"row",
"in",
"reader",
":",
"for",... | Deserialize ``fp`` (a ``.read()``-supporting file-like object
containing a XPORT document) to a Python object. | [
"Deserialize",
"fp",
"(",
"a",
".",
"read",
"()",
"-",
"supporting",
"file",
"-",
"like",
"object",
"containing",
"a",
"XPORT",
"document",
")",
"to",
"a",
"Python",
"object",
"."
] | train | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/__init__.py#L23-L34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.