partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
MeasurementController.completeMeasurement
Completes the measurement session. :param deviceId: the device id. :param measurementId: the measurement id. :return: true if it was completed.
backend/src/analyser/common/measurementcontroller.py
def completeMeasurement(self, measurementId, deviceId): """ Completes the measurement session. :param deviceId: the device id. :param measurementId: the measurement id. :return: true if it was completed. """ am, handler = self.getDataHandler(measurementId, deviceI...
def completeMeasurement(self, measurementId, deviceId): """ Completes the measurement session. :param deviceId: the device id. :param measurementId: the measurement id. :return: true if it was completed. """ am, handler = self.getDataHandler(measurementId, deviceI...
[ "Completes", "the", "measurement", "session", ".", ":", "param", "deviceId", ":", "the", "device", "id", ".", ":", "param", "measurementId", ":", "the", "measurement", "id", ".", ":", "return", ":", "true", "if", "it", "was", "completed", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L394-L407
[ "def", "completeMeasurement", "(", "self", ",", "measurementId", ",", "deviceId", ")", ":", "am", ",", "handler", "=", "self", ".", "getDataHandler", "(", "measurementId", ",", "deviceId", ")", "if", "handler", "is", "not", "None", ":", "handler", ".", "st...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.failMeasurement
Fails the measurement session. :param deviceName: the device name. :param measurementId: the measurement name. :param failureReason: why it failed. :return: true if it was completed.
backend/src/analyser/common/measurementcontroller.py
def failMeasurement(self, measurementId, deviceName, failureReason=None): """ Fails the measurement session. :param deviceName: the device name. :param measurementId: the measurement name. :param failureReason: why it failed. :return: true if it was completed. """...
def failMeasurement(self, measurementId, deviceName, failureReason=None): """ Fails the measurement session. :param deviceName: the device name. :param measurementId: the measurement name. :param failureReason: why it failed. :return: true if it was completed. """...
[ "Fails", "the", "measurement", "session", ".", ":", "param", "deviceName", ":", "the", "device", "name", ".", ":", "param", "measurementId", ":", "the", "measurement", "name", ".", ":", "param", "failureReason", ":", "why", "it", "failed", ".", ":", "retur...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L409-L423
[ "def", "failMeasurement", "(", "self", ",", "measurementId", ",", "deviceName", ",", "failureReason", "=", "None", ")", ":", "am", ",", "handler", "=", "self", ".", "getDataHandler", "(", "measurementId", ",", "deviceName", ")", "if", "handler", "is", "not",...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController._deleteCompletedMeasurement
Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted
backend/src/analyser/common/measurementcontroller.py
def _deleteCompletedMeasurement(self, measurementId): """ Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted """ message, cou...
def _deleteCompletedMeasurement(self, measurementId): """ Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted """ message, cou...
[ "Deletes", "the", "named", "measurement", "from", "the", "completed", "measurement", "store", "if", "it", "exists", ".", ":", "param", "measurementId", ":", ":", "return", ":", "String", ":", "error", "messages", "Integer", ":", "count", "of", "measurements", ...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L434-L445
[ "def", "_deleteCompletedMeasurement", "(", "self", ",", "measurementId", ")", ":", "message", ",", "count", ",", "deleted", "=", "self", ".", "deleteFrom", "(", "measurementId", ",", "self", ".", "completeMeasurements", ")", "if", "count", "is", "0", ":", "m...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.reloadCompletedMeasurements
Reloads the completed measurements from the backing store.
backend/src/analyser/common/measurementcontroller.py
def reloadCompletedMeasurements(self): """ Reloads the completed measurements from the backing store. """ from pathlib import Path reloaded = [self.load(x.resolve()) for x in Path(self.dataDir).glob('*/*/*') if x.is_dir()] logger.info('Reloaded ' + str(len(reloaded)) + ' ...
def reloadCompletedMeasurements(self): """ Reloads the completed measurements from the backing store. """ from pathlib import Path reloaded = [self.load(x.resolve()) for x in Path(self.dataDir).glob('*/*/*') if x.is_dir()] logger.info('Reloaded ' + str(len(reloaded)) + ' ...
[ "Reloads", "the", "completed", "measurements", "from", "the", "backing", "store", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L469-L477
[ "def", "reloadCompletedMeasurements", "(", "self", ")", ":", "from", "pathlib", "import", "Path", "reloaded", "=", "[", "self", ".", "load", "(", "x", ".", "resolve", "(", ")", ")", "for", "x", "in", "Path", "(", "self", ".", "dataDir", ")", ".", "gl...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.getMeasurements
Gets all available measurements. :param measurementStatus return only the measurements in the given state. :return:
backend/src/analyser/common/measurementcontroller.py
def getMeasurements(self, measurementStatus=None): """ Gets all available measurements. :param measurementStatus return only the measurements in the given state. :return: """ if measurementStatus is None: return self.activeMeasurements + self.completeMeasureme...
def getMeasurements(self, measurementStatus=None): """ Gets all available measurements. :param measurementStatus return only the measurements in the given state. :return: """ if measurementStatus is None: return self.activeMeasurements + self.completeMeasureme...
[ "Gets", "all", "available", "measurements", ".", ":", "param", "measurementStatus", "return", "only", "the", "measurements", "in", "the", "given", "state", ".", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L479-L494
[ "def", "getMeasurements", "(", "self", ",", "measurementStatus", "=", "None", ")", ":", "if", "measurementStatus", "is", "None", ":", "return", "self", ".", "activeMeasurements", "+", "self", ".", "completeMeasurements", "+", "self", ".", "failedMeasurements", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.getMeasurement
Gets the measurement with the given id. :param measurementId: the id. :param measurementStatus: the status of the requested measurement. :return: the matching measurement or none if it doesn't exist.
backend/src/analyser/common/measurementcontroller.py
def getMeasurement(self, measurementId, measurementStatus=None): """ Gets the measurement with the given id. :param measurementId: the id. :param measurementStatus: the status of the requested measurement. :return: the matching measurement or none if it doesn't exist. """...
def getMeasurement(self, measurementId, measurementStatus=None): """ Gets the measurement with the given id. :param measurementId: the id. :param measurementStatus: the status of the requested measurement. :return: the matching measurement or none if it doesn't exist. """...
[ "Gets", "the", "measurement", "with", "the", "given", "id", ".", ":", "param", "measurementId", ":", "the", "id", ".", ":", "param", "measurementStatus", ":", "the", "status", "of", "the", "requested", "measurement", ".", ":", "return", ":", "the", "matchi...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L496-L503
[ "def", "getMeasurement", "(", "self", ",", "measurementId", ",", "measurementStatus", "=", "None", ")", ":", "return", "next", "(", "(", "x", "for", "x", "in", "self", ".", "getMeasurements", "(", "measurementStatus", ")", "if", "x", ".", "id", "==", "me...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.store
Writes the measurement metadata to disk on completion. :param activeMeasurement: the measurement that has completed. :returns the persisted metadata.
backend/src/analyser/common/measurementcontroller.py
def store(self, measurement): """ Writes the measurement metadata to disk on completion. :param activeMeasurement: the measurement that has completed. :returns the persisted metadata. """ os.makedirs(self._getPathToMeasurementMetaDir(measurement.idAsPath), exist_ok=True) ...
def store(self, measurement): """ Writes the measurement metadata to disk on completion. :param activeMeasurement: the measurement that has completed. :returns the persisted metadata. """ os.makedirs(self._getPathToMeasurementMetaDir(measurement.idAsPath), exist_ok=True) ...
[ "Writes", "the", "measurement", "metadata", "to", "disk", "on", "completion", ".", ":", "param", "activeMeasurement", ":", "the", "measurement", "that", "has", "completed", ".", ":", "returns", "the", "persisted", "metadata", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L505-L515
[ "def", "store", "(", "self", ",", "measurement", ")", ":", "os", ".", "makedirs", "(", "self", ".", "_getPathToMeasurementMetaDir", "(", "measurement", ".", "idAsPath", ")", ",", "exist_ok", "=", "True", ")", "output", "=", "marshal", "(", "measurement", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.load
Loads a CompletedMeasurement from the path.á :param path: the path at which the data is found. :return: the measurement
backend/src/analyser/common/measurementcontroller.py
def load(self, path): """ Loads a CompletedMeasurement from the path.á :param path: the path at which the data is found. :return: the measurement """ meta = self._loadMetaFromJson(path) return CompleteMeasurement(meta, self.dataDir) if meta is not None else None
def load(self, path): """ Loads a CompletedMeasurement from the path.á :param path: the path at which the data is found. :return: the measurement """ meta = self._loadMetaFromJson(path) return CompleteMeasurement(meta, self.dataDir) if meta is not None else None
[ "Loads", "a", "CompletedMeasurement", "from", "the", "path", ".", "á", ":", "param", "path", ":", "the", "path", "at", "which", "the", "data", "is", "found", ".", ":", "return", ":", "the", "measurement" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L517-L524
[ "def", "load", "(", "self", ",", "path", ")", ":", "meta", "=", "self", ".", "_loadMetaFromJson", "(", "path", ")", "return", "CompleteMeasurement", "(", "meta", ",", "self", ".", "dataDir", ")", "if", "meta", "is", "not", "None", "else", "None" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController._loadMetaFromJson
Reads the json meta into memory. :return: the meta.
backend/src/analyser/common/measurementcontroller.py
def _loadMetaFromJson(self, path): """ Reads the json meta into memory. :return: the meta. """ try: with (path / 'metadata.json').open() as infile: return json.load(infile) except FileNotFoundError: logger.error('Metadata does not e...
def _loadMetaFromJson(self, path): """ Reads the json meta into memory. :return: the meta. """ try: with (path / 'metadata.json').open() as infile: return json.load(infile) except FileNotFoundError: logger.error('Metadata does not e...
[ "Reads", "the", "json", "meta", "into", "memory", ".", ":", "return", ":", "the", "meta", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L526-L536
[ "def", "_loadMetaFromJson", "(", "self", ",", "path", ")", ":", "try", ":", "with", "(", "path", "/", "'metadata.json'", ")", ".", "open", "(", ")", "as", "infile", ":", "return", "json", ".", "load", "(", "infile", ")", "except", "FileNotFoundError", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController.editMeasurement
Edits the specified measurement with the provided data. :param measurementId: the measurement id. :param data: the data to update. :return: true if the measurement was edited
backend/src/analyser/common/measurementcontroller.py
def editMeasurement(self, measurementId, data): """ Edits the specified measurement with the provided data. :param measurementId: the measurement id. :param data: the data to update. :return: true if the measurement was edited """ oldMeasurement = self.getMeasur...
def editMeasurement(self, measurementId, data): """ Edits the specified measurement with the provided data. :param measurementId: the measurement id. :param data: the data to update. :return: true if the measurement was edited """ oldMeasurement = self.getMeasur...
[ "Edits", "the", "specified", "measurement", "with", "the", "provided", "data", ".", ":", "param", "measurementId", ":", "the", "measurement", "id", ".", ":", "param", "data", ":", "the", "data", "to", "update", ".", ":", "return", ":", "true", "if", "the...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L544-L601
[ "def", "editMeasurement", "(", "self", ",", "measurementId", ",", "data", ")", ":", "oldMeasurement", "=", "self", ".", "getMeasurement", "(", "measurementId", ",", "measurementStatus", "=", "MeasurementStatus", ".", "COMPLETE", ")", "if", "oldMeasurement", ":", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
MeasurementController._filterCopy
Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting the times as appropriate so it starts from 0. :param dataFile: the input file. :param newStart: the new start time. :param newEnd: the new end time. :param newDataDir: ...
backend/src/analyser/common/measurementcontroller.py
def _filterCopy(self, dataFile, newStart, newEnd, newDataDir): """ Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting the times as appropriate so it starts from 0. :param dataFile: the input file. :param newStart: the n...
def _filterCopy(self, dataFile, newStart, newEnd, newDataDir): """ Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting the times as appropriate so it starts from 0. :param dataFile: the input file. :param newStart: the n...
[ "Copies", "the", "data", "file", "to", "a", "new", "file", "in", "the", "tmp", "dir", "filtering", "it", "according", "to", "newStart", "and", "newEnd", "and", "adjusting", "the", "times", "as", "appropriate", "so", "it", "starts", "from", "0", ".", ":",...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L603-L635
[ "def", "_filterCopy", "(", "self", ",", "dataFile", ",", "newStart", ",", "newEnd", ",", "newDataDir", ")", ":", "import", "csv", "pathToData", "=", "os", ".", "path", ".", "split", "(", "dataFile", ")", "dataFileName", "=", "pathToData", "[", "1", "]", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
checkFiles
- Converts waiver fits sciece and data quality files to MEF format - Converts GEIS science and data quality files to MEF format - Checks for stis association tables and splits them into single imsets - Removes files with EXPTIME=0 and the corresponding ivm files - Removes files with NGOODPIX == 0 (to ex...
lib/stsci/tools/check_files.py
def checkFiles(filelist,ivmlist = None): """ - Converts waiver fits sciece and data quality files to MEF format - Converts GEIS science and data quality files to MEF format - Checks for stis association tables and splits them into single imsets - Removes files with EXPTIME=0 and the corresponding iv...
def checkFiles(filelist,ivmlist = None): """ - Converts waiver fits sciece and data quality files to MEF format - Converts GEIS science and data quality files to MEF format - Checks for stis association tables and splits them into single imsets - Removes files with EXPTIME=0 and the corresponding iv...
[ "-", "Converts", "waiver", "fits", "sciece", "and", "data", "quality", "files", "to", "MEF", "format", "-", "Converts", "GEIS", "science", "and", "data", "quality", "files", "to", "MEF", "format", "-", "Checks", "for", "stis", "association", "tables", "and",...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L20-L62
[ "def", "checkFiles", "(", "filelist", ",", "ivmlist", "=", "None", ")", ":", "toclose", "=", "False", "if", "isinstance", "(", "filelist", "[", "0", "]", ",", "str", ")", ":", "toclose", "=", "True", "newfilelist", ",", "ivmlist", "=", "checkFITSFormat",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
checkFITSFormat
This code will check whether or not files are GEIS or WAIVER FITS and convert them to MEF if found. It also keeps the IVMLIST consistent with the input filelist, in the case that some inputs get dropped during the check/conversion.
lib/stsci/tools/check_files.py
def checkFITSFormat(filelist, ivmlist=None): """ This code will check whether or not files are GEIS or WAIVER FITS and convert them to MEF if found. It also keeps the IVMLIST consistent with the input filelist, in the case that some inputs get dropped during the check/conversion. """ if ivml...
def checkFITSFormat(filelist, ivmlist=None): """ This code will check whether or not files are GEIS or WAIVER FITS and convert them to MEF if found. It also keeps the IVMLIST consistent with the input filelist, in the case that some inputs get dropped during the check/conversion. """ if ivml...
[ "This", "code", "will", "check", "whether", "or", "not", "files", "are", "GEIS", "or", "WAIVER", "FITS", "and", "convert", "them", "to", "MEF", "if", "found", ".", "It", "also", "keeps", "the", "IVMLIST", "consistent", "with", "the", "input", "filelist", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L64-L86
[ "def", "checkFITSFormat", "(", "filelist", ",", "ivmlist", "=", "None", ")", ":", "if", "ivmlist", "is", "None", ":", "ivmlist", "=", "[", "None", "for", "l", "in", "filelist", "]", "sci_ivm", "=", "list", "(", "zip", "(", "filelist", ",", "ivmlist", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
check_exptime
Removes files with EXPTIME==0 from filelist.
lib/stsci/tools/check_files.py
def check_exptime(filelist): """ Removes files with EXPTIME==0 from filelist. """ toclose = False removed_files = [] for f in filelist: if isinstance(f, str): f = fits.open(f) toclose = True try: exptime = f[0].header['EXPTIME'] except...
def check_exptime(filelist): """ Removes files with EXPTIME==0 from filelist. """ toclose = False removed_files = [] for f in filelist: if isinstance(f, str): f = fits.open(f) toclose = True try: exptime = f[0].header['EXPTIME'] except...
[ "Removes", "files", "with", "EXPTIME", "==", "0", "from", "filelist", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L139-L164
[ "def", "check_exptime", "(", "filelist", ")", ":", "toclose", "=", "False", "removed_files", "=", "[", "]", "for", "f", "in", "filelist", ":", "if", "isinstance", "(", "f", ",", "str", ")", ":", "f", "=", "fits", ".", "open", "(", "f", ")", "toclos...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
checkNGOODPIX
Only for ACS, WFC3 and STIS, check NGOODPIX If all pixels are 'bad' on all chips, exclude this image from further processing. Similar checks requiring comparing 'driz_sep_bits' against WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be done separately (and later).
lib/stsci/tools/check_files.py
def checkNGOODPIX(filelist): """ Only for ACS, WFC3 and STIS, check NGOODPIX If all pixels are 'bad' on all chips, exclude this image from further processing. Similar checks requiring comparing 'driz_sep_bits' against WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be done separately...
def checkNGOODPIX(filelist): """ Only for ACS, WFC3 and STIS, check NGOODPIX If all pixels are 'bad' on all chips, exclude this image from further processing. Similar checks requiring comparing 'driz_sep_bits' against WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be done separately...
[ "Only", "for", "ACS", "WFC3", "and", "STIS", "check", "NGOODPIX", "If", "all", "pixels", "are", "bad", "on", "all", "chips", "exclude", "this", "image", "from", "further", "processing", ".", "Similar", "checks", "requiring", "comparing", "driz_sep_bits", "agai...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L166-L201
[ "def", "checkNGOODPIX", "(", "filelist", ")", ":", "toclose", "=", "False", "removed_files", "=", "[", "]", "supported_instruments", "=", "[", "'ACS'", ",", "'STIS'", ",", "'WFC3'", "]", "for", "inputfile", "in", "filelist", ":", "if", "isinstance", "(", "...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
stisObsCount
Input: A stis multiextension file Output: Number of stis science extensions in input
lib/stsci/tools/check_files.py
def stisObsCount(input): """ Input: A stis multiextension file Output: Number of stis science extensions in input """ count = 0 toclose = False if isinstance(input, str): input = fits.open(input) toclose = True for ext in input: if 'extname' in ext.header: ...
def stisObsCount(input): """ Input: A stis multiextension file Output: Number of stis science extensions in input """ count = 0 toclose = False if isinstance(input, str): input = fits.open(input) toclose = True for ext in input: if 'extname' in ext.header: ...
[ "Input", ":", "A", "stis", "multiextension", "file", "Output", ":", "Number", "of", "stis", "science", "extensions", "in", "input" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L221-L237
[ "def", "stisObsCount", "(", "input", ")", ":", "count", "=", "0", "toclose", "=", "False", "if", "isinstance", "(", "input", ",", "str", ")", ":", "input", "=", "fits", ".", "open", "(", "input", ")", "toclose", "=", "True", "for", "ext", "in", "in...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
splitStis
Split a STIS association file into multiple imset MEF files. Split the corresponding spt file if present into single spt files. If an spt file can't be split or is missing a Warning is printed. Returns ------- names: list a list with the names of the new flt files.
lib/stsci/tools/check_files.py
def splitStis(stisfile, sci_count): """ Split a STIS association file into multiple imset MEF files. Split the corresponding spt file if present into single spt files. If an spt file can't be split or is missing a Warning is printed. Returns ------- names: list a list with the name...
def splitStis(stisfile, sci_count): """ Split a STIS association file into multiple imset MEF files. Split the corresponding spt file if present into single spt files. If an spt file can't be split or is missing a Warning is printed. Returns ------- names: list a list with the name...
[ "Split", "a", "STIS", "association", "file", "into", "multiple", "imset", "MEF", "files", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L239-L340
[ "def", "splitStis", "(", "stisfile", ",", "sci_count", ")", ":", "newfiles", "=", "[", "]", "toclose", "=", "False", "if", "isinstance", "(", "stisfile", ",", "str", ")", ":", "f", "=", "fits", ".", "open", "(", "stisfile", ")", "toclose", "=", "True...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
stisExt2PrimKw
Several kw which are usually in the primary header are in the extension header for STIS. They are copied to the primary header for convenience. List if kw: 'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME'
lib/stsci/tools/check_files.py
def stisExt2PrimKw(stisfiles): """ Several kw which are usually in the primary header are in the extension header for STIS. They are copied to the primary header for convenience. List if kw: 'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME' """ kw_list = ['DATE-OBS', 'EXPE...
def stisExt2PrimKw(stisfiles): """ Several kw which are usually in the primary header are in the extension header for STIS. They are copied to the primary header for convenience. List if kw: 'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME' """ kw_list = ['DATE-OBS', 'EXPE...
[ "Several", "kw", "which", "are", "usually", "in", "the", "primary", "header", "are", "in", "the", "extension", "header", "for", "STIS", ".", "They", "are", "copied", "to", "the", "primary", "header", "for", "convenience", ".", "List", "if", "kw", ":", "D...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L342-L365
[ "def", "stisExt2PrimKw", "(", "stisfiles", ")", ":", "kw_list", "=", "[", "'DATE-OBS'", ",", "'EXPEND'", ",", "'EXPSTART'", ",", "'EXPTIME'", "]", "for", "sfile", "in", "stisfiles", ":", "toclose", "=", "False", "if", "isinstance", "(", "sfile", ",", "str"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
convert2fits
Checks if a file is in WAIVER of GEIS format and converts it to MEF
lib/stsci/tools/check_files.py
def convert2fits(sci_ivm): """ Checks if a file is in WAIVER of GEIS format and converts it to MEF """ removed_files = [] translated_names = [] newivmlist = [] for file in sci_ivm: #find out what the input is # if science file is not found on disk, add it to removed_files fo...
def convert2fits(sci_ivm): """ Checks if a file is in WAIVER of GEIS format and converts it to MEF """ removed_files = [] translated_names = [] newivmlist = [] for file in sci_ivm: #find out what the input is # if science file is not found on disk, add it to removed_files fo...
[ "Checks", "if", "a", "file", "is", "in", "WAIVER", "of", "GEIS", "format", "and", "converts", "it", "to", "MEF" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L408-L452
[ "def", "convert2fits", "(", "sci_ivm", ")", ":", "removed_files", "=", "[", "]", "translated_names", "=", "[", "]", "newivmlist", "=", "[", "]", "for", "file", "in", "sci_ivm", ":", "#find out what the input is", "# if science file is not found on disk, add it to remo...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
waiver2mef
Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image.
lib/stsci/tools/check_files.py
def waiver2mef(sciname, newname=None, convert_dq=True, writefits=True): """ Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image. """ if isinstance(sciname, fits.HDUList): ...
def waiver2mef(sciname, newname=None, convert_dq=True, writefits=True): """ Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image. """ if isinstance(sciname, fits.HDUList): ...
[ "Converts", "a", "GEIS", "science", "file", "and", "its", "corresponding", "data", "quality", "file", "(", "if", "present", ")", "to", "MEF", "format", "Writes", "out", "both", "files", "to", "disk", ".", "Returns", "the", "new", "name", "of", "the", "sc...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L454-L510
[ "def", "waiver2mef", "(", "sciname", ",", "newname", "=", "None", ",", "convert_dq", "=", "True", ",", "writefits", "=", "True", ")", ":", "if", "isinstance", "(", "sciname", ",", "fits", ".", "HDUList", ")", ":", "filename", "=", "sciname", ".", "file...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
geis2mef
Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image.
lib/stsci/tools/check_files.py
def geis2mef(sciname, convert_dq=True): """ Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image. """ clobber = True mode = 'update' memmap = True # Input was speci...
def geis2mef(sciname, convert_dq=True): """ Converts a GEIS science file and its corresponding data quality file (if present) to MEF format Writes out both files to disk. Returns the new name of the science image. """ clobber = True mode = 'update' memmap = True # Input was speci...
[ "Converts", "a", "GEIS", "science", "file", "and", "its", "corresponding", "data", "quality", "file", "(", "if", "present", ")", "to", "MEF", "format", "Writes", "out", "both", "files", "to", "disk", ".", "Returns", "the", "new", "name", "of", "the", "sc...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L513-L568
[ "def", "geis2mef", "(", "sciname", ",", "convert_dq", "=", "True", ")", ":", "clobber", "=", "True", "mode", "=", "'update'", "memmap", "=", "True", "# Input was specified as a GEIS image, but no FITS copy", "# exists. Read it in with 'readgeis' and make a copy", "# then o...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
Issue.journals
Retrieve journals attribute for this very Issue
redmine/redmine.py
def journals(self): """ Retrieve journals attribute for this very Issue """ try: target = self._item_path json_data = self._redmine.get(target % str(self.id), parms={'include': 'journals'}) data = self._redmine...
def journals(self): """ Retrieve journals attribute for this very Issue """ try: target = self._item_path json_data = self._redmine.get(target % str(self.id), parms={'include': 'journals'}) data = self._redmine...
[ "Retrieve", "journals", "attribute", "for", "this", "very", "Issue" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L239-L256
[ "def", "journals", "(", "self", ")", ":", "try", ":", "target", "=", "self", ".", "_item_path", "json_data", "=", "self", ".", "_redmine", ".", "get", "(", "target", "%", "str", "(", "self", ".", "id", ")", ",", "parms", "=", "{", "'include'", ":",...
b2b0581483632738a3acca3b4e093c181847b813
train
Issue.save
Save all changes back to Redmine with optional notes.
redmine/redmine.py
def save(self, notes=None): '''Save all changes back to Redmine with optional notes.''' # Capture the notes if given if notes: self._changes['notes'] = notes # Call the base-class save function super(Issue, self).save()
def save(self, notes=None): '''Save all changes back to Redmine with optional notes.''' # Capture the notes if given if notes: self._changes['notes'] = notes # Call the base-class save function super(Issue, self).save()
[ "Save", "all", "changes", "back", "to", "Redmine", "with", "optional", "notes", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L258-L265
[ "def", "save", "(", "self", ",", "notes", "=", "None", ")", ":", "# Capture the notes if given", "if", "notes", ":", "self", ".", "_changes", "[", "'notes'", "]", "=", "notes", "# Call the base-class save function", "super", "(", "Issue", ",", "self", ")", "...
b2b0581483632738a3acca3b4e093c181847b813
train
Issue.set_status
Save all changes and set to the given new_status
redmine/redmine.py
def set_status(self, new_status, notes=None): '''Save all changes and set to the given new_status''' self.status_id = new_status try: self.status['id'] = self.status_id # We don't have the id to name mapping, so blank the name self.status['name'] = None ...
def set_status(self, new_status, notes=None): '''Save all changes and set to the given new_status''' self.status_id = new_status try: self.status['id'] = self.status_id # We don't have the id to name mapping, so blank the name self.status['name'] = None ...
[ "Save", "all", "changes", "and", "set", "to", "the", "given", "new_status" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L267-L276
[ "def", "set_status", "(", "self", ",", "new_status", ",", "notes", "=", "None", ")", ":", "self", ".", "status_id", "=", "new_status", "try", ":", "self", ".", "status", "[", "'id'", "]", "=", "self", ".", "status_id", "# We don't have the id to name mapping...
b2b0581483632738a3acca3b4e093c181847b813
train
Issue.resolve
Save all changes and resolve this issue
redmine/redmine.py
def resolve(self, notes=None): '''Save all changes and resolve this issue''' self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes)
def resolve(self, notes=None): '''Save all changes and resolve this issue''' self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes)
[ "Save", "all", "changes", "and", "resolve", "this", "issue" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L278-L280
[ "def", "resolve", "(", "self", ",", "notes", "=", "None", ")", ":", "self", ".", "set_status", "(", "self", ".", "_redmine", ".", "ISSUE_STATUS_ID_RESOLVED", ",", "notes", "=", "notes", ")" ]
b2b0581483632738a3acca3b4e093c181847b813
train
Issue.close
Save all changes and close this issue
redmine/redmine.py
def close(self, notes=None): '''Save all changes and close this issue''' self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes)
def close(self, notes=None): '''Save all changes and close this issue''' self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes)
[ "Save", "all", "changes", "and", "close", "this", "issue" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L282-L284
[ "def", "close", "(", "self", ",", "notes", "=", "None", ")", ":", "self", ".", "set_status", "(", "self", ".", "_redmine", ".", "ISSUE_STATUS_ID_CLOSED", ",", "notes", "=", "notes", ")" ]
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Wiki_Pages_Manager._objectify
Return an object derived from the given json data.
redmine/redmine.py
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
[ "Return", "an", "object", "derived", "from", "the", "given", "json", "data", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L610-L635
[ "def", "_objectify", "(", "self", ",", "json_data", "=", "None", ",", "data", "=", "{", "}", ")", ":", "if", "json_data", ":", "# Parse the data", "try", ":", "data", "=", "json", ".", "loads", "(", "json_data", ")", "except", "ValueError", ":", "# If ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Wiki_Pages_Manager.new
Create a new item with the provided dict information at the given page_name. Returns the new item. As of version 2.2 of Redmine, this doesn't seem to function.
redmine/redmine.py
def new(self, page_name, **dict): ''' Create a new item with the provided dict information at the given page_name. Returns the new item. As of version 2.2 of Redmine, this doesn't seem to function. ''' self._item_new_path = '/projects/%s/wiki/%s.json' % \ (s...
def new(self, page_name, **dict): ''' Create a new item with the provided dict information at the given page_name. Returns the new item. As of version 2.2 of Redmine, this doesn't seem to function. ''' self._item_new_path = '/projects/%s/wiki/%s.json' % \ (s...
[ "Create", "a", "new", "item", "with", "the", "provided", "dict", "information", "at", "the", "given", "page_name", ".", "Returns", "the", "new", "item", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L638-L648
[ "def", "new", "(", "self", ",", "page_name", ",", "*", "*", "dict", ")", ":", "self", ".", "_item_new_path", "=", "'/projects/%s/wiki/%s.json'", "%", "(", "self", ".", "_project", ".", "identifier", ",", "page_name", ")", "# Call the base class new method", "r...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine._set_version
Set up this object based on the capabilities of the known versions of Redmine
redmine/redmine.py
def _set_version(self, version): ''' Set up this object based on the capabilities of the known versions of Redmine ''' # Store the version we are evaluating self.version = version or None # To evaluate the version capabilities, # assume the best-case if no...
def _set_version(self, version): ''' Set up this object based on the capabilities of the known versions of Redmine ''' # Store the version we are evaluating self.version = version or None # To evaluate the version capabilities, # assume the best-case if no...
[ "Set", "up", "this", "object", "based", "on", "the", "capabilities", "of", "the", "known", "versions", "of", "Redmine" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L744-L783
[ "def", "_set_version", "(", "self", ",", "version", ")", ":", "# Store the version we are evaluating", "self", ".", "version", "=", "version", "or", "None", "# To evaluate the version capabilities,", "# assume the best-case if no version is provided.", "version_check", "=", "...
b2b0581483632738a3acca3b4e093c181847b813
train
loadTargetState
extracts a new TargetState object from the specified configuration :param targetStateConfig: the config dict. :param existingTargetState: the existing state :return:
backend/src/analyser/common/config.py
def loadTargetState(targetStateConfig, existingTargetState=None): """ extracts a new TargetState object from the specified configuration :param targetStateConfig: the config dict. :param existingTargetState: the existing state :return: """ from analyser.common.targetstatecontroller import Ta...
def loadTargetState(targetStateConfig, existingTargetState=None): """ extracts a new TargetState object from the specified configuration :param targetStateConfig: the config dict. :param existingTargetState: the existing state :return: """ from analyser.common.targetstatecontroller import Ta...
[ "extracts", "a", "new", "TargetState", "object", "from", "the", "specified", "configuration", ":", "param", "targetStateConfig", ":", "the", "config", "dict", ".", ":", "param", "existingTargetState", ":", "the", "existing", "state", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/config.py#L58-L87
[ "def", "loadTargetState", "(", "targetStateConfig", ",", "existingTargetState", "=", "None", ")", ":", "from", "analyser", ".", "common", ".", "targetstatecontroller", "import", "TargetState", "targetState", "=", "TargetState", "(", ")", "if", "existingTargetState", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
interpret_bit_flags
Converts input bit flags to a single integer value (bitmask) or `None`. When input is a list of flags (either a Python list of integer flags or a sting of comma- or '+'-separated list of flags), the returned bitmask is obtained by summing input flags. .. note:: In order to flip the bits of the...
lib/stsci/tools/bitmask.py
def interpret_bit_flags(bit_flags, flip_bits=None): """ Converts input bit flags to a single integer value (bitmask) or `None`. When input is a list of flags (either a Python list of integer flags or a sting of comma- or '+'-separated list of flags), the returned bitmask is obtained by summing inpu...
def interpret_bit_flags(bit_flags, flip_bits=None): """ Converts input bit flags to a single integer value (bitmask) or `None`. When input is a list of flags (either a Python list of integer flags or a sting of comma- or '+'-separated list of flags), the returned bitmask is obtained by summing inpu...
[ "Converts", "input", "bit", "flags", "to", "a", "single", "integer", "value", "(", "bitmask", ")", "or", "None", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L89-L242
[ "def", "interpret_bit_flags", "(", "bit_flags", ",", "flip_bits", "=", "None", ")", ":", "has_flip_bits", "=", "flip_bits", "is", "not", "None", "flip_bits", "=", "bool", "(", "flip_bits", ")", "allow_non_flags", "=", "False", "if", "_is_int", "(", "bit_flags"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
bitfield_to_boolean_mask
bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \ good_mask_value=True, dtype=numpy.bool\_) Converts an array of bit fields to a boolean (or integer) mask array according to a bitmask constructed from the supplied bit flags (see ``ignore_flags`` parameter). This function is partic...
lib/stsci/tools/bitmask.py
def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None, good_mask_value=True, dtype=np.bool_): """ bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \ good_mask_value=True, dtype=numpy.bool\_) Converts an array of bit fields to a boolean (or in...
def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None, good_mask_value=True, dtype=np.bool_): """ bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \ good_mask_value=True, dtype=numpy.bool\_) Converts an array of bit fields to a boolean (or in...
[ "bitfield_to_boolean_mask", "(", "bitfield", "ignore_flags", "=", "None", "flip_bits", "=", "None", "\\", "good_mask_value", "=", "True", "dtype", "=", "numpy", ".", "bool", "\\", "_", ")", "Converts", "an", "array", "of", "bit", "fields", "to", "a", "boolea...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L245-L438
[ "def", "bitfield_to_boolean_mask", "(", "bitfield", ",", "ignore_flags", "=", "0", ",", "flip_bits", "=", "None", ",", "good_mask_value", "=", "True", ",", "dtype", "=", "np", ".", "bool_", ")", ":", "bitfield", "=", "np", ".", "asarray", "(", "bitfield", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
interpret_bits_value
Converts input bits value from string to a single integer value or None. If a comma- or '+'-separated set of values are provided, they are summed. .. note:: In order to flip the bits of the final result (after summation), for input of `str` type, prepend '~' to the input string. '~' must ...
lib/stsci/tools/bitmask.py
def interpret_bits_value(val): """ Converts input bits value from string to a single integer value or None. If a comma- or '+'-separated set of values are provided, they are summed. .. note:: In order to flip the bits of the final result (after summation), for input of `str` type, prepe...
def interpret_bits_value(val): """ Converts input bits value from string to a single integer value or None. If a comma- or '+'-separated set of values are provided, they are summed. .. note:: In order to flip the bits of the final result (after summation), for input of `str` type, prepe...
[ "Converts", "input", "bits", "value", "from", "string", "to", "a", "single", "integer", "value", "or", "None", ".", "If", "a", "comma", "-", "or", "+", "-", "separated", "set", "of", "values", "are", "provided", "they", "are", "summed", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L443-L509
[ "def", "interpret_bits_value", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "int", ")", "or", "val", "is", "None", ":", "return", "val", "else", ":", "val", "=", "str", "(", "val", ")", ".", "strip", "(", ")", "if", "val", ".", "sta...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
bitmask2mask
bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_) Interprets an array of bit flags and converts it to a "binary" mask array. This function is particularly useful to convert data quality arrays to binary masks. Parameters ---------- bitmask : numpy.ndarray An arra...
lib/stsci/tools/bitmask.py
def bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=np.bool_): """ bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_) Interprets an array of bit flags and converts it to a "binary" mask array. This function is particularly useful to convert data quality arrays to b...
def bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=np.bool_): """ bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_) Interprets an array of bit flags and converts it to a "binary" mask array. This function is particularly useful to convert data quality arrays to b...
[ "bitmask2mask", "(", "bitmask", "ignore_bits", "good_mask_value", "=", "1", "dtype", "=", "numpy", ".", "bool", "\\", "_", ")", "Interprets", "an", "array", "of", "bit", "flags", "and", "converts", "it", "to", "a", "binary", "mask", "array", ".", "This", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L514-L623
[ "def", "bitmask2mask", "(", "bitmask", ",", "ignore_bits", ",", "good_mask_value", "=", "1", ",", "dtype", "=", "np", ".", "bool_", ")", ":", "if", "not", "np", ".", "issubdtype", "(", "bitmask", ".", "dtype", ",", "np", ".", "integer", ")", ":", "ra...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
output_text
Format data to get a readable output.
pyhydroquebec/output.py
def output_text(account, all_data, show_hourly=False): """Format data to get a readable output.""" print(""" ################################# # Hydro Quebec data for account # # {} #################################""".format(account)) for contract, data in all_data.items(): data['contract'] = contr...
def output_text(account, all_data, show_hourly=False): """Format data to get a readable output.""" print(""" ################################# # Hydro Quebec data for account # # {} #################################""".format(account)) for contract, data in all_data.items(): data['contract'] = contr...
[ "Format", "data", "to", "get", "a", "readable", "output", "." ]
titilambert/pyhydroquebec
python
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/output.py#L14-L91
[ "def", "output_text", "(", "account", ",", "all_data", ",", "show_hourly", "=", "False", ")", ":", "print", "(", "\"\"\"\n#################################\n# Hydro Quebec data for account #\n# {}\n#################################\"\"\"", ".", "format", "(", "account", ")", ...
4ea1374a63944413889c147d91961eda0605d4fd
train
output_influx
Print data using influxDB format.
pyhydroquebec/output.py
def output_influx(data): """Print data using influxDB format.""" for contract in data: # Pop yesterdays data yesterday_data = data[contract]['yesterday_hourly_consumption'] del data[contract]['yesterday_hourly_consumption'] # Print general data out = "pyhydroquebec,cont...
def output_influx(data): """Print data using influxDB format.""" for contract in data: # Pop yesterdays data yesterday_data = data[contract]['yesterday_hourly_consumption'] del data[contract]['yesterday_hourly_consumption'] # Print general data out = "pyhydroquebec,cont...
[ "Print", "data", "using", "influxDB", "format", "." ]
titilambert/pyhydroquebec
python
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/output.py#L94-L130
[ "def", "output_influx", "(", "data", ")", ":", "for", "contract", "in", "data", ":", "# Pop yesterdays data", "yesterday_data", "=", "data", "[", "contract", "]", "[", "'yesterday_hourly_consumption'", "]", "del", "data", "[", "contract", "]", "[", "'yesterday_h...
4ea1374a63944413889c147d91961eda0605d4fd
train
which_darwin_linkage
Convenience function. Returns one of ('x11', 'aqua') in answer to the question of whether this is an X11-linked Python/tkinter, or a natively built (framework, Aqua) one. This is only for OSX. This relies on the assumption that on OSX, PyObjC is installed in the Framework builds of Python. If it does...
lib/stsci/tools/capable.py
def which_darwin_linkage(force_otool_check=False): """ Convenience function. Returns one of ('x11', 'aqua') in answer to the question of whether this is an X11-linked Python/tkinter, or a natively built (framework, Aqua) one. This is only for OSX. This relies on the assumption that on OSX, PyObjC is i...
def which_darwin_linkage(force_otool_check=False): """ Convenience function. Returns one of ('x11', 'aqua') in answer to the question of whether this is an X11-linked Python/tkinter, or a natively built (framework, Aqua) one. This is only for OSX. This relies on the assumption that on OSX, PyObjC is i...
[ "Convenience", "function", ".", "Returns", "one", "of", "(", "x11", "aqua", ")", "in", "answer", "to", "the", "question", "of", "whether", "this", "is", "an", "X11", "-", "linked", "Python", "/", "tkinter", "or", "a", "natively", "built", "(", "framework...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/capable.py#L26-L86
[ "def", "which_darwin_linkage", "(", "force_otool_check", "=", "False", ")", ":", "# sanity check", "assert", "sys", ".", "platform", "==", "'darwin'", ",", "'Incorrect usage, not on OSX'", "# If not forced to run otool, then make some quick and dirty", "# simple checks/assumption...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
get_dc_owner
Convenience function to return owner of /dev/console. If raises is True, this raises an exception on any error. If not, it returns any error string as the owner name. If owner is self, and if mask_if_self, returns "<self>".
lib/stsci/tools/capable.py
def get_dc_owner(raises, mask_if_self): """ Convenience function to return owner of /dev/console. If raises is True, this raises an exception on any error. If not, it returns any error string as the owner name. If owner is self, and if mask_if_self, returns "<self>".""" try: from pwd import ...
def get_dc_owner(raises, mask_if_self): """ Convenience function to return owner of /dev/console. If raises is True, this raises an exception on any error. If not, it returns any error string as the owner name. If owner is self, and if mask_if_self, returns "<self>".""" try: from pwd import ...
[ "Convenience", "function", "to", "return", "owner", "of", "/", "dev", "/", "console", ".", "If", "raises", "is", "True", "this", "raises", "an", "exception", "on", "any", "error", ".", "If", "not", "it", "returns", "any", "error", "string", "as", "the", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/capable.py#L89-L106
[ "def", "get_dc_owner", "(", "raises", ",", "mask_if_self", ")", ":", "try", ":", "from", "pwd", "import", "getpwuid", "owner_uid", "=", "os", ".", "stat", "(", "'/dev/console'", ")", ".", "st_uid", "self_uid", "=", "os", ".", "getuid", "(", ")", "if", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
to_jd
Determine Julian day from Bahai date
convertdate/bahai.py
def to_jd(year, month, day): '''Determine Julian day from Bahai date''' gy = year - 1 + EPOCH_GREGORIAN_YEAR if month != 20: m = 0 else: if isleap(gy + 1): m = -14 else: m = -15 return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day
def to_jd(year, month, day): '''Determine Julian day from Bahai date''' gy = year - 1 + EPOCH_GREGORIAN_YEAR if month != 20: m = 0 else: if isleap(gy + 1): m = -14 else: m = -15 return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day
[ "Determine", "Julian", "day", "from", "Bahai", "date" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/bahai.py#L29-L40
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "gy", "=", "year", "-", "1", "+", "EPOCH_GREGORIAN_YEAR", "if", "month", "!=", "20", ":", "m", "=", "0", "else", ":", "if", "isleap", "(", "gy", "+", "1", ")", ":", "m", "=", "-...
e920f168a87f99183b0aa7290d6c3af222582d43
train
from_jd
Calculate Bahai date from Julian day
convertdate/bahai.py
def from_jd(jd): '''Calculate Bahai date from Julian day''' jd = trunc(jd) + 0.5 g = gregorian.from_jd(jd) gy = g[0] bstarty = EPOCH_GREGORIAN_YEAR if jd <= gregorian.to_jd(gy, 3, 20): x = 1 else: x = 0 # verify this next line... bys = gy - (bstarty + (((gregorian....
def from_jd(jd): '''Calculate Bahai date from Julian day''' jd = trunc(jd) + 0.5 g = gregorian.from_jd(jd) gy = g[0] bstarty = EPOCH_GREGORIAN_YEAR if jd <= gregorian.to_jd(gy, 3, 20): x = 1 else: x = 0 # verify this next line... bys = gy - (bstarty + (((gregorian....
[ "Calculate", "Bahai", "date", "from", "Julian", "day" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/bahai.py#L43-L69
[ "def", "from_jd", "(", "jd", ")", ":", "jd", "=", "trunc", "(", "jd", ")", "+", "0.5", "g", "=", "gregorian", ".", "from_jd", "(", "jd", ")", "gy", "=", "g", "[", "0", "]", "bstarty", "=", "EPOCH_GREGORIAN_YEAR", "if", "jd", "<=", "gregorian", "....
e920f168a87f99183b0aa7290d6c3af222582d43
train
to_jd
Determine Julian day from Mayan long count
convertdate/mayan.py
def to_jd(baktun, katun, tun, uinal, kin): '''Determine Julian day from Mayan long count''' return EPOCH + (baktun * 144000) + (katun * 7200) + (tun * 360) + (uinal * 20) + kin
def to_jd(baktun, katun, tun, uinal, kin): '''Determine Julian day from Mayan long count''' return EPOCH + (baktun * 144000) + (katun * 7200) + (tun * 360) + (uinal * 20) + kin
[ "Determine", "Julian", "day", "from", "Mayan", "long", "count" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L36-L38
[ "def", "to_jd", "(", "baktun", ",", "katun", ",", "tun", ",", "uinal", ",", "kin", ")", ":", "return", "EPOCH", "+", "(", "baktun", "*", "144000", ")", "+", "(", "katun", "*", "7200", ")", "+", "(", "tun", "*", "360", ")", "+", "(", "uinal", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
from_jd
Calculate Mayan long count from Julian day
convertdate/mayan.py
def from_jd(jd): '''Calculate Mayan long count from Julian day''' d = jd - EPOCH baktun = trunc(d / 144000) d = (d % 144000) katun = trunc(d / 7200) d = (d % 7200) tun = trunc(d / 360) d = (d % 360) uinal = trunc(d / 20) kin = int((d % 20)) return (baktun, katun, tun, uinal,...
def from_jd(jd): '''Calculate Mayan long count from Julian day''' d = jd - EPOCH baktun = trunc(d / 144000) d = (d % 144000) katun = trunc(d / 7200) d = (d % 7200) tun = trunc(d / 360) d = (d % 360) uinal = trunc(d / 20) kin = int((d % 20)) return (baktun, katun, tun, uinal,...
[ "Calculate", "Mayan", "long", "count", "from", "Julian", "day" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L41-L53
[ "def", "from_jd", "(", "jd", ")", ":", "d", "=", "jd", "-", "EPOCH", "baktun", "=", "trunc", "(", "d", "/", "144000", ")", "d", "=", "(", "d", "%", "144000", ")", "katun", "=", "trunc", "(", "d", "/", "7200", ")", "d", "=", "(", "d", "%", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
to_haab
Determine Mayan Haab "month" and day from Julian day
convertdate/mayan.py
def to_haab(jd): '''Determine Mayan Haab "month" and day from Julian day''' # Number of days since the start of the long count lcount = trunc(jd) + 0.5 - EPOCH # Long Count begins 348 days after the start of the cycle day = (lcount + 348) % 365 count = day % 20 month = trunc(day / 20) ...
def to_haab(jd): '''Determine Mayan Haab "month" and day from Julian day''' # Number of days since the start of the long count lcount = trunc(jd) + 0.5 - EPOCH # Long Count begins 348 days after the start of the cycle day = (lcount + 348) % 365 count = day % 20 month = trunc(day / 20) ...
[ "Determine", "Mayan", "Haab", "month", "and", "day", "from", "Julian", "day" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L66-L76
[ "def", "to_haab", "(", "jd", ")", ":", "# Number of days since the start of the long count", "lcount", "=", "trunc", "(", "jd", ")", "+", "0.5", "-", "EPOCH", "# Long Count begins 348 days after the start of the cycle", "day", "=", "(", "lcount", "+", "348", ")", "%...
e920f168a87f99183b0aa7290d6c3af222582d43
train
to_tzolkin
Determine Mayan Tzolkin "month" and day from Julian day
convertdate/mayan.py
def to_tzolkin(jd): '''Determine Mayan Tzolkin "month" and day from Julian day''' lcount = trunc(jd) + 0.5 - EPOCH day = amod(lcount + 4, 13) name = amod(lcount + 20, 20) return int(day), TZOLKIN_NAMES[int(name) - 1]
def to_tzolkin(jd): '''Determine Mayan Tzolkin "month" and day from Julian day''' lcount = trunc(jd) + 0.5 - EPOCH day = amod(lcount + 4, 13) name = amod(lcount + 20, 20) return int(day), TZOLKIN_NAMES[int(name) - 1]
[ "Determine", "Mayan", "Tzolkin", "month", "and", "day", "from", "Julian", "day" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L79-L84
[ "def", "to_tzolkin", "(", "jd", ")", ":", "lcount", "=", "trunc", "(", "jd", ")", "+", "0.5", "-", "EPOCH", "day", "=", "amod", "(", "lcount", "+", "4", ",", "13", ")", "name", "=", "amod", "(", "lcount", "+", "20", ",", "20", ")", "return", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
_haab_count
Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365
convertdate/mayan.py
def _haab_count(day, month): '''Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365''' if day < 0 or day > 19: raise IndexError("Invalid day number") try: i = HAAB_MONTHS.index(month) except ValueError: raise ValueError("'{0}' is not a valid Haab' m...
def _haab_count(day, month): '''Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365''' if day < 0 or day > 19: raise IndexError("Invalid day number") try: i = HAAB_MONTHS.index(month) except ValueError: raise ValueError("'{0}' is not a valid Haab' m...
[ "Return", "the", "count", "of", "the", "given", "haab", "in", "the", "cycle", ".", "e", ".", "g", ".", "0", "Pop", "==", "1", "5", "Wayeb", "==", "365" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L111-L121
[ "def", "_haab_count", "(", "day", ",", "month", ")", ":", "if", "day", "<", "0", "or", "day", ">", "19", ":", "raise", "IndexError", "(", "\"Invalid day number\"", ")", "try", ":", "i", "=", "HAAB_MONTHS", ".", "index", "(", "month", ")", "except", "...
e920f168a87f99183b0aa7290d6c3af222582d43
train
tzolkin_generator
For a given tzolkin name/number combination, return a generator that gives cycle, starting with the input
convertdate/mayan.py
def tzolkin_generator(number=None, name=None): '''For a given tzolkin name/number combination, return a generator that gives cycle, starting with the input''' # By default, it will start at the beginning number = number or 13 name = name or "Ajaw" if number > 13: raise ValueError("Inva...
def tzolkin_generator(number=None, name=None): '''For a given tzolkin name/number combination, return a generator that gives cycle, starting with the input''' # By default, it will start at the beginning number = number or 13 name = name or "Ajaw" if number > 13: raise ValueError("Inva...
[ "For", "a", "given", "tzolkin", "name", "/", "number", "combination", "return", "a", "generator", "that", "gives", "cycle", "starting", "with", "the", "input" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L145-L164
[ "def", "tzolkin_generator", "(", "number", "=", "None", ",", "name", "=", "None", ")", ":", "# By default, it will start at the beginning", "number", "=", "number", "or", "13", "name", "=", "name", "or", "\"Ajaw\"", "if", "number", ">", "13", ":", "raise", "...
e920f168a87f99183b0aa7290d6c3af222582d43
train
longcount_generator
Generate long counts, starting with input
convertdate/mayan.py
def longcount_generator(baktun, katun, tun, uinal, kin): '''Generate long counts, starting with input''' j = to_jd(baktun, katun, tun, uinal, kin) while True: yield from_jd(j) j = j + 1
def longcount_generator(baktun, katun, tun, uinal, kin): '''Generate long counts, starting with input''' j = to_jd(baktun, katun, tun, uinal, kin) while True: yield from_jd(j) j = j + 1
[ "Generate", "long", "counts", "starting", "with", "input" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L167-L173
[ "def", "longcount_generator", "(", "baktun", ",", "katun", ",", "tun", ",", "uinal", ",", "kin", ")", ":", "j", "=", "to_jd", "(", "baktun", ",", "katun", ",", "tun", ",", "uinal", ",", "kin", ")", "while", "True", ":", "yield", "from_jd", "(", "j"...
e920f168a87f99183b0aa7290d6c3af222582d43
train
next_haab
For a given haab month and a julian day count, find the next start of that month on or after the JDC
convertdate/mayan.py
def next_haab(month, jd): '''For a given haab month and a julian day count, find the next start of that month on or after the JDC''' if jd < EPOCH: raise IndexError("Input day is before Mayan epoch.") hday, hmonth = to_haab(jd) if hmonth == month: days = 1 - hday else: cou...
def next_haab(month, jd): '''For a given haab month and a julian day count, find the next start of that month on or after the JDC''' if jd < EPOCH: raise IndexError("Input day is before Mayan epoch.") hday, hmonth = to_haab(jd) if hmonth == month: days = 1 - hday else: cou...
[ "For", "a", "given", "haab", "month", "and", "a", "julian", "day", "count", "find", "the", "next", "start", "of", "that", "month", "on", "or", "after", "the", "JDC" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L176-L194
[ "def", "next_haab", "(", "month", ",", "jd", ")", ":", "if", "jd", "<", "EPOCH", ":", "raise", "IndexError", "(", "\"Input day is before Mayan epoch.\"", ")", "hday", ",", "hmonth", "=", "to_haab", "(", "jd", ")", "if", "hmonth", "==", "month", ":", "day...
e920f168a87f99183b0aa7290d6c3af222582d43
train
next_tzolkin
For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date
convertdate/mayan.py
def next_tzolkin(tzolkin, jd): '''For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date''' if jd < EPOCH: raise IndexError("Input day is before Mayan epoch.") count1 = _tzolkin_count(*to_tzolkin(jd)) count2 = _tzolkin_count(*tzolkin) add...
def next_tzolkin(tzolkin, jd): '''For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date''' if jd < EPOCH: raise IndexError("Input day is before Mayan epoch.") count1 = _tzolkin_count(*to_tzolkin(jd)) count2 = _tzolkin_count(*tzolkin) add...
[ "For", "a", "given", "tzolk", "in", "day", "and", "a", "julian", "day", "count", "find", "the", "next", "occurrance", "of", "that", "tzolk", "in", "after", "the", "date" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L197-L206
[ "def", "next_tzolkin", "(", "tzolkin", ",", "jd", ")", ":", "if", "jd", "<", "EPOCH", ":", "raise", "IndexError", "(", "\"Input day is before Mayan epoch.\"", ")", "count1", "=", "_tzolkin_count", "(", "*", "to_tzolkin", "(", "jd", ")", ")", "count2", "=", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
next_tzolkin_haab
For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date
convertdate/mayan.py
def next_tzolkin_haab(tzolkin, haab, jd): '''For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date''' # get H & T of input jd, and their place in the 18,980 day cycle haabcount = _haab_count(*to_haab(jd)) haab_desired_count = _haab_coun...
def next_tzolkin_haab(tzolkin, haab, jd): '''For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date''' # get H & T of input jd, and their place in the 18,980 day cycle haabcount = _haab_count(*to_haab(jd)) haab_desired_count = _haab_coun...
[ "For", "a", "given", "haab", "-", "tzolk", "in", "combination", "and", "a", "Julian", "day", "count", "find", "the", "next", "occurrance", "of", "the", "combination", "after", "the", "date" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L209-L230
[ "def", "next_tzolkin_haab", "(", "tzolkin", ",", "haab", ",", "jd", ")", ":", "# get H & T of input jd, and their place in the 18,980 day cycle", "haabcount", "=", "_haab_count", "(", "*", "to_haab", "(", "jd", ")", ")", "haab_desired_count", "=", "_haab_count", "(", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
haab_monthcalendar
For a given long count, return a calender of the current haab month, divided into tzolkin "weeks"
convertdate/mayan.py
def haab_monthcalendar(baktun=None, katun=None, tun=None, uinal=None, kin=None, jdc=None): '''For a given long count, return a calender of the current haab month, divided into tzolkin "weeks"''' if not jdc: jdc = to_jd(baktun, katun, tun, uinal, kin) haab_number, haab_month = to_haab(jdc) first...
def haab_monthcalendar(baktun=None, katun=None, tun=None, uinal=None, kin=None, jdc=None): '''For a given long count, return a calender of the current haab month, divided into tzolkin "weeks"''' if not jdc: jdc = to_jd(baktun, katun, tun, uinal, kin) haab_number, haab_month = to_haab(jdc) first...
[ "For", "a", "given", "long", "count", "return", "a", "calender", "of", "the", "current", "haab", "month", "divided", "into", "tzolkin", "weeks" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L241-L267
[ "def", "haab_monthcalendar", "(", "baktun", "=", "None", ",", "katun", "=", "None", ",", "tun", "=", "None", ",", "uinal", "=", "None", ",", "kin", "=", "None", ",", "jdc", "=", "None", ")", ":", "if", "not", "jdc", ":", "jdc", "=", "to_jd", "(",...
e920f168a87f99183b0aa7290d6c3af222582d43
train
Redmine_Item._update_data
Update the data in this object.
redmine/redmine_rest.py
def _update_data(self, data={}): '''Update the data in this object.''' # Store the changes to prevent this update from affecting it pending_changes = self._changes or {} try: del self._changes except: pass # Map custom fields into our custom fiel...
def _update_data(self, data={}): '''Update the data in this object.''' # Store the changes to prevent this update from affecting it pending_changes = self._changes or {} try: del self._changes except: pass # Map custom fields into our custom fiel...
[ "Update", "the", "data", "in", "this", "object", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L77-L109
[ "def", "_update_data", "(", "self", ",", "data", "=", "{", "}", ")", ":", "# Store the changes to prevent this update from affecting it", "pending_changes", "=", "self", ".", "_changes", "or", "{", "}", "try", ":", "del", "self", ".", "_changes", "except", ":", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Item._remap_tag_to_tag_id
Remaps a given changed field from tag to tag_id.
redmine/redmine_rest.py
def _remap_tag_to_tag_id(cls, tag, new_data): '''Remaps a given changed field from tag to tag_id.''' try: value = new_data[tag] except: # If tag wasn't changed, just return return tag_id = tag + '_id' try: # Remap the ID change to ...
def _remap_tag_to_tag_id(cls, tag, new_data): '''Remaps a given changed field from tag to tag_id.''' try: value = new_data[tag] except: # If tag wasn't changed, just return return tag_id = tag + '_id' try: # Remap the ID change to ...
[ "Remaps", "a", "given", "changed", "field", "from", "tag", "to", "tag_id", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L198-L219
[ "def", "_remap_tag_to_tag_id", "(", "cls", ",", "tag", ",", "new_data", ")", ":", "try", ":", "value", "=", "new_data", "[", "tag", "]", "except", ":", "# If tag wasn't changed, just return", "return", "tag_id", "=", "tag", "+", "'_id'", "try", ":", "# Remap...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Item._add_item_manager
Add an item manager to this object.
redmine/redmine_rest.py
def _add_item_manager(self, key, item_class, **paths): ''' Add an item manager to this object. ''' updated_paths = {} for path_type, path_value in paths.iteritems(): updated_paths[path_type] = path_value.format(**self.__dict__) manager = Redmine_Items_Manager...
def _add_item_manager(self, key, item_class, **paths): ''' Add an item manager to this object. ''' updated_paths = {} for path_type, path_value in paths.iteritems(): updated_paths[path_type] = path_value.format(**self.__dict__) manager = Redmine_Items_Manager...
[ "Add", "an", "item", "manager", "to", "this", "object", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L221-L231
[ "def", "_add_item_manager", "(", "self", ",", "key", ",", "item_class", ",", "*", "*", "paths", ")", ":", "updated_paths", "=", "{", "}", "for", "path_type", ",", "path_value", "in", "paths", ".", "iteritems", "(", ")", ":", "updated_paths", "[", "path_t...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Item.save
Save all changes on this item (if any) back to Redmine.
redmine/redmine_rest.py
def save(self): '''Save all changes on this item (if any) back to Redmine.''' self._check_custom_fields() if not self._changes: return None for tag in self._remap_to_id: self._remap_tag_to_tag_id(tag, self._changes) # Check for custom handlers for tags ...
def save(self): '''Save all changes on this item (if any) back to Redmine.''' self._check_custom_fields() if not self._changes: return None for tag in self._remap_to_id: self._remap_tag_to_tag_id(tag, self._changes) # Check for custom handlers for tags ...
[ "Save", "all", "changes", "on", "this", "item", "(", "if", "any", ")", "back", "to", "Redmine", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L233-L271
[ "def", "save", "(", "self", ")", ":", "self", ".", "_check_custom_fields", "(", ")", "if", "not", "self", ".", "_changes", ":", "return", "None", "for", "tag", "in", "self", ".", "_remap_to_id", ":", "self", ".", "_remap_tag_to_tag_id", "(", "tag", ",", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Item.refresh
Refresh this item from data on the server. Will save any unsaved data first.
redmine/redmine_rest.py
def refresh(self): '''Refresh this item from data on the server. Will save any unsaved data first.''' if not self._item_path: raise AttributeError('refresh is not available for %s' % self._type) if not self.id: raise RedmineError('%s did not come from the Redmine...
def refresh(self): '''Refresh this item from data on the server. Will save any unsaved data first.''' if not self._item_path: raise AttributeError('refresh is not available for %s' % self._type) if not self.id: raise RedmineError('%s did not come from the Redmine...
[ "Refresh", "this", "item", "from", "data", "on", "the", "server", ".", "Will", "save", "any", "unsaved", "data", "first", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L284-L302
[ "def", "refresh", "(", "self", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'refresh is not available for %s'", "%", "self", ".", "_type", ")", "if", "not", "self", ".", "id", ":", "raise", "RedmineError", "(", "'...
b2b0581483632738a3acca3b4e093c181847b813
train
Custom_Fields._get_changes
Get all changed values.
redmine/redmine_rest.py
def _get_changes(self): '''Get all changed values.''' result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) ) self._clear_changes return result
def _get_changes(self): '''Get all changed values.''' result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) ) self._clear_changes return result
[ "Get", "all", "changed", "values", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L335-L339
[ "def", "_get_changes", "(", "self", ")", ":", "result", "=", "dict", "(", "(", "f", "[", "'id'", "]", ",", "f", ".", "get", "(", "'value'", ",", "''", ")", ")", "for", "f", "in", "self", ".", "_data", "if", "f", ".", "get", "(", "'changed'", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.iteritems
Return a query interator with (id, object) pairs.
redmine/redmine_rest.py
def iteritems(self, **options): '''Return a query interator with (id, object) pairs.''' iter = self.query(**options) while True: obj = iter.next() yield (obj.id, obj)
def iteritems(self, **options): '''Return a query interator with (id, object) pairs.''' iter = self.query(**options) while True: obj = iter.next() yield (obj.id, obj)
[ "Return", "a", "query", "interator", "with", "(", "id", "object", ")", "pairs", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L488-L493
[ "def", "iteritems", "(", "self", ",", "*", "*", "options", ")", ":", "iter", "=", "self", ".", "query", "(", "*", "*", "options", ")", "while", "True", ":", "obj", "=", "iter", ".", "next", "(", ")", "yield", "(", "obj", ".", "id", ",", "obj", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager._objectify
Return an object derived from the given json data.
redmine/redmine_rest.py
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
[ "Return", "an", "object", "derived", "from", "the", "given", "json", "data", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L503-L520
[ "def", "_objectify", "(", "self", ",", "json_data", "=", "None", ",", "data", "=", "{", "}", ")", ":", "if", "json_data", ":", "# Parse the data", "try", ":", "data", "=", "json", ".", "loads", "(", "json_data", ")", "except", "ValueError", ":", "# If ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.new
Create a new item with the provided dict information. Returns the new item.
redmine/redmine_rest.py
def new(self, **dict): '''Create a new item with the provided dict information. Returns the new item.''' if not self._item_new_path: raise AttributeError('new is not available for %s' % self._item_name) # Remap various tag to tag_id for tag in self._object._remap_to_id: ...
def new(self, **dict): '''Create a new item with the provided dict information. Returns the new item.''' if not self._item_new_path: raise AttributeError('new is not available for %s' % self._item_name) # Remap various tag to tag_id for tag in self._object._remap_to_id: ...
[ "Create", "a", "new", "item", "with", "the", "provided", "dict", "information", ".", "Returns", "the", "new", "item", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L522-L536
[ "def", "new", "(", "self", ",", "*", "*", "dict", ")", ":", "if", "not", "self", ".", "_item_new_path", ":", "raise", "AttributeError", "(", "'new is not available for %s'", "%", "self", ".", "_item_name", ")", "# Remap various tag to tag_id", "for", "tag", "i...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.get
Get a single item with the given ID
redmine/redmine_rest.py
def get(self, id, **options): '''Get a single item with the given ID''' if not self._item_path: raise AttributeError('get is not available for %s' % self._item_name) target = self._item_path % id json_data = self._redmine.get(target, **options) data = self._redmine.un...
def get(self, id, **options): '''Get a single item with the given ID''' if not self._item_path: raise AttributeError('get is not available for %s' % self._item_name) target = self._item_path % id json_data = self._redmine.get(target, **options) data = self._redmine.un...
[ "Get", "a", "single", "item", "with", "the", "given", "ID" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L538-L546
[ "def", "get", "(", "self", ",", "id", ",", "*", "*", "options", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'get is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "self", ".", "_ite...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.update
Update a given item with the passed data.
redmine/redmine_rest.py
def update(self, id, **dict): '''Update a given item with the passed data.''' if not self._item_path: raise AttributeError('update is not available for %s' % self._item_name) target = (self._update_path or self._item_path) % id payload = json.dumps({self._item_type:dict}) ...
def update(self, id, **dict): '''Update a given item with the passed data.''' if not self._item_path: raise AttributeError('update is not available for %s' % self._item_name) target = (self._update_path or self._item_path) % id payload = json.dumps({self._item_type:dict}) ...
[ "Update", "a", "given", "item", "with", "the", "passed", "data", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L548-L555
[ "def", "update", "(", "self", ",", "id", ",", "*", "*", "dict", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'update is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "(", "self", "....
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.delete
Delete a single item with the given ID
redmine/redmine_rest.py
def delete(self, id): '''Delete a single item with the given ID''' if not self._item_path: raise AttributeError('delete is not available for %s' % self._item_name) target = self._item_path % id self._redmine.delete(target) return None
def delete(self, id): '''Delete a single item with the given ID''' if not self._item_path: raise AttributeError('delete is not available for %s' % self._item_name) target = self._item_path % id self._redmine.delete(target) return None
[ "Delete", "a", "single", "item", "with", "the", "given", "ID" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L557-L563
[ "def", "delete", "(", "self", ",", "id", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'delete is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "self", ".", "_item_path", "%", "id", "s...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_Items_Manager.query
Return an iterator for the given items.
redmine/redmine_rest.py
def query(self, **options): '''Return an iterator for the given items.''' if not self._query_path: raise AttributeError('query is not available for %s' % self._item_name) last_item = 0 offset = 0 current_item = None limit = options.get('limit', 25) opt...
def query(self, **options): '''Return an iterator for the given items.''' if not self._query_path: raise AttributeError('query is not available for %s' % self._item_name) last_item = 0 offset = 0 current_item = None limit = options.get('limit', 25) opt...
[ "Return", "an", "iterator", "for", "the", "given", "items", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L565-L602
[ "def", "query", "(", "self", ",", "*", "*", "options", ")", ":", "if", "not", "self", ".", "_query_path", ":", "raise", "AttributeError", "(", "'query is not available for %s'", "%", "self", ".", "_item_name", ")", "last_item", "=", "0", "offset", "=", "0"...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS._setup_authentication
Create the authentication object with the given credentials.
redmine/redmine_rest.py
def _setup_authentication(self, username, password): '''Create the authentication object with the given credentials.''' ## BUG WORKAROUND if self.version < 1.1: # Version 1.0 had a bug when using the key parameter. # Later versions have the opposite bug (a key in the use...
def _setup_authentication(self, username, password): '''Create the authentication object with the given credentials.''' ## BUG WORKAROUND if self.version < 1.1: # Version 1.0 had a bug when using the key parameter. # Later versions have the opposite bug (a key in the use...
[ "Create", "the", "authentication", "object", "with", "the", "given", "credentials", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L631-L661
[ "def", "_setup_authentication", "(", "self", ",", "username", ",", "password", ")", ":", "## BUG WORKAROUND", "if", "self", ".", "version", "<", "1.1", ":", "# Version 1.0 had a bug when using the key parameter.", "# Later versions have the opposite bug (a key in the username d...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.open_raw
Opens a page from the server with optional XML. Returns a response file-like object
redmine/redmine_rest.py
def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ): '''Opens a page from the server with optional XML. Returns a response file-like object''' if not parms: parms={} # if we're using a key, but it's not going in the header, add it ...
def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ): '''Opens a page from the server with optional XML. Returns a response file-like object''' if not parms: parms={} # if we're using a key, but it's not going in the header, add it ...
[ "Opens", "a", "page", "from", "the", "server", "with", "optional", "XML", ".", "Returns", "a", "response", "file", "-", "like", "object" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L663-L713
[ "def", "open_raw", "(", "self", ",", "page", ",", "parms", "=", "None", ",", "payload", "=", "None", ",", "HTTPrequest", "=", "None", ",", "payload_type", "=", "'application/json'", ")", ":", "if", "not", "parms", ":", "parms", "=", "{", "}", "# if we'...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.open
Opens a page from the server with optional content. Returns the string response.
redmine/redmine_rest.py
def open(self, page, parms=None, payload=None, HTTPrequest=None ): '''Opens a page from the server with optional content. Returns the string response.''' response = self.open_raw( page, parms, payload, HTTPrequest ) return response.read()
def open(self, page, parms=None, payload=None, HTTPrequest=None ): '''Opens a page from the server with optional content. Returns the string response.''' response = self.open_raw( page, parms, payload, HTTPrequest ) return response.read()
[ "Opens", "a", "page", "from", "the", "server", "with", "optional", "content", ".", "Returns", "the", "string", "response", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L715-L718
[ "def", "open", "(", "self", ",", "page", ",", "parms", "=", "None", ",", "payload", "=", "None", ",", "HTTPrequest", "=", "None", ")", ":", "response", "=", "self", ".", "open_raw", "(", "page", ",", "parms", ",", "payload", ",", "HTTPrequest", ")", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.post
Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.
redmine/redmine_rest.py
def post(self, page, payload, parms=None ): '''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.''' if self.readonlytest: print 'Redmine read only test: Pretending to create: ' + page return payload else: ...
def post(self, page, payload, parms=None ): '''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.''' if self.readonlytest: print 'Redmine read only test: Pretending to create: ' + page return payload else: ...
[ "Posts", "a", "string", "payload", "to", "the", "server", "-", "used", "to", "make", "new", "Redmine", "items", ".", "Returns", "an", "JSON", "string", "or", "error", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L725-L731
[ "def", "post", "(", "self", ",", "page", ",", "payload", ",", "parms", "=", "None", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to create: '", "+", "page", "return", "payload", "else", ":", "return", "self", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.put
Puts an XML object on the server - used to update Redmine items. Returns nothing useful.
redmine/redmine_rest.py
def put(self, page, payload, parms=None ): '''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.''' if self.readonlytest: print 'Redmine read only test: Pretending to update: ' + page else: return self.open( page, parms, payload, HTT...
def put(self, page, payload, parms=None ): '''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.''' if self.readonlytest: print 'Redmine read only test: Pretending to update: ' + page else: return self.open( page, parms, payload, HTT...
[ "Puts", "an", "XML", "object", "on", "the", "server", "-", "used", "to", "update", "Redmine", "items", ".", "Returns", "nothing", "useful", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L733-L738
[ "def", "put", "(", "self", ",", "page", ",", "payload", ",", "parms", "=", "None", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to update: '", "+", "page", "else", ":", "return", "self", ".", "open", "(", ...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.delete
Deletes a given object on the server - used to remove items from Redmine. Use carefully!
redmine/redmine_rest.py
def delete(self, page ): '''Deletes a given object on the server - used to remove items from Redmine. Use carefully!''' if self.readonlytest: print 'Redmine read only test: Pretending to delete: ' + page else: return self.open( page, HTTPrequest=self.DELETE_Request )
def delete(self, page ): '''Deletes a given object on the server - used to remove items from Redmine. Use carefully!''' if self.readonlytest: print 'Redmine read only test: Pretending to delete: ' + page else: return self.open( page, HTTPrequest=self.DELETE_Request )
[ "Deletes", "a", "given", "object", "on", "the", "server", "-", "used", "to", "remove", "items", "from", "Redmine", ".", "Use", "carefully!" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L740-L745
[ "def", "delete", "(", "self", ",", "page", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to delete: '", "+", "page", "else", ":", "return", "self", ".", "open", "(", "page", ",", "HTTPrequest", "=", "self", "...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.unwrap_json
Decodes a json string, and unwraps any 'type' it finds within.
redmine/redmine_rest.py
def unwrap_json(self, type, json_data): '''Decodes a json string, and unwraps any 'type' it finds within.''' # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which likely contains an error message ins...
def unwrap_json(self, type, json_data): '''Decodes a json string, and unwraps any 'type' it finds within.''' # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which likely contains an error message ins...
[ "Decodes", "a", "json", "string", "and", "unwraps", "any", "type", "it", "finds", "within", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L752-L766
[ "def", "unwrap_json", "(", "self", ",", "type", ",", "json_data", ")", ":", "# Parse the data", "try", ":", "data", "=", "json", ".", "loads", "(", "json_data", ")", "except", "ValueError", ":", "# If parsing failed, then raise the string which likely contains an erro...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.find_all_item_classes
Finds and stores a reference to all Redmine_Item subclasses for later use.
redmine/redmine_rest.py
def find_all_item_classes(self): '''Finds and stores a reference to all Redmine_Item subclasses for later use.''' # This is a circular import, but performed after the class is defined and an object is instatiated. # We do this in order to get references to any objects definitions in the redmine....
def find_all_item_classes(self): '''Finds and stores a reference to all Redmine_Item subclasses for later use.''' # This is a circular import, but performed after the class is defined and an object is instatiated. # We do this in order to get references to any objects definitions in the redmine....
[ "Finds", "and", "stores", "a", "reference", "to", "all", "Redmine_Item", "subclasses", "for", "later", "use", "." ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L769-L783
[ "def", "find_all_item_classes", "(", "self", ")", ":", "# This is a circular import, but performed after the class is defined and an object is instatiated.", "# We do this in order to get references to any objects definitions in the redmine.py file", "# without requiring anyone editing the file to d...
b2b0581483632738a3acca3b4e093c181847b813
train
Redmine_WS.check_cache
Returns the updated cached version of the given dict
redmine/redmine_rest.py
def check_cache(self, type, data, obj=None): '''Returns the updated cached version of the given dict''' try: id = data['id'] except: # Not an identifiable item #print 'don\'t know this item %r:%r' % (type, data) return data # If obj was pa...
def check_cache(self, type, data, obj=None): '''Returns the updated cached version of the given dict''' try: id = data['id'] except: # Not an identifiable item #print 'don\'t know this item %r:%r' % (type, data) return data # If obj was pa...
[ "Returns", "the", "updated", "cached", "version", "of", "the", "given", "dict" ]
ianepperson/pyredminews
python
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L785-L822
[ "def", "check_cache", "(", "self", ",", "type", ",", "data", ",", "obj", "=", "None", ")", ":", "try", ":", "id", "=", "data", "[", "'id'", "]", "except", ":", "# Not an identifiable item", "#print 'don\\'t know this item %r:%r' % (type, data)", "return", "data"...
b2b0581483632738a3acca3b4e093c181847b813
train
Point.substract
Return a Point instance as the displacement of two points.
vectors/vectors.py
def substract(self, pt): """Return a Point instance as the displacement of two points.""" if isinstance(pt, Point): return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z) else: raise TypeError
def substract(self, pt): """Return a Point instance as the displacement of two points.""" if isinstance(pt, Point): return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z) else: raise TypeError
[ "Return", "a", "Point", "instance", "as", "the", "displacement", "of", "two", "points", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L54-L59
[ "def", "substract", "(", "self", ",", "pt", ")", ":", "if", "isinstance", "(", "pt", ",", "Point", ")", ":", "return", "Point", "(", "pt", ".", "x", "-", "self", ".", "x", ",", "pt", ".", "y", "-", "self", ".", "y", ",", "pt", ".", "z", "-"...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Point.from_list
Return a Point instance from a given list
vectors/vectors.py
def from_list(cls, l): """Return a Point instance from a given list""" if len(l) == 3: x, y, z = map(float, l) return cls(x, y, z) elif len(l) == 2: x, y = map(float, l) return cls(x, y) else: raise AttributeError
def from_list(cls, l): """Return a Point instance from a given list""" if len(l) == 3: x, y, z = map(float, l) return cls(x, y, z) elif len(l) == 2: x, y = map(float, l) return cls(x, y) else: raise AttributeError
[ "Return", "a", "Point", "instance", "from", "a", "given", "list" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L62-L71
[ "def", "from_list", "(", "cls", ",", "l", ")", ":", "if", "len", "(", "l", ")", "==", "3", ":", "x", ",", "y", ",", "z", "=", "map", "(", "float", ",", "l", ")", "return", "cls", "(", "x", ",", "y", ",", "z", ")", "elif", "len", "(", "l...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.multiply
Return a Vector as the product of the vector and a real number.
vectors/vectors.py
def multiply(self, number): """Return a Vector as the product of the vector and a real number.""" return self.from_list([x * number for x in self.to_list()])
def multiply(self, number): """Return a Vector as the product of the vector and a real number.""" return self.from_list([x * number for x in self.to_list()])
[ "Return", "a", "Vector", "as", "the", "product", "of", "the", "vector", "and", "a", "real", "number", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L120-L122
[ "def", "multiply", "(", "self", ",", "number", ")", ":", "return", "self", ".", "from_list", "(", "[", "x", "*", "number", "for", "x", "in", "self", ".", "to_list", "(", ")", "]", ")" ]
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.magnitude
Return magnitude of the vector.
vectors/vectors.py
def magnitude(self): """Return magnitude of the vector.""" return math.sqrt( reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()]) )
def magnitude(self): """Return magnitude of the vector.""" return math.sqrt( reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()]) )
[ "Return", "magnitude", "of", "the", "vector", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L124-L128
[ "def", "magnitude", "(", "self", ")", ":", "return", "math", ".", "sqrt", "(", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "+", "y", ",", "[", "x", "**", "2", "for", "x", "in", "self", ".", "to_list", "(", ")", "]", ")", ")" ]
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.sum
Return a Vector instance as the vector sum of two vectors.
vectors/vectors.py
def sum(self, vector): """Return a Vector instance as the vector sum of two vectors.""" return self.from_list( [x + vector.vector[i] for i, x in self.to_list()] )
def sum(self, vector): """Return a Vector instance as the vector sum of two vectors.""" return self.from_list( [x + vector.vector[i] for i, x in self.to_list()] )
[ "Return", "a", "Vector", "instance", "as", "the", "vector", "sum", "of", "two", "vectors", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L130-L134
[ "def", "sum", "(", "self", ",", "vector", ")", ":", "return", "self", ".", "from_list", "(", "[", "x", "+", "vector", ".", "vector", "[", "i", "]", "for", "i", ",", "x", "in", "self", ".", "to_list", "(", ")", "]", ")" ]
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.dot
Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees.
vectors/vectors.py
def dot(self, vector, theta=None): """Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees. """ if theta is not None: return (self.magnitude() * vector.m...
def dot(self, vector, theta=None): """Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees. """ if theta is not None: return (self.magnitude() * vector.m...
[ "Return", "the", "dot", "product", "of", "two", "vectors", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L140-L151
[ "def", "dot", "(", "self", ",", "vector", ",", "theta", "=", "None", ")", ":", "if", "theta", "is", "not", "None", ":", "return", "(", "self", ".", "magnitude", "(", ")", "*", "vector", ".", "magnitude", "(", ")", "*", "math", ".", "degrees", "("...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.cross
Return a Vector instance as the cross product of two vectors
vectors/vectors.py
def cross(self, vector): """Return a Vector instance as the cross product of two vectors""" return Vector((self.y * vector.z - self.z * vector.y), (self.z * vector.x - self.x * vector.z), (self.x * vector.y - self.y * vector.x))
def cross(self, vector): """Return a Vector instance as the cross product of two vectors""" return Vector((self.y * vector.z - self.z * vector.y), (self.z * vector.x - self.x * vector.z), (self.x * vector.y - self.y * vector.x))
[ "Return", "a", "Vector", "instance", "as", "the", "cross", "product", "of", "two", "vectors" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L153-L157
[ "def", "cross", "(", "self", ",", "vector", ")", ":", "return", "Vector", "(", "(", "self", ".", "y", "*", "vector", ".", "z", "-", "self", ".", "z", "*", "vector", ".", "y", ")", ",", "(", "self", ".", "z", "*", "vector", ".", "x", "-", "s...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.unit
Return a Vector instance of the unit vector
vectors/vectors.py
def unit(self): """Return a Vector instance of the unit vector""" return Vector( (self.x / self.magnitude()), (self.y / self.magnitude()), (self.z / self.magnitude()) )
def unit(self): """Return a Vector instance of the unit vector""" return Vector( (self.x / self.magnitude()), (self.y / self.magnitude()), (self.z / self.magnitude()) )
[ "Return", "a", "Vector", "instance", "of", "the", "unit", "vector" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L159-L165
[ "def", "unit", "(", "self", ")", ":", "return", "Vector", "(", "(", "self", ".", "x", "/", "self", ".", "magnitude", "(", ")", ")", ",", "(", "self", ".", "y", "/", "self", ".", "magnitude", "(", ")", ")", ",", "(", "self", ".", "z", "/", "...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.angle
Return the angle between two vectors in degrees.
vectors/vectors.py
def angle(self, vector): """Return the angle between two vectors in degrees.""" return math.degrees( math.acos( self.dot(vector) / (self.magnitude() * vector.magnitude()) ) )
def angle(self, vector): """Return the angle between two vectors in degrees.""" return math.degrees( math.acos( self.dot(vector) / (self.magnitude() * vector.magnitude()) ) )
[ "Return", "the", "angle", "between", "two", "vectors", "in", "degrees", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L167-L174
[ "def", "angle", "(", "self", ",", "vector", ")", ":", "return", "math", ".", "degrees", "(", "math", ".", "acos", "(", "self", ".", "dot", "(", "vector", ")", "/", "(", "self", ".", "magnitude", "(", ")", "*", "vector", ".", "magnitude", "(", ")"...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.non_parallel
Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other.
vectors/vectors.py
def non_parallel(self, vector): """Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other. """ if (self.is_parallel(vector) is not True and self.is_perpendicular(vector) is not True): ...
def non_parallel(self, vector): """Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other. """ if (self.is_parallel(vector) is not True and self.is_perpendicular(vector) is not True): ...
[ "Return", "True", "if", "vectors", "are", "non", "-", "parallel", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L188-L197
[ "def", "non_parallel", "(", "self", ",", "vector", ")", ":", "if", "(", "self", ".", "is_parallel", "(", "vector", ")", "is", "not", "True", "and", "self", ".", "is_perpendicular", "(", "vector", ")", "is", "not", "True", ")", ":", "return", "True", ...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.rotate
Returns the rotated vector. Assumes angle is in radians
vectors/vectors.py
def rotate(self, angle, axis=(0, 0, 1)): """Returns the rotated vector. Assumes angle is in radians""" if not all(isinstance(a, int) for a in axis): raise ValueError x, y, z = self.x, self.y, self.z # Z axis rotation if(axis[2]): x = (self.x * math.cos(an...
def rotate(self, angle, axis=(0, 0, 1)): """Returns the rotated vector. Assumes angle is in radians""" if not all(isinstance(a, int) for a in axis): raise ValueError x, y, z = self.x, self.y, self.z # Z axis rotation if(axis[2]): x = (self.x * math.cos(an...
[ "Returns", "the", "rotated", "vector", ".", "Assumes", "angle", "is", "in", "radians" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L199-L220
[ "def", "rotate", "(", "self", ",", "angle", ",", "axis", "=", "(", "0", ",", "0", ",", "1", ")", ")", ":", "if", "not", "all", "(", "isinstance", "(", "a", ",", "int", ")", "for", "a", "in", "axis", ")", ":", "raise", "ValueError", "x", ",", ...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.from_points
Return a Vector instance from two given points.
vectors/vectors.py
def from_points(cls, point1, point2): """Return a Vector instance from two given points.""" if isinstance(point1, Point) and isinstance(point2, Point): displacement = point1.substract(point2) return cls(displacement.x, displacement.y, displacement.z) raise TypeError
def from_points(cls, point1, point2): """Return a Vector instance from two given points.""" if isinstance(point1, Point) and isinstance(point2, Point): displacement = point1.substract(point2) return cls(displacement.x, displacement.y, displacement.z) raise TypeError
[ "Return", "a", "Vector", "instance", "from", "two", "given", "points", "." ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L227-L232
[ "def", "from_points", "(", "cls", ",", "point1", ",", "point2", ")", ":", "if", "isinstance", "(", "point1", ",", "Point", ")", "and", "isinstance", "(", "point2", ",", "Point", ")", ":", "displacement", "=", "point1", ".", "substract", "(", "point2", ...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.spherical
Returns a Vector instance from spherical coordinates
vectors/vectors.py
def spherical(cls, mag, theta, phi=0): '''Returns a Vector instance from spherical coordinates''' return cls( mag * math.sin(phi) * math.cos(theta), # X mag * math.sin(phi) * math.sin(theta), # Y mag * math.cos(phi) # Z )
def spherical(cls, mag, theta, phi=0): '''Returns a Vector instance from spherical coordinates''' return cls( mag * math.sin(phi) * math.cos(theta), # X mag * math.sin(phi) * math.sin(theta), # Y mag * math.cos(phi) # Z )
[ "Returns", "a", "Vector", "instance", "from", "spherical", "coordinates" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L235-L241
[ "def", "spherical", "(", "cls", ",", "mag", ",", "theta", ",", "phi", "=", "0", ")", ":", "return", "cls", "(", "mag", "*", "math", ".", "sin", "(", "phi", ")", "*", "math", ".", "cos", "(", "theta", ")", ",", "# X", "mag", "*", "math", ".", ...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
Vector.cylindrical
Returns a Vector instance from cylindircal coordinates
vectors/vectors.py
def cylindrical(cls, mag, theta, z=0): '''Returns a Vector instance from cylindircal coordinates''' return cls( mag * math.cos(theta), # X mag * math.sin(theta), # Y z # Z )
def cylindrical(cls, mag, theta, z=0): '''Returns a Vector instance from cylindircal coordinates''' return cls( mag * math.cos(theta), # X mag * math.sin(theta), # Y z # Z )
[ "Returns", "a", "Vector", "instance", "from", "cylindircal", "coordinates" ]
allelos/vectors
python
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L244-L250
[ "def", "cylindrical", "(", "cls", ",", "mag", ",", "theta", ",", "z", "=", "0", ")", ":", "return", "cls", "(", "mag", "*", "math", ".", "cos", "(", "theta", ")", ",", "# X", "mag", "*", "math", ".", "sin", "(", "theta", ")", ",", "# Y", "z",...
55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee
train
amod
Modulus function which returns numerator if modulus is zero
convertdate/utils.py
def amod(a, b): '''Modulus function which returns numerator if modulus is zero''' modded = int(a % b) return b if modded is 0 else modded
def amod(a, b): '''Modulus function which returns numerator if modulus is zero''' modded = int(a % b) return b if modded is 0 else modded
[ "Modulus", "function", "which", "returns", "numerator", "if", "modulus", "is", "zero" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L24-L27
[ "def", "amod", "(", "a", ",", "b", ")", ":", "modded", "=", "int", "(", "a", "%", "b", ")", "return", "b", "if", "modded", "is", "0", "else", "modded" ]
e920f168a87f99183b0aa7290d6c3af222582d43
train
search_weekday
Determine the Julian date for the next or previous weekday
convertdate/utils.py
def search_weekday(weekday, jd, direction, offset): '''Determine the Julian date for the next or previous weekday''' return weekday_before(weekday, jd + (direction * offset))
def search_weekday(weekday, jd, direction, offset): '''Determine the Julian date for the next or previous weekday''' return weekday_before(weekday, jd + (direction * offset))
[ "Determine", "the", "Julian", "date", "for", "the", "next", "or", "previous", "weekday" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L44-L46
[ "def", "search_weekday", "(", "weekday", ",", "jd", ",", "direction", ",", "offset", ")", ":", "return", "weekday_before", "(", "weekday", ",", "jd", "+", "(", "direction", "*", "offset", ")", ")" ]
e920f168a87f99183b0aa7290d6c3af222582d43
train
nth_day_of_month
Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0
convertdate/utils.py
def nth_day_of_month(n, weekday, month, year): """ Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0 """ if not (0 <= n <= 5): raise IndexError("Nth day of month must be 0-5. Received: {}".format(n)) ...
def nth_day_of_month(n, weekday, month, year): """ Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0 """ if not (0 <= n <= 5): raise IndexError("Nth day of month must be 0-5. Received: {}".format(n)) ...
[ "Return", "(", "year", "month", "day", ")", "tuple", "that", "represents", "nth", "weekday", "of", "month", "in", "year", ".", "If", "n", "==", "0", "returns", "last", "weekday", "of", "month", ".", "Weekdays", ":", "Monday", "=", "0" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L93-L121
[ "def", "nth_day_of_month", "(", "n", ",", "weekday", ",", "month", ",", "year", ")", ":", "if", "not", "(", "0", "<=", "n", "<=", "5", ")", ":", "raise", "IndexError", "(", "\"Nth day of month must be 0-5. Received: {}\"", ".", "format", "(", "n", ")", "...
e920f168a87f99183b0aa7290d6c3af222582d43
train
irafglob
Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card characters, e.g. `a.fits`, `@file.lst`, `*flt...
lib/stsci/tools/irafglob.py
def irafglob(inlist, atfile=None): """ Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card ch...
def irafglob(inlist, atfile=None): """ Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card ch...
[ "Returns", "a", "list", "of", "filenames", "based", "on", "the", "type", "of", "IRAF", "input", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafglob.py#L13-L54
[ "def", "irafglob", "(", "inlist", ",", "atfile", "=", "None", ")", ":", "# Sanity check", "if", "inlist", "is", "None", "or", "len", "(", "inlist", ")", "==", "0", ":", "return", "[", "]", "# Determine which form of input was provided:", "if", "isinstance", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
Packet.pack
Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS.
tsip/hlapi.py
def pack(self): """Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS. """ # Possible structs for packet ID. # try: structs_ = ...
def pack(self): """Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS. """ # Possible structs for packet ID. # try: structs_ = ...
[ "Return", "binary", "format", "of", "packet", "." ]
mjuenema/python-TSIP
python
https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/hlapi.py#L92-L132
[ "def", "pack", "(", "self", ")", ":", "# Possible structs for packet ID.", "#", "try", ":", "structs_", "=", "get_structs_for_fields", "(", "[", "self", ".", "fields", "[", "0", "]", "]", ")", "except", "(", "TypeError", ")", ":", "# TypeError, if self.fields[...
e02b68d05772127ea493cd639b3d5f8fb73df402
train
Packet.unpack
Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed.
tsip/hlapi.py
def unpack(cls, rawpacket): """Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed. """ structs_ = g...
def unpack(cls, rawpacket): """Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed. """ structs_ = g...
[ "Instantiate", "Packet", "from", "binary", "string", "." ]
mjuenema/python-TSIP
python
https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/hlapi.py#L136-L160
[ "def", "unpack", "(", "cls", ",", "rawpacket", ")", ":", "structs_", "=", "get_structs_for_rawpacket", "(", "rawpacket", ")", "for", "struct_", "in", "structs_", ":", "try", ":", "return", "cls", "(", "*", "struct_", ".", "unpack", "(", "rawpacket", ")", ...
e02b68d05772127ea493cd639b3d5f8fb73df402
train
ch_handler
Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD.
lib/stsci/tools/clipboard_helper.py
def ch_handler(offset=0, length=-1, **kw): """ Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD. """ global _lastSel offset = int(offset) length = int(length) if length < 0: length = len(_lastSel) return _lastSel[offs...
def ch_handler(offset=0, length=-1, **kw): """ Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD. """ global _lastSel offset = int(offset) length = int(length) if length < 0: length = len(_lastSel) return _lastSel[offs...
[ "Handle", "standard", "PRIMARY", "clipboard", "access", ".", "Note", "that", "offset", "and", "length", "are", "passed", "as", "strings", ".", "This", "differs", "from", "CLIPBOARD", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L19-L27
[ "def", "ch_handler", "(", "offset", "=", "0", ",", "length", "=", "-", "1", ",", "*", "*", "kw", ")", ":", "global", "_lastSel", "offset", "=", "int", "(", "offset", ")", "length", "=", "int", "(", "length", ")", "if", "length", "<", "0", ":", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
put
Put the given string into the given clipboard.
lib/stsci/tools/clipboard_helper.py
def put(text, cbname): """ Put the given string into the given clipboard. """ global _lastSel _checkTkInit() if cbname == 'CLIPBOARD': _theRoot.clipboard_clear() if text: # for clipboard_append, kwds can be -displayof, -format, or -type _theRoot.clipboard_append(t...
def put(text, cbname): """ Put the given string into the given clipboard. """ global _lastSel _checkTkInit() if cbname == 'CLIPBOARD': _theRoot.clipboard_clear() if text: # for clipboard_append, kwds can be -displayof, -format, or -type _theRoot.clipboard_append(t...
[ "Put", "the", "given", "string", "into", "the", "given", "clipboard", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L38-L55
[ "def", "put", "(", "text", ",", "cbname", ")", ":", "global", "_lastSel", "_checkTkInit", "(", ")", "if", "cbname", "==", "'CLIPBOARD'", ":", "_theRoot", ".", "clipboard_clear", "(", ")", "if", "text", ":", "# for clipboard_append, kwds can be -displayof, -format,...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
get
Get the contents of the given clipboard.
lib/stsci/tools/clipboard_helper.py
def get(cbname): """ Get the contents of the given clipboard. """ _checkTkInit() if cbname == 'PRIMARY': try: return _theRoot.selection_get(selection='PRIMARY') except: return None if cbname == 'CLIPBOARD': try: return _theRoot.selection_get(se...
def get(cbname): """ Get the contents of the given clipboard. """ _checkTkInit() if cbname == 'PRIMARY': try: return _theRoot.selection_get(selection='PRIMARY') except: return None if cbname == 'CLIPBOARD': try: return _theRoot.selection_get(se...
[ "Get", "the", "contents", "of", "the", "given", "clipboard", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L58-L71
[ "def", "get", "(", "cbname", ")", ":", "_checkTkInit", "(", ")", "if", "cbname", "==", "'PRIMARY'", ":", "try", ":", "return", "_theRoot", ".", "selection_get", "(", "selection", "=", "'PRIMARY'", ")", "except", ":", "return", "None", "if", "cbname", "==...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
Config.createDevice
Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg.
backend/src/recorder/common/config.py
def createDevice(self, deviceCfg): """ Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg. """ ioCfg = deviceCfg['io'] type = deviceC...
def createDevice(self, deviceCfg): """ Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg. """ ioCfg = deviceCfg['io'] type = deviceC...
[ "Creates", "a", "measurement", "deviceCfg", "from", "the", "input", "configuration", ".", ":", "param", ":", "deviceCfg", ":", "the", "deviceCfg", "cfg", ".", ":", "param", ":", "handlers", ":", "the", "loaded", "handlers", ".", ":", "return", ":", "the", ...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L57-L86
[ "def", "createDevice", "(", "self", ",", "deviceCfg", ")", ":", "ioCfg", "=", "deviceCfg", "[", "'io'", "]", "type", "=", "deviceCfg", "[", "'type'", "]", "if", "type", "==", "'mpu6050'", ":", "fs", "=", "deviceCfg", ".", "get", "(", "'fs'", ")", "na...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
Config._loadRecordingDevices
Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name.
backend/src/recorder/common/config.py
def _loadRecordingDevices(self): """ Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name. """ return {device.name: device for device in [self.cre...
def _loadRecordingDevices(self): """ Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name. """ return {device.name: device for device in [self.cre...
[ "Loads", "the", "recordingDevices", "specified", "in", "the", "configuration", ".", ":", "param", ":", "handlers", "the", "loaded", "handlers", ".", ":", "return", ":", "the", "constructed", "recordingDevices", "in", "a", "dict", "keyed", "by", "name", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L88-L95
[ "def", "_loadRecordingDevices", "(", "self", ")", ":", "return", "{", "device", ".", "name", ":", "device", "for", "device", "in", "[", "self", ".", "createDevice", "(", "deviceCfg", ")", "for", "deviceCfg", "in", "self", ".", "config", "[", "'acceleromete...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
Config.createHandler
Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler.
backend/src/recorder/common/config.py
def createHandler(self, handler): """ Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler. """ target = handler['target'] if handler['type'] == 'log': self.logger.warning("Initialising ...
def createHandler(self, handler): """ Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler. """ target = handler['target'] if handler['type'] == 'log': self.logger.warning("Initialising ...
[ "Creates", "a", "data", "handler", "from", "the", "input", "configuration", ".", ":", "param", "handler", ":", "the", "handler", "cfg", ".", ":", "return", ":", "the", "constructed", "handler", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L105-L117
[ "def", "createHandler", "(", "self", ",", "handler", ")", ":", "target", "=", "handler", "[", "'target'", "]", "if", "handler", "[", "'type'", "]", "==", "'log'", ":", "self", ".", "logger", ".", "warning", "(", "\"Initialising csvlogger to log data to \"", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
Config._loadHandlers
creates a dictionary of named handler instances :return: the dictionary
backend/src/recorder/common/config.py
def _loadHandlers(self): """ creates a dictionary of named handler instances :return: the dictionary """ return {handler.name: handler for handler in map(self.createHandler, self.config['handlers'])}
def _loadHandlers(self): """ creates a dictionary of named handler instances :return: the dictionary """ return {handler.name: handler for handler in map(self.createHandler, self.config['handlers'])}
[ "creates", "a", "dictionary", "of", "named", "handler", "instances", ":", "return", ":", "the", "dictionary" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L119-L124
[ "def", "_loadHandlers", "(", "self", ")", ":", "return", "{", "handler", ".", "name", ":", "handler", "for", "handler", "in", "map", "(", "self", ".", "createHandler", ",", "self", ".", "config", "[", "'handlers'", "]", ")", "}" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5