repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
cbrand/vpnchooser
src/vpnchooser/resources/vpn.py
VpnListResource.post
def post(self) -> Vpn: """ Creates the vpn with the given data. """ vpn = Vpn() session.add(vpn) self.update(vpn) session.flush() session.commit() return vpn, 201, { 'Location': url_for('vpn', vpn_id=vpn.id) }
python
def post(self) -> Vpn: """ Creates the vpn with the given data. """ vpn = Vpn() session.add(vpn) self.update(vpn) session.flush() session.commit() return vpn, 201, { 'Location': url_for('vpn', vpn_id=vpn.id) }
[ "def", "post", "(", "self", ")", "->", "Vpn", ":", "vpn", "=", "Vpn", "(", ")", "session", ".", "add", "(", "vpn", ")", "self", ".", "update", "(", "vpn", ")", "session", ".", "flush", "(", ")", "session", ".", "commit", "(", ")", "return", "vp...
Creates the vpn with the given data.
[ "Creates", "the", "vpn", "with", "the", "given", "data", "." ]
train
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/vpn.py#L121-L132
tBaxter/tango-comments
build/lib/tango_comments/templatetags/comments.py
BaseCommentNode.handle_token
def handle_token(cls, parser, token): """Class method to parse get_comment_list/count/form and return a Node.""" tokens = token.contents.split() if tokens[1] != 'for': raise template.TemplateSyntaxError( "Second argument in %r tag must be 'for'" % tokens[0] ...
python
def handle_token(cls, parser, token): """Class method to parse get_comment_list/count/form and return a Node.""" tokens = token.contents.split() if tokens[1] != 'for': raise template.TemplateSyntaxError( "Second argument in %r tag must be 'for'" % tokens[0] ...
[ "def", "handle_token", "(", "cls", ",", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "tokens", "[", "1", "]", "!=", "'for'", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "\"Secon...
Class method to parse get_comment_list/count/form and return a Node.
[ "Class", "method", "to", "parse", "get_comment_list", "/", "count", "/", "form", "and", "return", "a", "Node", "." ]
train
https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/templatetags/comments.py#L20-L48
tBaxter/tango-comments
build/lib/tango_comments/templatetags/comments.py
RenderCommentListNode.handle_token
def handle_token(cls, parser, token): """Class method to parse render_comment_list and return a Node.""" tokens = token.contents.split() if tokens[1] != 'for': raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0]) # {% render_comment_list ...
python
def handle_token(cls, parser, token): """Class method to parse render_comment_list and return a Node.""" tokens = token.contents.split() if tokens[1] != 'for': raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0]) # {% render_comment_list ...
[ "def", "handle_token", "(", "cls", ",", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "tokens", "[", "1", "]", "!=", "'for'", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "\"Secon...
Class method to parse render_comment_list and return a Node.
[ "Class", "method", "to", "parse", "render_comment_list", "and", "return", "a", "Node", "." ]
train
https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/templatetags/comments.py#L188-L203
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.get_current_data
def get_current_data(self): """Return the calibration data for the current IMU, if any.""" if self.current_imuid in self.calibration_data: return self.calibration_data[self.current_imuid] return {}
python
def get_current_data(self): """Return the calibration data for the current IMU, if any.""" if self.current_imuid in self.calibration_data: return self.calibration_data[self.current_imuid] return {}
[ "def", "get_current_data", "(", "self", ")", ":", "if", "self", ".", "current_imuid", "in", "self", ".", "calibration_data", ":", "return", "self", ".", "calibration_data", "[", "self", ".", "current_imuid", "]", "return", "{", "}" ]
Return the calibration data for the current IMU, if any.
[ "Return", "the", "calibration", "data", "for", "the", "current", "IMU", "if", "any", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L271-L276
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.update_battery
def update_battery(self): """Updates the battery level in the UI for the connected SK8, if any""" if self.sk8 is None: return battery = self.sk8.get_battery_level() self.lblBattery.setText('Battery: {}%'.format(battery))
python
def update_battery(self): """Updates the battery level in the UI for the connected SK8, if any""" if self.sk8 is None: return battery = self.sk8.get_battery_level() self.lblBattery.setText('Battery: {}%'.format(battery))
[ "def", "update_battery", "(", "self", ")", ":", "if", "self", ".", "sk8", "is", "None", ":", "return", "battery", "=", "self", ".", "sk8", ".", "get_battery_level", "(", ")", "self", ".", "lblBattery", ".", "setText", "(", "'Battery: {}%'", ".", "format"...
Updates the battery level in the UI for the connected SK8, if any
[ "Updates", "the", "battery", "level", "in", "the", "UI", "for", "the", "connected", "SK8", "if", "any" ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L278-L283
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.imu_changed
def imu_changed(self, val): """Handle clicks on the IMU index spinner.""" self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val) self.update_data_display(self.get_current_data())
python
def imu_changed(self, val): """Handle clicks on the IMU index spinner.""" self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val) self.update_data_display(self.get_current_data())
[ "def", "imu_changed", "(", "self", ",", "val", ")", ":", "self", ".", "current_imuid", "=", "'{}_IMU{}'", ".", "format", "(", "self", ".", "sk8", ".", "get_device_name", "(", ")", ",", "val", ")", "self", ".", "update_data_display", "(", "self", ".", "...
Handle clicks on the IMU index spinner.
[ "Handle", "clicks", "on", "the", "IMU", "index", "spinner", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L285-L288
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.accel_calibration
def accel_calibration(self): """Perform accelerometer calibration for current IMU.""" self.calibration_state = self.CAL_ACC self.acc_dialog = SK8AccDialog(self.sk8.get_imu(self.spinIMU.value()), self) if self.acc_dialog.exec_() == QDialog.Rejected: return sel...
python
def accel_calibration(self): """Perform accelerometer calibration for current IMU.""" self.calibration_state = self.CAL_ACC self.acc_dialog = SK8AccDialog(self.sk8.get_imu(self.spinIMU.value()), self) if self.acc_dialog.exec_() == QDialog.Rejected: return sel...
[ "def", "accel_calibration", "(", "self", ")", ":", "self", ".", "calibration_state", "=", "self", ".", "CAL_ACC", "self", ".", "acc_dialog", "=", "SK8AccDialog", "(", "self", ".", "sk8", ".", "get_imu", "(", "self", ".", "spinIMU", ".", "value", "(", ")"...
Perform accelerometer calibration for current IMU.
[ "Perform", "accelerometer", "calibration", "for", "current", "IMU", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L290-L297
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.gyro_calibration
def gyro_calibration(self): """Perform gyroscope calibration for current IMU.""" QtWidgets.QMessageBox.information(self, 'Gyro calibration', 'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\'t move the the IMU for a few seconds') self.calibration_state = self.CAL_GY...
python
def gyro_calibration(self): """Perform gyroscope calibration for current IMU.""" QtWidgets.QMessageBox.information(self, 'Gyro calibration', 'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\'t move the the IMU for a few seconds') self.calibration_state = self.CAL_GY...
[ "def", "gyro_calibration", "(", "self", ")", ":", "QtWidgets", ".", "QMessageBox", ".", "information", "(", "self", ",", "'Gyro calibration'", ",", "'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\\'t move the the IMU for a few seconds'", ")", "self...
Perform gyroscope calibration for current IMU.
[ "Perform", "gyroscope", "calibration", "for", "current", "IMU", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L299-L307
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.mag_calibration
def mag_calibration(self): """Perform magnetometer calibration for current IMU.""" self.calibration_state = self.CAL_MAG self.mag_dialog = SK8MagDialog(self.sk8.get_imu(self.spinIMU.value()), self) if self.mag_dialog.exec_() == QDialog.Rejected: return self.calculate...
python
def mag_calibration(self): """Perform magnetometer calibration for current IMU.""" self.calibration_state = self.CAL_MAG self.mag_dialog = SK8MagDialog(self.sk8.get_imu(self.spinIMU.value()), self) if self.mag_dialog.exec_() == QDialog.Rejected: return self.calculate...
[ "def", "mag_calibration", "(", "self", ")", ":", "self", ".", "calibration_state", "=", "self", ".", "CAL_MAG", "self", ".", "mag_dialog", "=", "SK8MagDialog", "(", "self", ".", "sk8", ".", "get_imu", "(", "self", ".", "spinIMU", ".", "value", "(", ")", ...
Perform magnetometer calibration for current IMU.
[ "Perform", "magnetometer", "calibration", "for", "current", "IMU", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L309-L316
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.update_data
def update_data(self): """Updates the displayed data in the GUI for the current IMU, applying current calibration if it is available. """ if self.sk8 is not None: imu = self.spinIMU.value() data = self.sk8.get_imu(imu) if self.current_imuid in self.calibration...
python
def update_data(self): """Updates the displayed data in the GUI for the current IMU, applying current calibration if it is available. """ if self.sk8 is not None: imu = self.spinIMU.value() data = self.sk8.get_imu(imu) if self.current_imuid in self.calibration...
[ "def", "update_data", "(", "self", ")", ":", "if", "self", ".", "sk8", "is", "not", "None", ":", "imu", "=", "self", ".", "spinIMU", ".", "value", "(", ")", "data", "=", "self", ".", "sk8", ".", "get_imu", "(", "imu", ")", "if", "self", ".", "c...
Updates the displayed data in the GUI for the current IMU, applying current calibration if it is available.
[ "Updates", "the", "displayed", "data", "in", "the", "GUI", "for", "the", "current", "IMU", "applying", "current", "calibration", "if", "it", "is", "available", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L318-L355
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.calculate_gyro_calibration
def calculate_gyro_calibration(self, gyro_samples): """Performs a basic gyroscope bias calculation. Takes a list of (x, y, z) samples and averages over each axis to calculate the bias values, and stores them in the calibration data structure for the currently connected SK8""" ...
python
def calculate_gyro_calibration(self, gyro_samples): """Performs a basic gyroscope bias calculation. Takes a list of (x, y, z) samples and averages over each axis to calculate the bias values, and stores them in the calibration data structure for the currently connected SK8""" ...
[ "def", "calculate_gyro_calibration", "(", "self", ",", "gyro_samples", ")", ":", "totals", "=", "[", "0", ",", "0", ",", "0", "]", "for", "gs", "in", "gyro_samples", ":", "totals", "[", "0", "]", "+=", "gs", "[", "0", "]", "totals", "[", "1", "]", ...
Performs a basic gyroscope bias calculation. Takes a list of (x, y, z) samples and averages over each axis to calculate the bias values, and stores them in the calibration data structure for the currently connected SK8
[ "Performs", "a", "basic", "gyroscope", "bias", "calculation", "." ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L357-L380
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.calculate_acc_calibration
def calculate_acc_calibration(self, acc_samples): """Performs accelerometer calibration. Assumes acc_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values""" # assumes 2g range data = self.calibration_data[self.current_imuid] accx_po...
python
def calculate_acc_calibration(self, acc_samples): """Performs accelerometer calibration. Assumes acc_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values""" # assumes 2g range data = self.calibration_data[self.current_imuid] accx_po...
[ "def", "calculate_acc_calibration", "(", "self", ",", "acc_samples", ")", ":", "# assumes 2g range", "data", "=", "self", ".", "calibration_data", "[", "self", ".", "current_imuid", "]", "accx_pos", "=", "sum", "(", "[", "x", "[", "0", "]", "for", "x", "in...
Performs accelerometer calibration. Assumes acc_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values
[ "Performs", "accelerometer", "calibration", ".", "Assumes", "acc_samples", "contains", "samples", "in", "order", "[", "+", "x", "-", "x", "+", "y", "-", "y", "+", "z", "-", "z", "]", ".", "Calculates", "per", "-", "axis", "scale", "/", "offset", "value...
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L382-L406
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.calculate_mag_calibration
def calculate_mag_calibration(self, mag_samples): """Performs magnetometer calibration. Assumes mag_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values""" max_vals = [mag_samples[0][0], mag_samples[2][1], mag_samples[3][2]] min_vals = [mag...
python
def calculate_mag_calibration(self, mag_samples): """Performs magnetometer calibration. Assumes mag_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values""" max_vals = [mag_samples[0][0], mag_samples[2][1], mag_samples[3][2]] min_vals = [mag...
[ "def", "calculate_mag_calibration", "(", "self", ",", "mag_samples", ")", ":", "max_vals", "=", "[", "mag_samples", "[", "0", "]", "[", "0", "]", ",", "mag_samples", "[", "2", "]", "[", "1", "]", ",", "mag_samples", "[", "3", "]", "[", "2", "]", "]...
Performs magnetometer calibration. Assumes mag_samples contains samples in order [+x, -x, +y, -y, +z, -z]. Calculates per-axis scale/offset values
[ "Performs", "magnetometer", "calibration", ".", "Assumes", "mag_samples", "contains", "samples", "in", "order", "[", "+", "x", "-", "x", "+", "y", "-", "y", "+", "z", "-", "z", "]", ".", "Calculates", "per", "-", "axis", "scale", "/", "offset", "values...
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L408-L434
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.device_selected
def device_selected(self, index): """Handler for selecting a device from the list in the UI""" device = self.devicelist_model.itemFromIndex(index) print(device.device.addr) self.btnConnect.setEnabled(True)
python
def device_selected(self, index): """Handler for selecting a device from the list in the UI""" device = self.devicelist_model.itemFromIndex(index) print(device.device.addr) self.btnConnect.setEnabled(True)
[ "def", "device_selected", "(", "self", ",", "index", ")", ":", "device", "=", "self", ".", "devicelist_model", ".", "itemFromIndex", "(", "index", ")", "print", "(", "device", ".", "device", ".", "addr", ")", "self", ".", "btnConnect", ".", "setEnabled", ...
Handler for selecting a device from the list in the UI
[ "Handler", "for", "selecting", "a", "device", "from", "the", "list", "in", "the", "UI" ]
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L475-L479
andrewramsay/sk8-drivers
pysk8/calibration/sk8_calibration_gui.py
SK8Calibration.update_data_display
def update_data_display(self, data): """Triggered when the selected device/IMU is changed. Updates the background colours of the text widgets in the UI to indicate which sensors have calibration data available (green) and which do not (red)""" acc_cal = self.ACC_TIMESTAMP in data ...
python
def update_data_display(self, data): """Triggered when the selected device/IMU is changed. Updates the background colours of the text widgets in the UI to indicate which sensors have calibration data available (green) and which do not (red)""" acc_cal = self.ACC_TIMESTAMP in data ...
[ "def", "update_data_display", "(", "self", ",", "data", ")", ":", "acc_cal", "=", "self", ".", "ACC_TIMESTAMP", "in", "data", "mag_cal", "=", "self", ".", "MAG_TIMESTAMP", "in", "data", "gyro_cal", "=", "self", ".", "GYRO_TIMESTAMP", "in", "data", "uncal", ...
Triggered when the selected device/IMU is changed. Updates the background colours of the text widgets in the UI to indicate which sensors have calibration data available (green) and which do not (red)
[ "Triggered", "when", "the", "selected", "device", "/", "IMU", "is", "changed", ".", "Updates", "the", "background", "colours", "of", "the", "text", "widgets", "in", "the", "UI", "to", "indicate", "which", "sensors", "have", "calibration", "data", "available", ...
train
https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L481-L517
alexseitsinger/page_scrapers
src/page_scrapers/wikipedia/utils.py
int_to_roman
def int_to_roman(num): """ https://stackoverflow.com/questions/42875103/integer-to-roman-number https://stackoverflow.com/questions/33486183/convert-from-numbers-to-roman-notation """ conv = ( ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ...
python
def int_to_roman(num): """ https://stackoverflow.com/questions/42875103/integer-to-roman-number https://stackoverflow.com/questions/33486183/convert-from-numbers-to-roman-notation """ conv = ( ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ...
[ "def", "int_to_roman", "(", "num", ")", ":", "conv", "=", "(", "(", "\"M\"", ",", "1000", ")", ",", "(", "\"CM\"", ",", "900", ")", ",", "(", "\"D\"", ",", "500", ")", ",", "(", "\"CD\"", ",", "400", ")", ",", "(", "\"C\"", ",", "100", ")", ...
https://stackoverflow.com/questions/42875103/integer-to-roman-number https://stackoverflow.com/questions/33486183/convert-from-numbers-to-roman-notation
[ "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "42875103", "/", "integer", "-", "to", "-", "roman", "-", "number", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "33486183", "/", "convert", "-", "from", ...
train
https://github.com/alexseitsinger/page_scrapers/blob/8892e4b5203ca68089e95f4c959744aa47f06b2c/src/page_scrapers/wikipedia/utils.py#L3-L30
alexseitsinger/page_scrapers
src/page_scrapers/wikipedia/utils.py
roman_to_int
def roman_to_int(roman): """ https://gist.github.com/kristopherjohnson/f4eca9018c5085fc736b2f29a202b8f8 """ vals = { "I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000, } total = 0 lastValue = sys.maxsize for char in li...
python
def roman_to_int(roman): """ https://gist.github.com/kristopherjohnson/f4eca9018c5085fc736b2f29a202b8f8 """ vals = { "I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000, } total = 0 lastValue = sys.maxsize for char in li...
[ "def", "roman_to_int", "(", "roman", ")", ":", "vals", "=", "{", "\"I\"", ":", "1", ",", "\"V\"", ":", "5", ",", "\"X\"", ":", "10", ",", "\"L\"", ":", "50", ",", "\"C\"", ":", "100", ",", "\"D\"", ":", "500", ",", "\"M\"", ":", "1000", ",", ...
https://gist.github.com/kristopherjohnson/f4eca9018c5085fc736b2f29a202b8f8
[ "https", ":", "//", "gist", ".", "github", ".", "com", "/", "kristopherjohnson", "/", "f4eca9018c5085fc736b2f29a202b8f8" ]
train
https://github.com/alexseitsinger/page_scrapers/blob/8892e4b5203ca68089e95f4c959744aa47f06b2c/src/page_scrapers/wikipedia/utils.py#L33-L55
xtrementl/focus
focus/plugin/modules/sites.py
SiteBlock._handle_block
def _handle_block(self, task, disable=False): """ Handles blocking domains using hosts file. `task` ``Task`` instance. `disable` Set to ``True``, to turn off blocking and restore hosts file; otherwise, ``False`` will enable blocking by up...
python
def _handle_block(self, task, disable=False): """ Handles blocking domains using hosts file. `task` ``Task`` instance. `disable` Set to ``True``, to turn off blocking and restore hosts file; otherwise, ``False`` will enable blocking by up...
[ "def", "_handle_block", "(", "self", ",", "task", ",", "disable", "=", "False", ")", ":", "backup_file", "=", "os", ".", "path", ".", "join", "(", "task", ".", "task_dir", ",", "'.hosts.bak'", ")", "self", ".", "orig_data", "=", "self", ".", "orig_data...
Handles blocking domains using hosts file. `task` ``Task`` instance. `disable` Set to ``True``, to turn off blocking and restore hosts file; otherwise, ``False`` will enable blocking by updating hosts file. Returns bo...
[ "Handles", "blocking", "domains", "using", "hosts", "file", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sites.py#L51-L137
xtrementl/focus
focus/plugin/modules/sites.py
SiteBlock.parse_option
def parse_option(self, option, block_name, *values): """ Parse domain values for option. """ _extra_subs = ('www', 'm', 'mobile') if len(values) == 0: # expect some values here.. raise ValueError for value in values: value = value.lower() ...
python
def parse_option(self, option, block_name, *values): """ Parse domain values for option. """ _extra_subs = ('www', 'm', 'mobile') if len(values) == 0: # expect some values here.. raise ValueError for value in values: value = value.lower() ...
[ "def", "parse_option", "(", "self", ",", "option", ",", "block_name", ",", "*", "values", ")", ":", "_extra_subs", "=", "(", "'www'", ",", "'m'", ",", "'mobile'", ")", "if", "len", "(", "values", ")", "==", "0", ":", "# expect some values here..", "raise...
Parse domain values for option.
[ "Parse", "domain", "values", "for", "option", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sites.py#L139-L174
tomokinakamaru/mapletree
mapletree/helpers/signing.py
Signing.sign
def sign(self, data): """ Create url-safe signed token. :param data: Data to sign :type data: object """ try: jsonstr = json.dumps(data, separators=(',', ':')) except TypeError as e: raise DataSignError(e.args[0]) else: signa...
python
def sign(self, data): """ Create url-safe signed token. :param data: Data to sign :type data: object """ try: jsonstr = json.dumps(data, separators=(',', ':')) except TypeError as e: raise DataSignError(e.args[0]) else: signa...
[ "def", "sign", "(", "self", ",", "data", ")", ":", "try", ":", "jsonstr", "=", "json", ".", "dumps", "(", "data", ",", "separators", "=", "(", "','", ",", "':'", ")", ")", "except", "TypeError", "as", "e", ":", "raise", "DataSignError", "(", "e", ...
Create url-safe signed token. :param data: Data to sign :type data: object
[ "Create", "url", "-", "safe", "signed", "token", "." ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/helpers/signing.py#L22-L36
tomokinakamaru/mapletree
mapletree/helpers/signing.py
Signing.unsign
def unsign(self, b64msg): """ Retrieves data from signed token. :param b64msg: Token to unsign :type b64msg: str """ msg = self._b64decode(b64msg) try: body, signature = msg.rsplit('.', 1) except ValueError as e: raise MalformedSigendMess...
python
def unsign(self, b64msg): """ Retrieves data from signed token. :param b64msg: Token to unsign :type b64msg: str """ msg = self._b64decode(b64msg) try: body, signature = msg.rsplit('.', 1) except ValueError as e: raise MalformedSigendMess...
[ "def", "unsign", "(", "self", ",", "b64msg", ")", ":", "msg", "=", "self", ".", "_b64decode", "(", "b64msg", ")", "try", ":", "body", ",", "signature", "=", "msg", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", "as", "e", ":", ...
Retrieves data from signed token. :param b64msg: Token to unsign :type b64msg: str
[ "Retrieves", "data", "from", "signed", "token", "." ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/helpers/signing.py#L38-L60
fred49/linshare-api
linshareapi/core.py
extract_file_name
def extract_file_name(content_dispo): """Extract file name from the input request body""" # print type(content_dispo) # print repr(content_dispo) # convertion of escape string (str type) from server # to unicode object content_dispo = content_dispo.decode('unicode-escape').strip('"') file_na...
python
def extract_file_name(content_dispo): """Extract file name from the input request body""" # print type(content_dispo) # print repr(content_dispo) # convertion of escape string (str type) from server # to unicode object content_dispo = content_dispo.decode('unicode-escape').strip('"') file_na...
[ "def", "extract_file_name", "(", "content_dispo", ")", ":", "# print type(content_dispo)", "# print repr(content_dispo)", "# convertion of escape string (str type) from server", "# to unicode object", "content_dispo", "=", "content_dispo", ".", "decode", "(", "'unicode-escape'", ")...
Extract file name from the input request body
[ "Extract", "file", "name", "from", "the", "input", "request", "body" ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L59-L72
fred49/linshare-api
linshareapi/core.py
CoreCli.list
def list(self, url): """ List ressources store into LinShare.""" url = self.get_full_url(url) self.log.debug("list url : " + url) # Building request request = urllib2.Request(url) request.add_header('Content-Type', 'application/json; charset=UTF-8') request.add_he...
python
def list(self, url): """ List ressources store into LinShare.""" url = self.get_full_url(url) self.log.debug("list url : " + url) # Building request request = urllib2.Request(url) request.add_header('Content-Type', 'application/json; charset=UTF-8') request.add_he...
[ "def", "list", "(", "self", ",", "url", ")", ":", "url", "=", "self", ".", "get_full_url", "(", "url", ")", "self", ".", "log", ".", "debug", "(", "\"list url : \"", "+", "url", ")", "# Building request", "request", "=", "urllib2", ".", "Request", "(",...
List ressources store into LinShare.
[ "List", "ressources", "store", "into", "LinShare", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L310-L323
fred49/linshare-api
linshareapi/core.py
CoreCli.update
def update(self, url, data): """ update ressources store into LinShare.""" url = self.get_full_url(url) self.log.debug("update url : " + url) # Building request post_data = json.dumps(data).encode("UTF-8") request = urllib2.Request(url, post_data) request.add_head...
python
def update(self, url, data): """ update ressources store into LinShare.""" url = self.get_full_url(url) self.log.debug("update url : " + url) # Building request post_data = json.dumps(data).encode("UTF-8") request = urllib2.Request(url, post_data) request.add_head...
[ "def", "update", "(", "self", ",", "url", ",", "data", ")", ":", "url", "=", "self", ".", "get_full_url", "(", "url", ")", "self", ".", "log", ".", "debug", "(", "\"update url : \"", "+", "url", ")", "# Building request", "post_data", "=", "json", ".",...
update ressources store into LinShare.
[ "update", "ressources", "store", "into", "LinShare", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L456-L471
fred49/linshare-api
linshareapi/core.py
CoreCli.download
def download(self, uuid, url, forced_file_name=None, progress_bar=True, chunk_size=256, directory=None, overwrite=False): """ download a file from LinShare using its rest api. This method could throw exceptions like urllib2.HTTPError.""" self.last_req_time = Non...
python
def download(self, uuid, url, forced_file_name=None, progress_bar=True, chunk_size=256, directory=None, overwrite=False): """ download a file from LinShare using its rest api. This method could throw exceptions like urllib2.HTTPError.""" self.last_req_time = Non...
[ "def", "download", "(", "self", ",", "uuid", ",", "url", ",", "forced_file_name", "=", "None", ",", "progress_bar", "=", "True", ",", "chunk_size", "=", "256", ",", "directory", "=", "None", ",", "overwrite", "=", "False", ")", ":", "self", ".", "last_...
download a file from LinShare using its rest api. This method could throw exceptions like urllib2.HTTPError.
[ "download", "a", "file", "from", "LinShare", "using", "its", "rest", "api", ".", "This", "method", "could", "throw", "exceptions", "like", "urllib2", ".", "HTTPError", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L558-L632
fred49/linshare-api
linshareapi/core.py
ResourceBuilder.add_field
def add_field(self, field, arg=None, value=None, extended=False, hidden=False, e_type=str, required=None): """Add a new field to the current ResourceBuilder. Keyword arguments: field -- field name arg -- name of the attribute name in arg object (argpar...
python
def add_field(self, field, arg=None, value=None, extended=False, hidden=False, e_type=str, required=None): """Add a new field to the current ResourceBuilder. Keyword arguments: field -- field name arg -- name of the attribute name in arg object (argpar...
[ "def", "add_field", "(", "self", ",", "field", ",", "arg", "=", "None", ",", "value", "=", "None", ",", "extended", "=", "False", ",", "hidden", "=", "False", ",", "e_type", "=", "str", ",", "required", "=", "None", ")", ":", "if", "required", "is"...
Add a new field to the current ResourceBuilder. Keyword arguments: field -- field name arg -- name of the attribute name in arg object (argparse) value -- a default for this field, used for resource creation. extended -- If set to true, the current fiel...
[ "Add", "a", "new", "field", "to", "the", "current", "ResourceBuilder", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L658-L686
laysakura/relshell
relshell/daemon_shelloperator.py
DaemonShellOperator.run
def run(self, in_batches): """Run shell operator synchronously to eat `in_batches` :param in_batches: `tuple` of batches to process """ if len(in_batches) != len(self._batcmd.batch_to_file_s): BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s) # [tod...
python
def run(self, in_batches): """Run shell operator synchronously to eat `in_batches` :param in_batches: `tuple` of batches to process """ if len(in_batches) != len(self._batcmd.batch_to_file_s): BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s) # [tod...
[ "def", "run", "(", "self", ",", "in_batches", ")", ":", "if", "len", "(", "in_batches", ")", "!=", "len", "(", "self", ".", "_batcmd", ".", "batch_to_file_s", ")", ":", "BaseShellOperator", ".", "_rm_process_input_tmpfiles", "(", "self", ".", "_batcmd", "....
Run shell operator synchronously to eat `in_batches` :param in_batches: `tuple` of batches to process
[ "Run", "shell", "operator", "synchronously", "to", "eat", "in_batches" ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/daemon_shelloperator.py#L82-L118
laysakura/relshell
relshell/daemon_shelloperator.py
DaemonShellOperator.kill
def kill(self): """Kill instantiated process :raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_ """ BaseShellOperator._close_process_input_stdin(self._batcmd.batch_to_file_s) BaseShellOpera...
python
def kill(self): """Kill instantiated process :raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_ """ BaseShellOperator._close_process_input_stdin(self._batcmd.batch_to_file_s) BaseShellOpera...
[ "def", "kill", "(", "self", ")", ":", "BaseShellOperator", ".", "_close_process_input_stdin", "(", "self", ".", "_batcmd", ".", "batch_to_file_s", ")", "BaseShellOperator", ".", "_wait_process", "(", "self", ".", "_process", ",", "self", ".", "_batcmd", ".", "...
Kill instantiated process :raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_
[ "Kill", "instantiated", "process" ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/daemon_shelloperator.py#L120-L128
simpleenergy/env-excavator
excavator/utils.py
env_int
def env_int(name, required=False, default=empty): """Pulls an environment variable out of the environment and casts it to an integer. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an ...
python
def env_int(name, required=False, default=empty): """Pulls an environment variable out of the environment and casts it to an integer. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an ...
[ "def", "env_int", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "value", "=", "get_env_value", "(", "name", ",", "required", "=", "required", ",", "default", "=", "default", ")", "if", "value", "is", "empty", ":", ...
Pulls an environment variable out of the environment and casts it to an integer. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an integer, a ``ValueError`` will be raised. :param...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "and", "casts", "it", "to", "an", "integer", ".", "If", "the", "name", "is", "not", "present", "in", "the", "environment", "and", "no", "default", "is", "specified", "then", "a", ...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L44-L69
simpleenergy/env-excavator
excavator/utils.py
env_float
def env_float(name, required=False, default=empty): """Pulls an environment variable out of the environment and casts it to an float. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an ...
python
def env_float(name, required=False, default=empty): """Pulls an environment variable out of the environment and casts it to an float. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an ...
[ "def", "env_float", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "value", "=", "get_env_value", "(", "name", ",", "required", "=", "required", ",", "default", "=", "default", ")", "if", "value", "is", "empty", ":"...
Pulls an environment variable out of the environment and casts it to an float. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. Similarly, if the environment value is not castable to an float, a ``ValueError`` will be raised. :param nam...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "and", "casts", "it", "to", "an", "float", ".", "If", "the", "name", "is", "not", "present", "in", "the", "environment", "and", "no", "default", "is", "specified", "then", "a", ...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L72-L97
simpleenergy/env-excavator
excavator/utils.py
env_bool
def env_bool(name, truthy_values=TRUE_VALUES, required=False, default=empty): """Pulls an environment variable out of the environment returning it as a boolean. The strings ``'True'`` and ``'true'`` are the default *truthy* values. If not present in the environment and no default is specified, ``None`` ...
python
def env_bool(name, truthy_values=TRUE_VALUES, required=False, default=empty): """Pulls an environment variable out of the environment returning it as a boolean. The strings ``'True'`` and ``'true'`` are the default *truthy* values. If not present in the environment and no default is specified, ``None`` ...
[ "def", "env_bool", "(", "name", ",", "truthy_values", "=", "TRUE_VALUES", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "value", "=", "get_env_value", "(", "name", ",", "required", "=", "required", ",", "default", "=", "default", ...
Pulls an environment variable out of the environment returning it as a boolean. The strings ``'True'`` and ``'true'`` are the default *truthy* values. If not present in the environment and no default is specified, ``None`` is returned. :param name: The name of the environment variable be pulled :ty...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "returning", "it", "as", "a", "boolean", ".", "The", "strings", "True", "and", "true", "are", "the", "default", "*", "truthy", "*", "values", ".", "If", "not", "present", "in", ...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L100-L125
simpleenergy/env-excavator
excavator/utils.py
env_string
def env_string(name, required=False, default=empty): """Pulls an environment variable out of the environment returning it as a string. If not present in the environment and no default is specified, an empty string is returned. :param name: The name of the environment variable be pulled :type name: ...
python
def env_string(name, required=False, default=empty): """Pulls an environment variable out of the environment returning it as a string. If not present in the environment and no default is specified, an empty string is returned. :param name: The name of the environment variable be pulled :type name: ...
[ "def", "env_string", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "value", "=", "get_env_value", "(", "name", ",", "default", "=", "default", ",", "required", "=", "required", ")", "if", "value", "is", "empty", ":...
Pulls an environment variable out of the environment returning it as a string. If not present in the environment and no default is specified, an empty string is returned. :param name: The name of the environment variable be pulled :type name: str :param required: Whether the environment variable i...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "returning", "it", "as", "a", "string", ".", "If", "not", "present", "in", "the", "environment", "and", "no", "default", "is", "specified", "an", "empty", "string", "is", "returned"...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L128-L148
simpleenergy/env-excavator
excavator/utils.py
env_list
def env_list(name, separator=',', required=False, default=empty): """Pulls an environment variable out of the environment, splitting it on a separator, and returning it as a list. Extra whitespace on the list values is stripped. List values that evaluate as falsy are removed. If not present and no defau...
python
def env_list(name, separator=',', required=False, default=empty): """Pulls an environment variable out of the environment, splitting it on a separator, and returning it as a list. Extra whitespace on the list values is stripped. List values that evaluate as falsy are removed. If not present and no defau...
[ "def", "env_list", "(", "name", ",", "separator", "=", "','", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "value", "=", "get_env_value", "(", "name", ",", "required", "=", "required", ",", "default", "=", "default", ")", "if"...
Pulls an environment variable out of the environment, splitting it on a separator, and returning it as a list. Extra whitespace on the list values is stripped. List values that evaluate as falsy are removed. If not present and no default specified, an empty list is returned. :param name: The name of th...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "splitting", "it", "on", "a", "separator", "and", "returning", "it", "as", "a", "list", ".", "Extra", "whitespace", "on", "the", "list", "values", "is", "stripped", ".", "List", "...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L151-L176
simpleenergy/env-excavator
excavator/utils.py
env_timestamp
def env_timestamp(name, required=False, default=empty): """Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be a timestamp in the form of a float. If the name is not present in the environment and no default is...
python
def env_timestamp(name, required=False, default=empty): """Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be a timestamp in the form of a float. If the name is not present in the environment and no default is...
[ "def", "env_timestamp", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "if", "required", "and", "default", "is", "not", "empty", ":", "raise", "ValueError", "(", "\"Using `default` with `required=True` is invalid\"", ")", "va...
Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be a timestamp in the form of a float. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. :para...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "and", "parses", "it", "to", "a", "datetime", ".", "datetime", "object", ".", "The", "environment", "variable", "is", "expected", "to", "be", "a", "timestamp", "in", "the", "form", ...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L179-L213
simpleenergy/env-excavator
excavator/utils.py
env_iso8601
def env_iso8601(name, required=False, default=empty): """Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be an iso8601 formatted string. If the name is not present in the environment and no default is specifie...
python
def env_iso8601(name, required=False, default=empty): """Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be an iso8601 formatted string. If the name is not present in the environment and no default is specifie...
[ "def", "env_iso8601", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ")", ":", "try", ":", "import", "iso8601", "except", "ImportError", ":", "raise", "ImportError", "(", "'Parsing iso8601 datetime strings requires the iso8601 library'", "...
Pulls an environment variable out of the environment and parses it to a ``datetime.datetime`` object. The environment variable is expected to be an iso8601 formatted string. If the name is not present in the environment and no default is specified then a ``ValueError`` will be raised. :param name:...
[ "Pulls", "an", "environment", "variable", "out", "of", "the", "environment", "and", "parses", "it", "to", "a", "datetime", ".", "datetime", "object", ".", "The", "environment", "variable", "is", "expected", "to", "be", "an", "iso8601", "formatted", "string", ...
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L216-L255
simpleenergy/env-excavator
excavator/utils.py
get
def get(name, required=False, default=empty, type=None): """Generic getter for environment variables. Handles defaults, required-ness, and what type to expect. :param name: The name of the environment variable be pulled :type name: str :param required: Whether the environment variable is required....
python
def get(name, required=False, default=empty, type=None): """Generic getter for environment variables. Handles defaults, required-ness, and what type to expect. :param name: The name of the environment variable be pulled :type name: str :param required: Whether the environment variable is required....
[ "def", "get", "(", "name", ",", "required", "=", "False", ",", "default", "=", "empty", ",", "type", "=", "None", ")", ":", "fn", "=", "{", "'int'", ":", "env_int", ",", "int", ":", "env_int", ",", "'bool'", ":", "env_bool", ",", "bool", ":", "en...
Generic getter for environment variables. Handles defaults, required-ness, and what type to expect. :param name: The name of the environment variable be pulled :type name: str :param required: Whether the environment variable is required. If ``True`` and the variable is not present, a ``KeyError``...
[ "Generic", "getter", "for", "environment", "variables", ".", "Handles", "defaults", "required", "-", "ness", "and", "what", "type", "to", "expect", "." ]
train
https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L258-L296
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader._set_es_workers
def _set_es_workers(self, **kwargs): """ Creates index worker instances for each class to index kwargs: ------- idx_only_base[bool]: True will only index the base class """ def make_es_worker(search_conn, es_index, es_doc_type, class_name): """ ...
python
def _set_es_workers(self, **kwargs): """ Creates index worker instances for each class to index kwargs: ------- idx_only_base[bool]: True will only index the base class """ def make_es_worker(search_conn, es_index, es_doc_type, class_name): """ ...
[ "def", "_set_es_workers", "(", "self", ",", "*", "*", "kwargs", ")", ":", "def", "make_es_worker", "(", "search_conn", ",", "es_index", ",", "es_doc_type", ",", "class_name", ")", ":", "\"\"\"\n Returns a new es_worker instance\n\n args:\n ...
Creates index worker instances for each class to index kwargs: ------- idx_only_base[bool]: True will only index the base class
[ "Creates", "index", "worker", "instances", "for", "each", "class", "to", "index" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L74-L123
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader._index_sub
def _index_sub(self, uri_list, num, batch_num): """ Converts a list of uris to elasticsearch json objects args: uri_list: list of uris to convert num: the ending count within the batch batch_num: the batch number """ bname = '%s-%s' % (batch_n...
python
def _index_sub(self, uri_list, num, batch_num): """ Converts a list of uris to elasticsearch json objects args: uri_list: list of uris to convert num: the ending count within the batch batch_num: the batch number """ bname = '%s-%s' % (batch_n...
[ "def", "_index_sub", "(", "self", ",", "uri_list", ",", "num", ",", "batch_num", ")", ":", "bname", "=", "'%s-%s'", "%", "(", "batch_num", ",", "num", ")", "log", ".", "debug", "(", "\"batch_num '%s' starting es_json conversion\"", ",", "bname", ")", "qry_da...
Converts a list of uris to elasticsearch json objects args: uri_list: list of uris to convert num: the ending count within the batch batch_num: the batch number
[ "Converts", "a", "list", "of", "uris", "to", "elasticsearch", "json", "objects" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L125-L168
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader.get_uri_list
def get_uri_list(self, **kwargs): """ Returns a list of Uris to index """ index_status_filter = """ optional {{ ?s dcterm:modified ?modTime }} . optional {{ ?s kds:esIndexTime ?time }} . optional {{ ?s kds:esIndexError ?error }} ...
python
def get_uri_list(self, **kwargs): """ Returns a list of Uris to index """ index_status_filter = """ optional {{ ?s dcterm:modified ?modTime }} . optional {{ ?s kds:esIndexTime ?time }} . optional {{ ?s kds:esIndexError ?error }} ...
[ "def", "get_uri_list", "(", "self", ",", "*", "*", "kwargs", ")", ":", "index_status_filter", "=", "\"\"\"\n optional {{ ?s dcterm:modified ?modTime }} .\n optional {{ ?s kds:esIndexTime ?time }} .\n optional {{ ?s kds:esIndexError ?error }}\n ...
Returns a list of Uris to index
[ "Returns", "a", "list", "of", "Uris", "to", "index" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L170-L202
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader._index_group_with_subgroup
def _index_group_with_subgroup(self, **kwargs): """ indexes all the URIs defined by the query into Elasticsearch """ log.setLevel(self.log_level) # get a list of all the uri to index uri_list = kwargs.get('uri_list', self.get_uri_list()) if not uri_list: log.info("0 ...
python
def _index_group_with_subgroup(self, **kwargs): """ indexes all the URIs defined by the query into Elasticsearch """ log.setLevel(self.log_level) # get a list of all the uri to index uri_list = kwargs.get('uri_list', self.get_uri_list()) if not uri_list: log.info("0 ...
[ "def", "_index_group_with_subgroup", "(", "self", ",", "*", "*", "kwargs", ")", ":", "log", ".", "setLevel", "(", "self", ".", "log_level", ")", "# get a list of all the uri to index", "uri_list", "=", "kwargs", ".", "get", "(", "'uri_list'", ",", "self", ".",...
indexes all the URIs defined by the query into Elasticsearch
[ "indexes", "all", "the", "URIs", "defined", "by", "the", "query", "into", "Elasticsearch" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L204-L314
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader._update_triplestore
def _update_triplestore(self, es_result, action_list, **kwargs): """ updates the triplestore with success of saves and failues of indexing Args: ----- es_result: the elasticsearch result list action_list: list of elasticsearch action items that were indexed ...
python
def _update_triplestore(self, es_result, action_list, **kwargs): """ updates the triplestore with success of saves and failues of indexing Args: ----- es_result: the elasticsearch result list action_list: list of elasticsearch action items that were indexed ...
[ "def", "_update_triplestore", "(", "self", ",", "es_result", ",", "action_list", ",", "*", "*", "kwargs", ")", ":", "idx_time", "=", "XsdDatetime", "(", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ")", "uri_keys", "=", "{", "}", "bnode_keys", "...
updates the triplestore with success of saves and failues of indexing Args: ----- es_result: the elasticsearch result list action_list: list of elasticsearch action items that were indexed
[ "updates", "the", "triplestore", "with", "success", "of", "saves", "and", "failues", "of", "indexing" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L321-L427
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader.delete_idx_status
def delete_idx_status(self, rdf_class): """ Removes all of the index status triples from the datastore Args: ----- rdf_class: The class of items to remove the status from """ sparql_template = """ DELETE {{ ?s kds:esIn...
python
def delete_idx_status(self, rdf_class): """ Removes all of the index status triples from the datastore Args: ----- rdf_class: The class of items to remove the status from """ sparql_template = """ DELETE {{ ?s kds:esIn...
[ "def", "delete_idx_status", "(", "self", ",", "rdf_class", ")", ":", "sparql_template", "=", "\"\"\"\n DELETE\n {{\n ?s kds:esIndexTime ?esTime .\n ?s kds:esIndexError ?esError .\n }}\n WHERE\n {{\n\n ...
Removes all of the index status triples from the datastore Args: ----- rdf_class: The class of items to remove the status from
[ "Removes", "all", "of", "the", "index", "status", "triples", "from", "the", "datastore" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L430-L463
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader.get_es_ids
def get_es_ids(self): """ reads all the elasticssearch ids for an index """ search = self.search.source(['uri']).sort(['uri']) es_ids = [item.meta.id for item in search.scan()] return es_ids
python
def get_es_ids(self): """ reads all the elasticssearch ids for an index """ search = self.search.source(['uri']).sort(['uri']) es_ids = [item.meta.id for item in search.scan()] return es_ids
[ "def", "get_es_ids", "(", "self", ")", ":", "search", "=", "self", ".", "search", ".", "source", "(", "[", "'uri'", "]", ")", ".", "sort", "(", "[", "'uri'", "]", ")", "es_ids", "=", "[", "item", ".", "meta", ".", "id", "for", "item", "in", "se...
reads all the elasticssearch ids for an index
[ "reads", "all", "the", "elasticssearch", "ids", "for", "an", "index" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L465-L471
KnowledgeLinks/rdfframework
rdfframework/search/esloaders.py
EsRdfBulkLoader.validate_index
def validate_index(self, rdf_class): """ Will compare the triplestore and elasticsearch index to ensure that that elasticsearch and triplestore items match. elasticsearch records that are not in the triplestore will be deleteed """ es_ids = set(self.get_es_ids()) ...
python
def validate_index(self, rdf_class): """ Will compare the triplestore and elasticsearch index to ensure that that elasticsearch and triplestore items match. elasticsearch records that are not in the triplestore will be deleteed """ es_ids = set(self.get_es_ids()) ...
[ "def", "validate_index", "(", "self", ",", "rdf_class", ")", ":", "es_ids", "=", "set", "(", "self", ".", "get_es_ids", "(", ")", ")", "tstore_ids", "=", "set", "(", "[", "item", "[", "1", "]", "for", "item", "in", "self", ".", "get_uri_list", "(", ...
Will compare the triplestore and elasticsearch index to ensure that that elasticsearch and triplestore items match. elasticsearch records that are not in the triplestore will be deleteed
[ "Will", "compare", "the", "triplestore", "and", "elasticsearch", "index", "to", "ensure", "that", "that", "elasticsearch", "and", "triplestore", "items", "match", ".", "elasticsearch", "records", "that", "are", "not", "in", "the", "triplestore", "will", "be", "d...
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L473-L487
anti1869/sunhead
src/sunhead/metrics/factory.py
Metrics._disable_prometheus_process_collector
def _disable_prometheus_process_collector(self) -> None: """ There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which its process_collector will fail. See https://github.com/prometheus/client_python/issues/80 """ logger.info("Remo...
python
def _disable_prometheus_process_collector(self) -> None: """ There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which its process_collector will fail. See https://github.com/prometheus/client_python/issues/80 """ logger.info("Remo...
[ "def", "_disable_prometheus_process_collector", "(", "self", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Removing prometheus process collector\"", ")", "try", ":", "core", ".", "REGISTRY", ".", "unregister", "(", "PROCESS_COLLECTOR", ")", "except", "KeyEr...
There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which its process_collector will fail. See https://github.com/prometheus/client_python/issues/80
[ "There", "is", "a", "bug", "in", "SDC", "Docker", "implementation", "and", "intolerable", "prometheus_client", "code", "due", "to", "which", "its", "process_collector", "will", "fail", "." ]
train
https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/metrics/factory.py#L63-L74
kcolford/txt2boil
txt2boil/__main__.py
main
def main(argv=sys.argv[1:]): """The main method.""" global ext_lang parser = argparse.ArgumentParser(description=description, epilog=epilog) parser.add_argument('files', metavar='FILES', nargs='*', help='the files to process') parser.add...
python
def main(argv=sys.argv[1:]): """The main method.""" global ext_lang parser = argparse.ArgumentParser(description=description, epilog=epilog) parser.add_argument('files', metavar='FILES', nargs='*', help='the files to process') parser.add...
[ "def", "main", "(", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "global", "ext_lang", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "description", ",", "epilog", "=", "epilog", ")", "parser", ".", "add_ar...
The main method.
[ "The", "main", "method", "." ]
train
https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/__main__.py#L38-L98
rackerlabs/silverberg
silverberg/thrift_client.py
OnDemandThriftClient.connection
def connection(self, handshake=None): """ Connects if necessary, returns existing one if it can. :param handshake: A function to be called with the client to complete the handshake. :returns: thrift connection, deferred if necessary """ if sel...
python
def connection(self, handshake=None): """ Connects if necessary, returns existing one if it can. :param handshake: A function to be called with the client to complete the handshake. :returns: thrift connection, deferred if necessary """ if sel...
[ "def", "connection", "(", "self", ",", "handshake", "=", "None", ")", ":", "if", "self", ".", "_state", "==", "_State", ".", "CONNECTED", ":", "return", "succeed", "(", "self", ".", "_current_client", ")", "elif", "self", ".", "_state", "==", "_State", ...
Connects if necessary, returns existing one if it can. :param handshake: A function to be called with the client to complete the handshake. :returns: thrift connection, deferred if necessary
[ "Connects", "if", "necessary", "returns", "existing", "one", "if", "it", "can", "." ]
train
https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/thrift_client.py#L184-L204
rackerlabs/silverberg
silverberg/thrift_client.py
OnDemandThriftClient.disconnect
def disconnect(self): """ Disconnects. You probably don't need to use this unless you are writing unit tests. """ if self._state == _State.CONNECTED: self._state = _State.DISCONNECTING self._transport.loseConnection() return self._noti...
python
def disconnect(self): """ Disconnects. You probably don't need to use this unless you are writing unit tests. """ if self._state == _State.CONNECTED: self._state = _State.DISCONNECTING self._transport.loseConnection() return self._noti...
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "_State", ".", "CONNECTED", ":", "self", ".", "_state", "=", "_State", ".", "DISCONNECTING", "self", ".", "_transport", ".", "loseConnection", "(", ")", "return", "self", ".",...
Disconnects. You probably don't need to use this unless you are writing unit tests.
[ "Disconnects", "." ]
train
https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/thrift_client.py#L206-L222
pavelsof/ipatok
ipatok/ipa.py
ensure_single_char
def ensure_single_char(func): """ Decorator that ensures that the first argument of the decorated function is a single character, i.e. a string of length one. """ @functools.wraps(func) def wrapper(*args, **kwargs): if not isinstance(args[0], str) or len(args[0]) != 1: raise ValueError(( 'This function s...
python
def ensure_single_char(func): """ Decorator that ensures that the first argument of the decorated function is a single character, i.e. a string of length one. """ @functools.wraps(func) def wrapper(*args, **kwargs): if not isinstance(args[0], str) or len(args[0]) != 1: raise ValueError(( 'This function s...
[ "def", "ensure_single_char", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "args", "[", "0", "]", ",", "str", ")", "...
Decorator that ensures that the first argument of the decorated function is a single character, i.e. a string of length one.
[ "Decorator", "that", "ensures", "that", "the", "first", "argument", "of", "the", "decorated", "function", "is", "a", "single", "character", "i", ".", "e", ".", "a", "string", "of", "length", "one", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L79-L92
pavelsof/ipatok
ipatok/ipa.py
is_letter
def is_letter(char, strict=True): """ Check whether the character is a letter (as opposed to a diacritic or suprasegmental). In strict mode return True only if the letter is part of the IPA spec. """ if (char in chart.consonants) or (char in chart.vowels): return True if not strict: return unicodedata.cate...
python
def is_letter(char, strict=True): """ Check whether the character is a letter (as opposed to a diacritic or suprasegmental). In strict mode return True only if the letter is part of the IPA spec. """ if (char in chart.consonants) or (char in chart.vowels): return True if not strict: return unicodedata.cate...
[ "def", "is_letter", "(", "char", ",", "strict", "=", "True", ")", ":", "if", "(", "char", "in", "chart", ".", "consonants", ")", "or", "(", "char", "in", "chart", ".", "vowels", ")", ":", "return", "True", "if", "not", "strict", ":", "return", "uni...
Check whether the character is a letter (as opposed to a diacritic or suprasegmental). In strict mode return True only if the letter is part of the IPA spec.
[ "Check", "whether", "the", "character", "is", "a", "letter", "(", "as", "opposed", "to", "a", "diacritic", "or", "suprasegmental", ")", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L96-L109
pavelsof/ipatok
ipatok/ipa.py
is_vowel
def is_vowel(char): """ Check whether the character is a vowel letter. """ if is_letter(char, strict=True): return char in chart.vowels return False
python
def is_vowel(char): """ Check whether the character is a vowel letter. """ if is_letter(char, strict=True): return char in chart.vowels return False
[ "def", "is_vowel", "(", "char", ")", ":", "if", "is_letter", "(", "char", ",", "strict", "=", "True", ")", ":", "return", "char", "in", "chart", ".", "vowels", "return", "False" ]
Check whether the character is a vowel letter.
[ "Check", "whether", "the", "character", "is", "a", "vowel", "letter", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L113-L120
pavelsof/ipatok
ipatok/ipa.py
is_diacritic
def is_diacritic(char, strict=True): """ Check whether the character is a diacritic (as opposed to a letter or a suprasegmental). In strict mode return True only if the diacritic is part of the IPA spec. """ if char in chart.diacritics: return True if not strict: return (unicodedata.category(char) in ['Lm'...
python
def is_diacritic(char, strict=True): """ Check whether the character is a diacritic (as opposed to a letter or a suprasegmental). In strict mode return True only if the diacritic is part of the IPA spec. """ if char in chart.diacritics: return True if not strict: return (unicodedata.category(char) in ['Lm'...
[ "def", "is_diacritic", "(", "char", ",", "strict", "=", "True", ")", ":", "if", "char", "in", "chart", ".", "diacritics", ":", "return", "True", "if", "not", "strict", ":", "return", "(", "unicodedata", ".", "category", "(", "char", ")", "in", "[", "...
Check whether the character is a diacritic (as opposed to a letter or a suprasegmental). In strict mode return True only if the diacritic is part of the IPA spec.
[ "Check", "whether", "the", "character", "is", "a", "diacritic", "(", "as", "opposed", "to", "a", "letter", "or", "a", "suprasegmental", ")", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L132-L148
pavelsof/ipatok
ipatok/ipa.py
is_suprasegmental
def is_suprasegmental(char, strict=True): """ Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec. """ if (char in chart.suprasegmentals) or (char in chart.length...
python
def is_suprasegmental(char, strict=True): """ Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec. """ if (char in chart.suprasegmentals) or (char in chart.length...
[ "def", "is_suprasegmental", "(", "char", ",", "strict", "=", "True", ")", ":", "if", "(", "char", "in", "chart", ".", "suprasegmentals", ")", "or", "(", "char", "in", "chart", ".", "lengths", ")", ":", "return", "True", "return", "is_tone", "(", "char"...
Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec.
[ "Check", "whether", "the", "character", "is", "a", "suprasegmental", "according", "to", "the", "IPA", "spec", ".", "This", "includes", "tones", "word", "accents", "and", "length", "markers", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L152-L162
pavelsof/ipatok
ipatok/ipa.py
is_tone
def is_tone(char, strict=True): """ Check whether the character is a tone or word accent symbol. In strict mode return True only for the symbols listed in the last group of the chart. If strict=False, also accept symbols that belong to the Modifier Tone Letters Unicode block [1]. [1]: http://www.unicode.org/char...
python
def is_tone(char, strict=True): """ Check whether the character is a tone or word accent symbol. In strict mode return True only for the symbols listed in the last group of the chart. If strict=False, also accept symbols that belong to the Modifier Tone Letters Unicode block [1]. [1]: http://www.unicode.org/char...
[ "def", "is_tone", "(", "char", ",", "strict", "=", "True", ")", ":", "if", "char", "in", "chart", ".", "tones", ":", "return", "True", "if", "not", "strict", ":", "return", "0xA700", "<=", "ord", "(", "char", ")", "<=", "0xA71F", "return", "False" ]
Check whether the character is a tone or word accent symbol. In strict mode return True only for the symbols listed in the last group of the chart. If strict=False, also accept symbols that belong to the Modifier Tone Letters Unicode block [1]. [1]: http://www.unicode.org/charts/PDF/UA700.pdf
[ "Check", "whether", "the", "character", "is", "a", "tone", "or", "word", "accent", "symbol", ".", "In", "strict", "mode", "return", "True", "only", "for", "the", "symbols", "listed", "in", "the", "last", "group", "of", "the", "chart", ".", "If", "strict"...
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L175-L190
pavelsof/ipatok
ipatok/ipa.py
get_precomposed_chars
def get_precomposed_chars(): """ Return the set of IPA characters that are defined in normal form C in the spec. As of 2015, this is only the voiceless palatal fricative, ç. """ return set([ letter for letter in chart.consonants if unicodedata.normalize('NFD', letter) != letter ])
python
def get_precomposed_chars(): """ Return the set of IPA characters that are defined in normal form C in the spec. As of 2015, this is only the voiceless palatal fricative, ç. """ return set([ letter for letter in chart.consonants if unicodedata.normalize('NFD', letter) != letter ])
[ "def", "get_precomposed_chars", "(", ")", ":", "return", "set", "(", "[", "letter", "for", "letter", "in", "chart", ".", "consonants", "if", "unicodedata", ".", "normalize", "(", "'NFD'", ",", "letter", ")", "!=", "letter", "]", ")" ]
Return the set of IPA characters that are defined in normal form C in the spec. As of 2015, this is only the voiceless palatal fricative, ç.
[ "Return", "the", "set", "of", "IPA", "characters", "that", "are", "defined", "in", "normal", "form", "C", "in", "the", "spec", ".", "As", "of", "2015", "this", "is", "only", "the", "voiceless", "palatal", "fricative", "ç", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L193-L200
pavelsof/ipatok
ipatok/ipa.py
replace_substitutes
def replace_substitutes(string): """ Return the given string with all known common substitutes replaced with their IPA-compliant counterparts. """ for non_ipa, ipa in chart.replacements.items(): string = string.replace(non_ipa, ipa) return string
python
def replace_substitutes(string): """ Return the given string with all known common substitutes replaced with their IPA-compliant counterparts. """ for non_ipa, ipa in chart.replacements.items(): string = string.replace(non_ipa, ipa) return string
[ "def", "replace_substitutes", "(", "string", ")", ":", "for", "non_ipa", ",", "ipa", "in", "chart", ".", "replacements", ".", "items", "(", ")", ":", "string", "=", "string", ".", "replace", "(", "non_ipa", ",", "ipa", ")", "return", "string" ]
Return the given string with all known common substitutes replaced with their IPA-compliant counterparts.
[ "Return", "the", "given", "string", "with", "all", "known", "common", "substitutes", "replaced", "with", "their", "IPA", "-", "compliant", "counterparts", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L203-L211
pavelsof/ipatok
ipatok/ipa.py
Chart.load_ipa
def load_ipa(self, file_path): """ Populate the instance's set properties using the specified file. """ sections = { '# consonants (pulmonic)': self.consonants, '# consonants (non-pulmonic)': self.consonants, '# other symbols': self.consonants, '# tie bars': self.tie_bars, '# vowels': self.vowels...
python
def load_ipa(self, file_path): """ Populate the instance's set properties using the specified file. """ sections = { '# consonants (pulmonic)': self.consonants, '# consonants (non-pulmonic)': self.consonants, '# other symbols': self.consonants, '# tie bars': self.tie_bars, '# vowels': self.vowels...
[ "def", "load_ipa", "(", "self", ",", "file_path", ")", ":", "sections", "=", "{", "'# consonants (pulmonic)'", ":", "self", ".", "consonants", ",", "'# consonants (non-pulmonic)'", ":", "self", ".", "consonants", ",", "'# other symbols'", ":", "self", ".", "cons...
Populate the instance's set properties using the specified file.
[ "Populate", "the", "instance", "s", "set", "properties", "using", "the", "specified", "file", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L39-L65
pavelsof/ipatok
ipatok/ipa.py
Chart.load_replacements
def load_replacements(self, file_path): """ Populate self.replacements using the specified file. """ with open(file_path, encoding='utf-8') as f: for line in map(lambda x: x.strip(), f): if line: line = line.split('\t') self.replacements[line[0]] = line[1]
python
def load_replacements(self, file_path): """ Populate self.replacements using the specified file. """ with open(file_path, encoding='utf-8') as f: for line in map(lambda x: x.strip(), f): if line: line = line.split('\t') self.replacements[line[0]] = line[1]
[ "def", "load_replacements", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "for", "line", "in", "map", "(", "lambda", "x", ":", "x", ".", "strip", "(", ")", ",", "f",...
Populate self.replacements using the specified file.
[ "Populate", "self", ".", "replacements", "using", "the", "specified", "file", "." ]
train
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L67-L75
thespacedoctor/sloancone
build/lib/sloancone/check_coverage.py
check_coverage.get
def get(self): """ *get the check_coverage object* **Return:** - ``check_coverage`` """ self.log.info('starting the ``get`` method') match = self._query_sdss() self.log.info('completed the ``get`` method') return match
python
def get(self): """ *get the check_coverage object* **Return:** - ``check_coverage`` """ self.log.info('starting the ``get`` method') match = self._query_sdss() self.log.info('completed the ``get`` method') return match
[ "def", "get", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "'starting the ``get`` method'", ")", "match", "=", "self", ".", "_query_sdss", "(", ")", "self", ".", "log", ".", "info", "(", "'completed the ``get`` method'", ")", "return", "mat...
*get the check_coverage object* **Return:** - ``check_coverage``
[ "*", "get", "the", "check_coverage", "object", "*" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/check_coverage.py#L95-L107
thespacedoctor/sloancone
build/lib/sloancone/check_coverage.py
check_coverage._query_sdss
def _query_sdss( self): """* query sdss* """ self.log.info('starting the ``_query_sdss`` method') raDeg = float(self.raDeg) decDeg = float(self.decDeg) raUpper = raDeg + 0.02 raLower = raDeg - 0.02 declUpper = decDeg + 0.02 declLower ...
python
def _query_sdss( self): """* query sdss* """ self.log.info('starting the ``_query_sdss`` method') raDeg = float(self.raDeg) decDeg = float(self.decDeg) raUpper = raDeg + 0.02 raLower = raDeg - 0.02 declUpper = decDeg + 0.02 declLower ...
[ "def", "_query_sdss", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "'starting the ``_query_sdss`` method'", ")", "raDeg", "=", "float", "(", "self", ".", "raDeg", ")", "decDeg", "=", "float", "(", "self", ".", "decDeg", ")", "raUpper", "=...
* query sdss*
[ "*", "query", "sdss", "*" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/check_coverage.py#L109-L165
thespacedoctor/sloancone
build/lib/sloancone/check_coverage.py
check_coverage._query
def _query( self, sql, url, fmt, log ): """* query* """ self.log.info('starting the ``_query`` method') try: response = requests.get( url=url, params={ "cmd": self._filtercomment(...
python
def _query( self, sql, url, fmt, log ): """* query* """ self.log.info('starting the ``_query`` method') try: response = requests.get( url=url, params={ "cmd": self._filtercomment(...
[ "def", "_query", "(", "self", ",", "sql", ",", "url", ",", "fmt", ",", "log", ")", ":", "self", ".", "log", ".", "info", "(", "'starting the ``_query`` method'", ")", "try", ":", "response", "=", "requests", ".", "get", "(", "url", "=", "url", ",", ...
* query*
[ "*", "query", "*" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/check_coverage.py#L167-L197
thespacedoctor/sloancone
build/lib/sloancone/check_coverage.py
check_coverage._filtercomment
def _filtercomment( self, sql): "Get rid of comments starting with --" import os fsql = '' for line in sql.split('\n'): fsql += line.split('--')[0] + ' ' + os.linesep return fsql
python
def _filtercomment( self, sql): "Get rid of comments starting with --" import os fsql = '' for line in sql.split('\n'): fsql += line.split('--')[0] + ' ' + os.linesep return fsql
[ "def", "_filtercomment", "(", "self", ",", "sql", ")", ":", "import", "os", "fsql", "=", "''", "for", "line", "in", "sql", ".", "split", "(", "'\\n'", ")", ":", "fsql", "+=", "line", ".", "split", "(", "'--'", ")", "[", "0", "]", "+", "' '", "+...
Get rid of comments starting with --
[ "Get", "rid", "of", "comments", "starting", "with", "--" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/check_coverage.py#L199-L207
pmichali/whodunit
whodunit/__init__.py
sort_by_name
def sort_by_name(names): """Sort by last name, uniquely.""" def last_name_key(full_name): parts = full_name.split(' ') if len(parts) == 1: return full_name.upper() last_first = parts[-1] + ' ' + ' '.join(parts[:-1]) return last_first.upper() return sorted(set(na...
python
def sort_by_name(names): """Sort by last name, uniquely.""" def last_name_key(full_name): parts = full_name.split(' ') if len(parts) == 1: return full_name.upper() last_first = parts[-1] + ' ' + ' '.join(parts[:-1]) return last_first.upper() return sorted(set(na...
[ "def", "sort_by_name", "(", "names", ")", ":", "def", "last_name_key", "(", "full_name", ")", ":", "parts", "=", "full_name", ".", "split", "(", "' '", ")", "if", "len", "(", "parts", ")", "==", "1", ":", "return", "full_name", ".", "upper", "(", ")"...
Sort by last name, uniquely.
[ "Sort", "by", "last", "name", "uniquely", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L467-L477
pmichali/whodunit
whodunit/__init__.py
build_owner
def build_owner(args): """Factory for creating owners, based on --sort option.""" if args.sort_by == 'cover': return CoverageOwners(args.root, args.verbose) if os.path.isdir(args.root): pass else: # File args.root, args.filter = os.path.split(args.root) if args.sort_by == 'd...
python
def build_owner(args): """Factory for creating owners, based on --sort option.""" if args.sort_by == 'cover': return CoverageOwners(args.root, args.verbose) if os.path.isdir(args.root): pass else: # File args.root, args.filter = os.path.split(args.root) if args.sort_by == 'd...
[ "def", "build_owner", "(", "args", ")", ":", "if", "args", ".", "sort_by", "==", "'cover'", ":", "return", "CoverageOwners", "(", "args", ".", "root", ",", "args", ".", "verbose", ")", "if", "os", ".", "path", ".", "isdir", "(", "args", ".", "root", ...
Factory for creating owners, based on --sort option.
[ "Factory", "for", "creating", "owners", "based", "on", "--", "sort", "option", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L500-L513
pmichali/whodunit
whodunit/__init__.py
BlameRecord.store_attribute
def store_attribute(self, key, value): """Store blame info we are interested in.""" if key == 'summary' or key == 'filename' or key == 'previous': return attr = key.replace('-', '_') if key.endswith('-time'): value = int(value) setattr(self, attr, value)
python
def store_attribute(self, key, value): """Store blame info we are interested in.""" if key == 'summary' or key == 'filename' or key == 'previous': return attr = key.replace('-', '_') if key.endswith('-time'): value = int(value) setattr(self, attr, value)
[ "def", "store_attribute", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "==", "'summary'", "or", "key", "==", "'filename'", "or", "key", "==", "'previous'", ":", "return", "attr", "=", "key", ".", "replace", "(", "'-'", ",", "'_'", ")...
Store blame info we are interested in.
[ "Store", "blame", "info", "we", "are", "interested", "in", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L111-L118
pmichali/whodunit
whodunit/__init__.py
Owners.is_git_file
def is_git_file(cls, path, name): """Determine if file is known by git.""" os.chdir(path) p = subprocess.Popen(['git', 'ls-files', '--error-unmatch', name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() return p.returncode == 0
python
def is_git_file(cls, path, name): """Determine if file is known by git.""" os.chdir(path) p = subprocess.Popen(['git', 'ls-files', '--error-unmatch', name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() return p.returncode == 0
[ "def", "is_git_file", "(", "cls", ",", "path", ",", "name", ")", ":", "os", ".", "chdir", "(", "path", ")", "p", "=", "subprocess", ".", "Popen", "(", "[", "'git'", ",", "'ls-files'", ",", "'--error-unmatch'", ",", "name", "]", ",", "stdout", "=", ...
Determine if file is known by git.
[ "Determine", "if", "file", "is", "known", "by", "git", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L175-L181
pmichali/whodunit
whodunit/__init__.py
Owners.collect_modules
def collect_modules(self): """Generator to look for git files in tree. Will handle all lines.""" for path, dirlist, filelist in os.walk(self.root): for name in fnmatch.filter(filelist, self.filter): if self.is_git_file(path, name): yield (os.path.join(path...
python
def collect_modules(self): """Generator to look for git files in tree. Will handle all lines.""" for path, dirlist, filelist in os.walk(self.root): for name in fnmatch.filter(filelist, self.filter): if self.is_git_file(path, name): yield (os.path.join(path...
[ "def", "collect_modules", "(", "self", ")", ":", "for", "path", ",", "dirlist", ",", "filelist", "in", "os", ".", "walk", "(", "self", ".", "root", ")", ":", "for", "name", "in", "fnmatch", ".", "filter", "(", "filelist", ",", "self", ".", "filter", ...
Generator to look for git files in tree. Will handle all lines.
[ "Generator", "to", "look", "for", "git", "files", "in", "tree", ".", "Will", "handle", "all", "lines", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L183-L188
pmichali/whodunit
whodunit/__init__.py
Owners.collect_blame_info
def collect_blame_info(cls, matches): """Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines. """ old_area = None for filename, ranges in matches: area, name = os.path.split(filename) ...
python
def collect_blame_info(cls, matches): """Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines. """ old_area = None for filename, ranges in matches: area, name = os.path.split(filename) ...
[ "def", "collect_blame_info", "(", "cls", ",", "matches", ")", ":", "old_area", "=", "None", "for", "filename", ",", "ranges", "in", "matches", ":", "area", ",", "name", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "if", "not", "area", ...
Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines.
[ "Runs", "git", "blame", "on", "files", "for", "the", "specified", "sets", "of", "line", "ranges", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L195-L218
pmichali/whodunit
whodunit/__init__.py
Owners.unique_authors
def unique_authors(self, limit): """Unique list of authors, but preserving order.""" seen = set() if limit == 0: limit = None seen_add = seen.add # Assign to variable, so not resolved each time return [x.author for x in self.sorted_commits[:limit] if ...
python
def unique_authors(self, limit): """Unique list of authors, but preserving order.""" seen = set() if limit == 0: limit = None seen_add = seen.add # Assign to variable, so not resolved each time return [x.author for x in self.sorted_commits[:limit] if ...
[ "def", "unique_authors", "(", "self", ",", "limit", ")", ":", "seen", "=", "set", "(", ")", "if", "limit", "==", "0", ":", "limit", "=", "None", "seen_add", "=", "seen", ".", "add", "# Assign to variable, so not resolved each time", "return", "[", "x", "."...
Unique list of authors, but preserving order.
[ "Unique", "list", "of", "authors", "but", "preserving", "order", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L247-L254
pmichali/whodunit
whodunit/__init__.py
Owners.show
def show(self, commit): """Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email> """ author = commit.author ...
python
def show(self, commit): """Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email> """ author = commit.author ...
[ "def", "show", "(", "self", ",", "commit", ")", ":", "author", "=", "commit", ".", "author", "author_width", "=", "25", "committer", "=", "''", "commit_date", "=", "date_to_str", "(", "commit", ".", "committer_time", ",", "commit", ".", "committer_tz", ","...
Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email>
[ "Display", "one", "commit", "line", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L262-L282
pmichali/whodunit
whodunit/__init__.py
SizeOwners.merge_user_commits
def merge_user_commits(cls, commits): """Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user. """ user = None for commit in commits: if not user: us...
python
def merge_user_commits(cls, commits): """Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user. """ user = None for commit in commits: if not user: us...
[ "def", "merge_user_commits", "(", "cls", ",", "commits", ")", ":", "user", "=", "None", "for", "commit", "in", "commits", ":", "if", "not", "user", ":", "user", "=", "commit", "else", ":", "if", "commit", ".", "committer_time", ">", "user", ".", "commi...
Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user.
[ "Merge", "all", "the", "commits", "for", "the", "user", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L288-L304
pmichali/whodunit
whodunit/__init__.py
SizeOwners.sort
def sort(self): """Sort by commit size, per author.""" # First sort commits by author email users = [] # Group commits by author email, so they can be merged for _, group in itertools.groupby(sorted(self.commits), operator.attrgetter('aut...
python
def sort(self): """Sort by commit size, per author.""" # First sort commits by author email users = [] # Group commits by author email, so they can be merged for _, group in itertools.groupby(sorted(self.commits), operator.attrgetter('aut...
[ "def", "sort", "(", "self", ")", ":", "# First sort commits by author email", "users", "=", "[", "]", "# Group commits by author email, so they can be merged", "for", "_", ",", "group", "in", "itertools", ".", "groupby", "(", "sorted", "(", "self", ".", "commits", ...
Sort by commit size, per author.
[ "Sort", "by", "commit", "size", "per", "author", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L306-L319
pmichali/whodunit
whodunit/__init__.py
DateOwners.sort
def sort(self): """Sort commits by the committer date/time.""" self.sorted_commits = sorted(self.commits, key=lambda x: x.committer_time, reverse=True) return self.sorted_commits
python
def sort(self): """Sort commits by the committer date/time.""" self.sorted_commits = sorted(self.commits, key=lambda x: x.committer_time, reverse=True) return self.sorted_commits
[ "def", "sort", "(", "self", ")", ":", "self", ".", "sorted_commits", "=", "sorted", "(", "self", ".", "commits", ",", "key", "=", "lambda", "x", ":", "x", ".", "committer_time", ",", "reverse", "=", "True", ")", "return", "self", ".", "sorted_commits" ...
Sort commits by the committer date/time.
[ "Sort", "commits", "by", "the", "committer", "date", "/", "time", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L324-L329
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.make_ranges
def make_ranges(cls, lines): """Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line. """ start_line = last_line = lines.pop(0) ranges = [] ...
python
def make_ranges(cls, lines): """Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line. """ start_line = last_line = lines.pop(0) ranges = [] ...
[ "def", "make_ranges", "(", "cls", ",", "lines", ")", ":", "start_line", "=", "last_line", "=", "lines", ".", "pop", "(", "0", ")", "ranges", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "line", "==", "(", "last_line", "+", "1", ")", ":...
Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line.
[ "Convert", "list", "of", "lines", "into", "list", "of", "line", "range", "tuples", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L340-L356
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.determine_coverage
def determine_coverage(cls, coverage_file): """Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag. """ lines =...
python
def determine_coverage(cls, coverage_file): """Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag. """ lines =...
[ "def", "determine_coverage", "(", "cls", ",", "coverage_file", ")", ":", "lines", "=", "[", "]", "source_file", "=", "'ERROR'", "for", "line", "in", "coverage_file", ":", "m", "=", "title_re", ".", "match", "(", "line", ")", "if", "m", ":", "if", "m", ...
Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag.
[ "Scan", "the", "summary", "section", "of", "report", "looking", "for", "coverage", "data", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L359-L382
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.collect_modules
def collect_modules(self): """Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory. """ coverage_dir = os.path.join(self.root, 'cover') for name in fnmatch.filter...
python
def collect_modules(self): """Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory. """ coverage_dir = os.path.join(self.root, 'cover') for name in fnmatch.filter...
[ "def", "collect_modules", "(", "self", ")", ":", "coverage_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root", ",", "'cover'", ")", "for", "name", "in", "fnmatch", ".", "filter", "(", "os", ".", "listdir", "(", "coverage_dir", ")", "...
Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory.
[ "Generator", "to", "obtain", "lines", "of", "interest", "from", "coverage", "report", "files", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L384-L405
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.sort
def sort(self): """Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID. """ self.sorted_commits = [] if not self.commits: return self.sorted_commits prev_commit = self.co...
python
def sort(self): """Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID. """ self.sorted_commits = [] if not self.commits: return self.sorted_commits prev_commit = self.co...
[ "def", "sort", "(", "self", ")", ":", "self", ".", "sorted_commits", "=", "[", "]", "if", "not", "self", ".", "commits", ":", "return", "self", ".", "sorted_commits", "prev_commit", "=", "self", ".", "commits", ".", "pop", "(", "0", ")", "prev_line", ...
Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID.
[ "Consolidate", "adjacent", "lines", "if", "same", "commit", "ID", "." ]
train
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L414-L438
monkeython/scriba
scriba/schemes/scriba_ftps.py
write
def write(url, content, **args): """Put an object into a ftps URL.""" with FTPSResource(url, **args) as resource: resource.write(content)
python
def write(url, content, **args): """Put an object into a ftps URL.""" with FTPSResource(url, **args) as resource: resource.write(content)
[ "def", "write", "(", "url", ",", "content", ",", "*", "*", "args", ")", ":", "with", "FTPSResource", "(", "url", ",", "*", "*", "args", ")", "as", "resource", ":", "resource", ".", "write", "(", "content", ")" ]
Put an object into a ftps URL.
[ "Put", "an", "object", "into", "a", "ftps", "URL", "." ]
train
https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/scriba_ftps.py#L27-L30
spookey/photon
photon/util/structures.py
yaml_str_join
def yaml_str_join(l, n): ''' YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader...
python
def yaml_str_join(l, n): ''' YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader...
[ "def", "yaml_str_join", "(", "l", ",", "n", ")", ":", "from", "photon", ".", "util", ".", "system", "import", "get_hostname", ",", "get_timestamp", "s", "=", "l", ".", "construct_sequence", "(", "n", ")", "for", "num", ",", "seq", "in", "enumerate", "(...
YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader_returns| .. note:: Be c...
[ "YAML", "loader", "to", "join", "strings" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L11-L39
spookey/photon
photon/util/structures.py
yaml_loc_join
def yaml_loc_join(l, n): ''' YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso| ''' from photon.util.locations i...
python
def yaml_loc_join(l, n): ''' YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso| ''' from photon.util.locations i...
[ "def", "yaml_loc_join", "(", "l", ",", "n", ")", ":", "from", "photon", ".", "util", ".", "locations", "import", "get_locations", "locations", "=", "get_locations", "(", ")", "s", "=", "l", ".", "construct_sequence", "(", "n", ")", "for", "num", ",", "...
YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso|
[ "YAML", "loader", "to", "join", "paths" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L42-L63
spookey/photon
photon/util/structures.py
dict_merge
def dict_merge(o, v): ''' Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, ...
python
def dict_merge(o, v): ''' Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, ...
[ "def", "dict_merge", "(", "o", ",", "v", ")", ":", "if", "not", "isinstance", "(", "v", ",", "dict", ")", ":", "return", "v", "res", "=", "_deepcopy", "(", "o", ")", "for", "key", "in", "v", ".", "keys", "(", ")", ":", "if", "res", ".", "get"...
Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, bad things will happen otherw...
[ "Recursively", "climbs", "through", "dictionaries", "and", "merges", "them", "together", "." ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L66-L90
spookey/photon
photon/util/structures.py
to_list
def to_list(i, use_keys=False): ''' Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, t...
python
def to_list(i, use_keys=False): ''' Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, t...
[ "def", "to_list", "(", "i", ",", "use_keys", "=", "False", ")", ":", "from", "photon", ".", "util", ".", "system", "import", "shell_notify", "if", "not", "i", ":", "return", "[", "]", "if", "isinstance", "(", "i", ",", "str", ")", ":", "return", "[...
Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, the result will be a flattened list. :pa...
[ "Converts", "items", "to", "a", "list", "." ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L93-L125
Ffisegydd/whatis
whatis/_core.py
this
def this(obj, **kwargs): """Prints series of debugging steps to user. Runs through pipeline of functions and print results of each. """ verbose = kwargs.get("verbose", True) if verbose: print('{:=^30}'.format(" whatis.this? ")) for func in pipeline: s = func(obj, **kwargs) ...
python
def this(obj, **kwargs): """Prints series of debugging steps to user. Runs through pipeline of functions and print results of each. """ verbose = kwargs.get("verbose", True) if verbose: print('{:=^30}'.format(" whatis.this? ")) for func in pipeline: s = func(obj, **kwargs) ...
[ "def", "this", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "kwargs", ".", "get", "(", "\"verbose\"", ",", "True", ")", "if", "verbose", ":", "print", "(", "'{:=^30}'", ".", "format", "(", "\" whatis.this? \"", ")", ")", "for", "fun...
Prints series of debugging steps to user. Runs through pipeline of functions and print results of each.
[ "Prints", "series", "of", "debugging", "steps", "to", "user", "." ]
train
https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_core.py#L29-L45
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_get_repeat_masker_header
def _get_repeat_masker_header(pairwise_alignment): """generate header string of repeatmasker formated repr of self.""" res = "" res += str(pairwise_alignment.meta[ALIG_SCORE_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_SUBS_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_S...
python
def _get_repeat_masker_header(pairwise_alignment): """generate header string of repeatmasker formated repr of self.""" res = "" res += str(pairwise_alignment.meta[ALIG_SCORE_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_SUBS_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_S...
[ "def", "_get_repeat_masker_header", "(", "pairwise_alignment", ")", ":", "res", "=", "\"\"", "res", "+=", "str", "(", "pairwise_alignment", ".", "meta", "[", "ALIG_SCORE_KEY", "]", ")", "+", "\" \"", "res", "+=", "\"{:.2f}\"", ".", "format", "(", "pairwise_ali...
generate header string of repeatmasker formated repr of self.
[ "generate", "header", "string", "of", "repeatmasker", "formated", "repr", "of", "self", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L102-L137
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_to_repeatmasker_string
def _to_repeatmasker_string(pairwise_alignment, column_width=DEFAULT_COL_WIDTH, m_name_width=DEFAULT_MAX_NAME_WIDTH): """ generate a repeatmasker formated representation of this pairwise alignment. :param column_width: number of characters to output per line of alignment :param m_na...
python
def _to_repeatmasker_string(pairwise_alignment, column_width=DEFAULT_COL_WIDTH, m_name_width=DEFAULT_MAX_NAME_WIDTH): """ generate a repeatmasker formated representation of this pairwise alignment. :param column_width: number of characters to output per line of alignment :param m_na...
[ "def", "_to_repeatmasker_string", "(", "pairwise_alignment", ",", "column_width", "=", "DEFAULT_COL_WIDTH", ",", "m_name_width", "=", "DEFAULT_MAX_NAME_WIDTH", ")", ":", "s1", "=", "pairwise_alignment", ".", "s1", "s2", "=", "pairwise_alignment", ".", "s2", "s1_neg", ...
generate a repeatmasker formated representation of this pairwise alignment. :param column_width: number of characters to output per line of alignment :param m_name_width: truncate names on alignment lines to this length (set to None for no truncation)
[ "generate", "a", "repeatmasker", "formated", "representation", "of", "this", "pairwise", "alignment", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L140-L233
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_is_alignment_line
def _rm_is_alignment_line(parts, s1_name, s2_name): """ return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this li...
python
def _rm_is_alignment_line(parts, s1_name, s2_name): """ return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this li...
[ "def", "_rm_is_alignment_line", "(", "parts", ",", "s1_name", ",", "s2_name", ")", ":", "if", "len", "(", "parts", ")", "<", "2", ":", "return", "False", "if", "_rm_name_match", "(", "parts", "[", "0", "]", ",", "s1_name", ")", ":", "return", "True", ...
return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this line is in :param s2_name: the name of the second sequence, ...
[ "return", "true", "if", "the", "tokenized", "line", "is", "a", "repeatmasker", "alignment", "line", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L252-L269
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_is_header_line
def _rm_is_header_line(parts, n): """ determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are. """ if (n == 15 and parts[8] == "C"): return True if ...
python
def _rm_is_header_line(parts, n): """ determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are. """ if (n == 15 and parts[8] == "C"): return True if ...
[ "def", "_rm_is_header_line", "(", "parts", ",", "n", ")", ":", "if", "(", "n", "==", "15", "and", "parts", "[", "8", "]", "==", "\"C\"", ")", ":", "return", "True", "if", "(", "n", "==", "14", "and", "parts", "[", "0", "]", ".", "isdigit", "(",...
determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are.
[ "determine", "whether", "a", "pre", "-", "split", "string", "is", "a", "repeat", "-", "masker", "alignment", "header", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L272-L282
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_compute_leading_space_alig
def _rm_compute_leading_space_alig(space_pres_split, seq): """ count the number of characters that precede the sequence in a repeatmasker alignment line. E.g. in the following line: ' chr1 11 CCCTGGAGATTCTTATT--AGTGATTTGGGCT 41' the answer would be 24. :param space_pres_split: the ali...
python
def _rm_compute_leading_space_alig(space_pres_split, seq): """ count the number of characters that precede the sequence in a repeatmasker alignment line. E.g. in the following line: ' chr1 11 CCCTGGAGATTCTTATT--AGTGATTTGGGCT 41' the answer would be 24. :param space_pres_split: the ali...
[ "def", "_rm_compute_leading_space_alig", "(", "space_pres_split", ",", "seq", ")", ":", "c", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "space_pres_split", ")", ")", ":", "if", "space_pres_split", "[", "i", "]", "==", "seq", ":", "...
count the number of characters that precede the sequence in a repeatmasker alignment line. E.g. in the following line: ' chr1 11 CCCTGGAGATTCTTATT--AGTGATTTGGGCT 41' the answer would be 24. :param space_pres_split: the alignment line, split into tokens around spaces, ...
[ "count", "the", "number", "of", "characters", "that", "precede", "the", "sequence", "in", "a", "repeatmasker", "alignment", "line", ".", "E", ".", "g", ".", "in", "the", "following", "line", ":", "chr1", "11", "CCCTGGAGATTCTTATT", "--", "AGTGATTTGGGCT", "41"...
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L296-L312
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_compute_leading_space
def _rm_compute_leading_space(space_s_pres_split): """ count the number of spaces that precede a non-space token (not including empty string tokens) in a string. :param space_s_pres_split: the string, split into tokens around spaces, but with the spaces conserved as tokens. """ ...
python
def _rm_compute_leading_space(space_s_pres_split): """ count the number of spaces that precede a non-space token (not including empty string tokens) in a string. :param space_s_pres_split: the string, split into tokens around spaces, but with the spaces conserved as tokens. """ ...
[ "def", "_rm_compute_leading_space", "(", "space_s_pres_split", ")", ":", "i", "=", "0", "c", "=", "0", "while", "(", "i", "<", "len", "(", "space_s_pres_split", ")", "and", "(", "space_s_pres_split", "[", "i", "]", ".", "isspace", "(", ")", "or", "(", ...
count the number of spaces that precede a non-space token (not including empty string tokens) in a string. :param space_s_pres_split: the string, split into tokens around spaces, but with the spaces conserved as tokens.
[ "count", "the", "number", "of", "spaces", "that", "precede", "a", "non", "-", "space", "token", "(", "not", "including", "empty", "string", "tokens", ")", "in", "a", "string", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L315-L330
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_get_names_from_header
def _rm_get_names_from_header(parts): """ get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at ...
python
def _rm_get_names_from_header(parts): """ get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at ...
[ "def", "_rm_get_names_from_header", "(", "parts", ")", ":", "assert", "(", "(", "parts", "[", "8", "]", "==", "\"C\"", "and", "len", "(", "parts", ")", "==", "15", ")", "or", "(", "len", "(", "parts", ")", "==", "14", ")", ")", "return", "(", "pa...
get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at position 9 if matching the reverse complement ...
[ "get", "repeat", "and", "seq", ".", "name", "from", "repeatmasker", "alignment", "header", "line", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L333-L349
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_get_reference_coords_from_header
def _rm_get_reference_coords_from_header(parts): """ extract the reference (genomic sequence match) coordinates of a repeat occurrence from a repeatmakser header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic start and end are always at po...
python
def _rm_get_reference_coords_from_header(parts): """ extract the reference (genomic sequence match) coordinates of a repeat occurrence from a repeatmakser header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic start and end are always at po...
[ "def", "_rm_get_reference_coords_from_header", "(", "parts", ")", ":", "s", "=", "int", "(", "parts", "[", "5", "]", ")", "e", "=", "int", "(", "parts", "[", "6", "]", ")", "+", "1", "if", "(", "s", ">=", "e", ")", ":", "raise", "AlignmentIteratorE...
extract the reference (genomic sequence match) coordinates of a repeat occurrence from a repeatmakser header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic start and end are always at positions 5 and 6 resepctively. In the repeatmasker forma...
[ "extract", "the", "reference", "(", "genomic", "sequence", "match", ")", "coordinates", "of", "a", "repeat", "occurrence", "from", "a", "repeatmakser", "header", "line", ".", "An", "example", "header", "line", "is", "::" ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L352-L371
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_get_repeat_coords_from_header
def _rm_get_repeat_coords_from_header(parts): """ extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match ...
python
def _rm_get_repeat_coords_from_header(parts): """ extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match ...
[ "def", "_rm_get_repeat_coords_from_header", "(", "parts", ")", ":", "assert", "(", "(", "parts", "[", "8", "]", "==", "\"C\"", "and", "len", "(", "parts", ")", "==", "15", ")", "or", "(", "len", "(", "parts", ")", "==", "14", ")", ")", "if", "len",...
extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match is to the reverse complement, the start and end coordi...
[ "extract", "the", "repeat", "coordinates", "of", "a", "repeat", "masker", "match", "from", "a", "header", "line", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L374-L404
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_parse_header_line
def _rm_parse_header_line(parts, meta_data): """ parse a repeatmasker alignment header line and place the extracted meta-data into the provided dictionary. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 If the alignment is to the consensus, this will have 1...
python
def _rm_parse_header_line(parts, meta_data): """ parse a repeatmasker alignment header line and place the extracted meta-data into the provided dictionary. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 If the alignment is to the consensus, this will have 1...
[ "def", "_rm_parse_header_line", "(", "parts", ",", "meta_data", ")", ":", "meta_data", "[", "ALIG_SCORE_KEY", "]", "=", "parts", "[", "0", "]", "meta_data", "[", "PCENT_SUBS_KEY", "]", "=", "float", "(", "parts", "[", "1", "]", ")", "meta_data", "[", "PC...
parse a repeatmasker alignment header line and place the extracted meta-data into the provided dictionary. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 If the alignment is to the consensus, this will have 14 fields; to the reverse complement of the repeat c...
[ "parse", "a", "repeatmasker", "alignment", "header", "line", "and", "place", "the", "extracted", "meta", "-", "data", "into", "the", "provided", "dictionary", ".", "An", "example", "header", "line", "is", "::" ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L456-L528
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_name_match
def _rm_name_match(s1, s2): """ determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False """ m_len = min(len(s1), len(s2)) return s1[:m_len] == s2[:m_len]
python
def _rm_name_match(s1, s2): """ determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False """ m_len = min(len(s1), len(s2)) return s1[:m_len] == s2[:m_len]
[ "def", "_rm_name_match", "(", "s1", ",", "s2", ")", ":", "m_len", "=", "min", "(", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", ")", "return", "s1", "[", ":", "m_len", "]", "==", "s2", "[", ":", "m_len", "]" ]
determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False
[ "determine", "whether", "two", "sequence", "names", "from", "a", "repeatmasker", "alignment", "match", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L531-L539
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_extract_sequence_and_name
def _rm_extract_sequence_and_name(alig_str_parts, s1_name, s2_name): """ parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_...
python
def _rm_extract_sequence_and_name(alig_str_parts, s1_name, s2_name): """ parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_...
[ "def", "_rm_extract_sequence_and_name", "(", "alig_str_parts", ",", "s1_name", ",", "s2_name", ")", ":", "# first, based on the number of parts we have we'll guess whether its a", "# reverse complement or not", "if", "len", "(", "alig_str_parts", ")", "==", "4", ":", "# expec...
parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_name: the name of the first sequence in the alignment this line is ...
[ "parse", "an", "alignment", "line", "from", "a", "repeatmasker", "alignment", "and", "return", "the", "name", "of", "the", "sequence", "it", "si", "from", "and", "the", "sequence", "portion", "contained", "in", "the", "line", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L555-L597
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
repeat_masker_alignment_iterator
def repeat_masker_alignment_iterator(fn, index_friendly=True, verbose=False): """ Iterator for repeat masker alignment files; yields multiple alignment objects. Iterate over a file/stream of full repeat alignments in the repeatmasker format. Briefly, this format is as follows: each record (alignment) begins ...
python
def repeat_masker_alignment_iterator(fn, index_friendly=True, verbose=False): """ Iterator for repeat masker alignment files; yields multiple alignment objects. Iterate over a file/stream of full repeat alignments in the repeatmasker format. Briefly, this format is as follows: each record (alignment) begins ...
[ "def", "repeat_masker_alignment_iterator", "(", "fn", ",", "index_friendly", "=", "True", ",", "verbose", "=", "False", ")", ":", "# step 1 -- build our iterator for the stream..", "try", ":", "fh", "=", "open", "(", "fn", ")", "except", "(", "TypeError", ")", "...
Iterator for repeat masker alignment files; yields multiple alignment objects. Iterate over a file/stream of full repeat alignments in the repeatmasker format. Briefly, this format is as follows: each record (alignment) begins with a header line (see _rm_parse_header_line documentation for details of header fo...
[ "Iterator", "for", "repeat", "masker", "alignment", "files", ";", "yields", "multiple", "alignment", "objects", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L600-L756
edeposit/edeposit.amqp.antivirus
src/edeposit/amqp/antivirus/wrappers/clamd.py
scan_file
def scan_file(path): """ Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: ...
python
def scan_file(path): """ Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: ...
[ "def", "scan_file", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "assert", "os", ".", "path", ".", "exists", "(", "path", ")", ",", "\"Unreachable file '%s'.\"", "%", "path", "try", ":", "cd", "=", "pyclamd...
Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: When the server is not running. ...
[ "Scan", "path", "for", "viruses", "using", "clamd", "antivirus", "daemon", "." ]
train
https://github.com/edeposit/edeposit.amqp.antivirus/blob/011b38bbe920819fab99a5891b1e70732321a598/src/edeposit/amqp/antivirus/wrappers/clamd.py#L16-L51
rackerlabs/silverberg
silverberg/cluster.py
RoundRobinCassandraCluster.execute
def execute(self, *args, **kwargs): """ See :py:func:`silverberg.client.CQLClient.execute` """ num_clients = len(self._seed_clients) start_client = (self._client_idx + 1) % num_clients def _client_error(failure, client_i): failure.trap(ConnectError) ...
python
def execute(self, *args, **kwargs): """ See :py:func:`silverberg.client.CQLClient.execute` """ num_clients = len(self._seed_clients) start_client = (self._client_idx + 1) % num_clients def _client_error(failure, client_i): failure.trap(ConnectError) ...
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "num_clients", "=", "len", "(", "self", ".", "_seed_clients", ")", "start_client", "=", "(", "self", ".", "_client_idx", "+", "1", ")", "%", "num_clients", "def", "_c...
See :py:func:`silverberg.client.CQLClient.execute`
[ "See", ":", "py", ":", "func", ":", "silverberg", ".", "client", ".", "CQLClient", ".", "execute" ]
train
https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/cluster.py#L46-L66
cbrand/vpnchooser
src/vpnchooser/helpers/parser.py
id_from_url
def id_from_url(url, param_name: str) -> int: """ Parses an object and tries to extract a url. Tries to parse if a resource_url has been given it as a url. :raise ValueError: If no id could be extracted. """ if url is None: raise ValueError('url is none') elif isinstance(url, int...
python
def id_from_url(url, param_name: str) -> int: """ Parses an object and tries to extract a url. Tries to parse if a resource_url has been given it as a url. :raise ValueError: If no id could be extracted. """ if url is None: raise ValueError('url is none') elif isinstance(url, int...
[ "def", "id_from_url", "(", "url", ",", "param_name", ":", "str", ")", "->", "int", ":", "if", "url", "is", "None", ":", "raise", "ValueError", "(", "'url is none'", ")", "elif", "isinstance", "(", "url", ",", "int", ")", ":", "# Seems to already be the url...
Parses an object and tries to extract a url. Tries to parse if a resource_url has been given it as a url. :raise ValueError: If no id could be extracted.
[ "Parses", "an", "object", "and", "tries", "to", "extract", "a", "url", ".", "Tries", "to", "parse", "if", "a", "resource_url", "has", "been", "given", "it", "as", "a", "url", ".", ":", "raise", "ValueError", ":", "If", "no", "id", "could", "be", "ext...
train
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/helpers/parser.py#L9-L44
minhhoit/yacms
yacms/utils/timezone.py
get_best_local_timezone
def get_best_local_timezone(): """ Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set. """ zone_name = tzlocal.get_localzone().zone if zone_name in pytz.all_timezones: return zone_name if time.daylight: ...
python
def get_best_local_timezone(): """ Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set. """ zone_name = tzlocal.get_localzone().zone if zone_name in pytz.all_timezones: return zone_name if time.daylight: ...
[ "def", "get_best_local_timezone", "(", ")", ":", "zone_name", "=", "tzlocal", ".", "get_localzone", "(", ")", ".", "zone", "if", "zone_name", "in", "pytz", ".", "all_timezones", ":", "return", "zone_name", "if", "time", ".", "daylight", ":", "local_offset", ...
Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set.
[ "Compares", "local", "timezone", "offset", "to", "pytz", "s", "timezone", "db", "to", "determine", "a", "matching", "timezone", "name", "to", "use", "when", "TIME_ZONE", "is", "not", "set", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/timezone.py#L9-L30