repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.getPacketSize
def getPacketSize(self): """ the current packet size. :return: the current packet size based on the enabled registers. """ size = 0 if self.isAccelerometerEnabled(): size += 6 if self.isGyroEnabled(): size += 6 if self.isTemperature...
python
def getPacketSize(self): """ the current packet size. :return: the current packet size based on the enabled registers. """ size = 0 if self.isAccelerometerEnabled(): size += 6 if self.isGyroEnabled(): size += 6 if self.isTemperature...
[ "def", "getPacketSize", "(", "self", ")", ":", "size", "=", "0", "if", "self", ".", "isAccelerometerEnabled", "(", ")", ":", "size", "+=", "6", "if", "self", ".", "isGyroEnabled", "(", ")", ":", "size", "+=", "6", "if", "self", ".", "isTemperatureEnabl...
the current packet size. :return: the current packet size based on the enabled registers.
[ "the", "current", "packet", "size", ".", ":", "return", ":", "the", "current", "packet", "size", "based", "on", "the", "enabled", "registers", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L273-L285
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.initialiseDevice
def initialiseDevice(self): """ performs initialisation of the device :param batchSize: the no of samples that each provideData call should yield :return: """ logger.debug("Initialising device") self.getInterruptStatus() self.setAccelerometerSensitivity(se...
python
def initialiseDevice(self): """ performs initialisation of the device :param batchSize: the no of samples that each provideData call should yield :return: """ logger.debug("Initialising device") self.getInterruptStatus() self.setAccelerometerSensitivity(se...
[ "def", "initialiseDevice", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Initialising device\"", ")", "self", ".", "getInterruptStatus", "(", ")", "self", ".", "setAccelerometerSensitivity", "(", "self", ".", "_accelerationFactor", "*", "32768.0", ")", ...
performs initialisation of the device :param batchSize: the no of samples that each provideData call should yield :return:
[ "performs", "initialisation", "of", "the", "device", ":", "param", "batchSize", ":", "the", "no", "of", "samples", "that", "each", "provideData", "call", "should", "yield", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L287-L308
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.enableAccelerometer
def enableAccelerometer(self): """ Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling acceleration sensor") self.fifoSensorMask |= self.enableAccelerometerMask self._acc...
python
def enableAccelerometer(self): """ Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling acceleration sensor") self.fifoSensorMask |= self.enableAccelerometerMask self._acc...
[ "def", "enableAccelerometer", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Enabling acceleration sensor\"", ")", "self", ".", "fifoSensorMask", "|=", "self", ".", "enableAccelerometerMask", "self", ".", "_accelEnabled", "=", "True", "self", ".", "_setSam...
Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "write", "acceleration", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L317-L325
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.disableAccelerometer
def disableAccelerometer(self): """ Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling acceleration sensor") self.fifoSensorMask &= ~self.enableAccelerometerMask ...
python
def disableAccelerometer(self): """ Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling acceleration sensor") self.fifoSensorMask &= ~self.enableAccelerometerMask ...
[ "def", "disableAccelerometer", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Disabling acceleration sensor\"", ")", "self", ".", "fifoSensorMask", "&=", "~", "self", ".", "enableAccelerometerMask", "self", ".", "_accelEnabled", "=", "False", "self", ".", ...
Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "NOT", "write", "acceleration", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L327-L336
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.enableGyro
def enableGyro(self): """ Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling gyro sensor") self.fifoSensorMask |= self.enableGyroMask self._gyroEnabled = True self._set...
python
def enableGyro(self): """ Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling gyro sensor") self.fifoSensorMask |= self.enableGyroMask self._gyroEnabled = True self._set...
[ "def", "enableGyro", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Enabling gyro sensor\"", ")", "self", ".", "fifoSensorMask", "|=", "self", ".", "enableGyroMask", "self", ".", "_gyroEnabled", "=", "True", "self", ".", "_setSampleSizeBytes", "(", ")"...
Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "write", "gyro", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L345-L353
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.disableGyro
def disableGyro(self): """ Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling gyro sensor") self.fifoSensorMask &= ~self.enableGyroMask self._gyroEnabled = False s...
python
def disableGyro(self): """ Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling gyro sensor") self.fifoSensorMask &= ~self.enableGyroMask self._gyroEnabled = False s...
[ "def", "disableGyro", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Disabling gyro sensor\"", ")", "self", ".", "fifoSensorMask", "&=", "~", "self", ".", "enableGyroMask", "self", ".", "_gyroEnabled", "=", "False", "self", ".", "_setSampleSizeBytes", ...
Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "NOT", "write", "gyro", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L355-L363
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.enableTemperature
def enableTemperature(self): """ Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling temperature sensor") self.fifoSensorMask |= self.enableTemperatureMask self._setSampl...
python
def enableTemperature(self): """ Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Enabling temperature sensor") self.fifoSensorMask |= self.enableTemperatureMask self._setSampl...
[ "def", "enableTemperature", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Enabling temperature sensor\"", ")", "self", ".", "fifoSensorMask", "|=", "self", ".", "enableTemperatureMask", "self", ".", "_setSampleSizeBytes", "(", ")" ]
Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "write", "temperature", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L372-L379
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.disableTemperature
def disableTemperature(self): """ Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling temperature sensor") self.fifoSensorMask &= ~self.enableTemperatureMask self._s...
python
def disableTemperature(self): """ Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called. :return: """ logger.debug("Disabling temperature sensor") self.fifoSensorMask &= ~self.enableTemperatureMask self._s...
[ "def", "disableTemperature", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Disabling temperature sensor\"", ")", "self", ".", "fifoSensorMask", "&=", "~", "self", ".", "enableTemperatureMask", "self", ".", "_setSampleSizeBytes", "(", ")" ]
Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called. :return:
[ "Specifies", "the", "device", "should", "NOT", "write", "temperature", "values", "to", "the", "FIFO", "is", "not", "applied", "until", "enableFIFO", "is", "called", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L381-L388
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.setGyroSensitivity
def setGyroSensitivity(self, value): """ Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the self tests) :param value: the target sensitivity. """ try: self.i2c_io.write(self.MPU6050_ADDRESS, se...
python
def setGyroSensitivity(self, value): """ Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the self tests) :param value: the target sensitivity. """ try: self.i2c_io.write(self.MPU6050_ADDRESS, se...
[ "def", "setGyroSensitivity", "(", "self", ",", "value", ")", ":", "try", ":", "self", ".", "i2c_io", ".", "write", "(", "self", ".", "MPU6050_ADDRESS", ",", "self", ".", "MPU6050_RA_GYRO_CONFIG", ",", "{", "250", ":", "0", ",", "500", ":", "8", ",", ...
Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the self tests) :param value: the target sensitivity.
[ "Sets", "the", "gyro", "sensitivity", "to", "250", "500", "1000", "or", "2000", "according", "to", "the", "given", "value", "(", "and", "implicitly", "disables", "the", "self", "tests", ")", ":", "param", "value", ":", "the", "target", "sensitivity", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L390-L404
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.setAccelerometerSensitivity
def setAccelerometerSensitivity(self, value): """ Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if the value provided is not valid. :param value: the target sensitivity. """ # note that this implicitly disables t...
python
def setAccelerometerSensitivity(self, value): """ Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if the value provided is not valid. :param value: the target sensitivity. """ # note that this implicitly disables t...
[ "def", "setAccelerometerSensitivity", "(", "self", ",", "value", ")", ":", "# note that this implicitly disables the self tests on each axis", "# i.e. the full byte is actually 000[accel]000 where the 1st 3 are the accelerometer self tests, the next two", "# values are the actual sensitivity and...
Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if the value provided is not valid. :param value: the target sensitivity.
[ "Sets", "the", "accelerometer", "sensitivity", "to", "2", "4", "8", "or", "16", "according", "to", "the", "given", "value", ".", "Throws", "an", "ArgumentError", "if", "the", "value", "provided", "is", "not", "valid", ".", ":", "param", "value", ":", "th...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L406-L426
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.setSampleRate
def setSampleRate(self, targetSampleRate): """ Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate is 1kHz. The target...
python
def setSampleRate(self, targetSampleRate): """ Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate is 1kHz. The target...
[ "def", "setSampleRate", "(", "self", ",", "targetSampleRate", ")", ":", "sampleRateDenominator", "=", "int", "(", "(", "8000", "/", "min", "(", "targetSampleRate", ",", "1000", ")", ")", "-", "1", ")", "self", ".", "i2c_io", ".", "write", "(", "self", ...
Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate is 1kHz. The target sample rate is therefore capped at 1kHz. :param target...
[ "Sets", "the", "internal", "sample", "rate", "of", "the", "MPU", "-", "6050", "this", "requires", "writing", "a", "value", "to", "the", "device", "to", "set", "the", "sample", "rate", "as", "Gyroscope", "Output", "Rate", "/", "(", "1", "+", "SMPLRT_DIV",...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L428-L439
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.resetFifo
def resetFifo(self): """ Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO. :return: """ logger.debug("Resetting FIFO") self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000) pass se...
python
def resetFifo(self): """ Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO. :return: """ logger.debug("Resetting FIFO") self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000) pass se...
[ "def", "resetFifo", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Resetting FIFO\"", ")", "self", ".", "i2c_io", ".", "write", "(", "self", ".", "MPU6050_ADDRESS", ",", "self", ".", "MPU6050_RA_USER_CTRL", ",", "0b00000000", ")", "pass", "self", "...
Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO. :return:
[ "Resets", "the", "FIFO", "by", "first", "disabling", "the", "FIFO", "then", "sending", "a", "FIFO_RESET", "and", "then", "re", "-", "enabling", "the", "FIFO", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L441-L452
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.enableFifo
def enableFifo(self): """ Enables the FIFO, resets it and then sets which values should be written to the FIFO. :return: """ logger.debug("Enabling FIFO") self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0) self.resetFifo() self.i2c_io.writ...
python
def enableFifo(self): """ Enables the FIFO, resets it and then sets which values should be written to the FIFO. :return: """ logger.debug("Enabling FIFO") self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0) self.resetFifo() self.i2c_io.writ...
[ "def", "enableFifo", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Enabling FIFO\"", ")", "self", ".", "i2c_io", ".", "write", "(", "self", ".", "MPU6050_ADDRESS", ",", "self", ".", "MPU6050_RA_FIFO_EN", ",", "0", ")", "self", ".", "resetFifo", ...
Enables the FIFO, resets it and then sets which values should be written to the FIFO. :return:
[ "Enables", "the", "FIFO", "resets", "it", "and", "then", "sets", "which", "values", "should", "be", "written", "to", "the", "FIFO", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L454-L463
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.getFifoCount
def getFifoCount(self): """ gets the amount of data available on the FIFO right now. :return: the number of bytes available on the FIFO which will be proportional to the number of samples available based on the values the device is configured to sample. """ bytes = self.i...
python
def getFifoCount(self): """ gets the amount of data available on the FIFO right now. :return: the number of bytes available on the FIFO which will be proportional to the number of samples available based on the values the device is configured to sample. """ bytes = self.i...
[ "def", "getFifoCount", "(", "self", ")", ":", "bytes", "=", "self", ".", "i2c_io", ".", "readBlock", "(", "self", ".", "MPU6050_ADDRESS", ",", "self", ".", "MPU6050_RA_FIFO_COUNTH", ",", "2", ")", "count", "=", "(", "bytes", "[", "0", "]", "<<", "8", ...
gets the amount of data available on the FIFO right now. :return: the number of bytes available on the FIFO which will be proportional to the number of samples available based on the values the device is configured to sample.
[ "gets", "the", "amount", "of", "data", "available", "on", "the", "FIFO", "right", "now", ".", ":", "return", ":", "the", "number", "of", "bytes", "available", "on", "the", "FIFO", "which", "will", "be", "proportional", "to", "the", "number", "of", "sampl...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L474-L483
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.getDataFromFIFO
def getDataFromFIFO(self, bytesToRead): """ reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there is new data available (to avoid reading duplicate data). :param bytesToRead: the number of bytes to read. :return: the byte...
python
def getDataFromFIFO(self, bytesToRead): """ reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there is new data available (to avoid reading duplicate data). :param bytesToRead: the number of bytes to read. :return: the byte...
[ "def", "getDataFromFIFO", "(", "self", ",", "bytesToRead", ")", ":", "return", "self", ".", "i2c_io", ".", "readBlock", "(", "self", ".", "MPU6050_ADDRESS", ",", "self", ".", "MPU6050_RA_FIFO_R_W", ",", "bytesToRead", ")" ]
reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there is new data available (to avoid reading duplicate data). :param bytesToRead: the number of bytes to read. :return: the bytes read.
[ "reads", "the", "specified", "number", "of", "bytes", "from", "the", "FIFO", "should", "be", "called", "after", "a", "call", "to", "getFifoCount", "to", "ensure", "there", "is", "new", "data", "available", "(", "to", "avoid", "reading", "duplicate", "data", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L485-L492
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.provideData
def provideData(self): """ reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read from the device itself. :return: a list of data where each item is a single sample of data converted into real values and stored as a dict. ...
python
def provideData(self): """ reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read from the device itself. :return: a list of data where each item is a single sample of data converted into real values and stored as a dict. ...
[ "def", "provideData", "(", "self", ")", ":", "samples", "=", "[", "]", "fifoBytesAvailable", "=", "0", "fifoWasReset", "=", "False", "logger", ".", "debug", "(", "\">> provideData target %d samples\"", ",", "self", ".", "samplesPerBatch", ")", "iterations", "=",...
reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read from the device itself. :return: a list of data where each item is a single sample of data converted into real values and stored as a dict.
[ "reads", "a", "batchSize", "batch", "of", "data", "from", "the", "FIFO", "while", "attempting", "to", "optimise", "the", "number", "of", "times", "we", "have", "to", "read", "from", "the", "device", "itself", ".", ":", "return", ":", "a", "list", "of", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L494-L564
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050.unpackSample
def unpackSample(self, rawData): """ unpacks a single sample of data (where sample length is based on the currently enabled sensors). :param rawData: the data to convert :return: a converted data set. """ length = len(rawData) # TODO error if not multiple of 2 ...
python
def unpackSample(self, rawData): """ unpacks a single sample of data (where sample length is based on the currently enabled sensors). :param rawData: the data to convert :return: a converted data set. """ length = len(rawData) # TODO error if not multiple of 2 ...
[ "def", "unpackSample", "(", "self", ",", "rawData", ")", ":", "length", "=", "len", "(", "rawData", ")", "# TODO error if not multiple of 2", "# logger.debug(\">> unpacking sample %d length %d\", self._sampleIdx, length)", "unpacked", "=", "struct", ".", "unpack", "(", "\...
unpacks a single sample of data (where sample length is based on the currently enabled sensors). :param rawData: the data to convert :return: a converted data set.
[ "unpacks", "a", "single", "sample", "of", "data", "(", "where", "sample", "length", "is", "based", "on", "the", "currently", "enabled", "sensors", ")", ".", ":", "param", "rawData", ":", "the", "data", "to", "convert", ":", "return", ":", "a", "converted...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L566-L603
train
spacetelescope/stsci.tools
lib/stsci/tools/textutil.py
wrap
def wrap(text, width, *args, **kwargs): """ Like :func:`textwrap.wrap` but preserves existing newlines which :func:`textwrap.wrap` does not otherwise handle well. See Also -------- :func:`textwrap.wrap` """ return sum([textwrap.wrap(line, width, *args, **kwargs) if line...
python
def wrap(text, width, *args, **kwargs): """ Like :func:`textwrap.wrap` but preserves existing newlines which :func:`textwrap.wrap` does not otherwise handle well. See Also -------- :func:`textwrap.wrap` """ return sum([textwrap.wrap(line, width, *args, **kwargs) if line...
[ "def", "wrap", "(", "text", ",", "width", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "sum", "(", "[", "textwrap", ".", "wrap", "(", "line", ",", "width", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "line", "else", ...
Like :func:`textwrap.wrap` but preserves existing newlines which :func:`textwrap.wrap` does not otherwise handle well. See Also -------- :func:`textwrap.wrap`
[ "Like", ":", "func", ":", "textwrap", ".", "wrap", "but", "preserves", "existing", "newlines", "which", ":", "func", ":", "textwrap", ".", "wrap", "does", "not", "otherwise", "handle", "well", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L7-L18
train
spacetelescope/stsci.tools
lib/stsci/tools/textutil.py
textbox
def textbox(text, width=78, boxchar='#', indent=0): """ Outputs line-wrapped text wrapped in a box drawn with a repeated (usually ASCII) character. For example: >>> print(textbox('Text to wrap', width=16)) ################ # # # Text to wrap # # ...
python
def textbox(text, width=78, boxchar='#', indent=0): """ Outputs line-wrapped text wrapped in a box drawn with a repeated (usually ASCII) character. For example: >>> print(textbox('Text to wrap', width=16)) ################ # # # Text to wrap # # ...
[ "def", "textbox", "(", "text", ",", "width", "=", "78", ",", "boxchar", "=", "'#'", ",", "indent", "=", "0", ")", ":", "min_width", "=", "len", "(", "boxchar", ")", "*", "2", "+", "3", "width", "=", "max", "(", "width", "-", "indent", ",", "min...
Outputs line-wrapped text wrapped in a box drawn with a repeated (usually ASCII) character. For example: >>> print(textbox('Text to wrap', width=16)) ################ # # # Text to wrap # # # ################ Parameters -------...
[ "Outputs", "line", "-", "wrapped", "text", "wrapped", "in", "a", "box", "drawn", "with", "a", "repeated", "(", "usually", "ASCII", ")", "character", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L21-L72
train
titilambert/pyhydroquebec
pyhydroquebec/__main__.py
main
def main(): """Entrypoint function.""" parser = argparse.ArgumentParser() parser.add_argument('-u', '--username', help='Hydro Quebec username') parser.add_argument('-p', '--password', help='Password') parser.add_argument('-j', '--json', action='store_t...
python
def main(): """Entrypoint function.""" parser = argparse.ArgumentParser() parser.add_argument('-u', '--username', help='Hydro Quebec username') parser.add_argument('-p', '--password', help='Password') parser.add_argument('-j', '--json', action='store_t...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-u'", ",", "'--username'", ",", "help", "=", "'Hydro Quebec username'", ")", "parser", ".", "add_argument", "(", "'-p'", ",", "'...
Entrypoint function.
[ "Entrypoint", "function", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/__main__.py#L14-L89
train
fitnr/convertdate
convertdate/holidays.py
easter
def easter(year): '''Calculate western easter''' # formula taken from http://aa.usno.navy.mil/faq/docs/easter.html c = trunc(year / 100) n = year - 19 * trunc(year / 19) k = trunc((c - 17) / 25) i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15 i = i - 30 * trunc(i / 30) i = i ...
python
def easter(year): '''Calculate western easter''' # formula taken from http://aa.usno.navy.mil/faq/docs/easter.html c = trunc(year / 100) n = year - 19 * trunc(year / 19) k = trunc((c - 17) / 25) i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15 i = i - 30 * trunc(i / 30) i = i ...
[ "def", "easter", "(", "year", ")", ":", "# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html", "c", "=", "trunc", "(", "year", "/", "100", ")", "n", "=", "year", "-", "19", "*", "trunc", "(", "year", "/", "19", ")", "k", "=", "trunc", "(", ...
Calculate western easter
[ "Calculate", "western", "easter" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L75-L95
train
fitnr/convertdate
convertdate/holidays.py
independence_day
def independence_day(year, observed=None): '''July 4th''' day = 4 if observed: if calendar.weekday(year, JUL, 4) == SAT: day = 3 if calendar.weekday(year, JUL, 4) == SUN: day = 5 return (year, JUL, day)
python
def independence_day(year, observed=None): '''July 4th''' day = 4 if observed: if calendar.weekday(year, JUL, 4) == SAT: day = 3 if calendar.weekday(year, JUL, 4) == SUN: day = 5 return (year, JUL, day)
[ "def", "independence_day", "(", "year", ",", "observed", "=", "None", ")", ":", "day", "=", "4", "if", "observed", ":", "if", "calendar", ".", "weekday", "(", "year", ",", "JUL", ",", "4", ")", "==", "SAT", ":", "day", "=", "3", "if", "calendar", ...
July 4th
[ "July", "4th" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L122-L133
train
fitnr/convertdate
convertdate/holidays.py
columbus_day
def columbus_day(year, country='usa'): '''in USA: 2nd Monday in Oct Elsewhere: Oct 12''' if country == 'usa': return nth_day_of_month(2, MON, OCT, year) else: return (year, OCT, 12)
python
def columbus_day(year, country='usa'): '''in USA: 2nd Monday in Oct Elsewhere: Oct 12''' if country == 'usa': return nth_day_of_month(2, MON, OCT, year) else: return (year, OCT, 12)
[ "def", "columbus_day", "(", "year", ",", "country", "=", "'usa'", ")", ":", "if", "country", "==", "'usa'", ":", "return", "nth_day_of_month", "(", "2", ",", "MON", ",", "OCT", ",", "year", ")", "else", ":", "return", "(", "year", ",", "OCT", ",", ...
in USA: 2nd Monday in Oct Elsewhere: Oct 12
[ "in", "USA", ":", "2nd", "Monday", "in", "Oct", "Elsewhere", ":", "Oct", "12" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L141-L147
train
fitnr/convertdate
convertdate/holidays.py
thanksgiving
def thanksgiving(year, country='usa'): '''USA: last Thurs. of November, Canada: 2nd Mon. of October''' if country == 'usa': if year in [1940, 1941]: return nth_day_of_month(3, THU, NOV, year) elif year == 1939: return nth_day_of_month(4, THU, NOV, year) else: ...
python
def thanksgiving(year, country='usa'): '''USA: last Thurs. of November, Canada: 2nd Mon. of October''' if country == 'usa': if year in [1940, 1941]: return nth_day_of_month(3, THU, NOV, year) elif year == 1939: return nth_day_of_month(4, THU, NOV, year) else: ...
[ "def", "thanksgiving", "(", "year", ",", "country", "=", "'usa'", ")", ":", "if", "country", "==", "'usa'", ":", "if", "year", "in", "[", "1940", ",", "1941", "]", ":", "return", "nth_day_of_month", "(", "3", ",", "THU", ",", "NOV", ",", "year", ")...
USA: last Thurs. of November, Canada: 2nd Mon. of October
[ "USA", ":", "last", "Thurs", ".", "of", "November", "Canada", ":", "2nd", "Mon", ".", "of", "October" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L173-L184
train
spacetelescope/stsci.tools
lib/stsci/tools/linefit.py
linefit
def linefit(x, y, weights=None): """ Parameters ---------- y: 1D numpy array The data to be fitted x: 1D numpy array The x values of the y array. x and y must have the same shape. weights: 1D numpy array, must have the same shape as x and y weight values E...
python
def linefit(x, y, weights=None): """ Parameters ---------- y: 1D numpy array The data to be fitted x: 1D numpy array The x values of the y array. x and y must have the same shape. weights: 1D numpy array, must have the same shape as x and y weight values E...
[ "def", "linefit", "(", "x", ",", "y", ",", "weights", "=", "None", ")", ":", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "print", "(", "\"Error: X and Y must have equal size\\n\"", ")", "return", "n", "=", "len", "(", "x", ")", "w"...
Parameters ---------- y: 1D numpy array The data to be fitted x: 1D numpy array The x values of the y array. x and y must have the same shape. weights: 1D numpy array, must have the same shape as x and y weight values Examples -------- >>> import numpy as N...
[ "Parameters", "----------", "y", ":", "1D", "numpy", "array", "The", "data", "to", "be", "fitted", "x", ":", "1D", "numpy", "array", "The", "x", "values", "of", "the", "y", "array", ".", "x", "and", "y", "must", "have", "the", "same", "shape", ".", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/linefit.py#L19-L72
train
3ll3d00d/vibe
backend/src/analyser/resources/analyse.py
Analyse.get
def get(self, measurementId): """ Analyses the measurement with the given parameters :param measurementId: :return: """ logger.info('Analysing ' + measurementId) measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.COMPLETE) ...
python
def get(self, measurementId): """ Analyses the measurement with the given parameters :param measurementId: :return: """ logger.info('Analysing ' + measurementId) measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.COMPLETE) ...
[ "def", "get", "(", "self", ",", "measurementId", ")", ":", "logger", ".", "info", "(", "'Analysing '", "+", "measurementId", ")", "measurement", "=", "self", ".", "_measurementController", ".", "getMeasurement", "(", "measurementId", ",", "MeasurementStatus", "....
Analyses the measurement with the given parameters :param measurementId: :return:
[ "Analyses", "the", "measurement", "with", "the", "given", "parameters", ":", "param", "measurementId", ":", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/analyse.py#L13-L49
train
3ll3d00d/vibe
backend/src/analyser/common/targetstatecontroller.py
_applyTargetState
def _applyTargetState(targetState, md, httpclient): """ compares the current device state against the targetStateProvider and issues updates as necessary to ensure the device is at that state. :param md: :param targetState: the target state. :param httpclient: the http client :return: ...
python
def _applyTargetState(targetState, md, httpclient): """ compares the current device state against the targetStateProvider and issues updates as necessary to ensure the device is at that state. :param md: :param targetState: the target state. :param httpclient: the http client :return: ...
[ "def", "_applyTargetState", "(", "targetState", ",", "md", ",", "httpclient", ")", ":", "anyUpdate", "=", "False", "if", "md", "[", "'fs'", "]", "!=", "targetState", ".", "fs", ":", "logger", ".", "info", "(", "\"Updating fs from \"", "+", "str", "(", "m...
compares the current device state against the targetStateProvider and issues updates as necessary to ensure the device is at that state. :param md: :param targetState: the target state. :param httpclient: the http client :return:
[ "compares", "the", "current", "device", "state", "against", "the", "targetStateProvider", "and", "issues", "updates", "as", "necessary", "to", "ensure", "the", "device", "is", "at", "that", "state", ".", ":", "param", "md", ":", ":", "param", "targetState", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L78-L130
train
3ll3d00d/vibe
backend/src/analyser/common/targetstatecontroller.py
TargetStateController.updateDeviceState
def updateDeviceState(self, device): """ Updates the target state on the specified device. :param targetState: the target state to reach. :param device: the device to update. :return: """ # this is only threadsafe because the targetstate is effectively immutable, ...
python
def updateDeviceState(self, device): """ Updates the target state on the specified device. :param targetState: the target state to reach. :param device: the device to update. :return: """ # this is only threadsafe because the targetstate is effectively immutable, ...
[ "def", "updateDeviceState", "(", "self", ",", "device", ")", ":", "# this is only threadsafe because the targetstate is effectively immutable, if it becomes mutable in future then", "# funkiness may result", "self", ".", "_reactor", ".", "offer", "(", "REACH_TARGET_STATE", ",", "...
Updates the target state on the specified device. :param targetState: the target state to reach. :param device: the device to update. :return:
[ "Updates", "the", "target", "state", "on", "the", "specified", "device", ".", ":", "param", "targetState", ":", "the", "target", "state", "to", "reach", ".", ":", "param", "device", ":", "the", "device", "to", "update", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L25-L34
train
3ll3d00d/vibe
backend/src/analyser/common/targetstatecontroller.py
TargetStateController.updateTargetState
def updateTargetState(self, newState): """ Updates the system target state and propagates that to all devices. :param newState: :return: """ self._targetStateProvider.state = loadTargetState(newState, self._targetStateProvider.state) for device in self.deviceContr...
python
def updateTargetState(self, newState): """ Updates the system target state and propagates that to all devices. :param newState: :return: """ self._targetStateProvider.state = loadTargetState(newState, self._targetStateProvider.state) for device in self.deviceContr...
[ "def", "updateTargetState", "(", "self", ",", "newState", ")", ":", "self", ".", "_targetStateProvider", ".", "state", "=", "loadTargetState", "(", "newState", ",", "self", ".", "_targetStateProvider", ".", "state", ")", "for", "device", "in", "self", ".", "...
Updates the system target state and propagates that to all devices. :param newState: :return:
[ "Updates", "the", "system", "target", "state", "and", "propagates", "that", "to", "all", "devices", ".", ":", "param", "newState", ":", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetstatecontroller.py#L36-L44
train
spacetelescope/stsci.tools
lib/stsci/tools/convertlog.py
convert
def convert(input, width=132, output=None, keep=False): """Input ASCII trailer file "input" will be read. The contents will then be written out to a FITS file in the same format as used by 'stwfits' from IRAF. Parameters =========== input : str Filename of input ASCII trailer file ...
python
def convert(input, width=132, output=None, keep=False): """Input ASCII trailer file "input" will be read. The contents will then be written out to a FITS file in the same format as used by 'stwfits' from IRAF. Parameters =========== input : str Filename of input ASCII trailer file ...
[ "def", "convert", "(", "input", ",", "width", "=", "132", ",", "output", "=", "None", ",", "keep", "=", "False", ")", ":", "# open input trailer file", "trl", "=", "open", "(", "input", ")", "# process all lines", "lines", "=", "np", ".", "array", "(", ...
Input ASCII trailer file "input" will be read. The contents will then be written out to a FITS file in the same format as used by 'stwfits' from IRAF. Parameters =========== input : str Filename of input ASCII trailer file width : int Number of characters wide to use for defin...
[ "Input", "ASCII", "trailer", "file", "input", "will", "be", "read", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertlog.py#L53-L112
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
flatten_errors
def flatten_errors(cfg, res, levels=None, results=None): """ An example function that will turn a nested dictionary of results (as returned by ``ConfigObj.validate``) into a flat list. ``cfg`` is the ConfigObj instance being checked, ``res`` is the results dictionary returned by ``validate``. ...
python
def flatten_errors(cfg, res, levels=None, results=None): """ An example function that will turn a nested dictionary of results (as returned by ``ConfigObj.validate``) into a flat list. ``cfg`` is the ConfigObj instance being checked, ``res`` is the results dictionary returned by ``validate``. ...
[ "def", "flatten_errors", "(", "cfg", ",", "res", ",", "levels", "=", "None", ",", "results", "=", "None", ")", ":", "if", "levels", "is", "None", ":", "# first time called", "levels", "=", "[", "]", "results", "=", "[", "]", "if", "res", "==", "True"...
An example function that will turn a nested dictionary of results (as returned by ``ConfigObj.validate``) into a flat list. ``cfg`` is the ConfigObj instance being checked, ``res`` is the results dictionary returned by ``validate``. (This is a recursive function, so you shouldn't use the ``levels`` or...
[ "An", "example", "function", "that", "will", "turn", "a", "nested", "dictionary", "of", "results", "(", "as", "returned", "by", "ConfigObj", ".", "validate", ")", "into", "a", "flat", "list", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2396-L2453
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
get_extra_values
def get_extra_values(conf, _prepend=()): """ Find all the values and sections not in the configspec from a validated ConfigObj. ``get_extra_values`` returns a list of tuples where each tuple represents either an extra section, or an extra value. The tuples contain two values, a tuple represent...
python
def get_extra_values(conf, _prepend=()): """ Find all the values and sections not in the configspec from a validated ConfigObj. ``get_extra_values`` returns a list of tuples where each tuple represents either an extra section, or an extra value. The tuples contain two values, a tuple represent...
[ "def", "get_extra_values", "(", "conf", ",", "_prepend", "=", "(", ")", ")", ":", "out", "=", "[", "]", "out", ".", "extend", "(", "[", "(", "_prepend", ",", "name", ")", "for", "name", "in", "conf", ".", "extra_values", "]", ")", "for", "name", ...
Find all the values and sections not in the configspec from a validated ConfigObj. ``get_extra_values`` returns a list of tuples where each tuple represents either an extra section, or an extra value. The tuples contain two values, a tuple representing the section the value is in and the name of t...
[ "Find", "all", "the", "values", "and", "sections", "not", "in", "the", "configspec", "from", "a", "validated", "ConfigObj", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2456-L2479
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
InterpolationEngine._fetch
def _fetch(self, key): """Helper function to fetch values from owning section. Returns a 2-tuple: the value, and the section where it was found. """ # switch off interpolation before we try and fetch anything ! save_interp = self.section.main.interpolation self.section.m...
python
def _fetch(self, key): """Helper function to fetch values from owning section. Returns a 2-tuple: the value, and the section where it was found. """ # switch off interpolation before we try and fetch anything ! save_interp = self.section.main.interpolation self.section.m...
[ "def", "_fetch", "(", "self", ",", "key", ")", ":", "# switch off interpolation before we try and fetch anything !", "save_interp", "=", "self", ".", "section", ".", "main", ".", "interpolation", "self", ".", "section", ".", "main", ".", "interpolation", "=", "Fal...
Helper function to fetch values from owning section. Returns a 2-tuple: the value, and the section where it was found.
[ "Helper", "function", "to", "fetch", "values", "from", "owning", "section", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L381-L412
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.pop
def pop(self, key, default=MISSING): """ 'D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised' """ try: val = self[key] except KeyError: if default is...
python
def pop(self, key, default=MISSING): """ 'D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised' """ try: val = self[key] except KeyError: if default is...
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "MISSING", ")", ":", "try", ":", "val", "=", "self", "[", "key", "]", "except", "KeyError", ":", "if", "default", "is", "MISSING", ":", "raise", "val", "=", "default", "else", ":", "del", ...
'D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised'
[ "D", ".", "pop", "(", "k", "[", "d", "]", ")", "-", ">", "v", "remove", "specified", "key", "and", "return", "the", "corresponding", "value", ".", "If", "key", "is", "not", "found", "d", "is", "returned", "if", "given", "otherwise", "KeyError", "is",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L680-L693
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.popitem
def popitem(self): """Pops the first (key,val)""" sequence = (self.scalars + self.sections) if not sequence: raise KeyError(": 'popitem(): dictionary is empty'") key = sequence[0] val = self[key] del self[key] return key, val
python
def popitem(self): """Pops the first (key,val)""" sequence = (self.scalars + self.sections) if not sequence: raise KeyError(": 'popitem(): dictionary is empty'") key = sequence[0] val = self[key] del self[key] return key, val
[ "def", "popitem", "(", "self", ")", ":", "sequence", "=", "(", "self", ".", "scalars", "+", "self", ".", "sections", ")", "if", "not", "sequence", ":", "raise", "KeyError", "(", "\": 'popitem(): dictionary is empty'\"", ")", "key", "=", "sequence", "[", "0...
Pops the first (key,val)
[ "Pops", "the", "first", "(", "key", "val", ")" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L696-L704
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.clear
def clear(self): """ A version of clear that also affects scalars/sections Also clears comments and configspec. Leaves other attributes alone : depth/main/parent are not affected """ dict.clear(self) self.scalars = [] self.sections = [] ...
python
def clear(self): """ A version of clear that also affects scalars/sections Also clears comments and configspec. Leaves other attributes alone : depth/main/parent are not affected """ dict.clear(self) self.scalars = [] self.sections = [] ...
[ "def", "clear", "(", "self", ")", ":", "dict", ".", "clear", "(", "self", ")", "self", ".", "scalars", "=", "[", "]", "self", ".", "sections", "=", "[", "]", "self", ".", "comments", "=", "{", "}", "self", ".", "inline_comments", "=", "{", "}", ...
A version of clear that also affects scalars/sections Also clears comments and configspec. Leaves other attributes alone : depth/main/parent are not affected
[ "A", "version", "of", "clear", "that", "also", "affects", "scalars", "/", "sections", "Also", "clears", "comments", "and", "configspec", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L707-L722
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.items
def items(self): """D.items() -> list of D's (key, value) pairs, as 2-tuples""" return list(zip((self.scalars + self.sections), list(self.values())))
python
def items(self): """D.items() -> list of D's (key, value) pairs, as 2-tuples""" return list(zip((self.scalars + self.sections), list(self.values())))
[ "def", "items", "(", "self", ")", ":", "return", "list", "(", "zip", "(", "(", "self", ".", "scalars", "+", "self", ".", "sections", ")", ",", "list", "(", "self", ".", "values", "(", ")", ")", ")", ")" ]
D.items() -> list of D's (key, value) pairs, as 2-tuples
[ "D", ".", "items", "()", "-", ">", "list", "of", "D", "s", "(", "key", "value", ")", "pairs", "as", "2", "-", "tuples" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L734-L736
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.dict
def dict(self): """ Return a deepcopy of self as a dictionary. All members that are ``Section`` instances are recursively turned to ordinary dictionaries - by calling their ``dict`` method. >>> n = a.dict() # doctest: +SKIP >>> n == a # doctest: +SKIP 1 ...
python
def dict(self): """ Return a deepcopy of self as a dictionary. All members that are ``Section`` instances are recursively turned to ordinary dictionaries - by calling their ``dict`` method. >>> n = a.dict() # doctest: +SKIP >>> n == a # doctest: +SKIP 1 ...
[ "def", "dict", "(", "self", ")", ":", "newdict", "=", "{", "}", "for", "entry", "in", "self", ":", "this_entry", "=", "self", "[", "entry", "]", "if", "isinstance", "(", "this_entry", ",", "Section", ")", ":", "this_entry", "=", "this_entry", ".", "d...
Return a deepcopy of self as a dictionary. All members that are ``Section`` instances are recursively turned to ordinary dictionaries - by calling their ``dict`` method. >>> n = a.dict() # doctest: +SKIP >>> n == a # doctest: +SKIP 1 >>> n is a # doctest: +SKIP ...
[ "Return", "a", "deepcopy", "of", "self", "as", "a", "dictionary", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L782-L807
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.merge
def merge(self, indict): """ A recursive update - useful for merging config files. >>> a = '''[section1] ... option1 = True ... [[subsection]] ... more_options = False ... # end of file'''.splitlines() >>> b = '''# File is user.ini ...
python
def merge(self, indict): """ A recursive update - useful for merging config files. >>> a = '''[section1] ... option1 = True ... [[subsection]] ... more_options = False ... # end of file'''.splitlines() >>> b = '''# File is user.ini ...
[ "def", "merge", "(", "self", ",", "indict", ")", ":", "for", "key", ",", "val", "in", "list", "(", "indict", ".", "items", "(", ")", ")", ":", "if", "(", "key", "in", "self", "and", "isinstance", "(", "self", "[", "key", "]", ",", "dict", ")", ...
A recursive update - useful for merging config files. >>> a = '''[section1] ... option1 = True ... [[subsection]] ... more_options = False ... # end of file'''.splitlines() >>> b = '''# File is user.ini ... [section1] ... option1 =...
[ "A", "recursive", "update", "-", "useful", "for", "merging", "config", "files", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L810-L834
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.rename
def rename(self, oldkey, newkey): """ Change a keyname to another, without changing position in sequence. Implemented so that transformations can be made on keys, as well as on values. (used by encode and decode) Also renames comments. """ if oldkey in self.scal...
python
def rename(self, oldkey, newkey): """ Change a keyname to another, without changing position in sequence. Implemented so that transformations can be made on keys, as well as on values. (used by encode and decode) Also renames comments. """ if oldkey in self.scal...
[ "def", "rename", "(", "self", ",", "oldkey", ",", "newkey", ")", ":", "if", "oldkey", "in", "self", ".", "scalars", ":", "the_list", "=", "self", ".", "scalars", "elif", "oldkey", "in", "self", ".", "sections", ":", "the_list", "=", "self", ".", "sec...
Change a keyname to another, without changing position in sequence. Implemented so that transformations can be made on keys, as well as on values. (used by encode and decode) Also renames comments.
[ "Change", "a", "keyname", "to", "another", "without", "changing", "position", "in", "sequence", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L837-L864
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.walk
def walk(self, function, raise_errors=True, call_on_sections=False, **keywargs): """ Walk every member and call a function on the keyword and value. Return a dictionary of the return values If the function raises an exception, raise the errror unless ``raise_errors=...
python
def walk(self, function, raise_errors=True, call_on_sections=False, **keywargs): """ Walk every member and call a function on the keyword and value. Return a dictionary of the return values If the function raises an exception, raise the errror unless ``raise_errors=...
[ "def", "walk", "(", "self", ",", "function", ",", "raise_errors", "=", "True", ",", "call_on_sections", "=", "False", ",", "*", "*", "keywargs", ")", ":", "out", "=", "{", "}", "# scalars first", "for", "i", "in", "range", "(", "len", "(", "self", "....
Walk every member and call a function on the keyword and value. Return a dictionary of the return values If the function raises an exception, raise the errror unless ``raise_errors=False``, in which case set the return value to ``False``. Any unrecognised keyword arguments you...
[ "Walk", "every", "member", "and", "call", "a", "function", "on", "the", "keyword", "and", "value", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L867-L949
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.as_bool
def as_bool(self, key): """ Accepts a key as input. The corresponding value must be a string or the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to retain compatibility with Python 2.2. If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns ...
python
def as_bool(self, key): """ Accepts a key as input. The corresponding value must be a string or the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to retain compatibility with Python 2.2. If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns ...
[ "def", "as_bool", "(", "self", ",", "key", ")", ":", "val", "=", "self", "[", "key", "]", "if", "val", "==", "True", ":", "return", "True", "elif", "val", "==", "False", ":", "return", "False", "else", ":", "try", ":", "if", "not", "isinstance", ...
Accepts a key as input. The corresponding value must be a string or the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to retain compatibility with Python 2.2. If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns ``True``. If the string is one ...
[ "Accepts", "a", "key", "as", "input", ".", "The", "corresponding", "value", "must", "be", "a", "string", "or", "the", "objects", "(", "True", "or", "1", ")", "or", "(", "False", "or", "0", ")", ".", "We", "allow", "0", "and", "1", "to", "retain", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L952-L993
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.as_list
def as_list(self, key): """ A convenience method which fetches the specified value, guaranteeing that it is a list. >>> a = ConfigObj() >>> a['a'] = 1 >>> a.as_list('a') [1] >>> a['a'] = (1,) >>> a.as_list('a') [1] >>> a['a'] = [1]...
python
def as_list(self, key): """ A convenience method which fetches the specified value, guaranteeing that it is a list. >>> a = ConfigObj() >>> a['a'] = 1 >>> a.as_list('a') [1] >>> a['a'] = (1,) >>> a.as_list('a') [1] >>> a['a'] = [1]...
[ "def", "as_list", "(", "self", ",", "key", ")", ":", "result", "=", "self", "[", "key", "]", "if", "isinstance", "(", "result", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "list", "(", "result", ")", "return", "[", "result", "]" ]
A convenience method which fetches the specified value, guaranteeing that it is a list. >>> a = ConfigObj() >>> a['a'] = 1 >>> a.as_list('a') [1] >>> a['a'] = (1,) >>> a.as_list('a') [1] >>> a['a'] = [1] >>> a.as_list('a') [1]
[ "A", "convenience", "method", "which", "fetches", "the", "specified", "value", "guaranteeing", "that", "it", "is", "a", "list", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1039-L1058
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.restore_default
def restore_default(self, key): """ Restore (and return) default value for the specified key. This method will only work for a ConfigObj that was created with a configspec and has been validated. If there is no default value for this key, ``KeyError`` is raised. """ ...
python
def restore_default(self, key): """ Restore (and return) default value for the specified key. This method will only work for a ConfigObj that was created with a configspec and has been validated. If there is no default value for this key, ``KeyError`` is raised. """ ...
[ "def", "restore_default", "(", "self", ",", "key", ")", ":", "default", "=", "self", ".", "default_values", "[", "key", "]", "dict", ".", "__setitem__", "(", "self", ",", "key", ",", "default", ")", "if", "key", "not", "in", "self", ".", "defaults", ...
Restore (and return) default value for the specified key. This method will only work for a ConfigObj that was created with a configspec and has been validated. If there is no default value for this key, ``KeyError`` is raised.
[ "Restore", "(", "and", "return", ")", "default", "value", "for", "the", "specified", "key", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1061-L1074
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
Section.restore_defaults
def restore_defaults(self): """ Recursively restore default values to all members that have them. This method will only work for a ConfigObj that was created with a configspec and has been validated. It doesn't delete or modify entries without default values. ""...
python
def restore_defaults(self): """ Recursively restore default values to all members that have them. This method will only work for a ConfigObj that was created with a configspec and has been validated. It doesn't delete or modify entries without default values. ""...
[ "def", "restore_defaults", "(", "self", ")", ":", "for", "key", "in", "self", ".", "default_values", ":", "self", ".", "restore_default", "(", "key", ")", "for", "section", "in", "self", ".", "sections", ":", "self", "[", "section", "]", ".", "restore_de...
Recursively restore default values to all members that have them. This method will only work for a ConfigObj that was created with a configspec and has been validated. It doesn't delete or modify entries without default values.
[ "Recursively", "restore", "default", "values", "to", "all", "members", "that", "have", "them", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1077-L1091
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._handle_bom
def _handle_bom(self, infile): """ Handle any BOM, and decode if necessary. If an encoding is specified, that *must* be used - but the BOM should still be removed (and the BOM attribute set). (If the encoding is wrongly specified, then a BOM for an alternative encoding ...
python
def _handle_bom(self, infile): """ Handle any BOM, and decode if necessary. If an encoding is specified, that *must* be used - but the BOM should still be removed (and the BOM attribute set). (If the encoding is wrongly specified, then a BOM for an alternative encoding ...
[ "def", "_handle_bom", "(", "self", ",", "infile", ")", ":", "if", "(", "(", "self", ".", "encoding", "is", "not", "None", ")", "and", "(", "self", ".", "encoding", ".", "lower", "(", ")", "not", "in", "BOM_LIST", ")", ")", ":", "# No need to check fo...
Handle any BOM, and decode if necessary. If an encoding is specified, that *must* be used - but the BOM should still be removed (and the BOM attribute set). (If the encoding is wrongly specified, then a BOM for an alternative encoding won't be discovered or removed.) If an enc...
[ "Handle", "any", "BOM", "and", "decode", "if", "necessary", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1395-L1493
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._decode
def _decode(self, infile, encoding): """ Decode infile to unicode. Using the specified encoding. if is a string, it also needs converting to a list. """ if isinstance(infile, string_types): # can't be unicode # NOTE: Could raise a ``UnicodeDecodeError`` ...
python
def _decode(self, infile, encoding): """ Decode infile to unicode. Using the specified encoding. if is a string, it also needs converting to a list. """ if isinstance(infile, string_types): # can't be unicode # NOTE: Could raise a ``UnicodeDecodeError`` ...
[ "def", "_decode", "(", "self", ",", "infile", ",", "encoding", ")", ":", "if", "isinstance", "(", "infile", ",", "string_types", ")", ":", "# can't be unicode", "# NOTE: Could raise a ``UnicodeDecodeError``", "return", "infile", ".", "decode", "(", "encoding", ")"...
Decode infile to unicode. Using the specified encoding. if is a string, it also needs converting to a list.
[ "Decode", "infile", "to", "unicode", ".", "Using", "the", "specified", "encoding", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1504-L1524
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._decode_element
def _decode_element(self, line): """Decode element to unicode if necessary.""" if not self.encoding: return line if isinstance(line, str) and self.default_encoding: return line.decode(self.default_encoding) return line
python
def _decode_element(self, line): """Decode element to unicode if necessary.""" if not self.encoding: return line if isinstance(line, str) and self.default_encoding: return line.decode(self.default_encoding) return line
[ "def", "_decode_element", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "encoding", ":", "return", "line", "if", "isinstance", "(", "line", ",", "str", ")", "and", "self", ".", "default_encoding", ":", "return", "line", ".", "decode", "...
Decode element to unicode if necessary.
[ "Decode", "element", "to", "unicode", "if", "necessary", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1527-L1533
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._parse
def _parse(self, infile): """Actually parse the config file.""" temp_list_values = self.list_values if self.unrepr: self.list_values = False comment_list = [] done_start = False this_section = self maxline = len(infile) - 1 cur_index = -1 ...
python
def _parse(self, infile): """Actually parse the config file.""" temp_list_values = self.list_values if self.unrepr: self.list_values = False comment_list = [] done_start = False this_section = self maxline = len(infile) - 1 cur_index = -1 ...
[ "def", "_parse", "(", "self", ",", "infile", ")", ":", "temp_list_values", "=", "self", ".", "list_values", "if", "self", ".", "unrepr", ":", "self", ".", "list_values", "=", "False", "comment_list", "=", "[", "]", "done_start", "=", "False", "this_section...
Actually parse the config file.
[ "Actually", "parse", "the", "config", "file", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1547-L1712
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._match_depth
def _match_depth(self, sect, depth): """ Given a section and a depth level, walk back through the sections parents to see if the depth level matches a previous section. Return a reference to the right section, or raise a SyntaxError. """ while depth < sect.depth:...
python
def _match_depth(self, sect, depth): """ Given a section and a depth level, walk back through the sections parents to see if the depth level matches a previous section. Return a reference to the right section, or raise a SyntaxError. """ while depth < sect.depth:...
[ "def", "_match_depth", "(", "self", ",", "sect", ",", "depth", ")", ":", "while", "depth", "<", "sect", ".", "depth", ":", "if", "sect", "is", "sect", ".", "parent", ":", "# we've reached the top level already", "raise", "SyntaxError", "(", ")", "sect", "=...
Given a section and a depth level, walk back through the sections parents to see if the depth level matches a previous section. Return a reference to the right section, or raise a SyntaxError.
[ "Given", "a", "section", "and", "a", "depth", "level", "walk", "back", "through", "the", "sections", "parents", "to", "see", "if", "the", "depth", "level", "matches", "a", "previous", "section", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1715-L1731
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._handle_error
def _handle_error(self, text, ErrorClass, infile, cur_index): """ Handle an error according to the error settings. Either raise the error or store it. The error will have occured at ``cur_index`` """ line = infile[cur_index] cur_index += 1 message = text ...
python
def _handle_error(self, text, ErrorClass, infile, cur_index): """ Handle an error according to the error settings. Either raise the error or store it. The error will have occured at ``cur_index`` """ line = infile[cur_index] cur_index += 1 message = text ...
[ "def", "_handle_error", "(", "self", ",", "text", ",", "ErrorClass", ",", "infile", ",", "cur_index", ")", ":", "line", "=", "infile", "[", "cur_index", "]", "cur_index", "+=", "1", "message", "=", "text", "%", "cur_index", "error", "=", "ErrorClass", "(...
Handle an error according to the error settings. Either raise the error or store it. The error will have occured at ``cur_index``
[ "Handle", "an", "error", "according", "to", "the", "error", "settings", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1734-L1750
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._unquote
def _unquote(self, value): """Return an unquoted version of a value""" if not value: # should only happen during parsing of lists raise SyntaxError if (value[0] == value[-1]) and (value[0] in ('"', "'")): value = value[1:-1] return value
python
def _unquote(self, value): """Return an unquoted version of a value""" if not value: # should only happen during parsing of lists raise SyntaxError if (value[0] == value[-1]) and (value[0] in ('"', "'")): value = value[1:-1] return value
[ "def", "_unquote", "(", "self", ",", "value", ")", ":", "if", "not", "value", ":", "# should only happen during parsing of lists", "raise", "SyntaxError", "if", "(", "value", "[", "0", "]", "==", "value", "[", "-", "1", "]", ")", "and", "(", "value", "["...
Return an unquoted version of a value
[ "Return", "an", "unquoted", "version", "of", "a", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1753-L1760
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._quote
def _quote(self, value, multiline=True): """ Return a safely quoted version of a value. Raise a ConfigObjError if the value cannot be safely quoted. If multiline is ``True`` (default) then use triple quotes if necessary. * Don't quote values that don't need it. ...
python
def _quote(self, value, multiline=True): """ Return a safely quoted version of a value. Raise a ConfigObjError if the value cannot be safely quoted. If multiline is ``True`` (default) then use triple quotes if necessary. * Don't quote values that don't need it. ...
[ "def", "_quote", "(", "self", ",", "value", ",", "multiline", "=", "True", ")", ":", "if", "multiline", "and", "self", ".", "write_empty_values", "and", "value", "==", "''", ":", "# Only if multiline is set, so that it is used for values not", "# keys, and not values ...
Return a safely quoted version of a value. Raise a ConfigObjError if the value cannot be safely quoted. If multiline is ``True`` (default) then use triple quotes if necessary. * Don't quote values that don't need it. * Recursively quote members of a list and return a comma join...
[ "Return", "a", "safely", "quoted", "version", "of", "a", "value", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1763-L1829
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._handle_value
def _handle_value(self, value): """ Given a value string, unquote, remove comment, handle lists. (including empty and single member lists) """ if self._inspec: # Parsing a configspec so don't handle comments return (value, '') # do we look for list...
python
def _handle_value(self, value): """ Given a value string, unquote, remove comment, handle lists. (including empty and single member lists) """ if self._inspec: # Parsing a configspec so don't handle comments return (value, '') # do we look for list...
[ "def", "_handle_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_inspec", ":", "# Parsing a configspec so don't handle comments", "return", "(", "value", ",", "''", ")", "# do we look for lists in values ?", "if", "not", "self", ".", "list_values", ...
Given a value string, unquote, remove comment, handle lists. (including empty and single member lists)
[ "Given", "a", "value", "string", "unquote", "remove", "comment", "handle", "lists", ".", "(", "including", "empty", "and", "single", "member", "lists", ")" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1852-L1898
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._multiline
def _multiline(self, value, infile, cur_index, maxline): """Extract the value, where we are in a multiline situation.""" quot = value[:3] newvalue = value[3:] single_line = self._triple_quote[quot][0] multi_line = self._triple_quote[quot][1] mat = single_line.match(value)...
python
def _multiline(self, value, infile, cur_index, maxline): """Extract the value, where we are in a multiline situation.""" quot = value[:3] newvalue = value[3:] single_line = self._triple_quote[quot][0] multi_line = self._triple_quote[quot][1] mat = single_line.match(value)...
[ "def", "_multiline", "(", "self", ",", "value", ",", "infile", ",", "cur_index", ",", "maxline", ")", ":", "quot", "=", "value", "[", ":", "3", "]", "newvalue", "=", "value", "[", "3", ":", "]", "single_line", "=", "self", ".", "_triple_quote", "[", ...
Extract the value, where we are in a multiline situation.
[ "Extract", "the", "value", "where", "we", "are", "in", "a", "multiline", "situation", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1901-L1933
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._handle_configspec
def _handle_configspec(self, configspec): """Parse the configspec.""" # FIXME: Should we check that the configspec was created with the # correct settings ? (i.e. ``list_values=False``) if not isinstance(configspec, ConfigObj): try: configspec = ConfigO...
python
def _handle_configspec(self, configspec): """Parse the configspec.""" # FIXME: Should we check that the configspec was created with the # correct settings ? (i.e. ``list_values=False``) if not isinstance(configspec, ConfigObj): try: configspec = ConfigO...
[ "def", "_handle_configspec", "(", "self", ",", "configspec", ")", ":", "# FIXME: Should we check that the configspec was created with the", "# correct settings ? (i.e. ``list_values=False``)", "if", "not", "isinstance", "(", "configspec", ",", "ConfigObj", ")", ":", "try...
Parse the configspec.
[ "Parse", "the", "configspec", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1936-L1953
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._set_configspec
def _set_configspec(self, section, copy): """ Called by validate. Handles setting the configspec on subsections including sections to be validated by __many__ """ configspec = section.configspec many = configspec.get('__many__') if isinstance(many, dict): ...
python
def _set_configspec(self, section, copy): """ Called by validate. Handles setting the configspec on subsections including sections to be validated by __many__ """ configspec = section.configspec many = configspec.get('__many__') if isinstance(many, dict): ...
[ "def", "_set_configspec", "(", "self", ",", "section", ",", "copy", ")", ":", "configspec", "=", "section", ".", "configspec", "many", "=", "configspec", ".", "get", "(", "'__many__'", ")", "if", "isinstance", "(", "many", ",", "dict", ")", ":", "for", ...
Called by validate. Handles setting the configspec on subsections including sections to be validated by __many__
[ "Called", "by", "validate", ".", "Handles", "setting", "the", "configspec", "on", "subsections", "including", "sections", "to", "be", "validated", "by", "__many__" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1957-L1982
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._write_line
def _write_line(self, indent_string, entry, this_entry, comment): """Write an individual line, for the write method""" # NOTE: the calls to self._quote here handles non-StringType values. if not self.unrepr: val = self._decode_element(self._quote(this_entry)) else: ...
python
def _write_line(self, indent_string, entry, this_entry, comment): """Write an individual line, for the write method""" # NOTE: the calls to self._quote here handles non-StringType values. if not self.unrepr: val = self._decode_element(self._quote(this_entry)) else: ...
[ "def", "_write_line", "(", "self", ",", "indent_string", ",", "entry", ",", "this_entry", ",", "comment", ")", ":", "# NOTE: the calls to self._quote here handles non-StringType values.", "if", "not", "self", ".", "unrepr", ":", "val", "=", "self", ".", "_decode_ele...
Write an individual line, for the write method
[ "Write", "an", "individual", "line", "for", "the", "write", "method" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1985-L1996
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._write_marker
def _write_marker(self, indent_string, depth, entry, comment): """Write a section marker line""" return '%s%s%s%s%s' % (indent_string, self._a_to_u('[' * depth), self._quote(self._decode_element(entry), multiline=False), ...
python
def _write_marker(self, indent_string, depth, entry, comment): """Write a section marker line""" return '%s%s%s%s%s' % (indent_string, self._a_to_u('[' * depth), self._quote(self._decode_element(entry), multiline=False), ...
[ "def", "_write_marker", "(", "self", ",", "indent_string", ",", "depth", ",", "entry", ",", "comment", ")", ":", "return", "'%s%s%s%s%s'", "%", "(", "indent_string", ",", "self", ".", "_a_to_u", "(", "'['", "*", "depth", ")", ",", "self", ".", "_quote", ...
Write a section marker line
[ "Write", "a", "section", "marker", "line" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L1999-L2005
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj._handle_comment
def _handle_comment(self, comment): """Deal with a comment.""" if not comment: return '' start = self.indent_type if not comment.startswith('#'): start += self._a_to_u(' # ') return (start + comment)
python
def _handle_comment(self, comment): """Deal with a comment.""" if not comment: return '' start = self.indent_type if not comment.startswith('#'): start += self._a_to_u(' # ') return (start + comment)
[ "def", "_handle_comment", "(", "self", ",", "comment", ")", ":", "if", "not", "comment", ":", "return", "''", "start", "=", "self", ".", "indent_type", "if", "not", "comment", ".", "startswith", "(", "'#'", ")", ":", "start", "+=", "self", ".", "_a_to_...
Deal with a comment.
[ "Deal", "with", "a", "comment", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2008-L2015
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj.write
def write(self, outfile=None, section=None): """ Write the current ConfigObj as a file tekNico: FIXME: use StringIO instead of real files >>> filename = a.filename # doctest: +SKIP >>> a.filename = 'test.ini' # doctest: +SKIP >>> a.write() # doctest: +SKIP ...
python
def write(self, outfile=None, section=None): """ Write the current ConfigObj as a file tekNico: FIXME: use StringIO instead of real files >>> filename = a.filename # doctest: +SKIP >>> a.filename = 'test.ini' # doctest: +SKIP >>> a.write() # doctest: +SKIP ...
[ "def", "write", "(", "self", ",", "outfile", "=", "None", ",", "section", "=", "None", ")", ":", "if", "self", ".", "indent_type", "is", "None", ":", "# this can be true if initialised from a dictionary", "self", ".", "indent_type", "=", "DEFAULT_INDENT_TYPE", "...
Write the current ConfigObj as a file tekNico: FIXME: use StringIO instead of real files >>> filename = a.filename # doctest: +SKIP >>> a.filename = 'test.ini' # doctest: +SKIP >>> a.write() # doctest: +SKIP >>> a.filename = filename # doctest: +SKIP >>> a == Con...
[ "Write", "the", "current", "ConfigObj", "as", "a", "file" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2020-L2128
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj.validate
def validate(self, validator, preserve_errors=False, copy=False, section=None): """ Test the ConfigObj against a configspec. It uses the ``validator`` object from *validate.py*. To run ``validate`` on the current ConfigObj, call: :: test = config.validate(...
python
def validate(self, validator, preserve_errors=False, copy=False, section=None): """ Test the ConfigObj against a configspec. It uses the ``validator`` object from *validate.py*. To run ``validate`` on the current ConfigObj, call: :: test = config.validate(...
[ "def", "validate", "(", "self", ",", "validator", ",", "preserve_errors", "=", "False", ",", "copy", "=", "False", ",", "section", "=", "None", ")", ":", "if", "section", "is", "None", ":", "if", "self", ".", "configspec", "is", "None", ":", "raise", ...
Test the ConfigObj against a configspec. It uses the ``validator`` object from *validate.py*. To run ``validate`` on the current ConfigObj, call: :: test = config.validate(validator) (Normally having previously passed in the configspec when the ConfigObj was created - you...
[ "Test", "the", "ConfigObj", "against", "a", "configspec", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2130-L2334
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj.reset
def reset(self): """Clear ConfigObj instance and restore to 'freshly created' state.""" self.clear() self._initialise() # FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload) # requires an empty dictionary self.configspec = None # ...
python
def reset(self): """Clear ConfigObj instance and restore to 'freshly created' state.""" self.clear() self._initialise() # FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload) # requires an empty dictionary self.configspec = None # ...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "_initialise", "(", ")", "# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)", "# requires an empty dictionary", "self", ".", "configspec", "=", "None"...
Clear ConfigObj instance and restore to 'freshly created' state.
[ "Clear", "ConfigObj", "instance", "and", "restore", "to", "freshly", "created", "state", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2337-L2345
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
ConfigObj.reload
def reload(self): """ Reload a ConfigObj from file. This method raises a ``ReloadError`` if the ConfigObj doesn't have a filename attribute pointing to a file. """ if not isinstance(self.filename, string_types): raise ReloadError() filename = self.fi...
python
def reload(self): """ Reload a ConfigObj from file. This method raises a ``ReloadError`` if the ConfigObj doesn't have a filename attribute pointing to a file. """ if not isinstance(self.filename, string_types): raise ReloadError() filename = self.fi...
[ "def", "reload", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "filename", ",", "string_types", ")", ":", "raise", "ReloadError", "(", ")", "filename", "=", "self", ".", "filename", "current_options", "=", "{", "}", "for", "entry", ...
Reload a ConfigObj from file. This method raises a ``ReloadError`` if the ConfigObj doesn't have a filename attribute pointing to a file.
[ "Reload", "a", "ConfigObj", "from", "file", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2348-L2370
train
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
SimpleVal.check
def check(self, check, member, missing=False): """A dummy check method, always returns the value unchanged.""" if missing: raise self.baseErrorClass() return member
python
def check(self, check, member, missing=False): """A dummy check method, always returns the value unchanged.""" if missing: raise self.baseErrorClass() return member
[ "def", "check", "(", "self", ",", "check", ",", "member", ",", "missing", "=", "False", ")", ":", "if", "missing", ":", "raise", "self", ".", "baseErrorClass", "(", ")", "return", "member" ]
A dummy check method, always returns the value unchanged.
[ "A", "dummy", "check", "method", "always", "returns", "the", "value", "unchanged", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2389-L2393
train
spacetelescope/stsci.tools
lib/stsci/tools/convertwaiveredfits.py
_processCommandLineArgs
def _processCommandLineArgs(): """ Get the command line arguments Parameters: NONE Returns: files list of file specifications to be converted outputFileNames list of output file specifications (one per input file) ...
python
def _processCommandLineArgs(): """ Get the command line arguments Parameters: NONE Returns: files list of file specifications to be converted outputFileNames list of output file specifications (one per input file) ...
[ "def", "_processCommandLineArgs", "(", ")", ":", "import", "getopt", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "sys", ".", "argv", "[", "1", ":", "]", ",", "\"hvmo:\"", ",", "[", "\"help\"", ",", "\"verbose\"", ",", "\"multiEx...
Get the command line arguments Parameters: NONE Returns: files list of file specifications to be converted outputFileNames list of output file specifications (one per input file) Default: a list of None value...
[ "Get", "the", "command", "line", "arguments" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L156-L246
train
spacetelescope/stsci.tools
lib/stsci/tools/convertwaiveredfits.py
_verify
def _verify(waiveredHdul): """ Verify that the input HDUList is for a waivered FITS file. Parameters: waiveredHdul HDUList object to be verified Returns: None Exceptions: ValueError Input HDUList is not for a waivered FITS file """ if len...
python
def _verify(waiveredHdul): """ Verify that the input HDUList is for a waivered FITS file. Parameters: waiveredHdul HDUList object to be verified Returns: None Exceptions: ValueError Input HDUList is not for a waivered FITS file """ if len...
[ "def", "_verify", "(", "waiveredHdul", ")", ":", "if", "len", "(", "waiveredHdul", ")", "==", "2", ":", "#", "# There must be exactly 2 HDU's", "#", "if", "waiveredHdul", "[", "0", "]", ".", "header", "[", "'NAXIS'", "]", ">", "0", ":", "#", "# The Prima...
Verify that the input HDUList is for a waivered FITS file. Parameters: waiveredHdul HDUList object to be verified Returns: None Exceptions: ValueError Input HDUList is not for a waivered FITS file
[ "Verify", "that", "the", "input", "HDUList", "is", "for", "a", "waivered", "FITS", "file", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L248-L288
train
spacetelescope/stsci.tools
lib/stsci/tools/convertwaiveredfits.py
toMultiExtensionFits
def toMultiExtensionFits(waiveredObject, multiExtensionFileName=None, forceFileOutput=False, verbose=False): """ Convert the input waivered FITS object to a multi-extension FITS HDUList object. Generate an output multi-exten...
python
def toMultiExtensionFits(waiveredObject, multiExtensionFileName=None, forceFileOutput=False, verbose=False): """ Convert the input waivered FITS object to a multi-extension FITS HDUList object. Generate an output multi-exten...
[ "def", "toMultiExtensionFits", "(", "waiveredObject", ",", "multiExtensionFileName", "=", "None", ",", "forceFileOutput", "=", "False", ",", "verbose", "=", "False", ")", ":", "if", "isinstance", "(", "waiveredObject", ",", "fits", ".", "HDUList", ")", ":", "w...
Convert the input waivered FITS object to a multi-extension FITS HDUList object. Generate an output multi-extension FITS file if requested. Parameters: waiveredObject input object representing a waivered FITS file; either a astroyp.io.fits.HDUList object, ...
[ "Convert", "the", "input", "waivered", "FITS", "object", "to", "a", "multi", "-", "extension", "FITS", "HDUList", "object", ".", "Generate", "an", "output", "multi", "-", "extension", "FITS", "file", "if", "requested", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L290-L512
train
spacetelescope/stsci.tools
lib/stsci/tools/convertwaiveredfits.py
convertwaiveredfits
def convertwaiveredfits(waiveredObject, outputFileName=None, forceFileOutput=False, convertTo='multiExtension', verbose=False): """ Convert the input waivered FITS object to various formats. The default ...
python
def convertwaiveredfits(waiveredObject, outputFileName=None, forceFileOutput=False, convertTo='multiExtension', verbose=False): """ Convert the input waivered FITS object to various formats. The default ...
[ "def", "convertwaiveredfits", "(", "waiveredObject", ",", "outputFileName", "=", "None", ",", "forceFileOutput", "=", "False", ",", "convertTo", "=", "'multiExtension'", ",", "verbose", "=", "False", ")", ":", "if", "convertTo", "==", "'multiExtension'", ":", "f...
Convert the input waivered FITS object to various formats. The default conversion format is multi-extension FITS. Generate an output file in the desired format if requested. Parameters: waiveredObject input object representing a waivered FITS file; either...
[ "Convert", "the", "input", "waivered", "FITS", "object", "to", "various", "formats", ".", "The", "default", "conversion", "format", "is", "multi", "-", "extension", "FITS", ".", "Generate", "an", "output", "file", "in", "the", "desired", "format", "if", "req...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertwaiveredfits.py#L515-L563
train
fitnr/convertdate
convertdate/persian.py
to_jd
def to_jd(year, month, day): '''Determine Julian day from Persian date''' if year >= 0: y = 474 else: y = 473 epbase = year - y epyear = 474 + (epbase % 2820) if month <= 7: m = (month - 1) * 31 else: m = (month - 1) * 30 + 6 return day + m + trunc(((ep...
python
def to_jd(year, month, day): '''Determine Julian day from Persian date''' if year >= 0: y = 474 else: y = 473 epbase = year - y epyear = 474 + (epbase % 2820) if month <= 7: m = (month - 1) * 31 else: m = (month - 1) * 30 + 6 return day + m + trunc(((ep...
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "if", "year", ">=", "0", ":", "y", "=", "474", "else", ":", "y", "=", "473", "epbase", "=", "year", "-", "y", "epyear", "=", "474", "+", "(", "epbase", "%", "2820", ")", "if", ...
Determine Julian day from Persian date
[ "Determine", "Julian", "day", "from", "Persian", "date" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/persian.py#L33-L48
train
fitnr/convertdate
convertdate/persian.py
from_jd
def from_jd(jd): '''Calculate Persian date from Julian day''' jd = trunc(jd) + 0.5 depoch = jd - to_jd(475, 1, 1) cycle = trunc(depoch / 1029983) cyear = (depoch % 1029983) if cyear == 1029982: ycycle = 2820 else: aux1 = trunc(cyear / 366) aux2 = cyear % 366 ...
python
def from_jd(jd): '''Calculate Persian date from Julian day''' jd = trunc(jd) + 0.5 depoch = jd - to_jd(475, 1, 1) cycle = trunc(depoch / 1029983) cyear = (depoch % 1029983) if cyear == 1029982: ycycle = 2820 else: aux1 = trunc(cyear / 366) aux2 = cyear % 366 ...
[ "def", "from_jd", "(", "jd", ")", ":", "jd", "=", "trunc", "(", "jd", ")", "+", "0.5", "depoch", "=", "jd", "-", "to_jd", "(", "475", ",", "1", ",", "1", ")", "cycle", "=", "trunc", "(", "depoch", "/", "1029983", ")", "cyear", "=", "(", "depo...
Calculate Persian date from Julian day
[ "Calculate", "Persian", "date", "from", "Julian", "day" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/persian.py#L51-L80
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
setup_global_logging
def setup_global_logging(): """ Initializes capture of stdout/stderr, Python warnings, and exceptions; redirecting them to the loggers for the modules from which they originated. """ global global_logging_started if not PY3K: sys.exc_clear() if global_logging_started: retu...
python
def setup_global_logging(): """ Initializes capture of stdout/stderr, Python warnings, and exceptions; redirecting them to the loggers for the modules from which they originated. """ global global_logging_started if not PY3K: sys.exc_clear() if global_logging_started: retu...
[ "def", "setup_global_logging", "(", ")", ":", "global", "global_logging_started", "if", "not", "PY3K", ":", "sys", ".", "exc_clear", "(", ")", "if", "global_logging_started", ":", "return", "orig_logger_class", "=", "logging", ".", "getLoggerClass", "(", ")", "l...
Initializes capture of stdout/stderr, Python warnings, and exceptions; redirecting them to the loggers for the modules from which they originated.
[ "Initializes", "capture", "of", "stdout", "/", "stderr", "Python", "warnings", "and", "exceptions", ";", "redirecting", "them", "to", "the", "loggers", "for", "the", "modules", "from", "which", "they", "originated", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L390-L428
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
teardown_global_logging
def teardown_global_logging(): """Disable global logging of stdio, warnings, and exceptions.""" global global_logging_started if not global_logging_started: return stdout_logger = logging.getLogger(__name__ + '.stdout') stderr_logger = logging.getLogger(__name__ + '.stderr') if sys.std...
python
def teardown_global_logging(): """Disable global logging of stdio, warnings, and exceptions.""" global global_logging_started if not global_logging_started: return stdout_logger = logging.getLogger(__name__ + '.stdout') stderr_logger = logging.getLogger(__name__ + '.stderr') if sys.std...
[ "def", "teardown_global_logging", "(", ")", ":", "global", "global_logging_started", "if", "not", "global_logging_started", ":", "return", "stdout_logger", "=", "logging", ".", "getLogger", "(", "__name__", "+", "'.stdout'", ")", "stderr_logger", "=", "logging", "."...
Disable global logging of stdio, warnings, and exceptions.
[ "Disable", "global", "logging", "of", "stdio", "warnings", "and", "exceptions", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L431-L464
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
create_logger
def create_logger(name, format='%(levelname)s: %(message)s', datefmt=None, stream=None, level=logging.INFO, filename=None, filemode='w', filelevel=None, propagate=True): """ Do basic configuration for the logging system. Similar to logging.basicConfig but the logger ``nam...
python
def create_logger(name, format='%(levelname)s: %(message)s', datefmt=None, stream=None, level=logging.INFO, filename=None, filemode='w', filelevel=None, propagate=True): """ Do basic configuration for the logging system. Similar to logging.basicConfig but the logger ``nam...
[ "def", "create_logger", "(", "name", ",", "format", "=", "'%(levelname)s: %(message)s'", ",", "datefmt", "=", "None", ",", "stream", "=", "None", ",", "level", "=", "logging", ".", "INFO", ",", "filename", "=", "None", ",", "filemode", "=", "'w'", ",", "...
Do basic configuration for the logging system. Similar to logging.basicConfig but the logger ``name`` is configurable and both a file output and a stream output can be created. Returns a logger object. The default behaviour is to create a logger called ``name`` with a null handled, and to use the "%(le...
[ "Do", "basic", "configuration", "for", "the", "logging", "system", ".", "Similar", "to", "logging", ".", "basicConfig", "but", "the", "logger", "name", "is", "configurable", "and", "both", "a", "file", "output", "and", "a", "stream", "output", "can", "be", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L469-L527
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
StreamTeeLogger.set_stream
def set_stream(self, stream): """ Set the stream that this logger is meant to replace. Usually this will be either `sys.stdout` or `sys.stderr`, but can be any object with `write()` and `flush()` methods, as supported by `logging.StreamHandler`. """ for handler ...
python
def set_stream(self, stream): """ Set the stream that this logger is meant to replace. Usually this will be either `sys.stdout` or `sys.stderr`, but can be any object with `write()` and `flush()` methods, as supported by `logging.StreamHandler`. """ for handler ...
[ "def", "set_stream", "(", "self", ",", "stream", ")", ":", "for", "handler", "in", "self", ".", "handlers", "[", ":", "]", ":", "if", "isinstance", "(", "handler", ",", "logging", ".", "StreamHandler", ")", ":", "self", ".", "handlers", ".", "remove", ...
Set the stream that this logger is meant to replace. Usually this will be either `sys.stdout` or `sys.stderr`, but can be any object with `write()` and `flush()` methods, as supported by `logging.StreamHandler`.
[ "Set", "the", "stream", "that", "this", "logger", "is", "meant", "to", "replace", ".", "Usually", "this", "will", "be", "either", "sys", ".", "stdout", "or", "sys", ".", "stderr", "but", "can", "be", "any", "object", "with", "write", "()", "and", "flus...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L206-L224
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
StreamTeeLogger.write
def write(self, message): """ Buffers each message until a newline is reached. Each complete line is then published to the logging system through ``self.log()``. """ self.__thread_local_ctx.write_count += 1 try: if self.__thread_local_ctx.write_count > 1: ...
python
def write(self, message): """ Buffers each message until a newline is reached. Each complete line is then published to the logging system through ``self.log()``. """ self.__thread_local_ctx.write_count += 1 try: if self.__thread_local_ctx.write_count > 1: ...
[ "def", "write", "(", "self", ",", "message", ")", ":", "self", ".", "__thread_local_ctx", ".", "write_count", "+=", "1", "try", ":", "if", "self", ".", "__thread_local_ctx", ".", "write_count", ">", "1", ":", "return", "# For each line in the buffer ending with ...
Buffers each message until a newline is reached. Each complete line is then published to the logging system through ``self.log()``.
[ "Buffers", "each", "message", "until", "a", "newline", "is", "reached", ".", "Each", "complete", "line", "is", "then", "published", "to", "the", "logging", "system", "through", "self", ".", "log", "()", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L226-L245
train
spacetelescope/stsci.tools
lib/stsci/tools/logutil.py
StreamTeeLogger.find_actual_caller
def find_actual_caller(self): """ Returns the full-qualified module name, full pathname, line number, and function in which `StreamTeeLogger.write()` was called. For example, if this instance is used to replace `sys.stdout`, this will return the location of any print statement. ...
python
def find_actual_caller(self): """ Returns the full-qualified module name, full pathname, line number, and function in which `StreamTeeLogger.write()` was called. For example, if this instance is used to replace `sys.stdout`, this will return the location of any print statement. ...
[ "def", "find_actual_caller", "(", "self", ")", ":", "# Gleaned from code in the logging module itself...", "try", ":", "f", "=", "sys", ".", "_getframe", "(", "1", ")", "##f = inspect.currentframe(1)", "except", "Exception", ":", "f", "=", "None", "# On some versions ...
Returns the full-qualified module name, full pathname, line number, and function in which `StreamTeeLogger.write()` was called. For example, if this instance is used to replace `sys.stdout`, this will return the location of any print statement.
[ "Returns", "the", "full", "-", "qualified", "module", "name", "full", "pathname", "line", "number", "and", "function", "in", "which", "StreamTeeLogger", ".", "write", "()", "was", "called", ".", "For", "example", "if", "this", "instance", "is", "used", "to",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/logutil.py#L274-L310
train
selik/xport
xport/__init__.py
load
def load(fp): ''' Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a XPORT document) to a Python object. ''' reader = reading.Reader(fp) keys = reader.fields columns = {k: [] for k in keys} for row in reader: for key, value in zip(keys, row): c...
python
def load(fp): ''' Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a XPORT document) to a Python object. ''' reader = reading.Reader(fp) keys = reader.fields columns = {k: [] for k in keys} for row in reader: for key, value in zip(keys, row): c...
[ "def", "load", "(", "fp", ")", ":", "reader", "=", "reading", ".", "Reader", "(", "fp", ")", "keys", "=", "reader", ".", "fields", "columns", "=", "{", "k", ":", "[", "]", "for", "k", "in", "keys", "}", "for", "row", "in", "reader", ":", "for",...
Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a XPORT document) to a Python object.
[ "Deserialize", "fp", "(", "a", ".", "read", "()", "-", "supporting", "file", "-", "like", "object", "containing", "a", "XPORT", "document", ")", "to", "a", "Python", "object", "." ]
fafd15a24ccd102fc92d0c0123b9877a0c752182
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/__init__.py#L23-L34
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_login_page
def _get_login_page(self): """Go to the login page.""" try: raw_res = yield from self._session.get(HOME_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can not connect to login page") # Get l...
python
def _get_login_page(self): """Go to the login page.""" try: raw_res = yield from self._session.get(HOME_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can not connect to login page") # Get l...
[ "def", "_get_login_page", "(", "self", ")", ":", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "HOME_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", "raise", "PyHydroQuebecError", ...
Go to the login page.
[ "Go", "to", "the", "login", "page", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L73-L89
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._post_login_page
def _post_login_page(self, login_url): """Login to HydroQuebec website.""" data = {"login": self.username, "_58_password": self.password} try: raw_res = yield from self._session.post(login_url, data=data, ...
python
def _post_login_page(self, login_url): """Login to HydroQuebec website.""" data = {"login": self.username, "_58_password": self.password} try: raw_res = yield from self._session.post(login_url, data=data, ...
[ "def", "_post_login_page", "(", "self", ",", "login_url", ")", ":", "data", "=", "{", "\"login\"", ":", "self", ".", "username", ",", "\"_58_password\"", ":", "self", ".", "password", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_sessi...
Login to HydroQuebec website.
[ "Login", "to", "HydroQuebec", "website", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L92-L107
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_p_p_id_and_contract
def _get_p_p_id_and_contract(self): """Get id of consumption profile.""" contracts = {} try: raw_res = yield from self._session.get(PROFILE_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can...
python
def _get_p_p_id_and_contract(self): """Get id of consumption profile.""" contracts = {} try: raw_res = yield from self._session.get(PROFILE_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can...
[ "def", "_get_p_p_id_and_contract", "(", "self", ")", ":", "contracts", "=", "{", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "PROFILE_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSEr...
Get id of consumption profile.
[ "Get", "id", "of", "consumption", "profile", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L110-L142
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_lonely_contract
def _get_lonely_contract(self): """Get contract number when we have only one contract.""" contracts = {} try: raw_res = yield from self._session.get(MAIN_URL, timeout=self._timeout) except OSError: raise PyHydroQu...
python
def _get_lonely_contract(self): """Get contract number when we have only one contract.""" contracts = {} try: raw_res = yield from self._session.get(MAIN_URL, timeout=self._timeout) except OSError: raise PyHydroQu...
[ "def", "_get_lonely_contract", "(", "self", ")", ":", "contracts", "=", "{", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "MAIN_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ...
Get contract number when we have only one contract.
[ "Get", "contract", "number", "when", "we", "have", "only", "one", "contract", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L145-L166
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_balances
def _get_balances(self): """Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that. """ balances = [] try: raw_res = yield fro...
python
def _get_balances(self): """Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that. """ balances = [] try: raw_res = yield fro...
[ "def", "_get_balances", "(", "self", ")", ":", "balances", "=", "[", "]", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "MAIN_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", ...
Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that.
[ "Get", "all", "balances", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L169-L199
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._load_contract_page
def _load_contract_page(self, contract_url): """Load the profile page of a specific contract when we have multiple contracts.""" try: yield from self._session.get(contract_url, timeout=self._timeout) except OSError: raise PyHydroQu...
python
def _load_contract_page(self, contract_url): """Load the profile page of a specific contract when we have multiple contracts.""" try: yield from self._session.get(contract_url, timeout=self._timeout) except OSError: raise PyHydroQu...
[ "def", "_load_contract_page", "(", "self", ",", "contract_url", ")", ":", "try", ":", "yield", "from", "self", ".", "_session", ".", "get", "(", "contract_url", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", "raise", "PyHydroQ...
Load the profile page of a specific contract when we have multiple contracts.
[ "Load", "the", "profile", "page", "of", "a", "specific", "contract", "when", "we", "have", "multiple", "contracts", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L202-L209
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_annual_data
def _get_annual_data(self, p_p_id): """Get annual data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationAnnuelles"} try: ...
python
def _get_annual_data(self, p_p_id): """Get annual data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationAnnuelles"} try: ...
[ "def", "_get_annual_data", "(", "self", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_state\"", ":", "\"normal\"", ",", "\"p_p_mode\"", ":", "\"view\"", ",", "\"p_p_resource_id\"", ":"...
Get annual data.
[ "Get", "annual", "data", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L212-L239
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_monthly_data
def _get_monthly_data(self, p_p_id): """Get monthly data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_resource_id": ("resourceObtenirDonnees" "PeriodesConsommation")} try: raw_res = yield from self....
python
def _get_monthly_data(self, p_p_id): """Get monthly data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_resource_id": ("resourceObtenirDonnees" "PeriodesConsommation")} try: raw_res = yield from self....
[ "def", "_get_monthly_data", "(", "self", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_resource_id\"", ":", "(", "\"resourceObtenirDonnees\"", "\"PeriodesConsommation\"", ")", "}", "try", ...
Get monthly data.
[ "Get", "monthly", "data", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L242-L262
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_hourly_data
def _get_hourly_data(self, day_date, p_p_id): """Get Hourly Data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationHoraires", ...
python
def _get_hourly_data(self, day_date, p_p_id): """Get Hourly Data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationHoraires", ...
[ "def", "_get_hourly_data", "(", "self", ",", "day_date", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_state\"", ":", "\"normal\"", ",", "\"p_p_mode\"", ":", "\"view\"", ",", "\"p_p_...
Get Hourly Data.
[ "Get", "Hourly", "Data", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L290-L355
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.fetch_data_detailled_energy_use
def fetch_data_detailled_energy_use(self, start_date=None, end_date=None): """Get detailled energy use from a specific contract.""" if start_date is None: start_date = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1) if end_date is None: end_date = datetime...
python
def fetch_data_detailled_energy_use(self, start_date=None, end_date=None): """Get detailled energy use from a specific contract.""" if start_date is None: start_date = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1) if end_date is None: end_date = datetime...
[ "def", "fetch_data_detailled_energy_use", "(", "self", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ")", ":", "if", "start_date", "is", "None", ":", "start_date", "=", "datetime", ".", "datetime", ".", "now", "(", "HQ_TIMEZONE", ")", "-", ...
Get detailled energy use from a specific contract.
[ "Get", "detailled", "energy", "use", "from", "a", "specific", "contract", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L358-L392
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.fetch_data
def fetch_data(self): """Get the latest data from HydroQuebec.""" # Get http session yield from self._get_httpsession() # Get login page login_url = yield from self._get_login_page() # Post login page yield from self._post_login_page(login_url) # Get p_p_i...
python
def fetch_data(self): """Get the latest data from HydroQuebec.""" # Get http session yield from self._get_httpsession() # Get login page login_url = yield from self._get_login_page() # Post login page yield from self._post_login_page(login_url) # Get p_p_i...
[ "def", "fetch_data", "(", "self", ")", ":", "# Get http session", "yield", "from", "self", ".", "_get_httpsession", "(", ")", "# Get login page", "login_url", "=", "yield", "from", "self", ".", "_get_login_page", "(", ")", "# Post login page", "yield", "from", "...
Get the latest data from HydroQuebec.
[ "Get", "the", "latest", "data", "from", "HydroQuebec", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L395-L468
train
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.get_data
def get_data(self, contract=None): """Return collected data.""" if contract is None: return self._data if contract in self._data.keys(): return {contract: self._data[contract]} raise PyHydroQuebecError("Contract {} not found".format(contract))
python
def get_data(self, contract=None): """Return collected data.""" if contract is None: return self._data if contract in self._data.keys(): return {contract: self._data[contract]} raise PyHydroQuebecError("Contract {} not found".format(contract))
[ "def", "get_data", "(", "self", ",", "contract", "=", "None", ")", ":", "if", "contract", "is", "None", ":", "return", "self", ".", "_data", "if", "contract", "in", "self", ".", "_data", ".", "keys", "(", ")", ":", "return", "{", "contract", ":", "...
Return collected data.
[ "Return", "collected", "data", "." ]
4ea1374a63944413889c147d91961eda0605d4fd
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L470-L476
train
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.ping
def ping(self): """ Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return: """ from datetime import datetime nextRun = datetime.utcnow().timestamp() + self.cfg.getPingInterval() self.sendHe...
python
def ping(self): """ Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return: """ from datetime import datetime nextRun = datetime.utcnow().timestamp() + self.cfg.getPingInterval() self.sendHe...
[ "def", "ping", "(", "self", ")", ":", "from", "datetime", "import", "datetime", "nextRun", "=", "datetime", ".", "utcnow", "(", ")", ".", "timestamp", "(", ")", "+", "self", ".", "cfg", ".", "getPingInterval", "(", ")", "self", ".", "sendHeartbeat", "(...
Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return:
[ "Posts", "the", "current", "state", "of", "each", "device", "to", "the", "server", "and", "schedules", "the", "next", "call", "in", "n", "seconds", ".", ":", "param", "serverURL", ":", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L16-L25
train
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.sendHeartbeat
def sendHeartbeat(self): """ Posts the current state to the server. :param serverURL: the URL to ping. :return: """ for name, md in self.cfg.recordingDevices.items(): try: data = marshal(md, recordingDeviceFields) data['serviceU...
python
def sendHeartbeat(self): """ Posts the current state to the server. :param serverURL: the URL to ping. :return: """ for name, md in self.cfg.recordingDevices.items(): try: data = marshal(md, recordingDeviceFields) data['serviceU...
[ "def", "sendHeartbeat", "(", "self", ")", ":", "for", "name", ",", "md", "in", "self", ".", "cfg", ".", "recordingDevices", ".", "items", "(", ")", ":", "try", ":", "data", "=", "marshal", "(", "md", ",", "recordingDeviceFields", ")", "data", "[", "'...
Posts the current state to the server. :param serverURL: the URL to ping. :return:
[ "Posts", "the", "current", "state", "to", "the", "server", ".", ":", "param", "serverURL", ":", "the", "URL", "to", "ping", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L27-L46
train
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.scheduleNextHeartbeat
def scheduleNextHeartbeat(self, nextRun): """ Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return: """ import threading from datetime import datetime tilNextTime = max(nextRun - datetime.utcn...
python
def scheduleNextHeartbeat(self, nextRun): """ Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return: """ import threading from datetime import datetime tilNextTime = max(nextRun - datetime.utcn...
[ "def", "scheduleNextHeartbeat", "(", "self", ",", "nextRun", ")", ":", "import", "threading", "from", "datetime", "import", "datetime", "tilNextTime", "=", "max", "(", "nextRun", "-", "datetime", ".", "utcnow", "(", ")", ".", "timestamp", "(", ")", ",", "0...
Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return:
[ "Schedules", "the", "next", "ping", ".", ":", "param", "nextRun", ":", "when", "we", "should", "run", "next", ".", ":", "param", "serverURL", ":", "the", "URL", "to", "ping", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L48-L59
train
Xion/callee
callee/collections.py
CollectionMatcher._validate_argument
def _validate_argument(self, arg): """Validate a type or matcher argument to the constructor.""" if arg is None: return arg if isinstance(arg, type): return InstanceOf(arg) if not isinstance(arg, BaseMatcher): raise TypeError( "argumen...
python
def _validate_argument(self, arg): """Validate a type or matcher argument to the constructor.""" if arg is None: return arg if isinstance(arg, type): return InstanceOf(arg) if not isinstance(arg, BaseMatcher): raise TypeError( "argumen...
[ "def", "_validate_argument", "(", "self", ",", "arg", ")", ":", "if", "arg", "is", "None", ":", "return", "arg", "if", "isinstance", "(", "arg", ",", "type", ")", ":", "return", "InstanceOf", "(", "arg", ")", "if", "not", "isinstance", "(", "arg", ",...
Validate a type or matcher argument to the constructor.
[ "Validate", "a", "type", "or", "matcher", "argument", "to", "the", "constructor", "." ]
58740f73ff9a76f5fe0075bf18d7345a0f9d961c
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/collections.py#L38-L50
train
Xion/callee
callee/collections.py
MappingMatcher._initialize
def _initialize(self, *args, **kwargs): """Initiaize the mapping matcher with constructor arguments.""" self.items = None self.keys = None self.values = None if args: if len(args) != 2: raise TypeError("expected exactly two positional arguments, " ...
python
def _initialize(self, *args, **kwargs): """Initiaize the mapping matcher with constructor arguments.""" self.items = None self.keys = None self.values = None if args: if len(args) != 2: raise TypeError("expected exactly two positional arguments, " ...
[ "def", "_initialize", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "items", "=", "None", "self", ".", "keys", "=", "None", "self", ".", "values", "=", "None", "if", "args", ":", "if", "len", "(", "args", ")", "...
Initiaize the mapping matcher with constructor arguments.
[ "Initiaize", "the", "mapping", "matcher", "with", "constructor", "arguments", "." ]
58740f73ff9a76f5fe0075bf18d7345a0f9d961c
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/collections.py#L163-L208
train
Xion/callee
tasks.py
docs
def docs(ctx, output='html', rebuild=False, show=True, verbose=True): """Build the docs and show them in default web browser.""" sphinx_build = ctx.run( 'sphinx-build -b {output} {all} {verbose} docs docs/_build'.format( output=output, all='-a -E' if rebuild else '', ...
python
def docs(ctx, output='html', rebuild=False, show=True, verbose=True): """Build the docs and show them in default web browser.""" sphinx_build = ctx.run( 'sphinx-build -b {output} {all} {verbose} docs docs/_build'.format( output=output, all='-a -E' if rebuild else '', ...
[ "def", "docs", "(", "ctx", ",", "output", "=", "'html'", ",", "rebuild", "=", "False", ",", "show", "=", "True", ",", "verbose", "=", "True", ")", ":", "sphinx_build", "=", "ctx", ".", "run", "(", "'sphinx-build -b {output} {all} {verbose} docs docs/_build'", ...
Build the docs and show them in default web browser.
[ "Build", "the", "docs", "and", "show", "them", "in", "default", "web", "browser", "." ]
58740f73ff9a76f5fe0075bf18d7345a0f9d961c
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L47-L61
train
Xion/callee
tasks.py
upload
def upload(ctx, yes=False): """Upload the package to PyPI.""" import callee version = callee.__version__ # check the packages version # TODO: add a 'release' to automatically bless a version as release one if version.endswith('-dev'): fatal("Can't upload a development version (%s) to Py...
python
def upload(ctx, yes=False): """Upload the package to PyPI.""" import callee version = callee.__version__ # check the packages version # TODO: add a 'release' to automatically bless a version as release one if version.endswith('-dev'): fatal("Can't upload a development version (%s) to Py...
[ "def", "upload", "(", "ctx", ",", "yes", "=", "False", ")", ":", "import", "callee", "version", "=", "callee", ".", "__version__", "# check the packages version", "# TODO: add a 'release' to automatically bless a version as release one", "if", "version", ".", "endswith", ...
Upload the package to PyPI.
[ "Upload", "the", "package", "to", "PyPI", "." ]
58740f73ff9a76f5fe0075bf18d7345a0f9d961c
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L69-L101
train
Xion/callee
tasks.py
fatal
def fatal(*args, **kwargs): """Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation """ # determine the exitcode to return to the o...
python
def fatal(*args, **kwargs): """Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation """ # determine the exitcode to return to the o...
[ "def", "fatal", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# determine the exitcode to return to the operating system", "exitcode", "=", "None", "if", "'exitcode'", "in", "kwargs", ":", "exitcode", "=", "kwargs", ".", "pop", "(", "'exitcode'", ")", ...
Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation
[ "Log", "an", "error", "message", "and", "exit", "." ]
58740f73ff9a76f5fe0075bf18d7345a0f9d961c
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L106-L128
train
scivision/msise00
archive/f2py.py
rungtd1d
def rungtd1d(time: Union[datetime, str, np.ndarray], altkm: np.ndarray, glat: float, glon: float) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todt64(time) # %% get solar parameters for date f107Ap = gi.getApF107(time, smooth...
python
def rungtd1d(time: Union[datetime, str, np.ndarray], altkm: np.ndarray, glat: float, glon: float) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todt64(time) # %% get solar parameters for date f107Ap = gi.getApF107(time, smooth...
[ "def", "rungtd1d", "(", "time", ":", "Union", "[", "datetime", ",", "str", ",", "np", ".", "ndarray", "]", ",", "altkm", ":", "np", ".", "ndarray", ",", "glat", ":", "float", ",", "glon", ":", "float", ")", "->", "xarray", ".", "Dataset", ":", "t...
This is the "atomic" function looped by other functions
[ "This", "is", "the", "atomic", "function", "looped", "by", "other", "functions" ]
13a283ec02679ab74672f284ba68a7a8f896dc6f
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/archive/f2py.py#L3-L51
train
WoLpH/mailjet
mailjet/contrib/django_mailjet/views.py
SubscriptionView.form_valid
def form_valid(self, form): """ Call `form.save()` and super itself. """ form.save() return super(SubscriptionView, self).form_valid(form)
python
def form_valid(self, form): """ Call `form.save()` and super itself. """ form.save() return super(SubscriptionView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "form", ".", "save", "(", ")", "return", "super", "(", "SubscriptionView", ",", "self", ")", ".", "form_valid", "(", "form", ")" ]
Call `form.save()` and super itself.
[ "Call", "form", ".", "save", "()", "and", "super", "itself", "." ]
f7f5102bf52be6a4a9c62afe474387481c806e27
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/views.py#L13-L16
train