repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
sontek/bulby
bulby/client.py
HueBridgeClient.get_lights
def get_lights(self): ''' Lists all available lights on the bridge. ''' url = '/api/%s/lights' % self.username response = self.make_request('GET', url) lights = [] # Did we get a success response back? # error responses look like: # [{'error': {'ad...
python
def get_lights(self): ''' Lists all available lights on the bridge. ''' url = '/api/%s/lights' % self.username response = self.make_request('GET', url) lights = [] # Did we get a success response back? # error responses look like: # [{'error': {'ad...
[ "def", "get_lights", "(", "self", ")", ":", "url", "=", "'/api/%s/lights'", "%", "self", ".", "username", "response", "=", "self", ".", "make_request", "(", "'GET'", ",", "url", ")", "lights", "=", "[", "]", "# Did we get a success response back?", "# error re...
Lists all available lights on the bridge.
[ "Lists", "all", "available", "lights", "on", "the", "bridge", "." ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/client.py#L99-L128
train
Lists all available lights on the bridge.
sontek/bulby
bulby/client.py
HueBridgeClient.set_state
def set_state(self, light_id, **kwargs): ''' Sets state on the light, can be used like this: .. code-block:: python set_state(1, xy=[1,2]) ''' light = self.get_light(light_id) url = '/api/%s/lights/%s/state' % (self.username, light.light_id) response...
python
def set_state(self, light_id, **kwargs): ''' Sets state on the light, can be used like this: .. code-block:: python set_state(1, xy=[1,2]) ''' light = self.get_light(light_id) url = '/api/%s/lights/%s/state' % (self.username, light.light_id) response...
[ "def", "set_state", "(", "self", ",", "light_id", ",", "*", "*", "kwargs", ")", ":", "light", "=", "self", ".", "get_light", "(", "light_id", ")", "url", "=", "'/api/%s/lights/%s/state'", "%", "(", "self", ".", "username", ",", "light", ".", "light_id", ...
Sets state on the light, can be used like this: .. code-block:: python set_state(1, xy=[1,2])
[ "Sets", "state", "on", "the", "light", "can", "be", "used", "like", "this", ":" ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/client.py#L147-L168
train
Sets state on the light.
sontek/bulby
bulby/client.py
HueBridgeClient.set_color
def set_color(self, light_id, hex_value, brightness=None): ''' This will set the light color based on a hex value ''' light = self.get_light(light_id) xy = get_xy_from_hex(hex_value) data = { 'xy': [xy.x, xy.y], } if brightness is not None: ...
python
def set_color(self, light_id, hex_value, brightness=None): ''' This will set the light color based on a hex value ''' light = self.get_light(light_id) xy = get_xy_from_hex(hex_value) data = { 'xy': [xy.x, xy.y], } if brightness is not None: ...
[ "def", "set_color", "(", "self", ",", "light_id", ",", "hex_value", ",", "brightness", "=", "None", ")", ":", "light", "=", "self", ".", "get_light", "(", "light_id", ")", "xy", "=", "get_xy_from_hex", "(", "hex_value", ")", "data", "=", "{", "'xy'", "...
This will set the light color based on a hex value
[ "This", "will", "set", "the", "light", "color", "based", "on", "a", "hex", "value" ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/client.py#L170-L184
train
This will set the light color based on a hex value.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py
plotfft
def plotfft(s, fmax, doplot=False): """ This functions computes the fft of a signal, returning the frequency and their magnitude values. Parameters ---------- s: array-like the input signal. fmax: int the sampling frequency. doplot: boolean a variable to indicate whether t...
python
def plotfft(s, fmax, doplot=False): """ This functions computes the fft of a signal, returning the frequency and their magnitude values. Parameters ---------- s: array-like the input signal. fmax: int the sampling frequency. doplot: boolean a variable to indicate whether t...
[ "def", "plotfft", "(", "s", ",", "fmax", ",", "doplot", "=", "False", ")", ":", "fs", "=", "abs", "(", "np", ".", "fft", ".", "fft", "(", "s", ")", ")", "f", "=", "linspace", "(", "0", ",", "fmax", "/", "2", ",", "len", "(", "s", ")", "/"...
This functions computes the fft of a signal, returning the frequency and their magnitude values. Parameters ---------- s: array-like the input signal. fmax: int the sampling frequency. doplot: boolean a variable to indicate whether the plot is done or not. Returns ---...
[ "This", "functions", "computes", "the", "fft", "of", "a", "signal", "returning", "the", "frequency", "and", "their", "magnitude", "values", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py#L8-L34
train
This function computes the fft of a signal and plots the frequency and magnitude values.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py
load_with_cache
def load_with_cache(file_, recache=False, sampling=1, columns=None, temp_dir='.', data_type='int16'): """@brief This function loads a file from the current directory and saves the cached file to later executions. It's also possible to make a recache or a subsampling of the signal and cho...
python
def load_with_cache(file_, recache=False, sampling=1, columns=None, temp_dir='.', data_type='int16'): """@brief This function loads a file from the current directory and saves the cached file to later executions. It's also possible to make a recache or a subsampling of the signal and cho...
[ "def", "load_with_cache", "(", "file_", ",", "recache", "=", "False", ",", "sampling", "=", "1", ",", "columns", "=", "None", ",", "temp_dir", "=", "'.'", ",", "data_type", "=", "'int16'", ")", ":", "cfile", "=", "'%s.npy'", "%", "file_", "if", "(", ...
@brief This function loads a file from the current directory and saves the cached file to later executions. It's also possible to make a recache or a subsampling of the signal and choose only a few columns of the signal, to accelerate the opening process. @param file String: the name of the file to ope...
[ "@brief", "This", "function", "loads", "a", "file", "from", "the", "current", "directory", "and", "saves", "the", "cached", "file", "to", "later", "executions", ".", "It", "s", "also", "possible", "to", "make", "a", "recache", "or", "a", "subsampling", "of...
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py#L95-L129
train
Loads a file from the current directory and saves it to later executions.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py
load_data
def load_data(filename): """ :rtype : numpy matrix """ data = pandas.read_csv(filename, header=None, delimiter='\t', skiprows=9) return data.as_matrix()
python
def load_data(filename): """ :rtype : numpy matrix """ data = pandas.read_csv(filename, header=None, delimiter='\t', skiprows=9) return data.as_matrix()
[ "def", "load_data", "(", "filename", ")", ":", "data", "=", "pandas", ".", "read_csv", "(", "filename", ",", "header", "=", "None", ",", "delimiter", "=", "'\\t'", ",", "skiprows", "=", "9", ")", "return", "data", ".", "as_matrix", "(", ")" ]
:rtype : numpy matrix
[ ":", "rtype", ":", "numpy", "matrix" ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tools.py#L132-L137
train
Load data from CSV file into numpy matrix.
thomasdelaet/python-velbus
velbus/messages/blind_status.py
BlindStatusNgMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 7) self.set_attributes(priority, address, rtr) self.channel = self...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 7) self.set_attributes(priority, address, rtr) self.channel = self...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/blind_status.py#L65-L81
train
Populates the object with the data from the server.
thomasdelaet/python-velbus
velbus/messages/blind_status.py
BlindStatusNgMessage.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel json_dict['timeout'] = self.timeout json_dict['status'] = self.status json_dict['led_status'] = self.led_status json_dict['blind_position']...
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel json_dict['timeout'] = self.timeout json_dict['status'] = self.status json_dict['led_status'] = self.led_status json_dict['blind_position']...
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'channel'", "]", "=", "self", ".", "channel", "json_dict", "[", "'timeout'", "]", "=", "self", ".", "timeout", "json_dict", "[", "'statu...
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/blind_status.py#L83-L95
train
Returns a string representation of the object.
thomasdelaet/python-velbus
velbus/messages/blind_status.py
BlindStatusNgMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]), self.timeout, self.status, self.led_status, self.blind_position, self.locked_inhibit_fo...
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]), self.timeout, self.status, self.led_status, self.blind_position, self.locked_inhibit_fo...
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "channels_to_byte", "(", "[", "self", ".", "channel", "]", ")", ",", "self", ".", "timeout", ",", "self", ".", "status", ",", "self", ".", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/blind_status.py#L127-L140
train
Convert the data to binary format.
sontek/bulby
bulby/ssdp.py
discover
def discover(service, timeout=5, retries=5): ''' Discovers services on a network using the SSDP Protocol. ''' group = ('239.255.255.250', 1900) message = '\r\n'.join([ 'M-SEARCH * HTTP/1.1', 'HOST: {0}:{1}', 'MAN: "ssdp:discover"', 'ST: {st}', 'MX: 3', '', '']) so...
python
def discover(service, timeout=5, retries=5): ''' Discovers services on a network using the SSDP Protocol. ''' group = ('239.255.255.250', 1900) message = '\r\n'.join([ 'M-SEARCH * HTTP/1.1', 'HOST: {0}:{1}', 'MAN: "ssdp:discover"', 'ST: {st}', 'MX: 3', '', '']) so...
[ "def", "discover", "(", "service", ",", "timeout", "=", "5", ",", "retries", "=", "5", ")", ":", "group", "=", "(", "'239.255.255.250'", ",", "1900", ")", "message", "=", "'\\r\\n'", ".", "join", "(", "[", "'M-SEARCH * HTTP/1.1'", ",", "'HOST: {0}:{1}'", ...
Discovers services on a network using the SSDP Protocol.
[ "Discovers", "services", "on", "a", "network", "using", "the", "SSDP", "Protocol", "." ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/ssdp.py#L32-L65
train
Discovers services on a network using the SSDP Protocol.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin._isinstance
def _isinstance(self, model, raise_error=True): """Checks if the specified model instance matches the class model. By default this method will raise a `ValueError` if the model is not of expected type. Args: model (Model) : The instance to be type checked raise...
python
def _isinstance(self, model, raise_error=True): """Checks if the specified model instance matches the class model. By default this method will raise a `ValueError` if the model is not of expected type. Args: model (Model) : The instance to be type checked raise...
[ "def", "_isinstance", "(", "self", ",", "model", ",", "raise_error", "=", "True", ")", ":", "rv", "=", "isinstance", "(", "model", ",", "self", ".", "__model__", ")", "if", "not", "rv", "and", "raise_error", ":", "raise", "ValueError", "(", "'%s is not o...
Checks if the specified model instance matches the class model. By default this method will raise a `ValueError` if the model is not of expected type. Args: model (Model) : The instance to be type checked raise_error (bool) : Flag to specify whether to raise error on ...
[ "Checks", "if", "the", "specified", "model", "instance", "matches", "the", "class", "model", ".", "By", "default", "this", "method", "will", "raise", "a", "ValueError", "if", "the", "model", "is", "not", "of", "expected", "type", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L108-L128
train
Checks if the specified model instance matches the class model.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin._preprocess_params
def _preprocess_params(cls, kwargs): """Returns a preprocessed dictionary of parameters. Use this to filter the kwargs passed to `new`, `create`, `build` methods. Args: **kwargs: a dictionary of parameters """ # kwargs.pop('csrf_token', None) for att...
python
def _preprocess_params(cls, kwargs): """Returns a preprocessed dictionary of parameters. Use this to filter the kwargs passed to `new`, `create`, `build` methods. Args: **kwargs: a dictionary of parameters """ # kwargs.pop('csrf_token', None) for att...
[ "def", "_preprocess_params", "(", "cls", ",", "kwargs", ")", ":", "# kwargs.pop('csrf_token', None)", "for", "attr", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "if", "cls", ".", "is_the_primary_key", "(", "attr", ")", "and", "cls", ".", "_pre...
Returns a preprocessed dictionary of parameters. Use this to filter the kwargs passed to `new`, `create`, `build` methods. Args: **kwargs: a dictionary of parameters
[ "Returns", "a", "preprocessed", "dictionary", "of", "parameters", ".", "Use", "this", "to", "filter", "the", "kwargs", "passed", "to", "new", "create", "build", "methods", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L135-L174
train
Returns a preprocessed dictionary of parameters.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.update
def update(self, **kwargs): """Updates an instance. Args: **kwargs : Arbitrary keyword arguments. Column names are keywords and their new values are the values. Examples: >>> customer.update(email="newemail@x.com", name="new") """ kwa...
python
def update(self, **kwargs): """Updates an instance. Args: **kwargs : Arbitrary keyword arguments. Column names are keywords and their new values are the values. Examples: >>> customer.update(email="newemail@x.com", name="new") """ kwa...
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_preprocess_params", "(", "kwargs", ")", "kwargs", "=", "self", ".", "preprocess_kwargs_before_update", "(", "kwargs", ")", "for", "key", ",", "value", "in", "k...
Updates an instance. Args: **kwargs : Arbitrary keyword arguments. Column names are keywords and their new values are the values. Examples: >>> customer.update(email="newemail@x.com", name="new")
[ "Updates", "an", "instance", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L203-L235
train
Updates an instance.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.filter_by
def filter_by(cls, **kwargs): """Same as SQLAlchemy's filter_by. Additionally this accepts two special keyword arguments `limit` and `reverse` for limiting the results and reversing the order respectively. Args: **kwargs: filter parameters Examples: >>...
python
def filter_by(cls, **kwargs): """Same as SQLAlchemy's filter_by. Additionally this accepts two special keyword arguments `limit` and `reverse` for limiting the results and reversing the order respectively. Args: **kwargs: filter parameters Examples: >>...
[ "def", "filter_by", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "limit", "=", "kwargs", ".", "pop", "(", "'limit'", ",", "None", ")", "reverse", "=", "kwargs", ".", "pop", "(", "'reverse'", ",", "False", ")", "q", "=", "cls", ".", "query", "."...
Same as SQLAlchemy's filter_by. Additionally this accepts two special keyword arguments `limit` and `reverse` for limiting the results and reversing the order respectively. Args: **kwargs: filter parameters Examples: >>> user = User.filter_by(email="new@x.com"...
[ "Same", "as", "SQLAlchemy", "s", "filter_by", ".", "Additionally", "this", "accepts", "two", "special", "keyword", "arguments", "limit", "and", "reverse", "for", "limiting", "the", "results", "and", "reversing", "the", "order", "respectively", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L238-L261
train
Same as SQLAlchemy s filter_by. Also this accepts two special keyword arguments limit and reverse for limiting the results and reversing the order respectively.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.count
def count(cls, *criterion, **kwargs): """Returns a count of the instances meeting the specified filter criterion and kwargs. Examples: >>> User.count() 500 >>> User.count(country="India") 300 >>> User.count(User.age > 50, country="I...
python
def count(cls, *criterion, **kwargs): """Returns a count of the instances meeting the specified filter criterion and kwargs. Examples: >>> User.count() 500 >>> User.count(country="India") 300 >>> User.count(User.age > 50, country="I...
[ "def", "count", "(", "cls", ",", "*", "criterion", ",", "*", "*", "kwargs", ")", ":", "if", "criterion", "or", "kwargs", ":", "return", "cls", ".", "filter", "(", "*", "criterion", ",", "*", "*", "kwargs", ")", ".", "count", "(", ")", "else", ":"...
Returns a count of the instances meeting the specified filter criterion and kwargs. Examples: >>> User.count() 500 >>> User.count(country="India") 300 >>> User.count(User.age > 50, country="India") 39
[ "Returns", "a", "count", "of", "the", "instances", "meeting", "the", "specified", "filter", "criterion", "and", "kwargs", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L290-L311
train
Returns a count of the instances meeting the specified filter criterion and kwargs.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.last
def last(cls, *criterion, **kwargs): """Returns the last instance matching the criterion and/or keyword arguments. Examples: last_male_user = User.last(gender="male") """ kwargs['reverse'] = True return cls.first(*criterion, **kwargs)
python
def last(cls, *criterion, **kwargs): """Returns the last instance matching the criterion and/or keyword arguments. Examples: last_male_user = User.last(gender="male") """ kwargs['reverse'] = True return cls.first(*criterion, **kwargs)
[ "def", "last", "(", "cls", ",", "*", "criterion", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'reverse'", "]", "=", "True", "return", "cls", ".", "first", "(", "*", "criterion", ",", "*", "*", "kwargs", ")" ]
Returns the last instance matching the criterion and/or keyword arguments. Examples: last_male_user = User.last(gender="male")
[ "Returns", "the", "last", "instance", "matching", "the", "criterion", "and", "/", "or", "keyword", "arguments", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L359-L368
train
Returns the last user in the hierarchy matching the criterion and or keyword arguments.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.new
def new(cls, **kwargs): """Returns a new, unsaved instance of the model class. """ kwargs = cls.preprocess_kwargs_before_new(kwargs) if cls.__mapper__.polymorphic_on is not None: discriminator_key = cls.__mapper__.polymorphic_on.name discriminator_val = kwargs.ge...
python
def new(cls, **kwargs): """Returns a new, unsaved instance of the model class. """ kwargs = cls.preprocess_kwargs_before_new(kwargs) if cls.__mapper__.polymorphic_on is not None: discriminator_key = cls.__mapper__.polymorphic_on.name discriminator_val = kwargs.ge...
[ "def", "new", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "cls", ".", "preprocess_kwargs_before_new", "(", "kwargs", ")", "if", "cls", ".", "__mapper__", ".", "polymorphic_on", "is", "not", "None", ":", "discriminator_key", "=", "cls", ...
Returns a new, unsaved instance of the model class.
[ "Returns", "a", "new", "unsaved", "instance", "of", "the", "model", "class", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L371-L386
train
Returns a new unsaved instance of the model class.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.add
def add(cls, model, commit=True): """Adds a model instance to session and commits the transaction. Args: model: The instance to add. Examples: >>> customer = Customer.new(name="hari", email="hari@gmail.com") >>> Customer.add(customer) ...
python
def add(cls, model, commit=True): """Adds a model instance to session and commits the transaction. Args: model: The instance to add. Examples: >>> customer = Customer.new(name="hari", email="hari@gmail.com") >>> Customer.add(customer) ...
[ "def", "add", "(", "cls", ",", "model", ",", "commit", "=", "True", ")", ":", "if", "not", "isinstance", "(", "model", ",", "cls", ")", ":", "raise", "ValueError", "(", "'%s is not of type %s'", "%", "(", "model", ",", "cls", ")", ")", "cls", ".", ...
Adds a model instance to session and commits the transaction. Args: model: The instance to add. Examples: >>> customer = Customer.new(name="hari", email="hari@gmail.com") >>> Customer.add(customer) hari@gmail.com
[ "Adds", "a", "model", "instance", "to", "session", "and", "commits", "the", "transaction", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L389-L413
train
Adds a model instance to the session and commits the transaction.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.add_all
def add_all(cls, models, commit=True, check_type=False): """Batch method for adding a list of model instances to the db in one get_or_404. Args: models (list): A list of the instances to add. commit (bool, optional): Defaults to True. If False, the trans...
python
def add_all(cls, models, commit=True, check_type=False): """Batch method for adding a list of model instances to the db in one get_or_404. Args: models (list): A list of the instances to add. commit (bool, optional): Defaults to True. If False, the trans...
[ "def", "add_all", "(", "cls", ",", "models", ",", "commit", "=", "True", ",", "check_type", "=", "False", ")", ":", "if", "check_type", ":", "for", "model", "in", "models", ":", "if", "not", "isinstance", "(", "model", ",", "cls", ")", ":", "raise", ...
Batch method for adding a list of model instances to the db in one get_or_404. Args: models (list): A list of the instances to add. commit (bool, optional): Defaults to True. If False, the transaction won't get committed. check_type (bool, optional) ...
[ "Batch", "method", "for", "adding", "a", "list", "of", "model", "instances", "to", "the", "db", "in", "one", "get_or_404", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L416-L447
train
Batch method for adding a list of models to the db in one get_or_404.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.get
def get(cls, keyval, key='id', user_id=None): """Fetches a single instance which has value `keyval` for the attribute `key`. Args: keyval: The value of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Ret...
python
def get(cls, keyval, key='id', user_id=None): """Fetches a single instance which has value `keyval` for the attribute `key`. Args: keyval: The value of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Ret...
[ "def", "get", "(", "cls", ",", "keyval", ",", "key", "=", "'id'", ",", "user_id", "=", "None", ")", ":", "if", "keyval", "is", "None", ":", "return", "None", "if", "(", "key", "in", "cls", ".", "__table__", ".", "columns", "and", "cls", ".", "__t...
Fetches a single instance which has value `keyval` for the attribute `key`. Args: keyval: The value of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: A model instance if found. Else None. ...
[ "Fetches", "a", "single", "instance", "which", "has", "value", "keyval", "for", "the", "attribute", "key", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L458-L494
train
Fetches a single instance which has value keyval for the attribute key.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.get_all
def get_all(cls, keyvals, key='id', user_id=None): """Works like a map function from keyvals to instances. Args: keyvals(list): The list of values of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: ...
python
def get_all(cls, keyvals, key='id', user_id=None): """Works like a map function from keyvals to instances. Args: keyvals(list): The list of values of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: ...
[ "def", "get_all", "(", "cls", ",", "keyvals", ",", "key", "=", "'id'", ",", "user_id", "=", "None", ")", ":", "if", "len", "(", "keyvals", ")", "==", "0", ":", "return", "[", "]", "original_keyvals", "=", "keyvals", "keyvals_set", "=", "list", "(", ...
Works like a map function from keyvals to instances. Args: keyvals(list): The list of values of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: list: A list of model instances, in the same order ...
[ "Works", "like", "a", "map", "function", "from", "keyvals", "to", "instances", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L497-L537
train
Works like a map function from keyvals to instances.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.create
def create(cls, **kwargs): """Initializes a new instance, adds it to the db and commits the transaction. Args: **kwargs: The keyword arguments for the init constructor. Examples: >>> user = User.create(name="Vicky", email="vicky@h.com") >>> user.id...
python
def create(cls, **kwargs): """Initializes a new instance, adds it to the db and commits the transaction. Args: **kwargs: The keyword arguments for the init constructor. Examples: >>> user = User.create(name="Vicky", email="vicky@h.com") >>> user.id...
[ "def", "create", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "cls", ".", "add", "(", "cls", ".", "new", "(", "*", "*", "kwargs", ")", ")", "except", ":", "cls", ".", "session", ".", "rollback", "(", ")", "raise" ]
Initializes a new instance, adds it to the db and commits the transaction. Args: **kwargs: The keyword arguments for the init constructor. Examples: >>> user = User.create(name="Vicky", email="vicky@h.com") >>> user.id 35
[ "Initializes", "a", "new", "instance", "adds", "it", "to", "the", "db", "and", "commits", "the", "transaction", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L559-L577
train
Initializes a new instance of the class and adds it to the db and commits the transaction.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.find_or_create
def find_or_create(cls, **kwargs): """Checks if an instance already exists by filtering with the kwargs. If yes, returns that instance. If not, creates a new instance with kwargs and returns it Args: **kwargs: The keyword arguments which are used for filtering ...
python
def find_or_create(cls, **kwargs): """Checks if an instance already exists by filtering with the kwargs. If yes, returns that instance. If not, creates a new instance with kwargs and returns it Args: **kwargs: The keyword arguments which are used for filtering ...
[ "def", "find_or_create", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "keys", "=", "kwargs", ".", "pop", "(", "'keys'", ")", "if", "'keys'", "in", "kwargs", "else", "[", "]", "return", "cls", ".", "first", "(", "*", "*", "subdict", "(", "kwargs",...
Checks if an instance already exists by filtering with the kwargs. If yes, returns that instance. If not, creates a new instance with kwargs and returns it Args: **kwargs: The keyword arguments which are used for filtering and initialization. keys(list, ...
[ "Checks", "if", "an", "instance", "already", "exists", "by", "filtering", "with", "the", "kwargs", ".", "If", "yes", "returns", "that", "instance", ".", "If", "not", "creates", "a", "new", "instance", "with", "kwargs", "and", "returns", "it" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L580-L615
train
Checks if an instance already exists by filtering with the kwargs and creates a new one if not. Returns None if no instance is found.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.update_or_create
def update_or_create(cls, **kwargs): """Checks if an instance already exists by filtering with the kwargs. If yes, updates the instance with new kwargs and returns that instance. If not, creates a new instance with kwargs and returns it. Args: **kwargs: The keyword ...
python
def update_or_create(cls, **kwargs): """Checks if an instance already exists by filtering with the kwargs. If yes, updates the instance with new kwargs and returns that instance. If not, creates a new instance with kwargs and returns it. Args: **kwargs: The keyword ...
[ "def", "update_or_create", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "keys", "=", "kwargs", ".", "pop", "(", "'keys'", ")", "if", "'keys'", "in", "kwargs", "else", "[", "]", "filter_kwargs", "=", "subdict", "(", "kwargs", ",", "keys", ")", "if",...
Checks if an instance already exists by filtering with the kwargs. If yes, updates the instance with new kwargs and returns that instance. If not, creates a new instance with kwargs and returns it. Args: **kwargs: The keyword arguments which are used for filtering ...
[ "Checks", "if", "an", "instance", "already", "exists", "by", "filtering", "with", "the", "kwargs", ".", "If", "yes", "updates", "the", "instance", "with", "new", "kwargs", "and", "returns", "that", "instance", ".", "If", "not", "creates", "a", "new", "inst...
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L671-L725
train
Checks if an instance already exists by filtering with the kwargs and creates a new one.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.create_all
def create_all(cls, list_of_kwargs): """Batch method for creating a list of instances Args: list_of_kwargs(list of dicts): hereA list of dicts where each dict denotes the keyword args that you would pass to the create method separately Examples: ...
python
def create_all(cls, list_of_kwargs): """Batch method for creating a list of instances Args: list_of_kwargs(list of dicts): hereA list of dicts where each dict denotes the keyword args that you would pass to the create method separately Examples: ...
[ "def", "create_all", "(", "cls", ",", "list_of_kwargs", ")", ":", "try", ":", "return", "cls", ".", "add_all", "(", "[", "cls", ".", "new", "(", "*", "*", "kwargs", ")", "if", "kwargs", "is", "not", "None", "else", "None", "for", "kwargs", "in", "l...
Batch method for creating a list of instances Args: list_of_kwargs(list of dicts): hereA list of dicts where each dict denotes the keyword args that you would pass to the create method separately Examples: >>> Customer.create_all([ ....
[ "Batch", "method", "for", "creating", "a", "list", "of", "instances" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L728-L747
train
Batch method for creating a list of instances of the specified class.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.find_or_create_all
def find_or_create_all(cls, list_of_kwargs, keys=[]): """Batch method for querying for a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass ...
python
def find_or_create_all(cls, list_of_kwargs, keys=[]): """Batch method for querying for a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass ...
[ "def", "find_or_create_all", "(", "cls", ",", "list_of_kwargs", ",", "keys", "=", "[", "]", ")", ":", "list_of_kwargs_wo_dupes", ",", "markers", "=", "remove_and_mark_duplicate_dicts", "(", "list_of_kwargs", ",", "keys", ")", "added_objs", "=", "cls", ".", "add_...
Batch method for querying for a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass to the create method separately keys (list, optional...
[ "Batch", "method", "for", "querying", "for", "a", "list", "of", "instances", "and", "creating", "them", "if", "required" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L750-L783
train
Batch method for querying for a list of instances and a list of instances and their related objects.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.update_or_create_all
def update_or_create_all(cls, list_of_kwargs, keys=[]): """Batch method for updating a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass to...
python
def update_or_create_all(cls, list_of_kwargs, keys=[]): """Batch method for updating a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass to...
[ "def", "update_or_create_all", "(", "cls", ",", "list_of_kwargs", ",", "keys", "=", "[", "]", ")", ":", "objs", "=", "[", "]", "for", "kwargs", "in", "list_of_kwargs", ":", "filter_kwargs", "=", "subdict", "(", "kwargs", ",", "keys", ")", "if", "filter_k...
Batch method for updating a list of instances and creating them if required Args: list_of_kwargs(list of dicts): A list of dicts where each dict denotes the keyword args that you would pass to the create method separately keys (list, optional): A...
[ "Batch", "method", "for", "updating", "a", "list", "of", "instances", "and", "creating", "them", "if", "required" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L786-L825
train
Batch method for updating a list of instances and a list of attributes that are not already present in the database. This method is used to update a list of instances and a list of attributes that are not present in the database.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.build
def build(cls, **kwargs): """Similar to create. But the transaction is not committed Args: **kwargs : The keyword arguments for the constructor Returns: A model instance which has been added to db session. But session transaction has not been committed yet...
python
def build(cls, **kwargs): """Similar to create. But the transaction is not committed Args: **kwargs : The keyword arguments for the constructor Returns: A model instance which has been added to db session. But session transaction has not been committed yet...
[ "def", "build", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "return", "cls", ".", "add", "(", "cls", ".", "new", "(", "*", "*", "kwargs", ")", ",", "commit", "=", "False", ")" ]
Similar to create. But the transaction is not committed Args: **kwargs : The keyword arguments for the constructor Returns: A model instance which has been added to db session. But session transaction has not been committed yet.
[ "Similar", "to", "create", ".", "But", "the", "transaction", "is", "not", "committed" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L870-L882
train
Similar to create but the transaction is not committed.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.find_or_build
def find_or_build(cls, **kwargs): """Checks if an instance already exists in db with these kwargs else returns a new, saved instance of the service's model class. Args: **kwargs: instance parameters """ keys = kwargs.pop('keys') if 'keys' in kwargs else [] re...
python
def find_or_build(cls, **kwargs): """Checks if an instance already exists in db with these kwargs else returns a new, saved instance of the service's model class. Args: **kwargs: instance parameters """ keys = kwargs.pop('keys') if 'keys' in kwargs else [] re...
[ "def", "find_or_build", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "keys", "=", "kwargs", ".", "pop", "(", "'keys'", ")", "if", "'keys'", "in", "kwargs", "else", "[", "]", "return", "cls", ".", "first", "(", "*", "*", "subdict", "(", "kwargs", ...
Checks if an instance already exists in db with these kwargs else returns a new, saved instance of the service's model class. Args: **kwargs: instance parameters
[ "Checks", "if", "an", "instance", "already", "exists", "in", "db", "with", "these", "kwargs", "else", "returns", "a", "new", "saved", "instance", "of", "the", "service", "s", "model", "class", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L885-L893
train
Checks if an instance already exists in db with these kwargs else returns a new saved instance of the service s model class.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.build_all
def build_all(cls, list_of_kwargs): """Similar to `create_all`. But transaction is not committed. """ return cls.add_all([ cls.new(**kwargs) for kwargs in list_of_kwargs], commit=False)
python
def build_all(cls, list_of_kwargs): """Similar to `create_all`. But transaction is not committed. """ return cls.add_all([ cls.new(**kwargs) for kwargs in list_of_kwargs], commit=False)
[ "def", "build_all", "(", "cls", ",", "list_of_kwargs", ")", ":", "return", "cls", ".", "add_all", "(", "[", "cls", ".", "new", "(", "*", "*", "kwargs", ")", "for", "kwargs", "in", "list_of_kwargs", "]", ",", "commit", "=", "False", ")" ]
Similar to `create_all`. But transaction is not committed.
[ "Similar", "to", "create_all", ".", "But", "transaction", "is", "not", "committed", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L909-L913
train
Similar to create_all but commit is not committed.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.find_or_build_all
def find_or_build_all(cls, list_of_kwargs): """Similar to `find_or_create_all`. But transaction is not committed. """ return cls.add_all([cls.first(**kwargs) or cls.new(**kwargs) for kwargs in list_of_kwargs], commit=False)
python
def find_or_build_all(cls, list_of_kwargs): """Similar to `find_or_create_all`. But transaction is not committed. """ return cls.add_all([cls.first(**kwargs) or cls.new(**kwargs) for kwargs in list_of_kwargs], commit=False)
[ "def", "find_or_build_all", "(", "cls", ",", "list_of_kwargs", ")", ":", "return", "cls", ".", "add_all", "(", "[", "cls", ".", "first", "(", "*", "*", "kwargs", ")", "or", "cls", ".", "new", "(", "*", "*", "kwargs", ")", "for", "kwargs", "in", "li...
Similar to `find_or_create_all`. But transaction is not committed.
[ "Similar", "to", "find_or_create_all", ".", "But", "transaction", "is", "not", "committed", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L916-L920
train
Similar to find_or_create_all but commit is not committed.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.update_all
def update_all(cls, *criterion, **kwargs): """Batch method for updating all instances obeying the criterion Args: *criterion: SQLAlchemy query criterion for filtering what instances to update **kwargs: The parameters to be updated Examples: ...
python
def update_all(cls, *criterion, **kwargs): """Batch method for updating all instances obeying the criterion Args: *criterion: SQLAlchemy query criterion for filtering what instances to update **kwargs: The parameters to be updated Examples: ...
[ "def", "update_all", "(", "cls", ",", "*", "criterion", ",", "*", "*", "kwargs", ")", ":", "try", ":", "r", "=", "cls", ".", "query", ".", "filter", "(", "*", "criterion", ")", ".", "update", "(", "kwargs", ",", "'fetch'", ")", "cls", ".", "sessi...
Batch method for updating all instances obeying the criterion Args: *criterion: SQLAlchemy query criterion for filtering what instances to update **kwargs: The parameters to be updated Examples: >>> User.update_all(active=True) >>> Cust...
[ "Batch", "method", "for", "updating", "all", "instances", "obeying", "the", "criterion" ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L923-L946
train
Batch method for updating all instances obeying the criterion
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.get_and_update
def get_and_update(cls, id, **kwargs): """Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters """ model = cls.get(id) for k, v in cls._preprocess_params(kwargs).items(): setatt...
python
def get_and_update(cls, id, **kwargs): """Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters """ model = cls.get(id) for k, v in cls._preprocess_params(kwargs).items(): setatt...
[ "def", "get_and_update", "(", "cls", ",", "id", ",", "*", "*", "kwargs", ")", ":", "model", "=", "cls", ".", "get", "(", "id", ")", "for", "k", ",", "v", "in", "cls", ".", "_preprocess_params", "(", "kwargs", ")", ".", "items", "(", ")", ":", "...
Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters
[ "Returns", "an", "updated", "instance", "of", "the", "service", "s", "model", "class", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L949-L960
train
Returns an updated instance of the service s model class.
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
QueryableMixin.get_and_setattr
def get_and_setattr(cls, id, **kwargs): """Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters """ model = cls.get(id) for k, v in cls._preprocess_params(kwargs).items(): setat...
python
def get_and_setattr(cls, id, **kwargs): """Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters """ model = cls.get(id) for k, v in cls._preprocess_params(kwargs).items(): setat...
[ "def", "get_and_setattr", "(", "cls", ",", "id", ",", "*", "*", "kwargs", ")", ":", "model", "=", "cls", ".", "get", "(", "id", ")", "for", "k", ",", "v", "in", "cls", ".", "_preprocess_params", "(", "kwargs", ")", ".", "items", "(", ")", ":", ...
Returns an updated instance of the service's model class. Args: model: the model to update **kwargs: update parameters
[ "Returns", "an", "updated", "instance", "of", "the", "service", "s", "model", "class", "." ]
444048d167ab7718f758e943665ef32d101423a5
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L963-L973
train
Returns an updated instance of the service s model class with the specified id and sets the attributes of the model class with the given kwargs.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/peakdelta.py
peakdelta
def peakdelta(v, delta, x=None): """ Returns two arrays function [maxtab, mintab]=peakdelta(v, delta, x) %PEAKDET Detect peaks in a vector % [MAXTAB, MINTAB] = peakdelta(V, DELTA) finds the local % maxima and minima ("peaks") in the vector V. % MAXTAB and MINTAB consist...
python
def peakdelta(v, delta, x=None): """ Returns two arrays function [maxtab, mintab]=peakdelta(v, delta, x) %PEAKDET Detect peaks in a vector % [MAXTAB, MINTAB] = peakdelta(V, DELTA) finds the local % maxima and minima ("peaks") in the vector V. % MAXTAB and MINTAB consist...
[ "def", "peakdelta", "(", "v", ",", "delta", ",", "x", "=", "None", ")", ":", "maxtab", "=", "[", "]", "mintab", "=", "[", "]", "if", "x", "is", "None", ":", "x", "=", "arange", "(", "len", "(", "v", ")", ")", "v", "=", "asarray", "(", "v", ...
Returns two arrays function [maxtab, mintab]=peakdelta(v, delta, x) %PEAKDET Detect peaks in a vector % [MAXTAB, MINTAB] = peakdelta(V, DELTA) finds the local % maxima and minima ("peaks") in the vector V. % MAXTAB and MINTAB consists of two columns. Column 1 % conta...
[ "Returns", "two", "arrays" ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/peakdelta.py#L15-L81
train
This function returns a new array where the values in v are at least delta and the values in x are at the same time.
thomasdelaet/python-velbus
velbus/messages/start_relay_blinking_timer.py
StartRelayBlinkingTimerMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_high_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self.relay_channel...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_high_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self.relay_channel...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_high_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr",...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/start_relay_blinking_timer.py#L28-L38
train
Populates the object with the data from the specified protocol buffer.
thomasdelaet/python-velbus
velbus/messages/start_relay_blinking_timer.py
StartRelayBlinkingTimerMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte(self.relay_channels)]) + \ struct.pack('>L', self.delay_time)[-3:]
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte(self.relay_channels)]) + \ struct.pack('>L', self.delay_time)[-3:]
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "channels_to_byte", "(", "self", ".", "relay_channels", ")", "]", ")", "+", "struct", ".", "pack", "(", "'>L'", ",", "self", ".", "delay_time",...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/start_relay_blinking_timer.py#L40-L47
train
Converts the data to binary format.
thomasdelaet/python-velbus
velbus/modules/vmbpbn.py
VMB2PBNModule.on_status_update
def on_status_update(self, channel, callback): """ Callback to execute on status of update of channel """ if channel not in self._callbacks: self._callbacks[channel] = [] self._callbacks[channel].append(callback)
python
def on_status_update(self, channel, callback): """ Callback to execute on status of update of channel """ if channel not in self._callbacks: self._callbacks[channel] = [] self._callbacks[channel].append(callback)
[ "def", "on_status_update", "(", "self", ",", "channel", ",", "callback", ")", ":", "if", "channel", "not", "in", "self", ".", "_callbacks", ":", "self", ".", "_callbacks", "[", "channel", "]", "=", "[", "]", "self", ".", "_callbacks", "[", "channel", "...
Callback to execute on status of update of channel
[ "Callback", "to", "execute", "on", "status", "of", "update", "of", "channel" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/modules/vmbpbn.py#L46-L52
train
Callback to execute when status of a specific resource is updated
thomasdelaet/python-velbus
velbus/messages/memory_data_block.py
MemoryDataBlockMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.high_address, self.low_address ]) + self.data
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.high_address, self.low_address ]) + self.data
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "high_address", ",", "self", ".", "low_address", "]", ")", "+", "self", ".", "data" ]
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/memory_data_block.py#L35-L43
train
Convert the data to binary format.
KE-works/pykechain
pykechain/utils.py
temp_chdir
def temp_chdir(cwd=None): """ Create and return a temporary directory which you can use as a context manager. When you are out of the context the temprorary disk gets erased. .. versionadded:: 2.3 :param cwd: path to change working directory back to path when out of context :type cwd: basestr...
python
def temp_chdir(cwd=None): """ Create and return a temporary directory which you can use as a context manager. When you are out of the context the temprorary disk gets erased. .. versionadded:: 2.3 :param cwd: path to change working directory back to path when out of context :type cwd: basestr...
[ "def", "temp_chdir", "(", "cwd", "=", "None", ")", ":", "if", "six", ".", "PY3", ":", "from", "tempfile", "import", "TemporaryDirectory", "with", "TemporaryDirectory", "(", ")", "as", "tempwd", ":", "origin", "=", "cwd", "or", "os", ".", "getcwd", "(", ...
Create and return a temporary directory which you can use as a context manager. When you are out of the context the temprorary disk gets erased. .. versionadded:: 2.3 :param cwd: path to change working directory back to path when out of context :type cwd: basestring or None :return: in context a ...
[ "Create", "and", "return", "a", "temporary", "directory", "which", "you", "can", "use", "as", "a", "context", "manager", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/utils.py#L42-L83
train
Create and return a temporary directory which you can use as a context manager.
KE-works/pykechain
pykechain/utils.py
parse_datetime
def parse_datetime(value): """ Convert datetime string to datetime object. Helper function to convert a datetime string found in json responses to a datetime object with timezone information. The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When ...
python
def parse_datetime(value): """ Convert datetime string to datetime object. Helper function to convert a datetime string found in json responses to a datetime object with timezone information. The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When ...
[ "def", "parse_datetime", "(", "value", ")", ":", "if", "value", "is", "None", ":", "# do not process the value", "return", "None", "def", "_get_fixed_timezone", "(", "offset", ")", ":", "\"\"\"Return a tzinfo instance with a fixed offset from UTC.\"\"\"", "if", "isinstanc...
Convert datetime string to datetime object. Helper function to convert a datetime string found in json responses to a datetime object with timezone information. The server is storing all datetime strings as UTC (ZULU time). This function supports time zone offsets. When the input contains one, the output u...
[ "Convert", "datetime", "string", "to", "datetime", "object", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/utils.py#L86-L144
train
Convert a datetime string found in json responses to a datetime object.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization._save_customization
def _save_customization(self, widgets): """ Save the complete customization to the activity. :param widgets: The complete set of widgets to be customized """ if len(widgets) > 0: # Get the current customization and only replace the 'ext' part of it custom...
python
def _save_customization(self, widgets): """ Save the complete customization to the activity. :param widgets: The complete set of widgets to be customized """ if len(widgets) > 0: # Get the current customization and only replace the 'ext' part of it custom...
[ "def", "_save_customization", "(", "self", ",", "widgets", ")", ":", "if", "len", "(", "widgets", ")", ">", "0", ":", "# Get the current customization and only replace the 'ext' part of it", "customization", "=", "self", ".", "activity", ".", "_json_data", ".", "get...
Save the complete customization to the activity. :param widgets: The complete set of widgets to be customized
[ "Save", "the", "complete", "customization", "to", "the", "activity", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L96-L126
train
Save the complete customization to the activity.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization._add_widget
def _add_widget(self, widget): """ Add a widget to the customization. Will save the widget to KE-chain. :param widget: The widget (specific json dict) to be added :type widget: dict """ widgets = self.widgets() widgets += [widget] self._save_cust...
python
def _add_widget(self, widget): """ Add a widget to the customization. Will save the widget to KE-chain. :param widget: The widget (specific json dict) to be added :type widget: dict """ widgets = self.widgets() widgets += [widget] self._save_cust...
[ "def", "_add_widget", "(", "self", ",", "widget", ")", ":", "widgets", "=", "self", ".", "widgets", "(", ")", "widgets", "+=", "[", "widget", "]", "self", ".", "_save_customization", "(", "widgets", ")" ]
Add a widget to the customization. Will save the widget to KE-chain. :param widget: The widget (specific json dict) to be added :type widget: dict
[ "Add", "a", "widget", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L128-L139
train
Add a widget to the KE - chain.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.widgets
def widgets(self): """ Get the Ext JS specific customization from the activity. :return: The Ext JS specific customization in `list(dict)` form """ customization = self.activity._json_data.get('customization') if customization and "ext" in customization.keys(): ...
python
def widgets(self): """ Get the Ext JS specific customization from the activity. :return: The Ext JS specific customization in `list(dict)` form """ customization = self.activity._json_data.get('customization') if customization and "ext" in customization.keys(): ...
[ "def", "widgets", "(", "self", ")", ":", "customization", "=", "self", ".", "activity", ".", "_json_data", ".", "get", "(", "'customization'", ")", "if", "customization", "and", "\"ext\"", "in", "customization", ".", "keys", "(", ")", ":", "return", "custo...
Get the Ext JS specific customization from the activity. :return: The Ext JS specific customization in `list(dict)` form
[ "Get", "the", "Ext", "JS", "specific", "customization", "from", "the", "activity", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L141-L152
train
Get the Ext JS specific customization from the activity.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.delete_widget
def delete_widget(self, index): """ Delete widgets by index. The widgets are saved to KE-chain. :param index: The index of the widget to be deleted in the self.widgets :type index: int :raises ValueError: if the customization has no widgets """ widgets =...
python
def delete_widget(self, index): """ Delete widgets by index. The widgets are saved to KE-chain. :param index: The index of the widget to be deleted in the self.widgets :type index: int :raises ValueError: if the customization has no widgets """ widgets =...
[ "def", "delete_widget", "(", "self", ",", "index", ")", ":", "widgets", "=", "self", ".", "widgets", "(", ")", "if", "len", "(", "widgets", ")", "==", "0", ":", "raise", "ValueError", "(", "\"This customization has no widgets\"", ")", "widgets", ".", "pop"...
Delete widgets by index. The widgets are saved to KE-chain. :param index: The index of the widget to be deleted in the self.widgets :type index: int :raises ValueError: if the customization has no widgets
[ "Delete", "widgets", "by", "index", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L154-L168
train
Delete a widget by index.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_json_widget
def add_json_widget(self, config): """ Add an Ext Json Widget to the customization. The configuration json provided must be interpretable by KE-chain. The json will be validated against the widget json schema. The widget will be saved to KE-chain. :param config: The js...
python
def add_json_widget(self, config): """ Add an Ext Json Widget to the customization. The configuration json provided must be interpretable by KE-chain. The json will be validated against the widget json schema. The widget will be saved to KE-chain. :param config: The js...
[ "def", "add_json_widget", "(", "self", ",", "config", ")", ":", "validate", "(", "config", ",", "component_jsonwidget_schema", ")", "self", ".", "_add_widget", "(", "dict", "(", "config", "=", "config", ",", "name", "=", "WidgetNames", ".", "JSONWIDGET", ")"...
Add an Ext Json Widget to the customization. The configuration json provided must be interpretable by KE-chain. The json will be validated against the widget json schema. The widget will be saved to KE-chain. :param config: The json configuration of the widget :type config: di...
[ "Add", "an", "Ext", "Json", "Widget", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L177-L190
train
Add an Ext Json Widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_property_grid_widget
def add_property_grid_widget(self, part_instance, max_height=None, custom_title=False, show_headers=True, show_columns=None): """ Add a KE-chain Property Grid widget to the customization. The widget will be saved to KE-chain. :param part_instance: The p...
python
def add_property_grid_widget(self, part_instance, max_height=None, custom_title=False, show_headers=True, show_columns=None): """ Add a KE-chain Property Grid widget to the customization. The widget will be saved to KE-chain. :param part_instance: The p...
[ "def", "add_property_grid_widget", "(", "self", ",", "part_instance", ",", "max_height", "=", "None", ",", "custom_title", "=", "False", ",", "show_headers", "=", "True", ",", "show_columns", "=", "None", ")", ":", "height", "=", "max_height", "# Check whether t...
Add a KE-chain Property Grid widget to the customization. The widget will be saved to KE-chain. :param part_instance: The part instance on which the property grid will be based :type part_instance: :class:`Part` or UUID :param max_height: The max height of the property grid in pixels ...
[ "Add", "a", "KE", "-", "chain", "Property", "Grid", "widget", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L360-L450
train
Adds a KE - chain Property Grid widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_text_widget
def add_text_widget(self, text=None, custom_title=None, collapsible=True, collapsed=False): """ Add a KE-chain Text widget to the customization. The widget will be saved to KE-chain. :param text: The text that will be shown by the widget. :type text: basestring or None ...
python
def add_text_widget(self, text=None, custom_title=None, collapsible=True, collapsed=False): """ Add a KE-chain Text widget to the customization. The widget will be saved to KE-chain. :param text: The text that will be shown by the widget. :type text: basestring or None ...
[ "def", "add_text_widget", "(", "self", ",", "text", "=", "None", ",", "custom_title", "=", "None", ",", "collapsible", "=", "True", ",", "collapsed", "=", "False", ")", ":", "# Declare text widget config", "config", "=", "{", "\"xtype\"", ":", "ComponentXType"...
Add a KE-chain Text widget to the customization. The widget will be saved to KE-chain. :param text: The text that will be shown by the widget. :type text: basestring or None :param custom_title: A custom title for the text panel:: * None (default): No title * St...
[ "Add", "a", "KE", "-", "chain", "Text", "widget", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L452-L504
train
Adds a KE - chain Text widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_paginated_grid_widget
def add_paginated_grid_widget(self, part_model, delete=False, edit=True, export=True, clone=True, new_instance=False, parent_part_instance=None, max_height=None, custom_title=False, emphasize_edit=False, emphasize_clone=False, emphasize_new_instance=Tr...
python
def add_paginated_grid_widget(self, part_model, delete=False, edit=True, export=True, clone=True, new_instance=False, parent_part_instance=None, max_height=None, custom_title=False, emphasize_edit=False, emphasize_clone=False, emphasize_new_instance=Tr...
[ "def", "add_paginated_grid_widget", "(", "self", ",", "part_model", ",", "delete", "=", "False", ",", "edit", "=", "True", ",", "export", "=", "True", ",", "clone", "=", "True", ",", "new_instance", "=", "False", ",", "parent_part_instance", "=", "None", "...
Add a KE-chain paginatedGrid (e.g. paginated table widget) to the customization. The widget will be saved to KE-chain. :param emphasize_new_instance: Emphasize the New instance button (default True) :type emphasize_new_instance: bool :param emphasize_edit: Emphasize the Edit button (de...
[ "Add", "a", "KE", "-", "chain", "paginatedGrid", "(", "e", ".", "g", ".", "paginated", "table", "widget", ")", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L506-L682
train
Add a paginated grid widget to the KE - chain.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_script_widget
def add_script_widget(self, script, custom_title=False, custom_button_text=False, emphasize_run=True, download_log=False): """ Add a KE-chain Script (e.g. script widget) to the customization. The widget will be saved to KE-chain. :param script: The Script to w...
python
def add_script_widget(self, script, custom_title=False, custom_button_text=False, emphasize_run=True, download_log=False): """ Add a KE-chain Script (e.g. script widget) to the customization. The widget will be saved to KE-chain. :param script: The Script to w...
[ "def", "add_script_widget", "(", "self", ",", "script", ",", "custom_title", "=", "False", ",", "custom_button_text", "=", "False", ",", "emphasize_run", "=", "True", ",", "download_log", "=", "False", ")", ":", "# Check whether the script is uuid type or class `Servi...
Add a KE-chain Script (e.g. script widget) to the customization. The widget will be saved to KE-chain. :param script: The Script to which the button will be coupled and will be ran when the button is pressed. :type script: :class:`Service` or UUID :param custom_title: A custom title fo...
[ "Add", "a", "KE", "-", "chain", "Script", "(", "e", ".", "g", ".", "script", "widget", ")", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L684-L766
train
Adds a KE - chain Script widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_notebook_widget
def add_notebook_widget(self, notebook, custom_title=False, height=None): """ Add a KE-chain Notebook (e.g. notebook widget) to the customization. The widget will be saved to KE-chain. :param notebook: The Notebook to which the button will be coupled and will start when the button is p...
python
def add_notebook_widget(self, notebook, custom_title=False, height=None): """ Add a KE-chain Notebook (e.g. notebook widget) to the customization. The widget will be saved to KE-chain. :param notebook: The Notebook to which the button will be coupled and will start when the button is p...
[ "def", "add_notebook_widget", "(", "self", ",", "notebook", ",", "custom_title", "=", "False", ",", "height", "=", "None", ")", ":", "# Check whether the script is uuid type or class `Service`", "if", "isinstance", "(", "notebook", ",", "Service", ")", ":", "noteboo...
Add a KE-chain Notebook (e.g. notebook widget) to the customization. The widget will be saved to KE-chain. :param notebook: The Notebook to which the button will be coupled and will start when the button is pressed. :type notebook: :class:`Service` or UUID :param custom_title: A custom...
[ "Add", "a", "KE", "-", "chain", "Notebook", "(", "e", ".", "g", ".", "notebook", "widget", ")", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L768-L823
train
Adds a KE - chain Notebook widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_attachment_viewer_widget
def add_attachment_viewer_widget(self, attachment_property, custom_title=False, height=None): """ Add a KE-chain Attachment Viewer (e.g. attachment viewer widget) to the customization. The widget will be saved to KE-chain. :param attachment_property: The Attachment Property to which th...
python
def add_attachment_viewer_widget(self, attachment_property, custom_title=False, height=None): """ Add a KE-chain Attachment Viewer (e.g. attachment viewer widget) to the customization. The widget will be saved to KE-chain. :param attachment_property: The Attachment Property to which th...
[ "def", "add_attachment_viewer_widget", "(", "self", ",", "attachment_property", ",", "custom_title", "=", "False", ",", "height", "=", "None", ")", ":", "# Check whether the attachment property is uuid type or class `Property`", "if", "isinstance", "(", "attachment_property",...
Add a KE-chain Attachment Viewer (e.g. attachment viewer widget) to the customization. The widget will be saved to KE-chain. :param attachment_property: The Attachment Property to which the Viewer will be connected to. :type attachment_property: :class:`Property` or UUID :param custom_...
[ "Add", "a", "KE", "-", "chain", "Attachment", "Viewer", "(", "e", ".", "g", ".", "attachment", "viewer", "widget", ")", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L825-L896
train
Adds a KE - chain Attachment Viewer widget to the customization.
KE-works/pykechain
pykechain/models/customization.py
ExtCustomization.add_navigation_bar_widget
def add_navigation_bar_widget(self, activities, alignment=NavigationBarAlignment.CENTER): """ Add a KE-chain Navigation Bar (e.g. navigation bar widget) to the customization. The widget will be saved to KE-chain. :param activities: List of activities. Each activity must be a Python dic...
python
def add_navigation_bar_widget(self, activities, alignment=NavigationBarAlignment.CENTER): """ Add a KE-chain Navigation Bar (e.g. navigation bar widget) to the customization. The widget will be saved to KE-chain. :param activities: List of activities. Each activity must be a Python dic...
[ "def", "add_navigation_bar_widget", "(", "self", ",", "activities", ",", "alignment", "=", "NavigationBarAlignment", ".", "CENTER", ")", ":", "# Loop through the list of activities", "set_of_expected_keys", "=", "{", "'activityId'", ",", "'customText'", ",", "'emphasize'"...
Add a KE-chain Navigation Bar (e.g. navigation bar widget) to the customization. The widget will be saved to KE-chain. :param activities: List of activities. Each activity must be a Python dict(), with the following keys: * customText: A custom text for each button in the attachment viewer...
[ "Add", "a", "KE", "-", "chain", "Navigation", "Bar", "(", "e", ".", "g", ".", "navigation", "bar", "widget", ")", "to", "the", "customization", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L898-L960
train
Adds a KE - chain navigation bar widget to the customization.
thomasdelaet/python-velbus
velbus/messages/bus_error_counter_status.py
BusErrorCounterStatusMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 3) self.transmit_error_counter = data[0] self.receive_error_counte...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 3) self.transmit_error_counter = data[0] self.receive_error_counte...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/bus_error_counter_status.py#L22-L32
train
Populates the internal state of the object with the data from the server.
thomasdelaet/python-velbus
velbus/messages/bus_error_counter_status.py
BusErrorCounterStatusMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([COMMAND_CODE, self.transmit_error_counter, self.receive_error_counter, self.bus_off_counter])
python
def data_to_binary(self): """ :return: bytes """ return bytes([COMMAND_CODE, self.transmit_error_counter, self.receive_error_counter, self.bus_off_counter])
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "transmit_error_counter", ",", "self", ".", "receive_error_counter", ",", "self", ".", "bus_off_counter", "]", ")" ]
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/bus_error_counter_status.py#L34-L39
train
Convert the data to binary format.
lobocv/crashreporter
crashreporter/process.py
enable_mp_crash_reporting
def enable_mp_crash_reporting(): """ Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess. Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead. This function must be called before any imports to mulitprocessing in order for the mon...
python
def enable_mp_crash_reporting(): """ Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess. Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead. This function must be called before any imports to mulitprocessing in order for the mon...
[ "def", "enable_mp_crash_reporting", "(", ")", ":", "global", "mp_crash_reporting_enabled", "multiprocessing", ".", "Process", "=", "multiprocessing", ".", "process", ".", "Process", "=", "CrashReportingProcess", "mp_crash_reporting_enabled", "=", "True" ]
Monkey-patch the multiprocessing.Process class with our own CrashReportingProcess. Any subsequent imports of multiprocessing.Process will reference CrashReportingProcess instead. This function must be called before any imports to mulitprocessing in order for the monkey-patching to work.
[ "Monkey", "-", "patch", "the", "multiprocessing", ".", "Process", "class", "with", "our", "own", "CrashReportingProcess", ".", "Any", "subsequent", "imports", "of", "multiprocessing", ".", "Process", "will", "reference", "CrashReportingProcess", "instead", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/process.py#L11-L20
train
Monkey - patch multiprocessing. Process with our own CrashReportingProcess.
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.feed
def feed(self, data): """ Add new incoming data to buffer and try to process """ self.buffer += data while len(self.buffer) >= 6: self.next_packet()
python
def feed(self, data): """ Add new incoming data to buffer and try to process """ self.buffer += data while len(self.buffer) >= 6: self.next_packet()
[ "def", "feed", "(", "self", ",", "data", ")", ":", "self", ".", "buffer", "+=", "data", "while", "len", "(", "self", ".", "buffer", ")", ">=", "6", ":", "self", ".", "next_packet", "(", ")" ]
Add new incoming data to buffer and try to process
[ "Add", "new", "incoming", "data", "to", "buffer", "and", "try", "to", "process" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L26-L32
train
Feed data into the internal buffer.
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.valid_header_waiting
def valid_header_waiting(self): """ Check if a valid header is waiting in buffer """ if len(self.buffer) < 4: self.logger.debug("Buffer does not yet contain full header") result = False else: result = True result = result and self.b...
python
def valid_header_waiting(self): """ Check if a valid header is waiting in buffer """ if len(self.buffer) < 4: self.logger.debug("Buffer does not yet contain full header") result = False else: result = True result = result and self.b...
[ "def", "valid_header_waiting", "(", "self", ")", ":", "if", "len", "(", "self", ".", "buffer", ")", "<", "4", ":", "self", ".", "logger", ".", "debug", "(", "\"Buffer does not yet contain full header\"", ")", "result", "=", "False", "else", ":", "result", ...
Check if a valid header is waiting in buffer
[ "Check", "if", "a", "valid", "header", "is", "waiting", "in", "buffer" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L34-L53
train
Check if a valid header is waiting in buffer
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.valid_body_waiting
def valid_body_waiting(self): """ Check if a valid body is waiting in buffer """ # 0f f8 be 04 00 08 00 00 2f 04 packet_size = velbus.MINIMUM_MESSAGE_SIZE + \ (self.buffer[3] & 0x0F) if len(self.buffer) < packet_size: self.logger.debug("Buffer does...
python
def valid_body_waiting(self): """ Check if a valid body is waiting in buffer """ # 0f f8 be 04 00 08 00 00 2f 04 packet_size = velbus.MINIMUM_MESSAGE_SIZE + \ (self.buffer[3] & 0x0F) if len(self.buffer) < packet_size: self.logger.debug("Buffer does...
[ "def", "valid_body_waiting", "(", "self", ")", ":", "# 0f f8 be 04 00 08 00 00 2f 04", "packet_size", "=", "velbus", ".", "MINIMUM_MESSAGE_SIZE", "+", "(", "self", ".", "buffer", "[", "3", "]", "&", "0x0F", ")", "if", "len", "(", "self", ".", "buffer", ")", ...
Check if a valid body is waiting in buffer
[ "Check", "if", "a", "valid", "body", "is", "waiting", "in", "buffer" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L55-L75
train
Check if a valid body is waiting in buffer.
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.next_packet
def next_packet(self): """ Process next packet if present """ try: start_byte_index = self.buffer.index(velbus.START_BYTE) except ValueError: self.buffer = bytes([]) return if start_byte_index >= 0: self.buffer = self.buffer...
python
def next_packet(self): """ Process next packet if present """ try: start_byte_index = self.buffer.index(velbus.START_BYTE) except ValueError: self.buffer = bytes([]) return if start_byte_index >= 0: self.buffer = self.buffer...
[ "def", "next_packet", "(", "self", ")", ":", "try", ":", "start_byte_index", "=", "self", ".", "buffer", ".", "index", "(", "velbus", ".", "START_BYTE", ")", "except", "ValueError", ":", "self", ".", "buffer", "=", "bytes", "(", "[", "]", ")", "return"...
Process next packet if present
[ "Process", "next", "packet", "if", "present" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L77-L93
train
Process next packet.
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.extract_packet
def extract_packet(self): """ Extract packet from buffer """ packet_size = velbus.MINIMUM_MESSAGE_SIZE + \ (self.buffer[3] & 0x0F) packet = self.buffer[0:packet_size] return packet
python
def extract_packet(self): """ Extract packet from buffer """ packet_size = velbus.MINIMUM_MESSAGE_SIZE + \ (self.buffer[3] & 0x0F) packet = self.buffer[0:packet_size] return packet
[ "def", "extract_packet", "(", "self", ")", ":", "packet_size", "=", "velbus", ".", "MINIMUM_MESSAGE_SIZE", "+", "(", "self", ".", "buffer", "[", "3", "]", "&", "0x0F", ")", "packet", "=", "self", ".", "buffer", "[", "0", ":", "packet_size", "]", "retur...
Extract packet from buffer
[ "Extract", "packet", "from", "buffer" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L95-L102
train
Extract packet from buffer
thomasdelaet/python-velbus
velbus/parser.py
VelbusParser.parse
def parse(self, data): """ :return: None """ # pylint: disable-msg=R0911,C1801 assert isinstance(data, bytes) assert len(data) > 0 assert len(data) >= velbus.MINIMUM_MESSAGE_SIZE assert data[0] == velbus.START_BYTE self.logger.debug("Processing mes...
python
def parse(self, data): """ :return: None """ # pylint: disable-msg=R0911,C1801 assert isinstance(data, bytes) assert len(data) > 0 assert len(data) >= velbus.MINIMUM_MESSAGE_SIZE assert data[0] == velbus.START_BYTE self.logger.debug("Processing mes...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "# pylint: disable-msg=R0911,C1801", "assert", "isinstance", "(", "data", ",", "bytes", ")", "assert", "len", "(", "data", ")", ">", "0", "assert", "len", "(", "data", ")", ">=", "velbus", ".", "MINIMUM...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/parser.py#L104-L158
train
Parses the message and returns a new instance of the appropriate class.
pytroll/trollsift
trollsift/parser.py
_get_number_from_fmt
def _get_number_from_fmt(fmt): """ Helper function for extract_values, figures out string length from format string. """ if '%' in fmt: # its datetime return len(("{0:" + fmt + "}").format(dt.datetime.now())) else: # its something else fmt = fmt.lstrip('0') ...
python
def _get_number_from_fmt(fmt): """ Helper function for extract_values, figures out string length from format string. """ if '%' in fmt: # its datetime return len(("{0:" + fmt + "}").format(dt.datetime.now())) else: # its something else fmt = fmt.lstrip('0') ...
[ "def", "_get_number_from_fmt", "(", "fmt", ")", ":", "if", "'%'", "in", "fmt", ":", "# its datetime", "return", "len", "(", "(", "\"{0:\"", "+", "fmt", "+", "\"}\"", ")", ".", "format", "(", "dt", ".", "datetime", ".", "now", "(", ")", ")", ")", "e...
Helper function for extract_values, figures out string length from format string.
[ "Helper", "function", "for", "extract_values", "figures", "out", "string", "length", "from", "format", "string", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L309-L320
train
Helper function for extract_values
pytroll/trollsift
trollsift/parser.py
_convert
def _convert(convdef, stri): """Convert the string *stri* to the given conversion definition *convdef*.""" if '%' in convdef: result = dt.datetime.strptime(stri, convdef) elif 'd' in convdef or 's' in convdef: regex_match = fmt_spec_regex.match(convdef) match_dict = regex_match.group...
python
def _convert(convdef, stri): """Convert the string *stri* to the given conversion definition *convdef*.""" if '%' in convdef: result = dt.datetime.strptime(stri, convdef) elif 'd' in convdef or 's' in convdef: regex_match = fmt_spec_regex.match(convdef) match_dict = regex_match.group...
[ "def", "_convert", "(", "convdef", ",", "stri", ")", ":", "if", "'%'", "in", "convdef", ":", "result", "=", "dt", ".", "datetime", ".", "strptime", "(", "stri", ",", "convdef", ")", "elif", "'d'", "in", "convdef", "or", "'s'", "in", "convdef", ":", ...
Convert the string *stri* to the given conversion definition *convdef*.
[ "Convert", "the", "string", "*", "stri", "*", "to", "the", "given", "conversion", "definition", "*", "convdef", "*", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L323-L351
train
Convert the string stri to the given conversion definition convdef.
pytroll/trollsift
trollsift/parser.py
get_convert_dict
def get_convert_dict(fmt): """Retrieve parse definition from the format string `fmt`.""" convdef = {} for literal_text, field_name, format_spec, conversion in formatter.parse(fmt): if field_name is None: continue # XXX: Do I need to include 'conversion'? convdef[field_nam...
python
def get_convert_dict(fmt): """Retrieve parse definition from the format string `fmt`.""" convdef = {} for literal_text, field_name, format_spec, conversion in formatter.parse(fmt): if field_name is None: continue # XXX: Do I need to include 'conversion'? convdef[field_nam...
[ "def", "get_convert_dict", "(", "fmt", ")", ":", "convdef", "=", "{", "}", "for", "literal_text", ",", "field_name", ",", "format_spec", ",", "conversion", "in", "formatter", ".", "parse", "(", "fmt", ")", ":", "if", "field_name", "is", "None", ":", "con...
Retrieve parse definition from the format string `fmt`.
[ "Retrieve", "parse", "definition", "from", "the", "format", "string", "fmt", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L354-L362
train
Retrieve parse definition from the format string fmt.
pytroll/trollsift
trollsift/parser.py
parse
def parse(fmt, stri): """Parse keys and corresponding values from *stri* using format described in *fmt* string.""" convdef = get_convert_dict(fmt) keyvals = regex_formatter.extract_values(fmt, stri) for key in convdef.keys(): keyvals[key] = _convert(convdef[key], keyvals[key]) return keyva...
python
def parse(fmt, stri): """Parse keys and corresponding values from *stri* using format described in *fmt* string.""" convdef = get_convert_dict(fmt) keyvals = regex_formatter.extract_values(fmt, stri) for key in convdef.keys(): keyvals[key] = _convert(convdef[key], keyvals[key]) return keyva...
[ "def", "parse", "(", "fmt", ",", "stri", ")", ":", "convdef", "=", "get_convert_dict", "(", "fmt", ")", "keyvals", "=", "regex_formatter", ".", "extract_values", "(", "fmt", ",", "stri", ")", "for", "key", "in", "convdef", ".", "keys", "(", ")", ":", ...
Parse keys and corresponding values from *stri* using format described in *fmt* string.
[ "Parse", "keys", "and", "corresponding", "values", "from", "*", "stri", "*", "using", "format", "described", "in", "*", "fmt", "*", "string", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L365-L372
train
Parse keys and corresponding values from string using format described in fmt string.
pytroll/trollsift
trollsift/parser.py
_generate_data_for_format
def _generate_data_for_format(fmt): """Generate a fake data dictionary to fill in the provided format string.""" # finally try some data, create some random data for the fmt. data = {} # keep track of how many "free_size" (wildcard) parameters we have # if we get two in a row then we know the patter...
python
def _generate_data_for_format(fmt): """Generate a fake data dictionary to fill in the provided format string.""" # finally try some data, create some random data for the fmt. data = {} # keep track of how many "free_size" (wildcard) parameters we have # if we get two in a row then we know the patter...
[ "def", "_generate_data_for_format", "(", "fmt", ")", ":", "# finally try some data, create some random data for the fmt.", "data", "=", "{", "}", "# keep track of how many \"free_size\" (wildcard) parameters we have", "# if we get two in a row then we know the pattern is invalid, meaning", ...
Generate a fake data dictionary to fill in the provided format string.
[ "Generate", "a", "fake", "data", "dictionary", "to", "fill", "in", "the", "provided", "format", "string", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L472-L524
train
Generate a fake data dictionary to fill in the provided format string.
pytroll/trollsift
trollsift/parser.py
is_one2one
def is_one2one(fmt): """ Runs a check to evaluate if the format string has a one to one correspondence. I.e. that successive composing and parsing opperations will result in the original data. In other words, that input data maps to a string, which then maps back to the original data without an...
python
def is_one2one(fmt): """ Runs a check to evaluate if the format string has a one to one correspondence. I.e. that successive composing and parsing opperations will result in the original data. In other words, that input data maps to a string, which then maps back to the original data without an...
[ "def", "is_one2one", "(", "fmt", ")", ":", "data", "=", "_generate_data_for_format", "(", "fmt", ")", "if", "data", "is", "None", ":", "return", "False", "# run data forward once and back to data", "stri", "=", "compose", "(", "fmt", ",", "data", ")", "data2",...
Runs a check to evaluate if the format string has a one to one correspondence. I.e. that successive composing and parsing opperations will result in the original data. In other words, that input data maps to a string, which then maps back to the original data without any change or loss in informati...
[ "Runs", "a", "check", "to", "evaluate", "if", "the", "format", "string", "has", "a", "one", "to", "one", "correspondence", ".", "I", ".", "e", ".", "that", "successive", "composing", "and", "parsing", "opperations", "will", "result", "in", "the", "original...
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L527-L558
train
Checks if the format string has a single to one correspondence.
pytroll/trollsift
trollsift/parser.py
StringFormatter.convert_field
def convert_field(self, value, conversion): """Apply conversions mentioned above.""" func = self.CONV_FUNCS.get(conversion) if func is not None: value = getattr(value, func)() elif conversion not in ['R']: # default conversion ('r', 's') return super(S...
python
def convert_field(self, value, conversion): """Apply conversions mentioned above.""" func = self.CONV_FUNCS.get(conversion) if func is not None: value = getattr(value, func)() elif conversion not in ['R']: # default conversion ('r', 's') return super(S...
[ "def", "convert_field", "(", "self", ",", "value", ",", "conversion", ")", ":", "func", "=", "self", ".", "CONV_FUNCS", ".", "get", "(", "conversion", ")", "if", "func", "is", "not", "None", ":", "value", "=", "getattr", "(", "value", ",", "func", ")...
Apply conversions mentioned above.
[ "Apply", "conversions", "mentioned", "above", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L123-L134
train
Apply conversions mentioned above.
pytroll/trollsift
trollsift/parser.py
RegexFormatter._escape
def _escape(self, s): """Escape bad characters for regular expressions. Similar to `re.escape` but allows '%' to pass through. """ for ch, r_ch in self.ESCAPE_SETS: s = s.replace(ch, r_ch) return s
python
def _escape(self, s): """Escape bad characters for regular expressions. Similar to `re.escape` but allows '%' to pass through. """ for ch, r_ch in self.ESCAPE_SETS: s = s.replace(ch, r_ch) return s
[ "def", "_escape", "(", "self", ",", "s", ")", ":", "for", "ch", ",", "r_ch", "in", "self", ".", "ESCAPE_SETS", ":", "s", "=", "s", ".", "replace", "(", "ch", ",", "r_ch", ")", "return", "s" ]
Escape bad characters for regular expressions. Similar to `re.escape` but allows '%' to pass through.
[ "Escape", "bad", "characters", "for", "regular", "expressions", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L196-L204
train
Escape bad characters for regular expressions.
pytroll/trollsift
trollsift/parser.py
RegexFormatter.format_spec_to_regex
def format_spec_to_regex(field_name, format_spec): """Make an attempt at converting a format spec to a regular expression.""" # NOTE: remove escaped backslashes so regex matches regex_match = fmt_spec_regex.match(format_spec.replace('\\', '')) if regex_match is None: raise Va...
python
def format_spec_to_regex(field_name, format_spec): """Make an attempt at converting a format spec to a regular expression.""" # NOTE: remove escaped backslashes so regex matches regex_match = fmt_spec_regex.match(format_spec.replace('\\', '')) if regex_match is None: raise Va...
[ "def", "format_spec_to_regex", "(", "field_name", ",", "format_spec", ")", ":", "# NOTE: remove escaped backslashes so regex matches", "regex_match", "=", "fmt_spec_regex", ".", "match", "(", "format_spec", ".", "replace", "(", "'\\\\'", ",", "''", ")", ")", "if", "...
Make an attempt at converting a format spec to a regular expression.
[ "Make", "an", "attempt", "at", "converting", "a", "format", "spec", "to", "a", "regular", "expression", "." ]
d0e5b6006e248974d806d0dd8e20cc6641d778fb
https://github.com/pytroll/trollsift/blob/d0e5b6006e248974d806d0dd8e20cc6641d778fb/trollsift/parser.py#L235-L271
train
Make an attempt at converting a format specification to a regular expression.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tictac.py
tac
def tac(label=''): """@brief This function prints in the screen the difference between the time saved with function tic.py and current time. @param label String: if something is desired to print (default = ''). @see also tic() """ global _tic delta_t = time.time() - _tic if label !=...
python
def tac(label=''): """@brief This function prints in the screen the difference between the time saved with function tic.py and current time. @param label String: if something is desired to print (default = ''). @see also tic() """ global _tic delta_t = time.time() - _tic if label !=...
[ "def", "tac", "(", "label", "=", "''", ")", ":", "global", "_tic", "delta_t", "=", "time", ".", "time", "(", ")", "-", "_tic", "if", "label", "!=", "''", ":", "print", "(", "'%s - %3.4f s'", "%", "(", "label", ",", "delta_t", ")", ")", "else", ":...
@brief This function prints in the screen the difference between the time saved with function tic.py and current time. @param label String: if something is desired to print (default = ''). @see also tic()
[ "@brief", "This", "function", "prints", "in", "the", "screen", "the", "difference", "between", "the", "time", "saved", "with", "function", "tic", ".", "py", "and", "current", "time", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/external_packages/novainstrumentation/tictac.py#L13-L29
train
This function prints in the screen the difference between the time saved with function tic. py and current time.
thomasdelaet/python-velbus
velbus/controller.py
Controller.feed_parser
def feed_parser(self, data): """ Feed parser with new data :return: None """ assert isinstance(data, bytes) self.parser.feed(data)
python
def feed_parser(self, data): """ Feed parser with new data :return: None """ assert isinstance(data, bytes) self.parser.feed(data)
[ "def", "feed_parser", "(", "self", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "parser", ".", "feed", "(", "data", ")" ]
Feed parser with new data :return: None
[ "Feed", "parser", "with", "new", "data" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L49-L56
train
Feed parser with new data
thomasdelaet/python-velbus
velbus/controller.py
Controller.scan
def scan(self, callback=None): """ Scan the bus and call the callback when a new module is discovered :return: None """ def scan_finished(): """ Callback when scan is finished """ time.sleep(3) logging.info('Scan finish...
python
def scan(self, callback=None): """ Scan the bus and call the callback when a new module is discovered :return: None """ def scan_finished(): """ Callback when scan is finished """ time.sleep(3) logging.info('Scan finish...
[ "def", "scan", "(", "self", ",", "callback", "=", "None", ")", ":", "def", "scan_finished", "(", ")", ":", "\"\"\"\n Callback when scan is finished\n \"\"\"", "time", ".", "sleep", "(", "3", ")", "logging", ".", "info", "(", "'Scan finished'"...
Scan the bus and call the callback when a new module is discovered :return: None
[ "Scan", "the", "bus", "and", "call", "the", "callback", "when", "a", "new", "module", "is", "discovered" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L96-L121
train
Scan the bus and call the callback when a new module is discovered
thomasdelaet/python-velbus
velbus/controller.py
Controller.send_binary
def send_binary(self, binary_message, callback=None): """ :return: None """ assert isinstance(binary_message, str) message = self.parser.parse(binary_message) if isinstance(message, velbus.Message): self.send(message, callback)
python
def send_binary(self, binary_message, callback=None): """ :return: None """ assert isinstance(binary_message, str) message = self.parser.parse(binary_message) if isinstance(message, velbus.Message): self.send(message, callback)
[ "def", "send_binary", "(", "self", ",", "binary_message", ",", "callback", "=", "None", ")", ":", "assert", "isinstance", "(", "binary_message", ",", "str", ")", "message", "=", "self", ".", "parser", ".", "parse", "(", "binary_message", ")", "if", "isinst...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L123-L130
train
Send a binary message to the local cache.
thomasdelaet/python-velbus
velbus/controller.py
Controller.new_message
def new_message(self, message): """ :return: None """ self.logger.info("New message: " + str(message)) if isinstance(message, velbus.BusActiveMessage): self.logger.info("Velbus active message received") if isinstance(message, velbus.ReceiveReadyMessage): ...
python
def new_message(self, message): """ :return: None """ self.logger.info("New message: " + str(message)) if isinstance(message, velbus.BusActiveMessage): self.logger.info("Velbus active message received") if isinstance(message, velbus.ReceiveReadyMessage): ...
[ "def", "new_message", "(", "self", ",", "message", ")", ":", "self", ".", "logger", ".", "info", "(", "\"New message: \"", "+", "str", "(", "message", ")", ")", "if", "isinstance", "(", "message", ",", "velbus", ".", "BusActiveMessage", ")", ":", "self",...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L132-L159
train
Called by the daemon to process a new message.
thomasdelaet/python-velbus
velbus/controller.py
Controller.sync_clock
def sync_clock(self): """ This will send all the needed messages to sync the cloc """ self.send(velbus.SetRealtimeClock()) self.send(velbus.SetDate()) self.send(velbus.SetDaylightSaving())
python
def sync_clock(self): """ This will send all the needed messages to sync the cloc """ self.send(velbus.SetRealtimeClock()) self.send(velbus.SetDate()) self.send(velbus.SetDaylightSaving())
[ "def", "sync_clock", "(", "self", ")", ":", "self", ".", "send", "(", "velbus", ".", "SetRealtimeClock", "(", ")", ")", "self", ".", "send", "(", "velbus", ".", "SetDate", "(", ")", ")", "self", ".", "send", "(", "velbus", ".", "SetDaylightSaving", "...
This will send all the needed messages to sync the cloc
[ "This", "will", "send", "all", "the", "needed", "messages", "to", "sync", "the", "cloc" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L167-L173
train
This will send all the needed messages to sync the cloc
lobocv/crashreporter
crashreporter/tools.py
string_variable_lookup
def string_variable_lookup(tb, s): """ Look up the value of an object in a traceback by a dot-lookup string. ie. "self.crashreporter.application_name" Returns ValueError if value was not found in the scope of the traceback. :param tb: traceback :param s: lookup string :return: value of the...
python
def string_variable_lookup(tb, s): """ Look up the value of an object in a traceback by a dot-lookup string. ie. "self.crashreporter.application_name" Returns ValueError if value was not found in the scope of the traceback. :param tb: traceback :param s: lookup string :return: value of the...
[ "def", "string_variable_lookup", "(", "tb", ",", "s", ")", ":", "refs", "=", "[", "]", "dot_refs", "=", "s", ".", "split", "(", "'.'", ")", "DOT_LOOKUP", "=", "0", "DICT_LOOKUP", "=", "1", "for", "ii", ",", "ref", "in", "enumerate", "(", "dot_refs", ...
Look up the value of an object in a traceback by a dot-lookup string. ie. "self.crashreporter.application_name" Returns ValueError if value was not found in the scope of the traceback. :param tb: traceback :param s: lookup string :return: value of the
[ "Look", "up", "the", "value", "of", "an", "object", "in", "a", "traceback", "by", "a", "dot", "-", "lookup", "string", ".", "ie", ".", "self", ".", "crashreporter", ".", "application_name" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L28-L70
train
Look up the value of an object in a traceback by a dot - lookup string.
lobocv/crashreporter
crashreporter/tools.py
get_object_references
def get_object_references(tb, source, max_string_length=1000): """ Find the values of referenced attributes of objects within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value) """ global obj_ref_regex referenced_attr = set() for line in ...
python
def get_object_references(tb, source, max_string_length=1000): """ Find the values of referenced attributes of objects within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value) """ global obj_ref_regex referenced_attr = set() for line in ...
[ "def", "get_object_references", "(", "tb", ",", "source", ",", "max_string_length", "=", "1000", ")", ":", "global", "obj_ref_regex", "referenced_attr", "=", "set", "(", ")", "for", "line", "in", "source", ".", "split", "(", "'\\n'", ")", ":", "referenced_at...
Find the values of referenced attributes of objects within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value)
[ "Find", "the", "values", "of", "referenced", "attributes", "of", "objects", "within", "the", "traceback", "scope", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L73-L91
train
Find the values of referenced attributes of objects within the traceback scope.
lobocv/crashreporter
crashreporter/tools.py
get_local_references
def get_local_references(tb, max_string_length=1000): """ Find the values of the local variables within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value) """ if 'self' in tb.tb_frame.f_locals: _locals = [('self', repr(tb.tb_frame.f_local...
python
def get_local_references(tb, max_string_length=1000): """ Find the values of the local variables within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value) """ if 'self' in tb.tb_frame.f_locals: _locals = [('self', repr(tb.tb_frame.f_local...
[ "def", "get_local_references", "(", "tb", ",", "max_string_length", "=", "1000", ")", ":", "if", "'self'", "in", "tb", ".", "tb_frame", ".", "f_locals", ":", "_locals", "=", "[", "(", "'self'", ",", "repr", "(", "tb", ".", "tb_frame", ".", "f_locals", ...
Find the values of the local variables within the traceback scope. :param tb: traceback :return: list of tuples containing (variable name, value)
[ "Find", "the", "values", "of", "the", "local", "variables", "within", "the", "traceback", "scope", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L94-L113
train
Find the values of the local variables within the traceback scope.
lobocv/crashreporter
crashreporter/tools.py
format_reference
def format_reference(ref, max_string_length=1000): """ Converts an object / value into a string representation to pass along in the payload :param ref: object or value :param max_string_length: maximum number of characters to represent the object :return: """ _pass = lambda *args: None _...
python
def format_reference(ref, max_string_length=1000): """ Converts an object / value into a string representation to pass along in the payload :param ref: object or value :param max_string_length: maximum number of characters to represent the object :return: """ _pass = lambda *args: None _...
[ "def", "format_reference", "(", "ref", ",", "max_string_length", "=", "1000", ")", ":", "_pass", "=", "lambda", "*", "args", ":", "None", "_numpy_info", "=", "(", "'dtype'", ",", "'shape'", ",", "'size'", ",", "'min'", ",", "'max'", ")", "additionals", "...
Converts an object / value into a string representation to pass along in the payload :param ref: object or value :param max_string_length: maximum number of characters to represent the object :return:
[ "Converts", "an", "object", "/", "value", "into", "a", "string", "representation", "to", "pass", "along", "in", "the", "payload", ":", "param", "ref", ":", "object", "or", "value", ":", "param", "max_string_length", ":", "maximum", "number", "of", "character...
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L116-L152
train
Converts an object or value into a string representation of the object or value
lobocv/crashreporter
crashreporter/tools.py
analyze_traceback
def analyze_traceback(tb, inspection_level=None, limit=None): """ Extract trace back information into a list of dictionaries. :param tb: traceback :return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks """ info = [] tb_level = tb e...
python
def analyze_traceback(tb, inspection_level=None, limit=None): """ Extract trace back information into a list of dictionaries. :param tb: traceback :return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks """ info = [] tb_level = tb e...
[ "def", "analyze_traceback", "(", "tb", ",", "inspection_level", "=", "None", ",", "limit", "=", "None", ")", ":", "info", "=", "[", "]", "tb_level", "=", "tb", "extracted_tb", "=", "traceback", ".", "extract_tb", "(", "tb", ",", "limit", "=", "limit", ...
Extract trace back information into a list of dictionaries. :param tb: traceback :return: list of dicts containing filepath, line, module, code, traceback level and source code for tracebacks
[ "Extract", "trace", "back", "information", "into", "a", "list", "of", "dictionaries", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/tools.py#L155-L183
train
Extract trace back information into a list of dicts.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py
poincare
def poincare(data, sample_rate, signal=False, in_seconds=False): """ ----- Brief ----- Function for generation of Poincaré Plot (Heart rate variability analysis). ----------- Description ----------- ECG signals measure the electric potential in the heart of the subject. In normal co...
python
def poincare(data, sample_rate, signal=False, in_seconds=False): """ ----- Brief ----- Function for generation of Poincaré Plot (Heart rate variability analysis). ----------- Description ----------- ECG signals measure the electric potential in the heart of the subject. In normal co...
[ "def", "poincare", "(", "data", ",", "sample_rate", ",", "signal", "=", "False", ",", "in_seconds", "=", "False", ")", ":", "# Generation of tachogram.", "tachogram_data", "=", "tachogram", "(", "data", ",", "sample_rate", ",", "signal", "=", "signal", ",", ...
----- Brief ----- Function for generation of Poincaré Plot (Heart rate variability analysis). ----------- Description ----------- ECG signals measure the electric potential in the heart of the subject. In normal conditions, it is expeted that the the electric potential to be similar in ...
[ "-----", "Brief", "-----", "Function", "for", "generation", "of", "Poincaré", "Plot", "(", "Heart", "rate", "variability", "analysis", ")", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py#L51-L112
train
This function generates a Poincaré plot for the given data points.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py
smooth
def smooth(input_signal, window_len=10, window='hanning'): """ ----- Brief ----- Smooth the data using a window with requested size. ----------- Description ----------- This method is based on the convolution of a scaled window with the signal. The signal is prepared by introduc...
python
def smooth(input_signal, window_len=10, window='hanning'): """ ----- Brief ----- Smooth the data using a window with requested size. ----------- Description ----------- This method is based on the convolution of a scaled window with the signal. The signal is prepared by introduc...
[ "def", "smooth", "(", "input_signal", ",", "window_len", "=", "10", ",", "window", "=", "'hanning'", ")", ":", "if", "input_signal", ".", "ndim", "!=", "1", ":", "raise", "ValueError", "(", "\"smooth only accepts 1 dimension arrays.\"", ")", "if", "input_signal"...
----- Brief ----- Smooth the data using a window with requested size. ----------- Description ----------- This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends ...
[ "-----", "Brief", "-----", "Smooth", "the", "data", "using", "a", "window", "with", "requested", "size", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py#L115-L186
train
This method is used to smooth the data using a scaled window with the input signal.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py
plotfft
def plotfft(s, fmax, doplot=False): """ ----- Brief ----- This functions computes the Fast Fourier Transform of a signal, returning the frequency and magnitude values. ----------- Description ----------- Fast Fourier Transform (FFT) is a method to computationally calculate the Fouri...
python
def plotfft(s, fmax, doplot=False): """ ----- Brief ----- This functions computes the Fast Fourier Transform of a signal, returning the frequency and magnitude values. ----------- Description ----------- Fast Fourier Transform (FFT) is a method to computationally calculate the Fouri...
[ "def", "plotfft", "(", "s", ",", "fmax", ",", "doplot", "=", "False", ")", ":", "fs", "=", "abs", "(", "numpy", ".", "fft", ".", "fft", "(", "s", ")", ")", "f", "=", "numpy", ".", "linspace", "(", "0", ",", "fmax", "/", "2", ",", "len", "("...
----- Brief ----- This functions computes the Fast Fourier Transform of a signal, returning the frequency and magnitude values. ----------- Description ----------- Fast Fourier Transform (FFT) is a method to computationally calculate the Fourier Transform of discrete finite signals. Thi...
[ "-----", "Brief", "-----", "This", "functions", "computes", "the", "Fast", "Fourier", "Transform", "of", "a", "signal", "returning", "the", "frequency", "and", "magnitude", "values", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py#L189-L227
train
This function plots the FFT of a discrete finite frequency domain signal.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py
bandpass
def bandpass(s, f1, f2, order=2, fs=1000.0, use_filtfilt=False): """ ----- Brief ----- For a given signal s passes the frequencies within a certain range (between f1 and f2) and rejects (attenuates) the frequencies outside that range by applying a Butterworth digital filter. ----------- ...
python
def bandpass(s, f1, f2, order=2, fs=1000.0, use_filtfilt=False): """ ----- Brief ----- For a given signal s passes the frequencies within a certain range (between f1 and f2) and rejects (attenuates) the frequencies outside that range by applying a Butterworth digital filter. ----------- ...
[ "def", "bandpass", "(", "s", ",", "f1", ",", "f2", ",", "order", "=", "2", ",", "fs", "=", "1000.0", ",", "use_filtfilt", "=", "False", ")", ":", "b", ",", "a", "=", "butter", "(", "order", ",", "[", "f1", "*", "2", "/", "fs", ",", "f2", "*...
----- Brief ----- For a given signal s passes the frequencies within a certain range (between f1 and f2) and rejects (attenuates) the frequencies outside that range by applying a Butterworth digital filter. ----------- Description ----------- Signals may have frequency components of mul...
[ "-----", "Brief", "-----", "For", "a", "given", "signal", "s", "passes", "the", "frequencies", "within", "a", "certain", "range", "(", "between", "f1", "and", "f2", ")", "and", "rejects", "(", "attenuates", ")", "the", "frequencies", "outside", "that", "ra...
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/process.py#L375-L422
train
Returns a new Brief for a given signal s with the given frequency range f1 and f2 and the given order.
kytos/kytos-utils
kytos/utils/config.py
KytosConfig.log_configs
def log_configs(self): """Log the read configs if debug is enabled.""" for sec in self.config.sections(): LOG.debug(' %s: %s', sec, self.config.options(sec))
python
def log_configs(self): """Log the read configs if debug is enabled.""" for sec in self.config.sections(): LOG.debug(' %s: %s', sec, self.config.options(sec))
[ "def", "log_configs", "(", "self", ")", ":", "for", "sec", "in", "self", ".", "config", ".", "sections", "(", ")", ":", "LOG", ".", "debug", "(", "' %s: %s'", ",", "sec", ",", "self", ".", "config", ".", "options", "(", "sec", ")", ")" ]
Log the read configs if debug is enabled.
[ "Log", "the", "read", "configs", "if", "debug", "is", "enabled", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L51-L54
train
Log the read configs if debug is enabled.
kytos/kytos-utils
kytos/utils/config.py
KytosConfig.set_env_or_defaults
def set_env_or_defaults(self): """Read some environment variables and set them on the config. If no environment variable is found and the config section/key is empty, then set some default values. """ option = namedtuple('Option', ['section', 'name', 'env_var', ...
python
def set_env_or_defaults(self): """Read some environment variables and set them on the config. If no environment variable is found and the config section/key is empty, then set some default values. """ option = namedtuple('Option', ['section', 'name', 'env_var', ...
[ "def", "set_env_or_defaults", "(", "self", ")", ":", "option", "=", "namedtuple", "(", "'Option'", ",", "[", "'section'", ",", "'name'", ",", "'env_var'", ",", "'default_value'", "]", ")", "options", "=", "[", "option", "(", "'auth'", ",", "'user'", ",", ...
Read some environment variables and set them on the config. If no environment variable is found and the config section/key is empty, then set some default values.
[ "Read", "some", "environment", "variables", "and", "set", "them", "on", "the", "config", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L56-L81
train
Read some environment variables and set them on the config.
kytos/kytos-utils
kytos/utils/config.py
KytosConfig.check_sections
def check_sections(config): """Create a empty config file.""" default_sections = ['global', 'auth', 'napps', 'kytos'] for section in default_sections: if not config.has_section(section): config.add_section(section)
python
def check_sections(config): """Create a empty config file.""" default_sections = ['global', 'auth', 'napps', 'kytos'] for section in default_sections: if not config.has_section(section): config.add_section(section)
[ "def", "check_sections", "(", "config", ")", ":", "default_sections", "=", "[", "'global'", ",", "'auth'", ",", "'napps'", ",", "'kytos'", "]", "for", "section", "in", "default_sections", ":", "if", "not", "config", ".", "has_section", "(", "section", ")", ...
Create a empty config file.
[ "Create", "a", "empty", "config", "file", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L84-L89
train
Create a empty config file.
kytos/kytos-utils
kytos/utils/config.py
KytosConfig.save_token
def save_token(self, user, token): """Save the token on the config file.""" self.config.set('auth', 'user', user) self.config.set('auth', 'token', token) # allow_no_value=True is used to keep the comments on the config file. new_config = ConfigParser(allow_no_value=True) ...
python
def save_token(self, user, token): """Save the token on the config file.""" self.config.set('auth', 'user', user) self.config.set('auth', 'token', token) # allow_no_value=True is used to keep the comments on the config file. new_config = ConfigParser(allow_no_value=True) ...
[ "def", "save_token", "(", "self", ",", "user", ",", "token", ")", ":", "self", ".", "config", ".", "set", "(", "'auth'", ",", "'user'", ",", "user", ")", "self", ".", "config", ".", "set", "(", "'auth'", ",", "'token'", ",", "token", ")", "# allow_...
Save the token on the config file.
[ "Save", "the", "token", "on", "the", "config", "file", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L91-L108
train
Save the token on the config file.
kytos/kytos-utils
kytos/utils/config.py
KytosConfig.clear_token
def clear_token(self): """Clear Token information on config file.""" # allow_no_value=True is used to keep the comments on the config file. new_config = ConfigParser(allow_no_value=True) # Parse the config file. If no config file was found, then create some # default sections on...
python
def clear_token(self): """Clear Token information on config file.""" # allow_no_value=True is used to keep the comments on the config file. new_config = ConfigParser(allow_no_value=True) # Parse the config file. If no config file was found, then create some # default sections on...
[ "def", "clear_token", "(", "self", ")", ":", "# allow_no_value=True is used to keep the comments on the config file.", "new_config", "=", "ConfigParser", "(", "allow_no_value", "=", "True", ")", "# Parse the config file. If no config file was found, then create some", "# default sect...
Clear Token information on config file.
[ "Clear", "Token", "information", "on", "config", "file", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/config.py#L110-L125
train
Clear the Token information on config file.
KE-works/pykechain
pykechain/extra_utils.py
relocate_model
def relocate_model(part, target_parent, name=None, include_children=True): """ Move the `Part` model to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :type ta...
python
def relocate_model(part, target_parent, name=None, include_children=True): """ Move the `Part` model to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :type ta...
[ "def", "relocate_model", "(", "part", ",", "target_parent", ",", "name", "=", "None", ",", "include_children", "=", "True", ")", ":", "if", "target_parent", ".", "id", "in", "get_illegal_targets", "(", "part", ",", "include", "=", "{", "part", ".", "id", ...
Move the `Part` model to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :type target_parent: :class:`Part` :param name: how the moved top-level `Part` should be ca...
[ "Move", "the", "Part", "model", "to", "target", "parent", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L42-L117
train
Move the Part model to target parent.
KE-works/pykechain
pykechain/extra_utils.py
get_illegal_targets
def get_illegal_targets(part, include): """ Retrieve the illegal parent parts where `Part` can be moved/copied. :param part: `Part` to be moved/copied. :type part: :class:`Part` :param include: `Set` object with id's to be avoided as target parent `Part` :type include: set :return: `List` o...
python
def get_illegal_targets(part, include): """ Retrieve the illegal parent parts where `Part` can be moved/copied. :param part: `Part` to be moved/copied. :type part: :class:`Part` :param include: `Set` object with id's to be avoided as target parent `Part` :type include: set :return: `List` o...
[ "def", "get_illegal_targets", "(", "part", ",", "include", ")", ":", "list_of_illegal_targets", "=", "include", "or", "set", "(", ")", "for", "descendant", "in", "part", ".", "children", "(", "descendants", "=", "'children'", ")", ":", "list_of_illegal_targets",...
Retrieve the illegal parent parts where `Part` can be moved/copied. :param part: `Part` to be moved/copied. :type part: :class:`Part` :param include: `Set` object with id's to be avoided as target parent `Part` :type include: set :return: `List` object of illegal id's :rtype: list
[ "Retrieve", "the", "illegal", "parent", "parts", "where", "Part", "can", "be", "moved", "/", "copied", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L120-L134
train
Retrieve the illegal parent parts where Part can be moved or copied.
KE-works/pykechain
pykechain/extra_utils.py
relocate_instance
def relocate_instance(part, target_parent, name=None, include_children=True): """ Move the `Part` instance to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :t...
python
def relocate_instance(part, target_parent, name=None, include_children=True): """ Move the `Part` instance to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :t...
[ "def", "relocate_instance", "(", "part", ",", "target_parent", ",", "name", "=", "None", ",", "include_children", "=", "True", ")", ":", "# First, if the user doesn't provide the name, then just use the default \"Clone - ...\" name", "if", "not", "name", ":", "name", "=",...
Move the `Part` instance to target parent. .. versionadded:: 2.3 :param part: `Part` object to be moved :type part: :class:`Part` :param target_parent: `Part` object under which the desired `Part` is moved :type target_parent: :class:`Part` :param name: how the moved top-level `Part` should be...
[ "Move", "the", "Part", "instance", "to", "target", "parent", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L137-L172
train
Move the Part instance to target parent.
KE-works/pykechain
pykechain/extra_utils.py
move_part_instance
def move_part_instance(part_instance, target_parent, part_model, name=None, include_children=True): """ Move the `Part` instance to target parent and updates the properties based on the original part instance. .. versionadded:: 2.3 :param part_instance: `Part` object to be moved :type part_instanc...
python
def move_part_instance(part_instance, target_parent, part_model, name=None, include_children=True): """ Move the `Part` instance to target parent and updates the properties based on the original part instance. .. versionadded:: 2.3 :param part_instance: `Part` object to be moved :type part_instanc...
[ "def", "move_part_instance", "(", "part_instance", ",", "target_parent", ",", "part_model", ",", "name", "=", "None", ",", "include_children", "=", "True", ")", ":", "# If no specific name has been required, then call in as Clone of the part_instance.", "if", "not", "name",...
Move the `Part` instance to target parent and updates the properties based on the original part instance. .. versionadded:: 2.3 :param part_instance: `Part` object to be moved :type part_instance: :class:`Part` :param part_model: `Part` object representing the model of part_instance :type part_mod...
[ "Move", "the", "Part", "instance", "to", "target", "parent", "and", "updates", "the", "properties", "based", "on", "the", "original", "part", "instance", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L175-L235
train
Move the Part instance to target parent and update the properties based on the original part instance.
KE-works/pykechain
pykechain/extra_utils.py
update_part_with_properties
def update_part_with_properties(part_instance, moved_instance, name=None): """ Update the newly created part and its properties based on the original one. :param part_instance: `Part` object to be copied :type part_instance: :class:`Part` :param moved_instance: `Part` object copied :type moved_...
python
def update_part_with_properties(part_instance, moved_instance, name=None): """ Update the newly created part and its properties based on the original one. :param part_instance: `Part` object to be copied :type part_instance: :class:`Part` :param moved_instance: `Part` object copied :type moved_...
[ "def", "update_part_with_properties", "(", "part_instance", ",", "moved_instance", ",", "name", "=", "None", ")", ":", "# Instantiate and empty dictionary later used to map {property.id: property.value} in order to update the part", "# in one go", "properties_id_dict", "=", "dict", ...
Update the newly created part and its properties based on the original one. :param part_instance: `Part` object to be copied :type part_instance: :class:`Part` :param moved_instance: `Part` object copied :type moved_instance: :class:`Part` :param name: Name of the updated part :type name: bases...
[ "Update", "the", "newly", "created", "part", "and", "its", "properties", "based", "on", "the", "original", "one", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L238-L276
train
Update the newly created part and its properties based on the original one.
KE-works/pykechain
pykechain/extra_utils.py
map_property_instances
def map_property_instances(original_part, new_part): """ Map the id of the original part with the `Part` object of the newly created one. Updated the singleton `mapping dictionary` with the new mapping table values. :param original_part: `Part` object to be copied/moved :type original_part: :class...
python
def map_property_instances(original_part, new_part): """ Map the id of the original part with the `Part` object of the newly created one. Updated the singleton `mapping dictionary` with the new mapping table values. :param original_part: `Part` object to be copied/moved :type original_part: :class...
[ "def", "map_property_instances", "(", "original_part", ",", "new_part", ")", ":", "# Map the original part with the new one", "get_mapping_dictionary", "(", ")", "[", "original_part", ".", "id", "]", "=", "new_part", "# Do the same for each Property of original part instance, u...
Map the id of the original part with the `Part` object of the newly created one. Updated the singleton `mapping dictionary` with the new mapping table values. :param original_part: `Part` object to be copied/moved :type original_part: :class:`Part` :param new_part: `Part` object copied/moved :type...
[ "Map", "the", "id", "of", "the", "original", "part", "with", "the", "Part", "object", "of", "the", "newly", "created", "one", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/extra_utils.py#L279-L298
train
Map the id of the original part with the new one.
kytos/kytos-utils
kytos/utils/users.py
UsersManager.register
def register(self): """Register a new user. This method will ask for user attributes and create the user in Napps server, when All required fields is filled. Returns: result(string): Response of user registration process. """ user = {} print('-----...
python
def register(self): """Register a new user. This method will ask for user attributes and create the user in Napps server, when All required fields is filled. Returns: result(string): Response of user registration process. """ user = {} print('-----...
[ "def", "register", "(", "self", ")", ":", "user", "=", "{", "}", "print", "(", "'--------------------------------------------------------------'", ")", "print", "(", "'Welcome to the user registration process.'", ")", "print", "(", "'------------------------------------------...
Register a new user. This method will ask for user attributes and create the user in Napps server, when All required fields is filled. Returns: result(string): Response of user registration process.
[ "Register", "a", "new", "user", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/users.py#L50-L79
train
This method will ask for user attributes and create the user in Napps server when All required fields are filled.
kytos/kytos-utils
kytos/utils/users.py
UsersManager.ask_question
def ask_question(self, field_name, pattern=NAME_PATTERN, is_required=False, password=False): """Ask a question and get the input values. This method will validade the input values. Args: field_name(string): Field name used to ask for input value. pat...
python
def ask_question(self, field_name, pattern=NAME_PATTERN, is_required=False, password=False): """Ask a question and get the input values. This method will validade the input values. Args: field_name(string): Field name used to ask for input value. pat...
[ "def", "ask_question", "(", "self", ",", "field_name", ",", "pattern", "=", "NAME_PATTERN", ",", "is_required", "=", "False", ",", "password", "=", "False", ")", ":", "input_value", "=", "\"\"", "question", "=", "(", "\"Insert the field using the pattern below:\""...
Ask a question and get the input values. This method will validade the input values. Args: field_name(string): Field name used to ask for input value. pattern(tuple): Pattern to validate the input value. is_required(bool): Boolean value if the input value is required...
[ "Ask", "a", "question", "and", "get", "the", "input", "values", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/users.py#L81-L116
train
Ask a question and get the input value.
samuelcolvin/grablib
grablib/cli.py
cli
def cli(action, config_file, debug, verbose): """ Static asset management in python. Called with no arguments grablib will download, then build. You can also choose to only download or build. See `grablib -h` and https://github.com/samuelcolvin/grablib for more help. """ if verbose is True: ...
python
def cli(action, config_file, debug, verbose): """ Static asset management in python. Called with no arguments grablib will download, then build. You can also choose to only download or build. See `grablib -h` and https://github.com/samuelcolvin/grablib for more help. """ if verbose is True: ...
[ "def", "cli", "(", "action", ",", "config_file", ",", "debug", ",", "verbose", ")", ":", "if", "verbose", "is", "True", ":", "log_level", "=", "'DEBUG'", "elif", "verbose", "is", "False", ":", "log_level", "=", "'WARNING'", "else", ":", "assert", "verbos...
Static asset management in python. Called with no arguments grablib will download, then build. You can also choose to only download or build. See `grablib -h` and https://github.com/samuelcolvin/grablib for more help.
[ "Static", "asset", "management", "in", "python", "." ]
2fca8a3950f29fb2a97a7bd75c0839060a91cedf
https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/cli.py#L18-L43
train
A simple wrapper for Grablib s main function.